Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06e764f2 authored by Pawan Wagh's avatar Pawan Wagh Committed by Automerger Merge Worker
Browse files

Merge "Connect and enable root before running each testcase" into main am:...

Merge "Connect and enable root before running each testcase" into main am: b03384d4 am: 60c70263

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/3501231



Change-Id: I91e57e73653654414e737413a5d5dc4bff047925
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6df46b06 60c70263
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
smoreland@google.com
waghpawan@google.com
 No newline at end of file
+21 −10
Original line number Diff line number Diff line
@@ -48,18 +48,21 @@ public class Enable16KbTest extends BaseHostJUnit4Test {
    private static final String SWITCH_TO_4KB = "enable16k_switchTo4Kb";
    private static final String DISABLE_DEV_OPTION = "enable16k_disableDeveloperOption";

    private static final int DEVICE_WAIT_TIMEOUT = 120000;
    private static final int DEVICE_UPDATE_TIMEOUT = 180000;

    @Test
    @AppModeFull
    public void enable16KbToggle() throws Exception {
        // Wait for 2 mins device to be online
        getDevice().waitForDeviceOnline(120000);
        // Wait for 2 minutes for device to be online
        prepareDevice();
        if (!isPackageInstalled(APP_PACKAGE)) {
            //If test app has failed for some reason, retry installation
            installTestApp();
        }

        // Check if developer option is enabled otherwise exit
        getDevice().enableAdbRoot();
        prepareDevice();
        String result = getDevice().getProperty("ro.product.build.16k_page.enabled");
        assumeTrue("true".equals(result));

@@ -72,8 +75,6 @@ public class Enable16KbTest extends BaseHostJUnit4Test {

        // Enables developer option and switch to ext4
        runTestAndWait(SWITCH_TO_EXT4);

        getDevice().enableAdbRoot();
        getDevice().executeShellCommand("am start -a com.android.setupwizard.FOUR_CORNER_EXIT");
        assertTrue(verifyExt4());

@@ -81,13 +82,11 @@ public class Enable16KbTest extends BaseHostJUnit4Test {
        installTestApp();

        // Enable developer option and switch to 16kb kernel and Check page size
        getDevice().enableAdbRoot();
        runTestAndWait(SWITCH_TO_16KB);
        result = getDevice().executeShellCommand("getconf PAGE_SIZE");
        assertEquals("16384", result.strip());

        // switch back to 4kb kernel and check page size
        getDevice().enableAdbRoot();
        runTestAndWait(SWITCH_TO_4KB);
        result = getDevice().executeShellCommand("getconf PAGE_SIZE");
        assertEquals("4096", result.strip());
@@ -105,11 +104,23 @@ public class Enable16KbTest extends BaseHostJUnit4Test {
    }

    private void runTestAndWait(String testMethodName) throws Exception {
        prepareDevice();
        runDeviceTests(APP_PACKAGE, APP_PACKAGE + "." + TEST_NAME, testMethodName);
        // Device is either formatting or applying update. It usually takes 3 minutes to boot.
        RunUtil.getDefault().sleep(180000);
        // Wait for 2 mins device to be online againg
        getDevice().waitForDeviceOnline(120000);
        RunUtil.getDefault().sleep(DEVICE_UPDATE_TIMEOUT);

        // make sure it is available again after the test
        prepareDevice();
    }

    private void prepareDevice() throws Exception {
        // Verify that device is online before running test and enable root
        getDevice().waitForDeviceOnline(DEVICE_WAIT_TIMEOUT);
        getDevice().enableAdbRoot();
        getDevice().waitForDeviceOnline(DEVICE_WAIT_TIMEOUT);

        getDevice().executeShellCommand("input keyevent KEYCODE_WAKEUP");
        getDevice().executeShellCommand("wm dismiss-keyguard");
    }

    private boolean verifyExt4() throws Exception {