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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations