Debian Codegraph @

tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt

raw
1 /*
2 * Copyright (C) 2021 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.server.wm.flicker.launch
18
19 import android.platform.test.annotations.Presubmit
20 import androidx.test.filters.FlakyTest
21 import com.android.server.wm.flicker.FlickerTestParameter
22 import com.android.server.wm.flicker.dsl.FlickerBuilder
23 import com.android.server.wm.flicker.navBarLayerPositionEnd
24 import com.android.server.wm.traces.common.FlickerComponentName
25 import org.junit.Test
26
27 /**
28 * Base class for app launch tests from lock screen
29 */
30 abstract class OpenAppFromLockTransition(testSpec: FlickerTestParameter)
31 : OpenAppTransition(testSpec) {
32
33 /**
34 * Defines the transition used to run the test
35 */
36 override val transition: FlickerBuilder.() -> Unit
37 get() = {
38 super.transition(this)
39 setup {
40 eachRun {
41 device.sleep()
42 wmHelper.waitFor("noAppWindowsOnTop") {
43 it.wmState.topVisibleAppWindow.isEmpty()
44 }
45 }
46 }
47 teardown {
48 eachRun {
49 testApp.exit(wmHelper)
50 }
51 }
52 transitions {
53 testApp.launchViaIntent(wmHelper)
54 wmHelper.waitForFullScreenApp(testApp.component)
55 }
56 }
57
58 /**
59 * Check that we go from no focus to focus on the [testApp]
60 */
61 @Presubmit
62 @Test
63 open fun focusChanges() {
64 testSpec.assertEventLog {
65 this.focusChanges("", testApp.`package`)
66 }
67 }
68
69 /**
70 * Checks that we start of with no top windows and then [testApp] becomes the first and only top
71 * window of the transition, with snapshot or splash screen windows optionally showing first.
72 */
73 @FlakyTest(bugId = 203538234)
74 @Test
75 open fun appWindowBecomesFirstAndOnlyTopWindow() {
76 testSpec.assertWm {
77 this.hasNoVisibleAppWindow()
78 .then()
79 .isAppWindowOnTop(FlickerComponentName.SNAPSHOT, isOptional = true)
80 .then()
81 .isAppWindowOnTop(FlickerComponentName.SPLASH_SCREEN, isOptional = true)
82 .then()
83 .isAppWindowOnTop(testApp.component)
84 }
85 }
86
87 /**
88 * Checks that the screen is locked at the start of the transition ([colorFadComponent])
89 * layer is visible
90 */
91 @Presubmit
92 @Test
93 fun screenLockedStart() {
94 testSpec.assertLayersStart {
95 isEmpty()
96 }
97 }
98
99 /** {@inheritDoc} */
100 @FlakyTest(bugId = 203538234)
101 @Test
102 override fun appWindowBecomesVisible() = super.appWindowBecomesVisible()
103
104 /**
105 * Checks the position of the navigation bar at the start and end of the transition
106 *
107 * Differently from the normal usage of this assertion, check only the final state of the
108 * transition because the display is off at the start and the NavBar is never visible
109 */
110 @Presubmit
111 @Test
112 override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd()
113
114 /**
115 * Checks that the status bar layer is visible at the end of the trace
116 *
117 * It is not possible to check at the start because the screen is off
118 */
119 @Presubmit
120 @Test
121 override fun statusBarLayerIsVisible() {
122 testSpec.assertLayersEnd {
123 this.isVisible(FlickerComponentName.STATUS_BAR)
124 }
125 }
126 }