1 /* 2 * Copyright (C) 2023 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.notification 18 19 import android.platform.test.annotations.Presubmit 20 import android.platform.test.rule.SettingOverrideRule 21 import android.provider.Settings 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 android.tools.traces.component.ComponentNameMatcher 27 import androidx.test.filters.FlakyTest 28 import androidx.test.filters.RequiresDevice 29 import com.android.server.wm.flicker.statusBarLayerPositionAtEnd 30 import org.junit.ClassRule 31 import org.junit.FixMethodOrder 32 import org.junit.Ignore 33 import org.junit.Test 34 import org.junit.runner.RunWith 35 import org.junit.runners.MethodSorters 36 import org.junit.runners.Parameterized 37 38 /** 39 * Test warm launching an app from a notification from the lock screen. 40 * 41 * This test assumes the device doesn't have AOD enabled 42 * 43 * To run this test: `atest FlickerTestsNotification:OpenAppFromLockscreenNotificationWarmTest` 44 */ 45 @RequiresDevice 46 @RunWith(Parameterized::class) 47 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) 48 @FixMethodOrder(MethodSorters.NAME_ASCENDING) 49 class OpenAppFromLockscreenNotificationWarmTest(flicker: LegacyFlickerTest) : 50 OpenAppFromNotificationWarmTest(flicker) { 51 52 override val transition: FlickerBuilder.() -> Unit <lambda>null53 get() = { 54 transitions { 55 device.wakeUp() 56 openAppFromLockNotification() 57 } 58 59 // Needs to run at the end of the setup, so after the setup defined in super.transition 60 setup { 61 launchAppAndPostNotification() 62 goHome() 63 device.sleep() 64 wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() 65 } 66 67 teardown { testApp.exit(wmHelper) } 68 } 69 70 /** 71 * Checks that we start of with no top windows and then [testApp] becomes the first and only top 72 * window of the transition, with snapshot or splash screen windows optionally showing first. 73 */ 74 @Test 75 @Presubmit appWindowBecomesFirstAndOnlyTopWindownull76 fun appWindowBecomesFirstAndOnlyTopWindow() { 77 flicker.assertWm { 78 this.hasNoVisibleAppWindow() 79 .then() 80 .isAppWindowOnTop(ComponentNameMatcher.SNAPSHOT, isOptional = true) 81 .then() 82 .isAppWindowOnTop(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) 83 .then() 84 .isAppWindowOnTop(testApp) 85 } 86 } 87 88 /** Checks that the screen is locked at the start of the transition */ 89 @Test 90 @Presubmit screenLockedStartnull91 fun screenLockedStart() { 92 flicker.assertWmStart { isKeyguardShowing() } 93 } 94 95 /** {@inheritDoc} */ 96 @Test 97 @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") navBarLayerPositionAtStartAndEndnull98 override fun navBarLayerPositionAtStartAndEnd() {} 99 100 /** {@inheritDoc} */ 101 @Test 102 @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") taskBarWindowIsAlwaysVisiblenull103 override fun taskBarWindowIsAlwaysVisible() {} 104 105 /** {@inheritDoc} */ 106 @Test 107 @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") statusBarLayerPositionAtStartAndEndnull108 override fun statusBarLayerPositionAtStartAndEnd() {} 109 110 /** {@inheritDoc} */ 111 @Test 112 @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") statusBarLayerIsVisibleAtStartAndEndnull113 override fun statusBarLayerIsVisibleAtStartAndEnd() = 114 super.statusBarLayerIsVisibleAtStartAndEnd() 115 116 /** 117 * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the 118 * transition 119 */ 120 @Presubmit @Test fun statusBarLayerPositionAtEnd() = flicker.statusBarLayerPositionAtEnd() 121 122 /** {@inheritDoc} */ 123 @Test 124 @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") 125 override fun navBarWindowIsVisibleAtStartAndEnd() = super.navBarWindowIsVisibleAtStartAndEnd() 126 127 /** {@inheritDoc} */ 128 @Test 129 @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") 130 override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() 131 132 /** {@inheritDoc} */ 133 @Test 134 @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") 135 override fun navBarWindowIsAlwaysVisible() {} 136 137 /** {@inheritDoc} */ 138 @FlakyTest(bugId = 246284526) 139 @Test visibleLayersShownMoreThanOneConsecutiveEntrynull140 override fun visibleLayersShownMoreThanOneConsecutiveEntry() = 141 super.visibleLayersShownMoreThanOneConsecutiveEntry() 142 143 @Presubmit 144 @Test 145 override fun visibleWindowsShownMoreThanOneConsecutiveEntry() { 146 flicker.assertWm { 147 this.visibleWindowsShownMoreThanOneConsecutiveEntry( 148 listOf( 149 ComponentNameMatcher.SPLASH_SCREEN, 150 ComponentNameMatcher.SNAPSHOT, 151 ComponentNameMatcher.SECONDARY_HOME_HANDLE, 152 Consts.IMAGE_WALLPAPER 153 ) 154 ) 155 } 156 } 157 158 companion object { 159 /** 160 * Creates the test configurations. 161 * 162 * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and 163 * navigation modes. 164 */ 165 @Parameterized.Parameters(name = "{0}") 166 @JvmStatic getParamsnull167 fun getParams() = LegacyFlickerTestFactory.nonRotationTests() 168 169 /** 170 * Ensures that posted notifications will be visible on the lockscreen and not suppressed 171 * due to being marked as seen. 172 */ 173 @ClassRule 174 @JvmField 175 val disableUnseenNotifFilterRule = 176 SettingOverrideRule( 177 Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, 178 "0", 179 ) 180 } 181 } 182