1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package android.server.cts;
import java.lang.Exception;
import java.lang.String;
public class ActivityManagerPinnedStackTests extends ActivityManagerTestBase {
private static final String PIP_ACTIVITY = "PipActivity";
private static final String AUTO_ENTER_PIP_ACTIVITY = "AutoEnterPipActivity";
private static final String ALWAYS_FOCUSABLE_PIP_ACTIVITY = "AlwaysFocusablePipActivity";
private static final String LAUNCH_INTO_PINNED_STACK_PIP_ACTIVITY =
"LaunchIntoPinnedStackPipActivity";
public void testEnterPictureInPictureMode() throws Exception {
pinnedStackTester(AUTO_ENTER_PIP_ACTIVITY, AUTO_ENTER_PIP_ACTIVITY, false, false);
}
public void testMoveTopActivityToPinnedStack() throws Exception {
pinnedStackTester(PIP_ACTIVITY, PIP_ACTIVITY, true, false);
}
public void testAlwaysFocusablePipActivity() throws Exception {
pinnedStackTester(ALWAYS_FOCUSABLE_PIP_ACTIVITY, ALWAYS_FOCUSABLE_PIP_ACTIVITY, true, true);
}
public void testLaunchIntoPinnedStack() throws Exception {
pinnedStackTester(
LAUNCH_INTO_PINNED_STACK_PIP_ACTIVITY, ALWAYS_FOCUSABLE_PIP_ACTIVITY, false, true);
}
private void pinnedStackTester(String startActivity, String topActivityName,
boolean moveTopToPinnedStack, boolean isFocusable) throws Exception {
executeShellCommand(getAmStartCmd(startActivity));
if (moveTopToPinnedStack) {
executeShellCommand(AM_MOVE_TOP_ACTIVITY_TO_PINNED_STACK_COMMAND);
}
mAmWmState.waitForValidState(mDevice, true, new String[] {topActivityName},
new int[] {PINNED_STACK_ID}, false /* compareTaskAndStackBounds */);
mAmWmState.computeState(mDevice, null);
if (supportsPip()) {
final String windowName = getWindowName(topActivityName);
mAmWmState.assertContainsStack("Must contain pinned stack.", PINNED_STACK_ID);
mAmWmState.assertFrontStack("Pinned stack must be the front stack.", PINNED_STACK_ID);
mAmWmState.assertVisibility(topActivityName, true);
if (isFocusable) {
mAmWmState.assertFocusedStack(
"Pinned stack must be the focused stack.", PINNED_STACK_ID);
mAmWmState.assertFocusedActivity(
"Pinned activity must be focused activity.", topActivityName);
mAmWmState.assertFocusedWindow(
"Pinned window must be focused window.", windowName);
// Not checking for resumed state here because PiP overlay can be launched on top
// in different task by SystemUI.
} else {
mAmWmState.assertNotFocusedStack(
"Pinned stack can't be the focused stack.", PINNED_STACK_ID);
mAmWmState.assertNotFocusedActivity(
"Pinned activity can't be the focused activity.", topActivityName);
mAmWmState.assertNotResumedActivity(
"Pinned activity can't be the resumed activity.", topActivityName);
mAmWmState.assertNotFocusedWindow(
"Pinned window can't be focused window.", windowName);
}
} else {
mAmWmState.assertDoesNotContainStack(
"Must not contain pinned stack.", PINNED_STACK_ID);
}
}
}
|