• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 
17 package com.android.wm.shell.scenarios
18 
19 import android.app.Instrumentation
20 import android.tools.NavBar
21 import android.tools.Rotation
22 import android.tools.flicker.rules.ChangeDisplayOrientationRule
23 import android.tools.traces.parsers.WindowManagerStateHelper
24 import android.window.DesktopModeFlags
25 import androidx.test.platform.app.InstrumentationRegistry
26 import androidx.test.uiautomator.UiDevice
27 import com.android.launcher3.tapl.LauncherInstrumentation
28 import com.android.server.wm.flicker.helpers.DesktopModeAppHelper
29 import com.android.server.wm.flicker.helpers.NewTasksAppHelper
30 import com.android.server.wm.flicker.helpers.NonResizeableAppHelper
31 import com.android.server.wm.flicker.helpers.SimpleAppHelper
32 import com.android.window.flags.Flags
33 import com.android.wm.shell.Utils
34 import org.junit.After
35 import org.junit.Assume
36 import org.junit.Before
37 import org.junit.Ignore
38 import org.junit.Rule
39 import org.junit.Test
40 
41 /**
42  * Base scenario test for minimizing all the desktop app windows one-by-one by clicking their
43  * minimize buttons.
44  */
45 @Ignore("Test Base Class")
46 abstract class MinimizeAppWindows
47 constructor(
48     private val rotation: Rotation = Rotation.ROTATION_0,
49     private val usingKeyboard: Boolean = false
50 ) {
51     private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
52     private val tapl = LauncherInstrumentation()
53     private val wmHelper = WindowManagerStateHelper(instrumentation)
54     private val device = UiDevice.getInstance(instrumentation)
55     private val testApp1 = DesktopModeAppHelper(SimpleAppHelper(instrumentation))
56     private val testApp2 = DesktopModeAppHelper(NonResizeableAppHelper(instrumentation))
57     private val testApp3 = DesktopModeAppHelper(NewTasksAppHelper(instrumentation))
58 
59     @Rule @JvmField val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, Rotation.ROTATION_0)
60 
61     @Before
setupnull62     fun setup() {
63         Assume.assumeTrue(Flags.enableDesktopWindowingMode() && tapl.isTablet)
64         Assume.assumeTrue(Flags.enableMinimizeButton())
65         if (usingKeyboard) {
66             Assume.assumeTrue(DesktopModeFlags.ENABLE_TASK_RESIZING_KEYBOARD_SHORTCUTS.isTrue)
67         }
68         tapl.setEnableRotation(true)
69         tapl.setExpectedRotation(rotation.value)
70         ChangeDisplayOrientationRule.setRotation(rotation)
71         testApp1.enterDesktopMode(wmHelper, device)
72         testApp2.launchViaIntent(wmHelper)
73         testApp3.launchViaIntent(wmHelper)
74     }
75 
76     @Test
minimizeAllAppWindowsnull77     open fun minimizeAllAppWindows() {
78         testApp3.minimizeDesktopApp(wmHelper, device, usingKeyboard = usingKeyboard)
79         testApp2.minimizeDesktopApp(wmHelper, device, usingKeyboard = usingKeyboard)
80         testApp1.minimizeDesktopApp(wmHelper, device, usingKeyboard = usingKeyboard)
81     }
82 
83     @After
teardownnull84     fun teardown() {
85         testApp1.exit(wmHelper)
86         testApp2.exit(wmHelper)
87         testApp3.exit(wmHelper)
88     }
89 }
90