From d0bb42bf2e75fd49d235160ea9331d46a40c1aa6 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Mon, 8 Mar 2021 17:10:23 -0600 Subject: [PATCH] Pause onAppsUpdate when AllApps is converted to tabs. To avoid onAppsUpdated conflicting with WorkTabEdu, this change pauses callback updates when AllApps is first converted to tabs. This should avoid the need for additional extended timeouts. Bug: 159671700 Test: Presubmit Change-Id: I0959629f47ae6d824e5886b2cf917635f5bfdf0e --- .../com/android/launcher3/ui/WorkTabTest.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/src/com/android/launcher3/ui/WorkTabTest.java b/tests/src/com/android/launcher3/ui/WorkTabTest.java index 63220adad0..a6c7c03da4 100644 --- a/tests/src/com/android/launcher3/ui/WorkTabTest.java +++ b/tests/src/com/android/launcher3/ui/WorkTabTest.java @@ -18,6 +18,7 @@ package com.android.launcher3.ui; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST; +import static com.android.launcher3.tapl.LauncherInstrumentation.LONG_WAIT_TIME_MS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -140,9 +141,13 @@ public class WorkTabTest extends AbstractLauncherUiTest { WorkEduView.KEY_WORK_EDU_STEP).remove( WorkEduView.KEY_LEGACY_WORK_EDU_SEEN).commit()); - waitForLauncherCondition("Work tab not setup", - launcher -> launcher.getAppsView().getContentView() instanceof AllAppsPagedView, - 60000); + waitForLauncherCondition("Work tab not setup", launcher -> { + if (launcher.getAppsView().getContentView() instanceof AllAppsPagedView) { + launcher.getAppsView().getAppsStore().enableDeferUpdates(DEFER_UPDATES_TEST); + return true; + } + return false; + }, LONG_WAIT_TIME_MS); executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS)); WorkEduView workEduView = getEduView(); @@ -153,16 +158,6 @@ public class WorkTabTest extends AbstractLauncherUiTest { workEduView.findViewById(R.id.proceed).callOnClick(); }); - executeOnLauncher(launcher -> Log.d(TestProtocol.WORK_PROFILE_REMOVED, - "work profile status (" + mProfileUserId + ") :" - + launcher.getAppsView().isWorkTabVisible())); - - - executeOnLauncher(launcher -> { - launcher.getAppsView().getAppsStore().enableDeferUpdates(DEFER_UPDATES_TEST); - Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Defer all apps update"); - }); - AtomicInteger attempt = new AtomicInteger(0); // verify work edu is seen next waitForLauncherCondition("Launcher did not show the next edu screen", l -> { @@ -178,7 +173,7 @@ public class WorkTabTest extends AbstractLauncherUiTest { } return ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals( l.getResources().getString(R.string.work_profile_edu_work_apps)); - }, 60000); + }); } @Test