Debian Codegraph @

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

raw
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.server.wm.flicker.launch
18
19 import android.platform.test.annotations.Postsubmit
20 import android.platform.test.annotations.RequiresDevice
21 import com.android.server.wm.flicker.FlickerParametersRunnerFactory
22 import com.android.server.wm.flicker.FlickerTestParameter
23 import com.android.server.wm.flicker.FlickerTestParameterFactory
24 import com.android.server.wm.flicker.annotation.Group1
25 import com.android.server.wm.flicker.dsl.FlickerBuilder
26 import org.junit.FixMethodOrder
27 import org.junit.Test
28 import org.junit.runner.RunWith
29 import org.junit.runners.MethodSorters
30 import org.junit.runners.Parameterized
31
32 /**
33 * Test cold launching an app from a notification.
34 *
35 * This test assumes the device doesn't have AOD enabled
36 *
37 * To run this test: `atest FlickerTests:OpenAppFromNotificationCold`
38 */
39 @RequiresDevice
40 @RunWith(Parameterized::class)
41 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
42 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
43 @Group1
44 @Postsubmit
45 open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter)
46 : OpenAppFromNotificationWarm(testSpec) {
47 override val transition: FlickerBuilder.() -> Unit
48 get() = {
49 super.transition(this)
50
51 setup {
52 eachRun {
53 // Close the app that posted the notification to trigger a cold start next time
54 // it is open - can't just kill it because that would remove the notification.
55 taplInstrumentation.goHome()
56 taplInstrumentation.workspace.switchToOverview()
57 taplInstrumentation.overview.dismissAllTasks()
58 }
59 }
60 }
61
62 @Test
63 @Postsubmit
64 override fun appWindowBecomesVisible() = appWindowBecomesVisible_coldStart()
65
66 @Test
67 @Postsubmit
68 override fun appLayerBecomesVisible() = appLayerBecomesVisible_coldStart()
69
70 companion object {
71 /**
72 * Creates the test configurations.
73 *
74 * See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring
75 * repetitions, screen orientation and navigation modes.
76 */
77 @Parameterized.Parameters(name = "{0}")
78 @JvmStatic
79 fun getParams(): Collection<FlickerTestParameter> {
80 return com.android.server.wm.flicker.FlickerTestParameterFactory.getInstance()
81 .getConfigNonRotationTests(repetitions = 3)
82 }
83 }
84 }