Search in sources :

Example 1 with LauncherInstrumentation

use of com.android.launcher3.tapl.LauncherInstrumentation in project android_packages_apps_Launcher3 by crdroidandroid.

the class NavigationModeSwitchRule method setActiveOverlay.

public static boolean setActiveOverlay(LauncherInstrumentation launcher, String overlayPackage, LauncherInstrumentation.NavigationModel expectedMode, Description description) throws Exception {
    if (!packageExists(overlayPackage)) {
        Log.d(TAG, "setActiveOverlay: " + overlayPackage + " pkg does not exist");
        return false;
    }
    Log.d(TAG, "setActiveOverlay: " + overlayPackage + "...");
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("cmd overlay enable-exclusive --category " + overlayPackage);
    if (currentSysUiNavigationMode() != expectedMode) {
        final CountDownLatch latch = new CountDownLatch(1);
        final Context targetContext = getInstrumentation().getTargetContext();
        final SysUINavigationMode.NavigationModeChangeListener listener = newMode -> {
            if (LauncherInstrumentation.getNavigationModel(newMode.resValue) == expectedMode) {
                latch.countDown();
            }
        };
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.addModeChangeListener(listener));
        // b/139137636
        // latch.await(60, TimeUnit.SECONDS);
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.removeModeChangeListener(listener));
        Wait.atMost(() -> "Navigation mode didn't change to " + expectedMode, () -> currentSysUiNavigationMode() == expectedMode, WAIT_TIME_MS, launcher);
    // b/139137636
    // assertTrue(launcher, "Navigation mode didn't change to " + expectedMode,
    // currentSysUiNavigationMode() == expectedMode, description);
    }
    Wait.atMost("Couldn't switch to " + overlayPackage, () -> launcher.getNavigationModel() == expectedMode, WAIT_TIME_MS, launcher);
    Wait.atMost(() -> "Switching nav mode: " + launcher.getNavigationModeMismatchError(false), () -> launcher.getNavigationModeMismatchError(false) == null, WAIT_TIME_MS, launcher);
    AbstractLauncherUiTest.checkDetectedLeaks(launcher);
    return true;
}
Also used : Context(android.content.Context) Context(android.content.Context) FailureWatcher(com.android.launcher3.util.rule.FailureWatcher) Statement(org.junit.runners.model.Statement) ZERO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON) NAV_BAR_MODE_3BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY) TWO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON) PackageManager(android.content.pm.PackageManager) TestRule(org.junit.rules.TestRule) QuickStepContract(com.android.systemui.shared.system.QuickStepContract) NAV_BAR_MODE_GESTURAL_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY) By(androidx.test.uiautomator.By) TestHelpers(com.android.launcher3.tapl.TestHelpers) Retention(java.lang.annotation.Retention) InstrumentationRegistry.getInstrumentation(androidx.test.InstrumentationRegistry.getInstrumentation) THREE_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) ALL(com.android.quickstep.NavigationModeSwitchRule.Mode.ALL) Log(android.util.Log) UiDevice(androidx.test.uiautomator.UiDevice) LauncherInstrumentation(com.android.launcher3.tapl.LauncherInstrumentation) NAV_BAR_MODE_2BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY) Description(org.junit.runner.Description) Target(java.lang.annotation.Target) ElementType(java.lang.annotation.ElementType) CountDownLatch(java.util.concurrent.CountDownLatch) Wait(com.android.launcher3.util.Wait) RetentionPolicy(java.lang.annotation.RetentionPolicy) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 2 with LauncherInstrumentation

use of com.android.launcher3.tapl.LauncherInstrumentation in project android_packages_apps_Launcher3 by AOSPA.

the class NavigationModeSwitchRule method setActiveOverlay.

