blob: 42b161f8a6046c0ac44967a22f6150b5eddb57d4 [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.editTextLoseFocusToHome;
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 to home transitions.
33 * To run this test: {@code atest FlickerTests:CloseImeWindowToHomeTest}
34 */
35@LargeTest
36@RunWith(AndroidJUnit4.class)
37public class CloseImeWindowToHomeTest 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(editTextLoseFocusToHome(uiDevice)
47 .includeJankyRuns().build());
48 }
49
50 @Test
51 public void checkVisibility_imeWindowBecomesInvisible() {
52 checkResults(result -> WmTraceSubject.assertThat(result)
53 .showsImeWindow(IME_WINDOW_TITLE)
54 .then()
55 .hidesImeWindow(IME_WINDOW_TITLE)
56 .forAllEntries());
57 }
58
59 @Test
60 public void checkVisibility_imeLayerBecomesInvisible() {
61 checkResults(result -> LayersTraceSubject.assertThat(result)
62 .showsLayer(IME_WINDOW_TITLE)
63 .then()
64 .hidesLayer(IME_WINDOW_TITLE)
65 .forAllEntries());
66 }
67
68 @Test
69 public void checkVisibility_imeAppLayerBecomesInvisible() {
70 checkResults(result -> LayersTraceSubject.assertThat(result)
71 .showsLayer(mImeTestApp.getPackage())
72 .then()
73 .hidesLayer(mImeTestApp.getPackage())
74 .forAllEntries());
75 }
76
77 @Test
78 public void checkVisibility_imeAppWindowBecomesInvisible() {
79 checkResults(result -> WmTraceSubject.assertThat(result)
80 .showsAppWindowOnTop(mImeTestApp.getPackage())
81 .then()
82 .hidesAppWindowOnTop(mImeTestApp.getPackage())
83 .forAllEntries());
84 }
85
86 @Test
87 public void checkCoveredRegion_noUncoveredRegions() {
88 checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
89 getDisplayBounds()).forAllEntries());
90 }
91}