1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.quickstep; 17 18 import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL; 19 import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT; 20 21 import static org.junit.Assert.assertNotNull; 22 import static org.junit.Assert.assertTrue; 23 24 import android.content.Intent; 25 import android.platform.test.annotations.PlatinumTest; 26 27 import com.android.launcher3.tapl.OverviewTask.OverviewSplitTask; 28 import com.android.launcher3.tapl.OverviewTaskMenu; 29 import com.android.launcher3.ui.AbstractLauncherUiTest; 30 import com.android.launcher3.uioverrides.QuickstepLauncher; 31 import com.android.launcher3.util.rule.TestStabilityRule; 32 33 import org.junit.Test; 34 35 /** 36 * This test run in both Out of process (Oop) and in-process (Ipc). 37 * Tests the app Icon in overview. 38 */ 39 public class TaplOverviewIconTest extends AbstractLauncherUiTest<QuickstepLauncher> { 40 41 private static final String CALCULATOR_APP_PACKAGE = 42 resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR); 43 44 @PlatinumTest(focusArea = "launcher") 45 @Test testOverviewActionsMenu()46 public void testOverviewActionsMenu() { 47 startTestAppsWithCheck(); 48 49 OverviewTaskMenu menu = mLauncher.goHome().switchToOverview().getCurrentTask().tapMenu(); 50 51 assertNotNull("Tapping App info menu item returned null", menu.tapAppInfoMenuItem()); 52 executeOnLauncher(launcher -> assertTrue( 53 "Launcher activity is the top activity; expecting another activity to be the top", 54 isInLaunchedApp(launcher))); 55 } 56 startTestAppsWithCheck()57 private void startTestAppsWithCheck() { 58 startTestApps(); 59 executeOnLauncher(launcher -> assertTrue( 60 "Launcher activity is the top activity; expecting another activity to be the top " 61 + "one", 62 isInLaunchedApp(launcher))); 63 } 64 startTestApps()65 private void startTestApps() { 66 startAppFast(getAppPackageName()); 67 startAppFast(CALCULATOR_APP_PACKAGE); 68 startTestActivity(2); 69 } 70 71 @Test 72 @TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/288939273 testSplitTaskTapBothIconMenus()73 public void testSplitTaskTapBothIconMenus() { 74 createAndLaunchASplitPair(); 75 76 OverviewTaskMenu taskMenu = 77 mLauncher.goHome().switchToOverview().getCurrentTask().tapMenu(); 78 assertTrue("App info item not appearing in expanded task menu.", 79 taskMenu.hasMenuItem("App info")); 80 taskMenu.touchOutsideTaskMenuToDismiss(); 81 82 OverviewTaskMenu splitMenu = 83 mLauncher.goHome().switchToOverview().getCurrentTask().tapMenu( 84 OverviewSplitTask.SPLIT_BOTTOM_OR_RIGHT); 85 assertTrue("App info item not appearing in expanded split task's menu.", 86 splitMenu.hasMenuItem("App info")); 87 splitMenu.touchOutsideTaskMenuToDismiss(); 88 } 89 createAndLaunchASplitPair()90 private void createAndLaunchASplitPair() { 91 clearAllRecentTasks(); 92 93 startTestActivity(2); 94 startTestActivity(3); 95 96 if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) { 97 mLauncher.goHome().switchToOverview().getOverviewActions() 98 .clickSplit() 99 .getTestActivityTask(2) 100 .open(); 101 } else { 102 mLauncher.goHome().switchToOverview().getCurrentTask() 103 .tapMenu() 104 .tapSplitMenuItem() 105 .getCurrentTask() 106 .open(); 107 } 108 } 109 } 110