public static boolean setActiveOverlay(LauncherInstrumentation launcher, String overlayPackage, LauncherInstrumentation.NavigationModel expectedMode, Description description) throws Exception {
    if (!packageExists(overlayPackage)) {
        Log.d(TAG, "setActiveOverlay: " + overlayPackage + " pkg does not exist");
        return false;
    }
    Log.d(TAG, "setActiveOverlay: " + overlayPackage + "...");
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("cmd overlay enable-exclusive --category " + overlayPackage);
    if (currentSysUiNavigationMode() != expectedMode) {
        final CountDownLatch latch = new CountDownLatch(1);
        final Context targetContext = getInstrumentation().getTargetContext();
        final SysUINavigationMode.NavigationModeChangeListener listener = newMode -> {
            if (LauncherInstrumentation.getNavigationModel(newMode.resValue) == expectedMode) {
                latch.countDown();
            }
        };
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.addModeChangeListener(listener));
        latch.await(60, TimeUnit.SECONDS);
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.removeModeChangeListener(listener));
        assertTrue(launcher, "Navigation mode didn't change to " + expectedMode, currentSysUiNavigationMode() == expectedMode, description);
    }
    Wait.atMost("Couldn't switch to " + overlayPackage, () -> launcher.getNavigationModel() == expectedMode, WAIT_TIME_MS, launcher);
    Wait.atMost(() -> "Switching nav mode: " + launcher.getNavigationModeMismatchError(false), () -> launcher.getNavigationModeMismatchError(false) == null, WAIT_TIME_MS, launcher);
    AbstractLauncherUiTest.checkDetectedLeaks(launcher);
    return true;
}
Also used : Context(android.content.Context) Context(android.content.Context) FailureWatcher(com.android.launcher3.util.rule.FailureWatcher) Statement(org.junit.runners.model.Statement) ZERO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON) NAV_BAR_MODE_3BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY) TWO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON) PackageManager(android.content.pm.PackageManager) TestRule(org.junit.rules.TestRule) QuickStepContract(com.android.systemui.shared.system.QuickStepContract) NAV_BAR_MODE_GESTURAL_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY) TestHelpers(com.android.launcher3.tapl.TestHelpers) Retention(java.lang.annotation.Retention) InstrumentationRegistry.getInstrumentation(androidx.test.InstrumentationRegistry.getInstrumentation) THREE_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) ALL(com.android.quickstep.NavigationModeSwitchRule.Mode.ALL) Log(android.util.Log) UiDevice(androidx.test.uiautomator.UiDevice) LauncherInstrumentation(com.android.launcher3.tapl.LauncherInstrumentation) NAV_BAR_MODE_2BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY) Description(org.junit.runner.Description) Target(java.lang.annotation.Target) ElementType(java.lang.annotation.ElementType) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) Wait(com.android.launcher3.util.Wait) RetentionPolicy(java.lang.annotation.RetentionPolicy) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 3 with LauncherInstrumentation

use of com.android.launcher3.tapl.LauncherInstrumentation in project android_packages_apps_Trebuchet by LineageOS.

the class NavigationModeSwitchRule method setActiveOverlay.

public static boolean setActiveOverlay(LauncherInstrumentation launcher, String overlayPackage, LauncherInstrumentation.NavigationModel expectedMode, Description description) throws Exception {
    if (!packageExists(overlayPackage)) {
        Log.d(TAG, "setActiveOverlay: " + overlayPackage + " pkg does not exist");
        return false;
    }
    Log.d(TAG, "setActiveOverlay: " + overlayPackage + "...");
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("cmd overlay enable-exclusive " + overlayPackage);
    if (currentSysUiNavigationMode() != expectedMode) {
        final CountDownLatch latch = new CountDownLatch(1);
        final Context targetContext = getInstrumentation().getTargetContext();
        final SysUINavigationMode.NavigationModeChangeListener listener = newMode -> {
            if (LauncherInstrumentation.getNavigationModel(newMode.resValue) == expectedMode) {
                latch.countDown();
            }
        };
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.addModeChangeListener(listener));
        // b/139137636
        // latch.await(60, TimeUnit.SECONDS);
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.removeModeChangeListener(listener));
        Wait.atMost(() -> "Navigation mode didn't change to " + expectedMode, () -> currentSysUiNavigationMode() == expectedMode, 60000, /* b/148422894 */
        launcher);
    // b/139137636
    // assertTrue(launcher, "Navigation mode didn't change to " + expectedMode,
    // currentSysUiNavigationMode() == expectedMode, description);
    }
    Wait.atMost("Couldn't switch to " + overlayPackage, () -> launcher.getNavigationModel() == expectedMode, WAIT_TIME_MS, launcher);
    Wait.atMost(() -> "Switching nav mode: " + launcher.getNavigationModeMismatchError(), () -> launcher.getNavigationModeMismatchError() == null, 60000, /* b/148422894 */
    launcher);
    AbstractLauncherUiTest.checkDetectedLeaks(launcher);
    return true;
}
Also used : Context(android.content.Context) Context(android.content.Context) FailureWatcher(com.android.launcher3.util.rule.FailureWatcher) Statement(org.junit.runners.model.Statement) ZERO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON) NAV_BAR_MODE_3BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY) TWO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON) PackageManager(android.content.pm.PackageManager) TestRule(org.junit.rules.TestRule) QuickStepContract(com.android.systemui.shared.system.QuickStepContract) NAV_BAR_MODE_GESTURAL_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY) By(androidx.test.uiautomator.By) TestHelpers(com.android.launcher3.tapl.TestHelpers) Retention(java.lang.annotation.Retention) InstrumentationRegistry.getInstrumentation(androidx.test.InstrumentationRegistry.getInstrumentation) THREE_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) ALL(com.android.quickstep.NavigationModeSwitchRule.Mode.ALL) Log(android.util.Log) UiDevice(androidx.test.uiautomator.UiDevice) LauncherInstrumentation(com.android.launcher3.tapl.LauncherInstrumentation) NAV_BAR_MODE_2BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY) Description(org.junit.runner.Description) Target(java.lang.annotation.Target) ElementType(java.lang.annotation.ElementType) CountDownLatch(java.util.concurrent.CountDownLatch) Wait(com.android.launcher3.util.Wait) RetentionPolicy(java.lang.annotation.RetentionPolicy) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 4 with LauncherInstrumentation

