| 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 androidx.test.filters.FlakyTest |
| 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.Group1 |
| 26 |
import com.android.server.wm.flicker.dsl.FlickerBuilder |
| 27 |
import com.android.server.wm.traces.common.FlickerComponentName |
| 28 |
import org.junit.FixMethodOrder |
| 29 |
import org.junit.Test |
| 30 |
import org.junit.runner.RunWith |
| 31 |
import org.junit.runners.MethodSorters |
| 32 |
import org.junit.runners.Parameterized |
| 33 |
|
| 34 |
/** |
| 35 |
* Test warm launching an app from a notification from the lock screen. |
| 36 |
* |
| 37 |
* This test assumes the device doesn't have AOD enabled |
| 38 |
* |
| 39 |
* To run this test: `atest FlickerTests:OpenAppFromLockNotificationWarm` |
| 40 |
*/ |
| 41 |
@RequiresDevice |
| 42 |
@RunWith(Parameterized::class) |
| 43 |
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) |
| 44 |
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
| 45 |
@Group1 |
| 46 |
@Postsubmit |
| 47 |
open class OpenAppFromLockNotificationWarm(testSpec: FlickerTestParameter) |
| 48 |
: OpenAppFromNotificationWarm(testSpec) { |
| 49 |
|
| 50 |
override val openingNotificationsFromLockScreen = true |
| 51 |
|
| 52 |
override val transition: FlickerBuilder.() -> Unit |
| 53 |
get() = { |
| 54 |
// Needs to run at start of transition, |
| 55 |
// so before the transition defined in super.transition |
| 56 |
transitions { |
| 57 |
device.wakeUp() |
| 58 |
} |
| 59 |
|
| 60 |
super.transition(this) |
| 61 |
|
| 62 |
// Needs to run at the end of the setup, so after the setup defined in super.transition |
| 63 |
setup { |
| 64 |
eachRun { |
| 65 |
device.sleep() |
| 66 |
wmHelper.waitFor("noAppWindowsOnTop") { |
| 67 |
it.wmState.topVisibleAppWindow.isEmpty() |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Checks that we start of with no top windows and then [testApp] becomes the first and |
| 75 |
* only top window of the transition, with snapshot or splash screen windows optionally showing |
| 76 |
* first. |
| 77 |
*/ |
| 78 |
@Test |
| 79 |
@Postsubmit |
| 80 |
open fun appWindowBecomesFirstAndOnlyTopWindow() { |
| 81 |
testSpec.assertWm { |
| 82 |
this.hasNoVisibleAppWindow() |
| 83 |
.then() |
| 84 |
.isAppWindowOnTop(FlickerComponentName.SNAPSHOT, isOptional = true) |
| 85 |
.then() |
| 86 |
.isAppWindowOnTop(FlickerComponentName.SPLASH_SCREEN, isOptional = true) |
| 87 |
.then() |
| 88 |
.isAppWindowOnTop(testApp.component) |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Checks that the screen is locked. |
| 94 |
*/ |
| 95 |
@Test |
| 96 |
@Postsubmit |
| 97 |
fun screenLockedStart() { |
| 98 |
testSpec.assertLayersStart { |
| 99 |
isEmpty() |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
/** {@inheritDoc} */ |
| 104 |
@FlakyTest(bugId = 229735718) |
| 105 |
@Test |
| 106 |
override fun entireScreenCovered() = super.entireScreenCovered() |
| 107 |
|
| 108 |
/** {@inheritDoc} */ |
| 109 |
@FlakyTest(bugId = 203538234) |
| 110 |
@Test |
| 111 |
override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = |
| 112 |
super.visibleWindowsShownMoreThanOneConsecutiveEntry() |
| 113 |
|
| 114 |
companion object { |
| 115 |
/** |
| 116 |
* Creates the test configurations. |
| 117 |
* |
| 118 |
* See [FlickerTestParameterFactory.getConfigNonRotationTests] for configuring |
| 119 |
* repetitions, screen orientation and navigation modes. |
| 120 |
*/ |
| 121 |
@Parameterized.Parameters(name = "{0}") |
| 122 |
@JvmStatic |
| 123 |
fun getParams(): Collection<FlickerTestParameter> { |
| 124 |
return com.android.server.wm.flicker.FlickerTestParameterFactory.getInstance() |
| 125 |
.getConfigNonRotationTests(repetitions = 3) |
| 126 |
} |
| 127 |
} |
| 128 |
} |