blob: 6590b86f1499752ec137eb0c8f8afc80e99d7274 [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;
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 back to app window transitions.
34 * To run this test: {@code atest FlickerTests:CloseImeWindowToAppTest}
35 */
36@LargeTest
37@RunWith(AndroidJUnit4.class)
38public class CloseImeWindowToAppTest 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(editTextLoseFocusToApp(uiDevice)
48 .includeJankyRuns().build());
49 }
50
51 @Test
52 public void checkVisibility_imeLayerBecomesInvisible() {
53 checkResults(result -> LayersTraceSubject.assertThat(result)
54 .showsLayer(IME_WINDOW_TITLE)
55 .then()
56 .hidesLayer(IME_WINDOW_TITLE)
57 .forAllEntries());
58 }
59
60 @Test
61 public void checkVisibility_imeAppLayerIsAlwaysVisible() {
62 checkResults(result -> LayersTraceSubject.assertThat(result)
63 .showsLayer(mImeTestApp.getPackage())
64 .forAllEntries());
65 }
66
67 @Test
68 public void checkVisibility_imeAppWindowIsAlwaysVisible() {
69 checkResults(result -> WmTraceSubject.assertThat(result)
70 .showsAppWindowOnTop(mImeTestApp.getPackage())
71 .forAllEntries());
72 }
73
74 @Test
75 public void checkCoveredRegion_noUncoveredRegions() {
76 checkResults(result -> LayersTraceSubject.assertThat(result).coversRegion(
77 getDisplayBounds()).forAllEntries());
78 }
79}