use of com.android.launcher3.tapl.LauncherInstrumentation in project android_packages_apps_Launcher3 by ArrowOS.

the class NavigationModeSwitchRule method setActiveOverlay.

public static boolean setActiveOverlay(LauncherInstrumentation launcher, String overlayPackage, LauncherInstrumentation.NavigationModel expectedMode, Description description) throws Exception {
    if (!packageExists(overlayPackage)) {
        Log.d(TAG, "setActiveOverlay: " + overlayPackage + " pkg does not exist");
        return false;
    }
    Log.d(TAG, "setActiveOverlay: " + overlayPackage + "...");
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("cmd overlay enable-exclusive --category " + overlayPackage);
    if (currentSysUiNavigationMode() != expectedMode) {
        final CountDownLatch latch = new CountDownLatch(1);
        final Context targetContext = getInstrumentation().getTargetContext();
        final SysUINavigationMode.NavigationModeChangeListener listener = newMode -> {
            if (LauncherInstrumentation.getNavigationModel(newMode.resValue) == expectedMode) {
                latch.countDown();
            }
        };
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.addModeChangeListener(listener));
        latch.await(60, TimeUnit.SECONDS);
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.removeModeChangeListener(listener));
        assertTrue(launcher, "Navigation mode didn't change to " + expectedMode, currentSysUiNavigationMode() == expectedMode, description);
    }
    Wait.atMost("Couldn't switch to " + overlayPackage, () -> launcher.getNavigationModel() == expectedMode, WAIT_TIME_MS, launcher);
    Wait.atMost(() -> "Switching nav mode: " + launcher.getNavigationModeMismatchError(false), () -> launcher.getNavigationModeMismatchError(false) == null, WAIT_TIME_MS, launcher);
    AbstractLauncherUiTest.checkDetectedLeaks(launcher);
    return true;
}
Also used : Context(android.content.Context) Context(android.content.Context) FailureWatcher(com.android.launcher3.util.rule.FailureWatcher) Statement(org.junit.runners.model.Statement) ZERO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON) NAV_BAR_MODE_3BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY) TWO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON) PackageManager(android.content.pm.PackageManager) TestRule(org.junit.rules.TestRule) QuickStepContract(com.android.systemui.shared.system.QuickStepContract) NAV_BAR_MODE_GESTURAL_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY) TestHelpers(com.android.launcher3.tapl.TestHelpers) Retention(java.lang.annotation.Retention) InstrumentationRegistry.getInstrumentation(androidx.test.InstrumentationRegistry.getInstrumentation) THREE_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) ALL(com.android.quickstep.NavigationModeSwitchRule.Mode.ALL) Log(android.util.Log) UiDevice(androidx.test.uiautomator.UiDevice) LauncherInstrumentation(com.android.launcher3.tapl.LauncherInstrumentation) NAV_BAR_MODE_2BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY) Description(org.junit.runner.Description) Target(java.lang.annotation.Target) ElementType(java.lang.annotation.ElementType) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) Wait(com.android.launcher3.util.Wait) RetentionPolicy(java.lang.annotation.RetentionPolicy) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 5 with LauncherInstrumentation

