1 /*
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 
17 package android.server.wm;
18 
19 import static android.server.wm.app.Components.RECURSIVE_ACTIVITY;
20 import static android.server.wm.app.Components.TEST_ACTIVITY;
21 
22 import android.platform.test.annotations.Presubmit;
23 
24 import org.junit.Test;
25 
26 /**
27  * Build/Install/Run:
28  *     atest CtsWindowManagerDeviceTestCases:RobustnessTests
29  */
30 @Presubmit
31 public class RobustnessTests extends ActivityManagerTestBase {
32 
33     /**
34      * Tests launching an activity that launches itself recursively limited number of times.
35      * This is a long test, so shouldn't be part of presubmit.
36      */
37     @Test
testLaunchActivityRecursively()38     public void testLaunchActivityRecursively() throws Exception {
39         getLaunchActivityBuilder().setUseInstrumentation()
40                 .setTargetActivity(RECURSIVE_ACTIVITY).execute();
41 
42         for (int retry = 1; retry <= 10; retry++) {
43             mWmState.computeState(TEST_ACTIVITY);
44             if (mWmState.isActivityVisible(TEST_ACTIVITY)) {
45                 break;
46             }
47         }
48         mWmState.waitForValidState(TEST_ACTIVITY);
49         mWmState.assertVisibility(TEST_ACTIVITY, true);
50     }
51 }
52