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.Postsubmit 20 import android.platform.test.annotations.Presubmit 21 import android.tools.flicker.junit.FlickerParametersRunnerFactory 22 import android.tools.flicker.legacy.FlickerBuilder 23 import android.tools.flicker.legacy.LegacyFlickerTest 24 import android.tools.flicker.legacy.LegacyFlickerTestFactory 25 import android.tools.helpers.wakeUpAndGoToHomeScreen 26 import android.tools.traces.component.ComponentNameMatcher 27 import com.android.server.wm.flicker.helpers.setRotation 28 import com.android.server.wm.flicker.statusBarLayerPositionAtEnd 29 import org.junit.FixMethodOrder 30 import org.junit.Ignore 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 cold launching an app from a notification. 38 * 39 * To run this test: `atest FlickerTestsNotification:OpenAppFromNotificationColdTest` 40 */ 41 @RunWith(Parameterized::class) 42 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) 43 @FixMethodOrder(MethodSorters.NAME_ASCENDING) 44 @Postsubmit 45 open class OpenAppFromNotificationColdTest(flicker: LegacyFlickerTest) : 46 OpenAppFromNotificationWarmTest(flicker) { 47 /** {@inheritDoc} */ 48 override val transition: FlickerBuilder.() -> Unit <lambda>null49 get() = { 50 setup { 51 device.wakeUpAndGoToHomeScreen() 52 this.setRotation(flicker.scenario.startRotation) 53 launchAppAndPostNotification() 54 clearOverview() 55 } 56 57 transitions { openAppFromNotification() } 58 59 teardown { testApp.exit(wmHelper) } 60 } 61 appWindowBecomesVisiblenull62 @Presubmit @Test override fun appWindowBecomesVisible() = appWindowBecomesVisible_coldStart() 63 64 @Presubmit @Test override fun appLayerBecomesVisible() = appLayerBecomesVisible_coldStart() 65 66 /** {@inheritDoc} */ 67 @Test 68 @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") 69 override fun navBarLayerPositionAtStartAndEnd() {} 70 71 /** {@inheritDoc} */ 72 @Test 73 @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") statusBarLayerPositionAtStartAndEndnull74 override fun statusBarLayerPositionAtStartAndEnd() {} 75 76 /** {@inheritDoc} */ 77 @Test 78 @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") statusBarLayerIsVisibleAtStartAndEndnull79 override fun statusBarLayerIsVisibleAtStartAndEnd() = 80 super.statusBarLayerIsVisibleAtStartAndEnd() 81 82 /** 83 * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the 84 * transition 85 */ 86 @Presubmit @Test open fun statusBarLayerPositionAtEnd() = flicker.statusBarLayerPositionAtEnd() 87 88 /** {@inheritDoc} */ 89 @Test 90 @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") 91 override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() 92 93 /** {@inheritDoc} */ 94 @Test 95 @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") 96 override fun navBarWindowIsAlwaysVisible() {} 97 98 companion object { 99 /** 100 * Creates the test configurations. 101 * 102 * See [LegacyFlickerTestFactory.nonRotationTests] for configuring screen orientation and 103 * navigation modes. 104 */ 105 @Parameterized.Parameters(name = "{0}") 106 @JvmStatic getParamsnull107 fun getParams() = LegacyFlickerTestFactory.nonRotationTests() 108 } 109 } 110