| 1 |
/* |
| 2 |
* Copyright (C) 2021 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.Presubmit |
| 20 |
import com.android.server.wm.flicker.FlickerTestParameter |
| 21 |
import com.android.server.wm.flicker.LAUNCHER_COMPONENT |
| 22 |
import com.android.server.wm.flicker.replacesLayer |
| 23 |
import com.android.server.wm.traces.common.FlickerComponentName |
| 24 |
import org.junit.Test |
| 25 |
|
| 26 |
/** |
| 27 |
* Base class for app launch tests |
| 28 |
*/ |
| 29 |
abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) |
| 30 |
: OpenAppTransition(testSpec) { |
| 31 |
|
| 32 |
/** |
| 33 |
* Checks that the focus changes from the launcher to [testApp] |
| 34 |
*/ |
| 35 |
@Presubmit |
| 36 |
@Test |
| 37 |
open fun focusChanges() { |
| 38 |
testSpec.assertEventLog { |
| 39 |
this.focusChanges("NexusLauncherActivity", testApp.`package`) |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Checks that [LAUNCHER_COMPONENT] layer is visible at the start of the transition, and |
| 45 |
* is replaced by [testApp], which remains visible until the end |
| 46 |
*/ |
| 47 |
open fun appLayerReplacesLauncher() { |
| 48 |
testSpec.replacesLayer(LAUNCHER_COMPONENT, testApp.component, |
| 49 |
ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true, |
| 50 |
ignoreSplashscreen = true) |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Checks that [LAUNCHER_COMPONENT] window is visible at the start of the transition, and |
| 55 |
* is replaced by a snapshot or splash screen (optional), and finally, is replaced by |
| 56 |
* [testApp], which remains visible until the end |
| 57 |
*/ |
| 58 |
@Presubmit |
| 59 |
@Test |
| 60 |
open fun appWindowReplacesLauncherAsTopWindow() { |
| 61 |
testSpec.assertWm { |
| 62 |
this.isAppWindowOnTop(LAUNCHER_COMPONENT) |
| 63 |
.then() |
| 64 |
.isAppWindowOnTop(FlickerComponentName.SNAPSHOT, isOptional = true) |
| 65 |
.then() |
| 66 |
.isAppWindowOnTop(FlickerComponentName.SPLASH_SCREEN, isOptional = true) |
| 67 |
.then() |
| 68 |
.isAppWindowOnTop(testApp.component) |
| 69 |
} |
| 70 |
} |
| 71 |
} |