Search in sources :

Example 1 with WorkProfileManager

use of com.android.launcher3.allapps.WorkProfileManager in project android_packages_apps_Launcher3 by ProtonAOSP.

the class WorkProfileTest method toggleWorks.

@Test
public void toggleWorks() {
    waitForWorkTabSetup();
    executeOnLauncher(launcher -> {
        AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
        pagedView.setCurrentPage(WORK_PAGE);
    });
    WorkProfileManager manager = getFromLauncher(l -> l.getAppsView().getWorkManager());
    waitForLauncherCondition("work profile initial state check failed", launcher -> manager.getWorkModeSwitch() != null && manager.getCurrentState() == WorkProfileManager.STATE_ENABLED && manager.getWorkModeSwitch().isEnabled(), LauncherInstrumentation.WAIT_TIME_MS);
    // start work profile toggle OFF test
    executeOnLauncher(l -> l.getAppsView().getWorkManager().getWorkModeSwitch().performClick());
    waitForLauncherCondition("Work profile toggle OFF failed", launcher -> {
        // pulls current state from system
        manager.reset();
        return manager.getCurrentState() == WorkProfileManager.STATE_DISABLED;
    }, LauncherInstrumentation.WAIT_TIME_MS);
    // start work profile toggle ON test
    executeOnLauncher(l -> {
        AllAppsContainerView allApps = l.getAppsView();
        assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
        View workPausedCard = allApps.getActiveRecyclerView().findViewHolderForAdapterPosition(0).itemView;
        workPausedCard.findViewById(R.id.enable_work_apps).performClick();
    });
    waitForLauncherCondition("Work profile toggle ON failed", launcher -> {
        // pulls current state from system
        manager.reset();
        return manager.getCurrentState() == WorkProfileManager.STATE_ENABLED;
    }, LauncherInstrumentation.WAIT_TIME_MS);
}
Also used : AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkProfileManager(com.android.launcher3.allapps.WorkProfileManager) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Test(org.junit.Test)

Example 2 with WorkProfileManager

use of com.android.launcher3.allapps.WorkProfileManager in project android_packages_apps_404Launcher by P-404.

the class WorkProfileTest method toggleWorks.

@Test
public void toggleWorks() {
    waitForWorkTabSetup();
    executeOnLauncher(launcher -> {
        AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
        pagedView.setCurrentPage(WORK_PAGE);
    });
    WorkProfileManager manager = getFromLauncher(l -> l.getAppsView().getWorkManager());
    waitForLauncherCondition("work profile initial state check failed", launcher -> manager.getWorkModeSwitch() != null && manager.getCurrentState() == WorkProfileManager.STATE_ENABLED && manager.getWorkModeSwitch().isEnabled(), LauncherInstrumentation.WAIT_TIME_MS);
    // start work profile toggle OFF test
    executeOnLauncher(l -> l.getAppsView().getWorkManager().getWorkModeSwitch().performClick());
    waitForLauncherCondition("Work profile toggle OFF failed", launcher -> {
        // pulls current state from system
        manager.reset();
        return manager.getCurrentState() == WorkProfileManager.STATE_DISABLED;
    }, LauncherInstrumentation.WAIT_TIME_MS);
    // start work profile toggle ON test
    executeOnLauncher(l -> {
        AllAppsContainerView allApps = l.getAppsView();
        assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
        View workPausedCard = allApps.getActiveRecyclerView().findViewHolderForAdapterPosition(0).itemView;
        workPausedCard.findViewById(R.id.enable_work_apps).performClick();
    });
    waitForLauncherCondition("Work profile toggle ON failed", launcher -> {
        // pulls current state from system
        manager.reset();
        return manager.getCurrentState() == WorkProfileManager.STATE_ENABLED;
    }, LauncherInstrumentation.WAIT_TIME_MS);
}
Also used : AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkProfileManager(com.android.launcher3.allapps.WorkProfileManager) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Test(org.junit.Test)

Example 3 with WorkProfileManager

use of com.android.launcher3.allapps.WorkProfileManager in project android_packages_apps_Launcher3 by ArrowOS.

