blob: 2b62fcf196fb44b9aaf206b4f1ce1e92dfadd8ab [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.editTextLoseFocusToApp;
20import static com.android.server.wm.flicker.WindowUtils.getDisplayBounds;
21
22import android.platform.helpers.IAppHelper;
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 IME window closing back to app window transitions.
33 * To run this test: {@code atest FlickerTests:CloseImeWindowToAppTest}
34 */
35@LargeTest
36@RunWith(AndroidJUnit4.class)
37public class CloseImeWindowToAppTest extends FlickerTestBase {
38
39 private static final String IME_WINDOW_TITLE = "InputMethod";
40 private IAppHelper mImeTestApp = new StandardAppHelper(
41 InstrumentationRegistry.getInstrumentation(),
42 "com.android.server.wm.flicker.testapp", "ImeApp");
43
44 @Before
45 public void runTransition() {
46 super.runTransition(editTextLoseFocusToApp(uiDevice)
47 .includeJankyRuns().build());
48 }
49
50 @Test
51 public void checkVisibility_imeLayerBecomesInvisible() {
52 checkResults(result -> LayersTraceSubject.assertThat(result)
53 .showsLayer(IME_WINDOW_TITLE)
54 .then()
55 .hidesLayer(IME_WINDOW_TITLE)
56 .forAllEntries());
57 }
58
59 @Test
60 public void checkVisibility_imeAppLayerIsAlwaysVisible() {
61 checkResults(result -> LayersTraceSubject.assertThat(result)
62 .showsLayer(mImeTestApp.getPackage())
63 .forAllEntries());
64 }
65
66 @Test
67 public void checkVisibility_imeAppWindowIsAlwaysVisible() {
68 checkResults(result -> WmTraceSubject.assertThat(result)
69 .showsAppWindowOnTop(mImeTestApp.getPackage())
70 .forAllEntries());
71 }
72
73 @Test
74 public void checkCoveredRegion_noUncoveredRegions() {
75 checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
76 getDisplayBounds()).forAllEntries());
77 }
78}