blob: aa591d919cbeb34f0c70b3a76542c0e2bd947e64 [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 android.view.Surface.rotationToString;
20
21import static com.android.server.wm.flicker.CommonTransitions.changeAppRotation;
22import static com.android.server.wm.flicker.WindowUtils.getAppPosition;
23import static com.android.server.wm.flicker.WindowUtils.getNavigationBarPosition;
24import static com.android.server.wm.flicker.WindowUtils.getStatusBarPosition;
25import static com.android.server.wm.flicker.WmTraceSubject.assertThat;
26
27import android.graphics.Rect;
Vishnu Nair8248b7c2018-08-01 10:13:36 -070028import android.util.Log;
29import android.view.Surface;
30
Brett Chabot502ec7a2019-03-01 14:43:20 -080031import androidx.test.InstrumentationRegistry;
Nataniel Borges0e476aa2019-09-18 16:10:03 +020032import androidx.test.filters.FlakyTest;
Brett Chabot502ec7a2019-03-01 14:43:20 -080033import androidx.test.filters.LargeTest;
34
Vishnu Nair8248b7c2018-08-01 10:13:36 -070035import org.junit.Before;
Nataniel Borgesf5c828c2019-09-09 17:29:23 +020036import org.junit.FixMethodOrder;
Nataniel Borges0e476aa2019-09-18 16:10:03 +020037import org.junit.Ignore;
Vishnu Nair8248b7c2018-08-01 10:13:36 -070038import org.junit.Test;
39import org.junit.runner.RunWith;
Nataniel Borgesf5c828c2019-09-09 17:29:23 +020040import org.junit.runners.MethodSorters;
Vishnu Nair8248b7c2018-08-01 10:13:36 -070041import org.junit.runners.Parameterized;
42import org.junit.runners.Parameterized.Parameters;
43
44import java.util.ArrayList;
45import java.util.Collection;
46
47/**
48 * Cycle through supported app rotations.
49 * To run this test: {@code atest FlickerTest:ChangeAppRotationTest}
50 */
Vishnu Nair8248b7c2018-08-01 10:13:36 -070051@LargeTest
Nataniel Borgesf5c828c2019-09-09 17:29:23 +020052@RunWith(Parameterized.class)
53@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Vishnu Nair8248b7c2018-08-01 10:13:36 -070054public class ChangeAppRotationTest extends FlickerTestBase {
Nataniel Borgesf5c828c2019-09-09 17:29:23 +020055 private int mBeginRotation;
56 private int mEndRotation;
Vishnu Nair8248b7c2018-08-01 10:13:36 -070057
58 public ChangeAppRotationTest(String beginRotationName, String endRotationName,
59 int beginRotation, int endRotation) {
Nataniel Borgesf5c828c2019-09-09 17:29:23 +020060 this.mTestApp = new StandardAppHelper(InstrumentationRegistry.getInstrumentation(),
Vishnu Nair8248b7c2018-08-01 10:13:36 -070061 "com.android.server.wm.flicker.testapp", "SimpleApp");
Nataniel Borgesf5c828c2019-09-09 17:29:23 +020062 this.mBeginRotation = beginRotation;
63 this.mEndRotation = endRotation;
Vishnu Nair8248b7c2018-08-01 10:13:36 -070064 }
65
66 @Parameters(name = "{0}-{1}")
67 public static Collection<Object[]> getParams() {
68 int[] supportedRotations =
69 {Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_270};
70 Collection<Object[]> params = new ArrayList<>();
71 for (int begin : supportedRotations) {
72 for (int end : supportedRotations) {
73 if (begin != end) {
74 params.add(new Object[]{rotationToString(begin), rotationToString(end), begin,
75 end});
76 }
77 }
78 }
79 return params;
80 }
81
82 @Before
83 public void runTransition() {
84 super.runTransition(
Nataniel Borgesf5c828c2019-09-09 17:29:23 +020085 changeAppRotation(mTestApp, mUiDevice, mBeginRotation, mEndRotation).build());
Vishnu Nair8248b7c2018-08-01 10:13:36 -070086 }
87
Nataniel Borges0e476aa2019-09-18 16:10:03 +020088 @FlakyTest(bugId = 140855415)
89 @Ignore("Waiting bug feedback")
Vishnu Nair8248b7c2018-08-01 10:13:36 -070090 @Test
91 public void checkVisibility_navBarWindowIsAlwaysVisible() {
92 checkResults(result -> assertThat(result)
93 .showsAboveAppWindow(NAVIGATION_BAR_WINDOW_TITLE).forAllEntries());
94 }
95
Nataniel Borges0e476aa2019-09-18 16:10:03 +020096 @FlakyTest(bugId = 140855415)
97 @Ignore("Waiting bug feedback")
Vishnu Nair8248b7c2018-08-01 10:13:36 -070098 @Test
99 public void checkVisibility_statusBarWindowIsAlwaysVisible() {
100 checkResults(result -> assertThat(result)
101 .showsAboveAppWindow(STATUS_BAR_WINDOW_TITLE).forAllEntries());
102 }
103
104 @Test
105 public void checkPosition_navBarLayerRotatesAndScales() {
Nataniel Borgesf5c828c2019-09-09 17:29:23 +0200106 Rect startingPos = getNavigationBarPosition(mBeginRotation);
107 Rect endingPos = getNavigationBarPosition(mEndRotation);
Vishnu Nair8248b7c2018-08-01 10:13:36 -0700108 checkResults(result -> {
109 LayersTraceSubject.assertThat(result)
110 .hasVisibleRegion(NAVIGATION_BAR_WINDOW_TITLE, startingPos)
111 .inTheBeginning();
112 LayersTraceSubject.assertThat(result)
113 .hasVisibleRegion(NAVIGATION_BAR_WINDOW_TITLE, endingPos).atTheEnd();
114 }
115 );
116 }
117
118 @Test
119 public void checkPosition_appLayerRotates() {
Nataniel Borgesf5c828c2019-09-09 17:29:23 +0200120 Rect startingPos = getAppPosition(mBeginRotation);
121 Rect endingPos = getAppPosition(mEndRotation);
Vishnu Nair8248b7c2018-08-01 10:13:36 -0700122 Log.e(TAG, "startingPos=" + startingPos + " endingPos=" + endingPos);
123 checkResults(result -> {
124 LayersTraceSubject.assertThat(result)
Nataniel Borgesf5c828c2019-09-09 17:29:23 +0200125 .hasVisibleRegion(mTestApp.getPackage(), startingPos).inTheBeginning();
Vishnu Nair8248b7c2018-08-01 10:13:36 -0700126 LayersTraceSubject.assertThat(result)
Nataniel Borgesf5c828c2019-09-09 17:29:23 +0200127 .hasVisibleRegion(mTestApp.getPackage(), endingPos).atTheEnd();
Vishnu Nair8248b7c2018-08-01 10:13:36 -0700128 }
129 );
130 }
131
132 @Test
133 public void checkPosition_statusBarLayerScales() {
Nataniel Borgesf5c828c2019-09-09 17:29:23 +0200134 Rect startingPos = getStatusBarPosition(mBeginRotation);
135 Rect endingPos = getStatusBarPosition(mEndRotation);
Vishnu Nair8248b7c2018-08-01 10:13:36 -0700136 checkResults(result -> {
137 LayersTraceSubject.assertThat(result)
138 .hasVisibleRegion(STATUS_BAR_WINDOW_TITLE, startingPos)
139 .inTheBeginning();
140 LayersTraceSubject.assertThat(result)
141 .hasVisibleRegion(STATUS_BAR_WINDOW_TITLE, endingPos).atTheEnd();
142 }
143 );
144 }
145
Nataniel Borges0e476aa2019-09-18 16:10:03 +0200146 @FlakyTest(bugId = 140855415)
147 @Ignore("Waiting bug feedback")
Vishnu Nair8248b7c2018-08-01 10:13:36 -0700148 @Test
149 public void checkVisibility_navBarLayerIsAlwaysVisible() {
150 checkResults(result -> LayersTraceSubject.assertThat(result)
151 .showsLayer(NAVIGATION_BAR_WINDOW_TITLE).forAllEntries());
152 }
153
Nataniel Borges0e476aa2019-09-18 16:10:03 +0200154 @FlakyTest(bugId = 140855415)
155 @Ignore("Waiting bug feedback")
Vishnu Nair8248b7c2018-08-01 10:13:36 -0700156 @Test
157 public void checkVisibility_statusBarLayerIsAlwaysVisible() {
158 checkResults(result -> LayersTraceSubject.assertThat(result)
159 .showsLayer(STATUS_BAR_WINDOW_TITLE).forAllEntries());
160 }
161}