• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
21 import static android.server.wm.app.Components.ANIMATION_TEST_ACTIVITY;
22 import static android.server.wm.app.Components.LAUNCHING_ACTIVITY;
23 import static android.view.Display.DEFAULT_DISPLAY;
24 
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
27 import static org.junit.Assume.assumeFalse;
28 
29 import android.content.ComponentName;
30 import android.platform.test.annotations.Presubmit;
31 import android.server.wm.WindowManagerState.Display;
32 
33 import org.junit.Test;
34 
35 /**
36  * Build/Install/Run:
37  *     atest CtsWindowManagerDeviceTestCases:AnimationBackgroundTests
38  */
39 @Presubmit
40 public class AnimationBackgroundTests extends ActivityManagerTestBase {
41 
42     @Test
testAnimationBackground_duringAnimation()43     public void testAnimationBackground_duringAnimation() throws Exception {
44         launchActivityOnDisplay(LAUNCHING_ACTIVITY, DEFAULT_DISPLAY);
45         getLaunchActivityBuilder()
46                 .setTargetActivity(ANIMATION_TEST_ACTIVITY)
47                 .setWaitForLaunched(false)
48                 .execute();
49 
50         // Make sure we're testing an activity that runs on fullscreen display. This animation API
51         // doesn't make much sense in freeform displays.
52         assumeActivityNotInFreeformDisplay(ANIMATION_TEST_ACTIVITY);
53 
54         // Make sure we are in the middle of the animation.
55         mAmWmState.waitForWithWmState(state -> state
56                 .getStandardStackByWindowingMode(WINDOWING_MODE_FULLSCREEN)
57                         .isWindowAnimationBackgroundSurfaceShowing(),
58                 "***Waiting for animation background showing");
59 
60         assertTrue("window animation background needs to be showing", mAmWmState.getWmState()
61                 .getStandardStackByWindowingMode(WINDOWING_MODE_FULLSCREEN)
62                 .isWindowAnimationBackgroundSurfaceShowing());
63     }
64 
65     @Test
testAnimationBackground_gone()66     public void testAnimationBackground_gone() throws Exception {
67         launchActivityOnDisplay(LAUNCHING_ACTIVITY, DEFAULT_DISPLAY);
68         getLaunchActivityBuilder().setTargetActivity(ANIMATION_TEST_ACTIVITY).execute();
69         mAmWmState.computeState(ANIMATION_TEST_ACTIVITY);
70         mAmWmState.waitForAppTransitionIdleOnDisplay(DEFAULT_DISPLAY);
71 
72         // Make sure we're testing an activity that runs on fullscreen display. This animation API
73         // doesn't make much sense in freeform displays.
74         assumeActivityNotInFreeformDisplay(ANIMATION_TEST_ACTIVITY);
75 
76         assertFalse("window animation background needs to be gone", mAmWmState.getWmState()
77                 .getStandardStackByWindowingMode(WINDOWING_MODE_FULLSCREEN)
78                 .isWindowAnimationBackgroundSurfaceShowing());
79     }
80 
assumeActivityNotInFreeformDisplay(ComponentName activity)81     private void assumeActivityNotInFreeformDisplay(ComponentName activity) throws Exception {
82         mAmWmState.waitForValidState(activity);
83         final int displayId = mAmWmState.getAmState().getDisplayByActivity(activity);
84         final Display display = mAmWmState.getWmState().getDisplay(displayId);
85         assumeFalse("Animation test activity is in freeform display. It may not run "
86                 + "cross-task animations.", display.getWindowingMode() == WINDOWING_MODE_FREEFORM);
87     }
88 }
89