1 /*
2  * Copyright (C) 2022 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.flicker.splitscreen
18 
19 import android.platform.test.annotations.Postsubmit
20 import android.platform.test.annotations.Presubmit
21 import android.tools.NavBar
22 import android.tools.flicker.junit.FlickerParametersRunnerFactory
23 import android.tools.flicker.legacy.FlickerBuilder
24 import android.tools.flicker.legacy.LegacyFlickerTest
25 import android.tools.flicker.legacy.LegacyFlickerTestFactory
26 import androidx.test.filters.FlakyTest
27 import androidx.test.filters.RequiresDevice
28 import com.android.wm.shell.flicker.splitscreen.benchmark.EnterSplitScreenByDragFromNotificationBenchmark
29 import com.android.wm.shell.flicker.utils.ICommonAssertions
30 import com.android.wm.shell.flicker.utils.SPLIT_SCREEN_DIVIDER_COMPONENT
31 import com.android.wm.shell.flicker.utils.appWindowIsVisibleAtEnd
32 import com.android.wm.shell.flicker.utils.layerBecomesVisible
33 import com.android.wm.shell.flicker.utils.layerIsVisibleAtEnd
34 import com.android.wm.shell.flicker.utils.splitAppLayerBoundsBecomesVisibleByDrag
35 import com.android.wm.shell.flicker.utils.splitAppLayerBoundsIsVisibleAtEnd
36 import com.android.wm.shell.flicker.utils.splitScreenDividerBecomesVisible
37 import org.junit.FixMethodOrder
38 import org.junit.Test
39 import org.junit.runner.RunWith
40 import org.junit.runners.MethodSorters
41 import org.junit.runners.Parameterized
42 
43 /**
44  * Test enter split screen by dragging app icon from notification. This test is only for large
45  * screen devices.
46  *
47  * To run this test: `atest WMShellFlickerTestsSplitScreen:EnterSplitScreenByDragFromNotification`
48  */
49 @RequiresDevice
50 @RunWith(Parameterized::class)
51 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
52 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
53 class EnterSplitScreenByDragFromNotification(override val flicker: LegacyFlickerTest) :
54     EnterSplitScreenByDragFromNotificationBenchmark(flicker), ICommonAssertions {
55     /** {@inheritDoc} */
56     override val transition: FlickerBuilder.() -> Unit
<lambda>null57         get() = {
58             defaultSetup(this)
59             defaultTeardown(this)
60             thisTransition(this)
61         }
62 
63     @FlakyTest(bugId = 245472831)
64     @Test
splitScreenDividerBecomesVisiblenull65     fun splitScreenDividerBecomesVisible() {
66         flicker.splitScreenDividerBecomesVisible()
67     }
68 
69     // TODO(b/245472831): Back to splitScreenDividerBecomesVisible after shell transition ready.
70     @Presubmit
71     @Test
splitScreenDividerIsVisibleAtEndnull72     fun splitScreenDividerIsVisibleAtEnd() {
73         flicker.assertLayersEnd { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) }
74     }
75 
primaryAppLayerIsVisibleAtEndnull76     @Presubmit @Test fun primaryAppLayerIsVisibleAtEnd() = flicker.layerIsVisibleAtEnd(primaryApp)
77 
78     @Presubmit
79     @Test
80     fun secondaryAppLayerBecomesVisible() {
81         flicker.layerBecomesVisible(sendNotificationApp)
82     }
83 
84     @Presubmit
85     @Test
primaryAppBoundsIsVisibleAtEndnull86     fun primaryAppBoundsIsVisibleAtEnd() =
87         flicker.splitAppLayerBoundsIsVisibleAtEnd(
88             primaryApp,
89             landscapePosLeft = false,
90             portraitPosTop = false
91         )
92 
93     @Presubmit
94     @Test
95     fun secondaryAppBoundsBecomesVisible() =
96         flicker.splitAppLayerBoundsBecomesVisibleByDrag(sendNotificationApp)
97 
98     @Presubmit
99     @Test
100     fun primaryAppWindowIsVisibleAtEnd() = flicker.appWindowIsVisibleAtEnd(primaryApp)
101 
102     @Presubmit
103     @Test
104     fun secondaryAppWindowIsVisibleAtEnd() = flicker.appWindowIsVisibleAtEnd(sendNotificationApp)
105 
106     /** {@inheritDoc} */
107     @Postsubmit @Test override fun entireScreenCovered() = super.entireScreenCovered()
108 
109     /** {@inheritDoc} */
110     @Postsubmit
111     @Test
112     override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()
113 
114     /** {@inheritDoc} */
115     @Postsubmit
116     @Test
117     override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()
118 
119     /** {@inheritDoc} */
120     @Postsubmit
121     @Test
122     override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
123 
124     /** {@inheritDoc} */
125     @Postsubmit
126     @Test
127     override fun statusBarLayerIsVisibleAtStartAndEnd() =
128         super.statusBarLayerIsVisibleAtStartAndEnd()
129 
130     /** {@inheritDoc} */
131     @Postsubmit
132     @Test
133     override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd()
134 
135     /** {@inheritDoc} */
136     @Postsubmit
137     @Test
138     override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()
139 
140     /** {@inheritDoc} */
141     @Postsubmit
142     @Test
143     override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd()
144 
145     /** {@inheritDoc} */
146     @Postsubmit
147     @Test
148     override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible()
149 
150     /** {@inheritDoc} */
151     @Postsubmit
152     @Test
153     override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
154         super.visibleLayersShownMoreThanOneConsecutiveEntry()
155 
156     /** {@inheritDoc} */
157     @Postsubmit
158     @Test
159     override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
160         super.visibleWindowsShownMoreThanOneConsecutiveEntry()
161 
162     companion object {
163         @Parameterized.Parameters(name = "{0}")
164         @JvmStatic
165         fun getParams() =
166             LegacyFlickerTestFactory.nonRotationTests(
167                 // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy.
168                 supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
169             )
170     }
171 }
172