1 /*
2  * Copyright (C) 2016 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 
17 package android.server.wm;
18 
19 import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
20 import static android.server.wm.app.Components.LOG_CONFIGURATION_ACTIVITY;
21 import static android.view.Surface.ROTATION_0;
22 import static android.view.Surface.ROTATION_180;
23 
24 import static org.junit.Assume.assumeTrue;
25 
26 import android.platform.test.annotations.Presubmit;
27 import android.server.wm.CommandSession.ActivityCallback;
28 
29 import org.junit.Test;
30 
31 /**
32  * Build/Install/Run:
33  *     atest CtsWindowManagerDeviceTestCases:OverrideConfigTests
34  */
35 @Presubmit
36 public class OverrideConfigTests extends ActivityManagerTestBase {
37 
38     @Test
testReceiveOverrideConfigFromRelayout()39     public void testReceiveOverrideConfigFromRelayout() {
40         assumeTrue("Device doesn't support freeform. Skipping test.", supportsFreeform());
41 
42         launchActivity(LOG_CONFIGURATION_ACTIVITY, WINDOWING_MODE_FREEFORM);
43 
44         final RotationSession rotationSession = createManagedRotationSession();
45         rotationSession.set(ROTATION_0);
46         separateTestJournal();
47         resizeActivityTask(LOG_CONFIGURATION_ACTIVITY, 0, 0, 100, 100);
48         new ActivityLifecycleCounts(LOG_CONFIGURATION_ACTIVITY).assertCountWithRetry(
49                 "Expected to observe configuration change when resizing",
50                 countSpec(ActivityCallback.ON_CONFIGURATION_CHANGED, CountSpec.EQUALS, 1));
51 
52         separateTestJournal();
53         rotationSession.set(ROTATION_180);
54         new ActivityLifecycleCounts(LOG_CONFIGURATION_ACTIVITY).assertCountWithRetry(
55                 "Not expected to observe configuration change after flip rotation",
56                 countSpec(ActivityCallback.ON_CONFIGURATION_CHANGED, CountSpec.EQUALS, 0));
57     }
58 }
59 
60