blob: a259588bf3f9dc2b67b362f0f301a97add616f02 [file] [log] [blame]
Liam Clarkc82e6702019-01-07 13:05:51 -08001/*
2 * Copyright (C) 2019 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
Tadashi G. Takaokae2bd5c52019-04-15 14:29:33 +090017package android.server.wm.intent;
Liam Clarkc82e6702019-01-07 13:05:51 -080018
19import android.content.ComponentName;
Tadashi G. Takaokae2bd5c52019-04-15 14:29:33 +090020import android.server.wm.ActivityManagerTestBase;
Tadashi G. Takaokae2bd5c52019-04-15 14:29:33 +090021import android.server.wm.intent.Persistence.TestCase;
Liam Clarkc82e6702019-01-07 13:05:51 -080022
23import org.junit.After;
24
25import java.util.List;
26
27public abstract class IntentTestBase extends ActivityManagerTestBase {
28
29 /**
30 * This get's called from {@link IntentGenerationTests} because {@link IntentGenerationTests}
Tadashi G. Takaokae2bd5c52019-04-15 14:29:33 +090031 * run multiple {@link TestCase}-s in a single junit test.
Liam Clarkc82e6702019-01-07 13:05:51 -080032 *
33 * Normal test classes can just extend this class with manual cleanUp.
34 *
35 * @param activitiesInUsedInTest activities that should be gone after tearDown
36 */
37 public void cleanUp(List<ComponentName> activitiesInUsedInTest) throws Exception {
Riddle Hsu79c77e02019-09-23 23:56:41 +080038 launchHomeActivityNoWait();
Liam Clarkc82e6702019-01-07 13:05:51 -080039 removeStacksWithActivityTypes(ALL_ACTIVITY_TYPE_BUT_HOME);
40
Wale Ogunwalecd739102020-01-29 06:15:52 -080041 this.getWmState().waitForWithAmState(
Liam Clarkc82e6702019-01-07 13:05:51 -080042 state -> state.containsNoneOf(activitiesInUsedInTest),
Riddle Hsueebde882019-06-11 18:20:53 -060043 "activity to be removed");
Liam Clarkc82e6702019-01-07 13:05:51 -080044 }
45
46 @After
Liam Clarkc82e6702019-01-07 13:05:51 -080047 public void tearDown() throws Exception {
Liam Clarkc82e6702019-01-07 13:05:51 -080048 cleanUp(activitiesUsedInTest());
49 }
50
51 /**
52 * @return The activities that are launched in this Test.
53 */
54 abstract List<ComponentName> activitiesUsedInTest();
55}