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.launch.common 18 19 import android.platform.test.annotations.Presubmit 20 import android.tools.flicker.legacy.LegacyFlickerTest 21 import android.tools.traces.component.ComponentNameMatcher 22 import com.android.server.wm.flicker.replacesLayer 23 import org.junit.Test 24 25 /** Base class for app launch tests */ 26 abstract class OpenAppFromLauncherTransition(flicker: LegacyFlickerTest) : 27 OpenAppTransition(flicker) { 28 29 /** Checks that the focus changes from the [ComponentNameMatcher.LAUNCHER] to [testApp] */ 30 @Presubmit 31 @Test focusChangesnull32 open fun focusChanges() { 33 flicker.assertEventLog { this.focusChanges("NexusLauncherActivity", testApp.packageName) } 34 } 35 36 /** 37 * Checks that [ComponentNameMatcher.LAUNCHER] layer is visible at the start of the transition, 38 * and is replaced by [testApp], which remains visible until the end 39 */ appLayerReplacesLaunchernull40 open fun appLayerReplacesLauncher() { 41 flicker.replacesLayer( 42 ComponentNameMatcher.LAUNCHER, 43 testApp, 44 ignoreEntriesWithRotationLayer = true, 45 ignoreSnapshot = true, 46 ignoreSplashscreen = true 47 ) 48 } 49 50 /** 51 * Checks that [ComponentNameMatcher.LAUNCHER] window is the top window at the start of the 52 * transition, and is replaced by a [ComponentNameMatcher.SNAPSHOT] or 53 * [ComponentNameMatcher.SPLASH_SCREEN], or [testApp], which remains visible until the end 54 */ 55 @Presubmit 56 @Test appWindowReplacesLauncherAsTopWindownull57 open fun appWindowReplacesLauncherAsTopWindow() { 58 flicker.assertWm { 59 this.isAppWindowOnTop(ComponentNameMatcher.LAUNCHER) 60 .then() 61 .isAppWindowOnTop( 62 testApp.or(ComponentNameMatcher.SNAPSHOT).or(ComponentNameMatcher.SPLASH_SCREEN) 63 ) 64 } 65 } 66 67 /** Checks that [testApp] window is the top window at the en dof the trace */ 68 @Presubmit 69 @Test appWindowAsTopWindowAtEndnull70 open fun appWindowAsTopWindowAtEnd() { 71 flicker.assertWmEnd { this.isAppWindowOnTop(testApp) } 72 } 73 } 74