the class WorkProfileTest method toggleWorks.

@Test
public void toggleWorks() {
    waitForWorkTabSetup();
    executeOnLauncher(launcher -> {
        AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
        pagedView.setCurrentPage(WORK_PAGE);
    });
    WorkProfileManager manager = getFromLauncher(l -> l.getAppsView().getWorkManager());
    waitForLauncherCondition("work profile initial state check failed", launcher -> manager.getWorkModeSwitch() != null && manager.getCurrentState() == WorkProfileManager.STATE_ENABLED && manager.getWorkModeSwitch().isEnabled(), LauncherInstrumentation.WAIT_TIME_MS);
    // start work profile toggle OFF test
    executeOnLauncher(l -> l.getAppsView().getWorkManager().getWorkModeSwitch().performClick());
    waitForLauncherCondition("Work profile toggle OFF failed", launcher -> {
        // pulls current state from system
        manager.reset();
        return manager.getCurrentState() == WorkProfileManager.STATE_DISABLED;
    }, LauncherInstrumentation.WAIT_TIME_MS);
    // start work profile toggle ON test
    executeOnLauncher(l -> {
        AllAppsContainerView allApps = l.getAppsView();
        assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
        View workPausedCard = allApps.getActiveRecyclerView().findViewHolderForAdapterPosition(0).itemView;
        workPausedCard.findViewById(R.id.enable_work_apps).performClick();
    });
    waitForLauncherCondition("Work profile toggle ON failed", launcher -> {
        // pulls current state from system
        manager.reset();
        return manager.getCurrentState() == WorkProfileManager.STATE_ENABLED;
    }, LauncherInstrumentation.WAIT_TIME_MS);
}
Also used : AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkProfileManager(com.android.launcher3.allapps.WorkProfileManager) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Test(org.junit.Test)

Example 4 with WorkProfileManager

use of com.android.launcher3.allapps.WorkProfileManager in project android_packages_apps_Launcher3 by AOSPA.

the class WorkProfileTest method toggleWorks.

@Test
public void toggleWorks() {
    waitForWorkTabSetup();
    executeOnLauncher(launcher -> {
        AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
        pagedView.setCurrentPage(WORK_PAGE);
    });
    WorkProfileManager manager = getFromLauncher(l -> l.getAppsView().getWorkManager());
    waitForLauncherCondition("work profile initial state check failed", launcher -> manager.getWorkModeSwitch() != null && manager.getCurrentState() == WorkProfileManager.STATE_ENABLED && manager.getWorkModeSwitch().isEnabled(), LauncherInstrumentation.WAIT_TIME_MS);
    // start work profile toggle OFF test
    executeOnLauncher(l -> l.getAppsView().getWorkManager().getWorkModeSwitch().performClick());
    waitForLauncherCondition("Work profile toggle OFF failed", launcher -> {
        // pulls current state from system
        manager.reset();
        return manager.getCurrentState() == WorkProfileManager.STATE_DISABLED;
    }, LauncherInstrumentation.WAIT_TIME_MS);
    // start work profile toggle ON test
    executeOnLauncher(l -> {
        AllAppsContainerView allApps = l.getAppsView();
        assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
        View workPausedCard = allApps.getActiveRecyclerView().findViewHolderForAdapterPosition(0).itemView;
        workPausedCard.findViewById(R.id.enable_work_apps).performClick();
    });
    waitForLauncherCondition("Work profile toggle ON failed", launcher -> {
        // pulls current state from system
        manager.reset();
        return manager.getCurrentState() == WorkProfileManager.STATE_ENABLED;
    }, LauncherInstrumentation.WAIT_TIME_MS);
}
Also used : AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkProfileManager(com.android.launcher3.allapps.WorkProfileManager) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Test(org.junit.Test)

Aggregations

View (android.view.View)4 AllAppsContainerView (com.android.launcher3.allapps.AllAppsContainerView)4 AllAppsPagedView (com.android.launcher3.allapps.AllAppsPagedView)4 WorkProfileManager (com.android.launcher3.allapps.WorkProfileManager)4 Test (org.junit.Test)4