Search in sources :

Example 1 with WorkEduView

use of com.android.launcher3.views.WorkEduView in project android_packages_apps_Launcher3 by crdroidandroid.

the class WorkTabTest method testWorkEduFlow.

@Ignore("b/182844465")
@Test
public void testWorkEduFlow() {
    mDevice.pressHome();
    waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
    executeOnLauncher(launcher -> launcher.getSharedPrefs().edit().remove(WorkEduView.KEY_WORK_EDU_STEP).remove(WorkEduView.KEY_LEGACY_WORK_EDU_SEEN).commit());
    waitForLauncherCondition("Work tab not setup", launcher -> {
        if (launcher.getAppsView().getContentView() instanceof AllAppsPagedView) {
            launcher.getAppsView().getAppsStore().enableDeferUpdates(DEFER_UPDATES_TEST);
            return true;
        }
        return false;
    }, LauncherInstrumentation.WAIT_TIME_MS);
    executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
    WorkEduView workEduView = getEduView();
    // verify personal app edu is seen first and click "next"
    executeOnLauncher(l -> {
        assertEquals(((TextView) workEduView.findViewById(R.id.content_text)).getText(), l.getResources().getString(R.string.work_profile_edu_personal_apps));
        workEduView.findViewById(R.id.proceed).callOnClick();
    });
    AtomicInteger attempt = new AtomicInteger(0);
    // verify work edu is seen next
    waitForLauncherCondition("Launcher did not show the next edu screen", l -> {
        Log.d(TestProtocol.WORK_PROFILE_REMOVED, "running test attempt" + attempt.getAndIncrement());
        if (!(l.getAppsView().getContentView() instanceof AllAppsPagedView)) {
            Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work tab not setup. Skipping test");
            return false;
        }
        if (((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage() != WORK_PAGE) {
            Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work page not highlighted");
        }
        return ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(l.getResources().getString(R.string.work_profile_edu_work_apps));
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Objects(java.util.Objects) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkEduView(com.android.launcher3.views.WorkEduView) Ignore(org.junit.Ignore) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 2 with WorkEduView

use of com.android.launcher3.views.WorkEduView in project android_packages_apps_Trebuchet by LineageOS.

the class WorkTabTest method testWorkEduFlow.

@Test
public void testWorkEduFlow() {
    mDevice.pressHome();
    waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
    executeOnLauncher(launcher -> launcher.getSharedPrefs().edit().remove(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);
    executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
    WorkEduView workEduView = getEduView();
    // verify personal app edu is seen first and click "next"
    executeOnLauncher(l -> {
        assertEquals(((TextView) workEduView.findViewById(R.id.content_text)).getText(), l.getResources().getString(R.string.work_profile_edu_personal_apps));
        workEduView.findViewById(R.id.proceed).callOnClick();
    });
    executeOnLauncher(launcher -> Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work profile status: " + launcher.getAppsView().isPersonalTabVisible()));
    // verify work edu is seen next
    waitForLauncherCondition("Launcher did not show the next edu screen", l -> ((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage() == WORK_PAGE && ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(l.getResources().getString(R.string.work_profile_edu_work_apps)));
}
Also used : Objects(java.util.Objects) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkEduView(com.android.launcher3.views.WorkEduView) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 3 with WorkEduView

use of com.android.launcher3.views.WorkEduView in project android_packages_apps_Launcher3 by crdroidandroid.

the class WorkTabTest method testWorkEduIntermittent.

@Ignore("b/182844465")
@Test
public void testWorkEduIntermittent() {
    mDevice.pressHome();
    waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
    executeOnLauncher(launcher -> launcher.getSharedPrefs().edit().remove(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);
    executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
    // verify personal app edu is seen
    getEduView();
    // dismiss personal edu
    mDevice.pressHome();
    waitForState("Launcher did not go home", () -> NORMAL);
    // open work tab
    executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
    waitForState("Launcher did not switch to all apps", () -> ALL_APPS);
    waitForLauncherCondition("Work tab not setup", launcher -> launcher.getAppsView().getContentView() instanceof AllAppsPagedView, 60000);
    executeOnLauncher(launcher -> {
        AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
        pagedView.setCurrentPage(WORK_PAGE);
    });
    WorkEduView workEduView = getEduView();
    // verify work tab edu is shown
    waitForLauncherCondition("Launcher did not show the next edu screen", l -> ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(l.getResources().getString(R.string.work_profile_edu_work_apps)));
}
Also used : Objects(java.util.Objects) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkEduView(com.android.launcher3.views.WorkEduView) TextView(android.widget.TextView) Ignore(org.junit.Ignore) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 4 with WorkEduView

use of com.android.launcher3.views.WorkEduView in project android_packages_apps_Trebuchet by LineageOS.

the class WorkTabTest method testWorkEduIntermittent.

@Test
public void testWorkEduIntermittent() {
    mDevice.pressHome();
    waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
    executeOnLauncher(launcher -> launcher.getSharedPrefs().edit().remove(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);
    executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
    // verify personal app edu is seen
    getEduView();
    // dismiss personal edu
    mDevice.pressHome();
    waitForState("Launcher did not go home", () -> NORMAL);
    // open work tab
    executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
    waitForState("Launcher did not switch to all apps", () -> ALL_APPS);
    executeOnLauncher(launcher -> {
        AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
        pagedView.setCurrentPage(WORK_PAGE);
    });
    WorkEduView workEduView = getEduView();
    // verify work tab edu is shown
    waitForLauncherCondition("Launcher did not show the next edu screen", l -> ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(l.getResources().getString(R.string.work_profile_edu_work_apps)));
}
Also used : Objects(java.util.Objects) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkEduView(com.android.launcher3.views.WorkEduView) TextView(android.widget.TextView) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 5 with WorkEduView

use of com.android.launcher3.views.WorkEduView in project android_packages_apps_Trebuchet by LineageOS.

the class WorkEduView method showEduFlowIfNeeded.

/**
 * Checks if user has not seen onboarding UI yet and shows it when user navigates to all apps
 */
public static StateListener<LauncherState> showEduFlowIfNeeded(Launcher launcher, @Nullable StateListener<LauncherState> oldListener) {
    if (oldListener != null) {
        launcher.getStateManager().removeStateListener(oldListener);
    }
    if (hasSeenLegacyEdu(launcher) || launcher.getSharedPrefs().getInt(KEY_WORK_EDU_STEP, WORK_EDU_NOT_STARTED) != WORK_EDU_NOT_STARTED) {
        return null;
    }
    StateListener<LauncherState> listener = new StateListener<LauncherState>() {

        @Override
        public void onStateTransitionComplete(LauncherState finalState) {
            if (finalState != LauncherState.ALL_APPS)
                return;
            LayoutInflater layoutInflater = LayoutInflater.from(launcher);
            WorkEduView v = (WorkEduView) layoutInflater.inflate(R.layout.work_profile_edu, launcher.getDragLayer(), false);
            v.show();
            v.goToFirstPage();
            launcher.getStateManager().removeStateListener(this);
        }
    };
    launcher.getStateManager().addStateListener(listener);
    return listener;
}
Also used : LauncherState(com.android.launcher3.LauncherState) LayoutInflater(android.view.LayoutInflater) StateListener(com.android.launcher3.statemanager.StateManager.StateListener)

Aggregations

LargeTest (androidx.test.filters.LargeTest)4 AllAppsPagedView (com.android.launcher3.allapps.AllAppsPagedView)4 WorkEduView (com.android.launcher3.views.WorkEduView)4 Objects (java.util.Objects)4 Test (org.junit.Test)4 TextView (android.widget.TextView)2 Ignore (org.junit.Ignore)2 LayoutInflater (android.view.LayoutInflater)1 LauncherState (com.android.launcher3.LauncherState)1 StateListener (com.android.launcher3.statemanager.StateManager.StateListener)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1