ActivityStackSupervisorTests.java revision 18498714fe22c62de461179aba3f08195db17e5f
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 17package com.android.server.am; 18 19import static org.junit.Assert.assertNull; 20 21import android.platform.test.annotations.Presubmit; 22import android.support.test.filters.MediumTest; 23import android.support.test.runner.AndroidJUnit4; 24 25import org.junit.runner.RunWith; 26import org.junit.Test; 27 28import static com.android.server.am.ActivityStackSupervisor.MATCH_TASK_IN_STACKS_OR_RECENT_TASKS_AND_RESTORE; 29 30/** 31 * Tests for the {@link ActivityStackSupervisor} class. 32 * 33 * Build/Install/Run: 34 * bit FrameworksServicesTests:com.android.server.am.ActivityStackSupervisorTests 35 */ 36@MediumTest 37@Presubmit 38@RunWith(AndroidJUnit4.class) 39public class ActivityStackSupervisorTests extends ActivityTestsBase { 40 /** 41 * This test ensures that we do not try to restore a task based off an invalid task id. The 42 * stack supervisor is a test version so there will be no tasks present. We should expect 43 * {@code null} to be returned in this case. 44 */ 45 @Test 46 public void testRestoringInvalidTask() throws Exception { 47 final ActivityManagerService service = createActivityManagerService(); 48 TaskRecord task = service.mStackSupervisor.anyTaskForIdLocked(0 /*taskId*/, 49 MATCH_TASK_IN_STACKS_OR_RECENT_TASKS_AND_RESTORE, 0 /*stackId*/); 50 assertNull(task); 51 } 52} 53