Debian Codegraph @

tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt

raw
1
2 /*
3 * Copyright (C) 2020 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package com.android.server.wm.flicker.close
19
20 import androidx.test.filters.FlakyTest
21 import androidx.test.filters.RequiresDevice
22 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
23 import com.android.server.wm.flicker.FlickerTestParameter
24 import com.android.server.wm.flicker.FlickerTestParameterFactory
25 import com.android.server.wm.flicker.annotation.Group4
26 import com.android.server.wm.flicker.dsl.FlickerBuilder
27 import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled
28 import org.junit.Assume.assumeFalse
29 import org.junit.Assume.assumeTrue
30 import org.junit.FixMethodOrder
31 import org.junit.Test
32 import org.junit.runner.RunWith
33 import org.junit.runners.MethodSorters
34 import org.junit.runners.Parameterized
35
36 /**
37 * Test app closes by pressing back button
38 *
39 * To run this test: `atest FlickerTests:CloseAppBackButtonTest`
40 *
41 * Actions:
42 * Make sure no apps are running on the device
43 * Launch an app [testApp] and wait animation to complete
44 * Press back button
45 *
46 * To run only the presubmit assertions add: `--
47 * --module-arg FlickerTests:exclude-annotation:androidx.test.filters.FlakyTest
48 * --module-arg FlickerTests:include-annotation:android.platform.test.annotations.Presubmit`
49 *
50 * To run only the postsubmit assertions add: `--
51 * --module-arg FlickerTests:exclude-annotation:androidx.test.filters.FlakyTest
52 * --module-arg FlickerTests:include-annotation:android.platform.test.annotations.Postsubmit`
53 *
54 * To run only the flaky assertions add: `--
55 * --module-arg FlickerTests:include-annotation:androidx.test.filters.FlakyTest`
56 *
57 * Notes:
58 * 1. Some default assertions (e.g., nav bar, status bar and screen covered)
59 * are inherited [CloseAppTransition]
60 * 2. Part of the test setup occurs automatically via
61 * [com.android.server.wm.flicker.TransitionRunnerWithRules],
62 * including configuring navigation mode, initial orientation and ensuring no
63 * apps are running before setup
64 */
65 @RequiresDevice
66 @RunWith(Parameterized::class)
67 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
68 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
69 @Group4
70 class CloseAppBackButtonTest(testSpec: FlickerTestParameter) : CloseAppTransition(testSpec) {
71 override val transition: FlickerBuilder.() -> Unit
72 get() = {
73 super.transition(this)
74 transitions {
75 device.pressBack()
76 wmHelper.waitForHomeActivityVisible()
77 }
78 }
79
80 /** {@inheritDoc} */
81 @FlakyTest
82 @Test
83 override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()
84
85 /** {@inheritDoc} */
86 @FlakyTest(bugId = 206753786)
87 @Test
88 override fun statusBarLayerRotatesScales() {
89 // This test doesn't work in shell transitions because of b/206753786
90 assumeFalse(isShellTransitionsEnabled)
91 super.statusBarLayerRotatesScales()
92 }
93
94 @FlakyTest(bugId = 214452854)
95 @Test
96 fun statusBarLayerRotatesScales_shellTransit() {
97 assumeTrue(isShellTransitionsEnabled)
98 super.statusBarLayerRotatesScales()
99 }
100
101 /** {@inheritDoc} */
102 @FlakyTest(bugId = 229762973)
103 @Test
104 override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
105 super.visibleLayersShownMoreThanOneConsecutiveEntry()
106
107 companion object {
108 /**
109 * Creates the test configurations.
110 *
111 * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring
112 * repetitions, screen orientation and navigation modes.
113 */
114 @Parameterized.Parameters(name = "{0}")
115 @JvmStatic
116 fun getParams(): List<FlickerTestParameter> {
117 return FlickerTestParameterFactory.getInstance()
118 .getConfigNonRotationTests(repetitions = 3)
119 }
120 }
121 }