1 /*
2  * Copyright (C) 2017 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.am;
18 
19 import static android.server.am.Components.DISMISS_KEYGUARD_ACTIVITY;
20 
21 import static org.junit.Assume.assumeTrue;
22 
23 import android.server.am.ActivityManagerState.ActivityDisplay;
24 
25 import org.junit.Before;
26 import org.junit.Test;
27 
28 /**
29  * Display tests that require a keyguard.
30  *
31  * <p>Build/Install/Run:
32  *     atest CtsActivityManagerDeviceTestCases:ActivityManagerDisplayKeyguardTests
33  */
34 public class ActivityManagerDisplayKeyguardTests extends ActivityManagerDisplayTestBase {
35 
36     @Before
37     @Override
setUp()38     public void setUp() throws Exception {
39         super.setUp();
40 
41         assumeTrue(supportsMultiDisplay());
42         assumeTrue(supportsInsecureLock());
43     }
44 
45     /**
46      * Tests whether a FLAG_DISMISS_KEYGUARD activity on a secondary display is visible (for an
47      * insecure keyguard).
48      */
49     @Test
testDismissKeyguardActivity_secondaryDisplay()50     public void testDismissKeyguardActivity_secondaryDisplay() throws Exception {
51         try (final LockScreenSession lockScreenSession = new LockScreenSession();
52              final VirtualDisplaySession virtualDisplaySession = new VirtualDisplaySession()) {
53             final ActivityDisplay newDisplay = virtualDisplaySession.createDisplay();
54 
55             lockScreenSession.gotoKeyguard();
56             mAmWmState.assertKeyguardShowingAndNotOccluded();
57             launchActivityOnDisplay(DISMISS_KEYGUARD_ACTIVITY, newDisplay.mId);
58             mAmWmState.waitForKeyguardShowingAndNotOccluded();
59             mAmWmState.assertKeyguardShowingAndNotOccluded();
60             mAmWmState.assertVisibility(DISMISS_KEYGUARD_ACTIVITY, true);
61         }
62     }
63 }
64