blob: 4771b02000c07ee7a22fb8af610d4d433e8ddc04 [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;
Brett Chabot502ec7a2019-03-01 14:43:20 -080023
24import androidx.test.InstrumentationRegistry;
25import androidx.test.filters.LargeTest;
26import androidx.test.runner.AndroidJUnit4;
Vishnu Nair8248b7c2018-08-01 10:13:36 -070027
28import org.junit.Before;
29import org.junit.Test;
30import org.junit.runner.RunWith;
31
32/**
33 * Test IME window closing to home transitions.
34 * To run this test: {@code atest FlickerTests:CloseImeWindowToHomeTest}
35 */
36@LargeTest
37@RunWith(AndroidJUnit4.class)
38public class CloseImeWindowToHomeTest extends FlickerTestBase {
39
40 private static final String IME_WINDOW_TITLE = "InputMethod";
41 private IAppHelper mImeTestApp = new StandardAppHelper(
42 InstrumentationRegistry.getInstrumentation(),
43 "com.android.server.wm.flicker.testapp", "ImeApp");
44
45 @Before
46 public void runTransition() {
47 super.runTransition(editTextLoseFocusToHome(uiDevice)
48 .includeJankyRuns().build());
49 }
50
51 @Test
52 public void checkVisibility_imeWindowBecomesInvisible() {
53 checkResults(result -> WmTraceSubject.assertThat(result)
54 .showsImeWindow(IME_WINDOW_TITLE)
55 .then()
56 .hidesImeWindow(IME_WINDOW_TITLE)
57 .forAllEntries());
58 }
59
60 @Test
61 public void checkVisibility_imeLayerBecomesInvisible() {
62 checkResults(result -> LayersTraceSubject.assertThat(result)
63 .showsLayer(IME_WINDOW_TITLE)
64 .then()
65 .hidesLayer(IME_WINDOW_TITLE)
66 .forAllEntries());
67 }
68
69 @Test
70 public void checkVisibility_imeAppLayerBecomesInvisible() {
71 checkResults(result -> LayersTraceSubject.assertThat(result)
72 .showsLayer(mImeTestApp.getPackage())
73 .then()
74 .hidesLayer(mImeTestApp.getPackage())
75 .forAllEntries());
76 }
77
78 @Test
79 public void checkVisibility_imeAppWindowBecomesInvisible() {
80 checkResults(result -> WmTraceSubject.assertThat(result)
81 .showsAppWindowOnTop(mImeTestApp.getPackage())
82 .then()
83 .hidesAppWindowOnTop(mImeTestApp.getPackage())
84 .forAllEntries());
85 }
86
87 @Test
88 public void checkCoveredRegion_noUncoveredRegions() {
89 checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
90 getDisplayBounds()).forAllEntries());
91 }
92}