Files
lawnchair/tests/src/com/android/launcher3/allapps/OopTaplOpenCloseAllApps.java
Pat Manning ff74bb5ded Mark existing Launcher CUJs as Platinum tests.
Exclusion CL: cl/565329636 & cl/569615823

Acceptance Criteria:
- TaplTestsQuickstep#testOverviewActionsMenu: https://android-build.corp.google.com/test_investigate/?invocationId=I68300010197543619&testResultId=TR13128935381586398&tab=performance
- OopTaplOpenCloseAllApps#testAllAppsSwipeUpToWorkspace: https://android-build.corp.google.com/test_investigate/?invocationId=I29900010197342608&testResultId=TR26328933842394642&tab=performance
- AddWidgetTest#testResizeWidget: https://android-build.corp.google.com/test_investigate/?invocationId=I56600010197561454&testResultId=TR14428935383013115&tab=performance
- TaplTestsLauncher3#testLaunchHomeScreenMenuItem: https://android-build.corp.google.com/test_investigate/?invocationId=I56600010197561454&testResultId=TR20028935383489058&tab=performance

Bug: 300249773
Test: TaplTestsLauncher3
Test: OopTaplOpenCloseAllApps
Test: AddWidgetTest
Test: TaplTestsQuickstep
Change-Id: Ica71dbad91efe8f5b4fd243f0ec78fc3c3c4d456
2023-09-29 23:27:27 +00:00

192 lines
6.9 KiB
Java

/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.allapps;
import static com.android.launcher3.ui.TaplTestsLauncher3.expectFail;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import android.platform.test.annotations.PlatinumTest;
import com.android.launcher3.LauncherState;
import com.android.launcher3.tapl.AllApps;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import org.junit.Before;
import org.junit.Test;
/**
* Test that we can open and close the all apps in multiple situations.
* The test runs in Out of process (Oop) and in process.
*/
public class OopTaplOpenCloseAllApps extends AbstractLauncherUiTest {
/**
* Calls static method initialize
*/
@Before
public void setUp() throws Exception {
super.setUp();
initialize(this);
}
/**
* Make sure we can go home after pressing the context menu on an Icon on the AllApps.
*/
@Test
public void testPressHomeOnAllAppsContextMenu() {
final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
allApps.getAppIcon("TestActivity7").openMenu();
} finally {
allApps.unfreeze();
}
mLauncher.goHome();
}
/**
* Make sure we can open AllApps from the Workspace.
*/
@Test
@PortraitLandscape
public void testWorkspaceSwitchToAllApps() {
assertNotNull("switchToAllApps() returned null",
mLauncher.getWorkspace().switchToAllApps());
assertTrue("Launcher internal state is not All Apps",
isInState(() -> LauncherState.ALL_APPS));
}
/**
* Make sure we can go to Workspace from AllApps
*/
@Test
@PortraitLandscape
public void testAllAppsSwitchToWorkspace() {
assertNotNull("switchToWorkspace() returned null",
mLauncher.getWorkspace().switchToAllApps()
.switchToWorkspace(/* swipeDown= */ true));
assertTrue("Launcher internal state is not Workspace",
isInState(() -> LauncherState.NORMAL));
}
/**
* Make sure the swipe up gesture can take us back to the workspace from AllApps
*/
@PlatinumTest(focusArea = "launcher")
@Test
@PortraitLandscape
public void testAllAppsSwipeUpToWorkspace() {
assertNotNull("testAllAppsSwipeUpToWorkspace() returned null",
mLauncher.getWorkspace().switchToAllApps()
.switchToWorkspace(/* swipeDown= */ false));
assertTrue("Launcher internal state is not Workspace",
isInState(() -> LauncherState.NORMAL));
}
/**
* Make sure we can go to the Workspace from AllApps on tablets by tapping on the background.
*/
@Test
@PortraitLandscape
public void testAllAppsDeadzoneForTablet() {
assumeTrue(mLauncher.isTablet());
mLauncher.getWorkspace().switchToAllApps().dismissByTappingOutsideForTablet(
true /* tapRight */);
mLauncher.getWorkspace().switchToAllApps().dismissByTappingOutsideForTablet(
false /* tapRight */);
}
/**
* Make sure that AllApps closes when pressing the home button
*/
@Test
@PortraitLandscape
public void testAllAppsFromHome() {
// Test opening all apps
assertNotNull("switchToAllApps() returned null",
mLauncher.getWorkspace().switchToAllApps());
runAllAppsTest(mLauncher.getAllApps());
// Testing pressHome.
assertTrue("Launcher internal state is not All Apps",
isInState(() -> LauncherState.ALL_APPS));
assertNotNull("pressHome returned null", mLauncher.goHome());
assertTrue("Launcher internal state is not Home",
isInState(() -> LauncherState.NORMAL));
assertNotNull("getHome returned null", mLauncher.getWorkspace());
}
/**
* Makes sure the state of AllApps is correct.
*/
public void runAllAppsTest(AllApps allApps) {
allApps.freeze();
try {
assertNotNull("allApps parameter is null", allApps);
assertTrue(
"Launcher internal state is not All Apps",
isInState(() -> LauncherState.ALL_APPS));
// Test flinging forward and backward.
executeOnLauncher(launcher -> assertEquals(
"All Apps started in already scrolled state", 0,
getAllAppsScroll(launcher)));
allApps.flingForward();
assertTrue("Launcher internal state is not All Apps",
isInState(() -> LauncherState.ALL_APPS));
final Integer flingForwardY = getFromLauncher(
launcher -> getAllAppsScroll(launcher));
executeOnLauncher(
launcher -> assertTrue("flingForward() didn't scroll App Apps",
flingForwardY > 0));
allApps.flingBackward();
assertTrue(
"Launcher internal state is not All Apps",
isInState(() -> LauncherState.ALL_APPS));
final Integer flingBackwardY = getFromLauncher(
launcher -> getAllAppsScroll(launcher));
executeOnLauncher(launcher -> assertTrue("flingBackward() didn't scroll App Apps",
flingBackwardY < flingForwardY));
// Test scrolling down to YouTube.
assertNotNull("All apps: can't find YouTube", allApps.getAppIcon("YouTube"));
// Test scrolling up to Camera.
assertNotNull("All apps: can't find Camera", allApps.getAppIcon("Camera"));
// Test failing to find a non-existing app.
final AllApps allAppsFinal = allApps;
expectFail("All apps: could find a non-existing app",
() -> allAppsFinal.getAppIcon("NO APP"));
assertTrue(
"Launcher internal state is not All Apps",
isInState(() -> LauncherState.ALL_APPS));
} finally {
allApps.unfreeze();
}
}
}