Liam Clark | c82e670 | 2019-01-07 13:05:51 -0800 | [diff] [blame] | 1 | /* |
| 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. Takaoka | e2bd5c5 | 2019-04-15 14:29:33 +0900 | [diff] [blame] | 17 | package android.server.wm.intent; |
Liam Clark | c82e670 | 2019-01-07 13:05:51 -0800 | [diff] [blame] | 18 | |
| 19 | import android.content.ComponentName; |
Tadashi G. Takaoka | e2bd5c5 | 2019-04-15 14:29:33 +0900 | [diff] [blame] | 20 | import android.server.wm.ActivityManagerTestBase; |
Tadashi G. Takaoka | e2bd5c5 | 2019-04-15 14:29:33 +0900 | [diff] [blame] | 21 | import android.server.wm.intent.Persistence.TestCase; |
Liam Clark | c82e670 | 2019-01-07 13:05:51 -0800 | [diff] [blame] | 22 | |
| 23 | import org.junit.After; |
| 24 | |
| 25 | import java.util.List; |
| 26 | |
| 27 | public abstract class IntentTestBase extends ActivityManagerTestBase { |
| 28 | |
| 29 | /** |
| 30 | * This get's called from {@link IntentGenerationTests} because {@link IntentGenerationTests} |
Tadashi G. Takaoka | e2bd5c5 | 2019-04-15 14:29:33 +0900 | [diff] [blame] | 31 | * run multiple {@link TestCase}-s in a single junit test. |
Liam Clark | c82e670 | 2019-01-07 13:05:51 -0800 | [diff] [blame] | 32 | * |
| 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 Hsu | 79c77e0 | 2019-09-23 23:56:41 +0800 | [diff] [blame] | 38 | launchHomeActivityNoWait(); |
Liam Clark | c82e670 | 2019-01-07 13:05:51 -0800 | [diff] [blame] | 39 | removeStacksWithActivityTypes(ALL_ACTIVITY_TYPE_BUT_HOME); |
| 40 | |
Wale Ogunwale | cd73910 | 2020-01-29 06:15:52 -0800 | [diff] [blame] | 41 | this.getWmState().waitForWithAmState( |
Liam Clark | c82e670 | 2019-01-07 13:05:51 -0800 | [diff] [blame] | 42 | state -> state.containsNoneOf(activitiesInUsedInTest), |
Riddle Hsu | eebde88 | 2019-06-11 18:20:53 -0600 | [diff] [blame] | 43 | "activity to be removed"); |
Liam Clark | c82e670 | 2019-01-07 13:05:51 -0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | @After |
Liam Clark | c82e670 | 2019-01-07 13:05:51 -0800 | [diff] [blame] | 47 | public void tearDown() throws Exception { |
Liam Clark | c82e670 | 2019-01-07 13:05:51 -0800 | [diff] [blame] | 48 | cleanUp(activitiesUsedInTest()); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @return The activities that are launched in this Test. |
| 53 | */ |
| 54 | abstract List<ComponentName> activitiesUsedInTest(); |
| 55 | } |