TaskSnapshotControllerTest.java revision 6d41026f1b3dc910c9d34ab89993a280dc9679cf
1/* 2 * Copyright (C) 2016 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.wm; 18 19import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; 20import static com.android.server.wm.AppTransition.TRANSIT_UNSET; 21import static junit.framework.Assert.assertEquals; 22 23import android.platform.test.annotations.Presubmit; 24import android.support.test.filters.SmallTest; 25import android.support.test.runner.AndroidJUnit4; 26import android.util.ArraySet; 27 28import org.junit.Test; 29import org.junit.runner.RunWith; 30 31/** 32 * Test class for {@link TaskSnapshotController}. 33 * 34 * runtest frameworks-services -c com.android.server.wm.TaskSnapshotControllerTest 35 */ 36@SmallTest 37@Presubmit 38@RunWith(AndroidJUnit4.class) 39public class TaskSnapshotControllerTest extends WindowTestsBase { 40 41 @Test 42 public void testGetClosingApps_closing() throws Exception { 43 final WindowState closingWindow = createWindow(null, FIRST_APPLICATION_WINDOW, 44 "closingWindow"); 45 closingWindow.mAppToken.setVisibility(null, false /* visible */, TRANSIT_UNSET, 46 true /* performLayout */, false /* isVoiceInteraction */); 47 final ArraySet<AppWindowToken> closingApps = new ArraySet<>(); 48 closingApps.add(closingWindow.mAppToken); 49 final ArraySet<Task> closingTasks = new ArraySet<>(); 50 sWm.mTaskSnapshotController.getClosingTasks(closingApps, closingTasks); 51 assertEquals(1, closingTasks.size()); 52 assertEquals(closingWindow.mAppToken.getTask(), closingTasks.valueAt(0)); 53 } 54 55 @Test 56 public void testGetClosingApps_notClosing() throws Exception { 57 final WindowState closingWindow = createWindow(null, FIRST_APPLICATION_WINDOW, 58 "closingWindow"); 59 final WindowState openingWindow = createAppWindow(closingWindow.getTask(), 60 FIRST_APPLICATION_WINDOW, "openingWindow"); 61 closingWindow.mAppToken.setVisibility(null, false /* visible */, TRANSIT_UNSET, 62 true /* performLayout */, false /* isVoiceInteraction */); 63 openingWindow.mAppToken.setVisibility(null, true /* visible */, TRANSIT_UNSET, 64 true /* performLayout */, false /* isVoiceInteraction */); 65 final ArraySet<AppWindowToken> closingApps = new ArraySet<>(); 66 closingApps.add(closingWindow.mAppToken); 67 final ArraySet<Task> closingTasks = new ArraySet<>(); 68 sWm.mTaskSnapshotController.getClosingTasks(closingApps, closingTasks); 69 assertEquals(0, closingTasks.size()); 70 } 71} 72