blob: 1d80b336beccd996868e1a7a6bddbc736f5c119e [file] [log] [blame]
Bryce Lee840c5662017-04-13 10:02:51 -07001/*
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
17package com.android.server.am;
18
19import static org.junit.Assert.assertNotNull;
20import static org.junit.Assert.assertNull;
21
22import android.content.ComponentName;
23import android.platform.test.annotations.Presubmit;
24import android.support.test.filters.SmallTest;
25import android.support.test.runner.AndroidJUnit4;
26
27import org.junit.runner.RunWith;
28import org.junit.Test;
29
30/**
31 * Tests for the {@link ActivityStack} class.
32 *
33 * Build/Install/Run:
34 * bit FrameworksServicesTests:com.android.server.am.ActivityStackTests
35 */
36@SmallTest
37@Presubmit
38@RunWith(AndroidJUnit4.class)
39public class ActivityStackTests extends ActivityTestsBase {
40 private final ComponentName testActivityComponent =
41 ComponentName.unflattenFromString("com.foo/.BarActivity");
42
43 @Test
44 public void testEmptyTaskCleanupOnRemove() throws Exception {
45 final ActivityManagerService service = createActivityManagerService();
46 final TestActivityStack testStack = new ActivityStackBuilder(service).build();
47 final TaskRecord task = createTask(service, testActivityComponent, testStack);
48 assertNotNull(task.getWindowContainerController());
49 testStack.removeTask(task, "testEmptyTaskCleanupOnRemove",
50 ActivityStack.REMOVE_TASK_MODE_DESTROYING);
51 assertNull(task.getWindowContainerController());
52 }
53 @Test
54 public void testOccupiedTaskCleanupOnRemove() throws Exception {
55 final ActivityManagerService service = createActivityManagerService();
56 final TestActivityStack testStack = new ActivityStackBuilder(service).build();
57 final TaskRecord task = createTask(service, testActivityComponent, testStack);
58 final ActivityRecord activityRecord = createActivity(service, testActivityComponent, task);
59 assertNotNull(task.getWindowContainerController());
60 testStack.removeTask(task, "testOccupiedTaskCleanupOnRemove",
61 ActivityStack.REMOVE_TASK_MODE_DESTROYING);
62 assertNotNull(task.getWindowContainerController());
63 }
64}