blob: de7639d43d3c38cd20219a7c11facd9ca27b9150 [file] [log] [blame]
Vishnu Nair8248b7c2018-08-01 10:13:36 -07001/*
2 * Copyright (C) 2018 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
17package com.android.server.wm.flicker;
18
19import static com.android.server.wm.flicker.CommonTransitions.openAppWarm;
20import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;
21import static com.android.server.wm.flicker.WmTraceSubject.assertThat;
22
23import android.support.test.InstrumentationRegistry;
24import android.support.test.filters.LargeTest;
25import android.support.test.runner.AndroidJUnit4;
26
27import org.junit.Before;
28import org.junit.Test;
29import org.junit.runner.RunWith;
30
31/**
32 * Test warm launch app.
33 * To run this test: {@code atest FlickerTests:OpenAppWarmTest}
34 */
35@LargeTest
36@RunWith(AndroidJUnit4.class)
37public class OpenAppWarmTest extends FlickerTestBase {
38
39 public OpenAppWarmTest() {
40 this.testApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
41 "com.android.server.wm.flicker.testapp", "SimpleApp");
42 }
43
44 @Before
45 public void runTransition() {
46 super.runTransition(openAppWarm(testApp, uiDevice).build());
47 }
48
49 @Test
50 public void checkVisibility_navBarIsAlwaysVisible() {
51 checkResults(result -> assertThat(result)
52 .showsAboveAppWindow(NAVIGATION_BAR_WINDOW_TITLE).forAllEntries());
53 }
54
55 @Test
56 public void checkVisibility_statusBarIsAlwaysVisible() {
57 checkResults(result -> assertThat(result)
58 .showsAboveAppWindow(STATUS_BAR_WINDOW_TITLE).forAllEntries());
59 }
60
61 @Test
62 public void checkVisibility_wallpaperBecomesInvisible() {
63 checkResults(result -> assertThat(result)
64 .showsBelowAppWindow("wallpaper")
65 .then()
66 .hidesBelowAppWindow("wallpaper")
67 .forAllEntries());
68 }
69
70 @Test
71 public void checkZOrder_appWindowReplacesLauncherAsTopWindow() {
72 checkResults(result -> assertThat(result)
73 .showsAppWindowOnTop(
74 "com.google.android.apps.nexuslauncher/.NexusLauncherActivity")
75 .then()
76 .showsAppWindowOnTop(testApp.getPackage())
77 .forAllEntries());
78 }
79
80 @Test
81 public void checkCoveredRegion_noUncoveredRegions() {
82 checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
83 getDisplayBounds()).forAllEntries());
84 }
85
86 @Test
87 public void checkVisibility_navBarLayerIsAlwaysVisible() {
88 checkResults(result -> LayersTraceSubject.assertThat(result)
89 .showsLayer(NAVIGATION_BAR_WINDOW_TITLE).forAllEntries());
90 }
91
92 @Test
93 public void checkVisibility_statusBarLayerIsAlwaysVisible() {
94 checkResults(result -> LayersTraceSubject.assertThat(result)
95 .showsLayer(STATUS_BAR_WINDOW_TITLE).forAllEntries());
96 }
97
98 @Test
99 public void checkVisibility_wallpaperLayerBecomesInvisible() {
100 checkResults(result -> LayersTraceSubject.assertThat(result)
101 .showsLayer("wallpaper")
102 .then()
103 .hidesLayer("wallpaper")
104 .forAllEntries());
105 }
106}