use of com.android.launcher3.tapl.LauncherInstrumentation in project android_packages_apps_404Launcher by P-404.

the class NavigationModeSwitchRule method setActiveOverlay.

public static boolean setActiveOverlay(LauncherInstrumentation launcher, String overlayPackage, LauncherInstrumentation.NavigationModel expectedMode, Description description) throws Exception {
    if (!packageExists(overlayPackage)) {
        Log.d(TAG, "setActiveOverlay: " + overlayPackage + " pkg does not exist");
        return false;
    }
    Log.d(TAG, "setActiveOverlay: " + overlayPackage + "...");
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("cmd overlay enable-exclusive --category " + overlayPackage);
    if (currentSysUiNavigationMode() != expectedMode) {
        final CountDownLatch latch = new CountDownLatch(1);
        final Context targetContext = getInstrumentation().getTargetContext();
        final SysUINavigationMode.NavigationModeChangeListener listener = newMode -> {
            if (LauncherInstrumentation.getNavigationModel(newMode.resValue) == expectedMode) {
                latch.countDown();
            }
        };
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.addModeChangeListener(listener));
        latch.await(60, TimeUnit.SECONDS);
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.removeModeChangeListener(listener));
        assertTrue(launcher, "Navigation mode didn't change to " + expectedMode, currentSysUiNavigationMode() == expectedMode, description);
    }
    Wait.atMost("Couldn't switch to " + overlayPackage, () -> launcher.getNavigationModel() == expectedMode, WAIT_TIME_MS, launcher);
    Wait.atMost(() -> "Switching nav mode: " + launcher.getNavigationModeMismatchError(false), () -> launcher.getNavigationModeMismatchError(false) == null, WAIT_TIME_MS, launcher);
    AbstractLauncherUiTest.checkDetectedLeaks(launcher);
    return true;
}
Also used : Context(android.content.Context) Context(android.content.Context) FailureWatcher(com.android.launcher3.util.rule.FailureWatcher) Statement(org.junit.runners.model.Statement) ZERO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON) NAV_BAR_MODE_3BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY) TWO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON) PackageManager(android.content.pm.PackageManager) TestRule(org.junit.rules.TestRule) QuickStepContract(com.android.systemui.shared.system.QuickStepContract) NAV_BAR_MODE_GESTURAL_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY) TestHelpers(com.android.launcher3.tapl.TestHelpers) Retention(java.lang.annotation.Retention) InstrumentationRegistry.getInstrumentation(androidx.test.InstrumentationRegistry.getInstrumentation) THREE_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) ALL(com.android.quickstep.NavigationModeSwitchRule.Mode.ALL) Log(android.util.Log) UiDevice(androidx.test.uiautomator.UiDevice) LauncherInstrumentation(com.android.launcher3.tapl.LauncherInstrumentation) NAV_BAR_MODE_2BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY) Description(org.junit.runner.Description) Target(java.lang.annotation.Target) ElementType(java.lang.annotation.ElementType) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) Wait(com.android.launcher3.util.Wait) RetentionPolicy(java.lang.annotation.RetentionPolicy) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Context (android.content.Context)6 PackageManager (android.content.pm.PackageManager)6 Log (android.util.Log)6 InstrumentationRegistry.getInstrumentation (androidx.test.InstrumentationRegistry.getInstrumentation)6 UiDevice (androidx.test.uiautomator.UiDevice)6 LauncherInstrumentation (com.android.launcher3.tapl.LauncherInstrumentation)6 TestHelpers (com.android.launcher3.tapl.TestHelpers)6 AbstractLauncherUiTest (com.android.launcher3.ui.AbstractLauncherUiTest)6 Wait (com.android.launcher3.util.Wait)6 FailureWatcher (com.android.launcher3.util.rule.FailureWatcher)6 ALL (com.android.quickstep.NavigationModeSwitchRule.Mode.ALL)6 THREE_BUTTON (com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON)6 TWO_BUTTON (com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON)6 ZERO_BUTTON (com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON)6 QuickStepContract (com.android.systemui.shared.system.QuickStepContract)6 NAV_BAR_MODE_2BUTTON_OVERLAY (com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY)6 NAV_BAR_MODE_3BUTTON_OVERLAY (com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY)6 NAV_BAR_MODE_GESTURAL_OVERLAY (com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY)6 ElementType (java.lang.annotation.ElementType)6 Retention (java.lang.annotation.Retention)6