Loading tests/src/com/android/launcher3/ui/WorkProfileTest.java +12 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import android.util.Log; import android.view.View; Loading @@ -47,6 +47,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest { private static final int WORK_PAGE = ActivityAllAppsContainerView.AdapterHolder.WORK; private int mProfileUserId; private boolean mWorkProfileSetupSuccessful; @Before @Override Loading @@ -56,7 +57,13 @@ public class WorkProfileTest extends AbstractLauncherUiTest { mDevice.executeShellCommand( "pm create-user --profileOf 0 --managed TestProfile"); Log.d("b/203817455", "pm create-user; output: " + output); if (output.startsWith("Success")){ assertTrue("Failed to create work profile", output.startsWith("Success")); mWorkProfileSetupSuccessful = true; } else { return; // no need to setup launcher since all tests will skip. } String[] tokens = output.split("\\s+"); mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]); Loading Loading @@ -99,6 +106,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest { @Test public void workTabExists() { assumeTrue(mWorkProfileSetupSuccessful); waitForLauncherCondition("Personal tab is missing", launcher -> launcher.getAppsView().isPersonalTabVisible(), LauncherInstrumentation.WAIT_TIME_MS); Loading @@ -109,8 +117,8 @@ public class WorkProfileTest extends AbstractLauncherUiTest { @Test public void toggleWorks() { assumeTrue(mWorkProfileSetupSuccessful); waitForWorkTabSetup(); executeOnLauncher(launcher -> { AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView(); pagedView.setCurrentPage(WORK_PAGE); Loading Loading @@ -152,6 +160,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest { @Test public void testEdu() { assumeTrue(mWorkProfileSetupSuccessful); waitForWorkTabSetup(); executeOnLauncher(l -> { l.getSharedPrefs().edit().putInt(WorkProfileManager.KEY_WORK_EDU_STEP, 0).commit(); Loading Loading
tests/src/com/android/launcher3/ui/WorkProfileTest.java +12 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import android.util.Log; import android.view.View; Loading @@ -47,6 +47,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest { private static final int WORK_PAGE = ActivityAllAppsContainerView.AdapterHolder.WORK; private int mProfileUserId; private boolean mWorkProfileSetupSuccessful; @Before @Override Loading @@ -56,7 +57,13 @@ public class WorkProfileTest extends AbstractLauncherUiTest { mDevice.executeShellCommand( "pm create-user --profileOf 0 --managed TestProfile"); Log.d("b/203817455", "pm create-user; output: " + output); if (output.startsWith("Success")){ assertTrue("Failed to create work profile", output.startsWith("Success")); mWorkProfileSetupSuccessful = true; } else { return; // no need to setup launcher since all tests will skip. } String[] tokens = output.split("\\s+"); mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]); Loading Loading @@ -99,6 +106,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest { @Test public void workTabExists() { assumeTrue(mWorkProfileSetupSuccessful); waitForLauncherCondition("Personal tab is missing", launcher -> launcher.getAppsView().isPersonalTabVisible(), LauncherInstrumentation.WAIT_TIME_MS); Loading @@ -109,8 +117,8 @@ public class WorkProfileTest extends AbstractLauncherUiTest { @Test public void toggleWorks() { assumeTrue(mWorkProfileSetupSuccessful); waitForWorkTabSetup(); executeOnLauncher(launcher -> { AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView(); pagedView.setCurrentPage(WORK_PAGE); Loading Loading @@ -152,6 +160,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest { @Test public void testEdu() { assumeTrue(mWorkProfileSetupSuccessful); waitForWorkTabSetup(); executeOnLauncher(l -> { l.getSharedPrefs().edit().putInt(WorkProfileManager.KEY_WORK_EDU_STEP, 0).commit(); Loading