WindowStateTests.java revision b699ce0d06eb6be91c0be0a791d8d8d7c68b4f41
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 android.content.Context; 20import android.test.AndroidTestCase; 21import android.view.IWindow; 22import android.view.WindowManager; 23import android.view.WindowManagerPolicy; 24 25import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; 26import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; 27 28/** 29 * Tests for the {@link WindowState} class. 30 * 31 * Build: mmma -j32 frameworks/base/services/tests/servicestests 32 * Install: adb install -r out/target/product/angler/data/app/FrameworksServicesTests/FrameworksServicesTests.apk 33 * Run: adb shell am instrument -w -e class com.android.server.wm.WindowStateTests com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner 34 */ 35public class WindowStateTests extends AndroidTestCase { 36 37 private WindowManagerService mWm; 38 private WindowToken mWindowToken; 39 private final WindowManagerPolicy mPolicy = new TestWindowManagerPolicy(); 40 private final IWindow mIWindow = new TestIWindow(); 41 42 @Override 43 public void setUp() throws Exception { 44 final Context context = getContext(); 45// final InputManagerService im = new InputManagerService(context); 46 mWm = WindowManagerService.main(context, /*im*/ null, true, false, false, mPolicy); 47 mWindowToken = new WindowToken(mWm, null, 0, false); 48 } 49 50 private WindowState createWindow(WindowState parent) { 51 final int type = (parent == null) ? TYPE_APPLICATION : FIRST_SUB_WINDOW; 52 final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(type); 53 54 return new WindowState(mWm, null, mIWindow, mWindowToken, parent, 0, 0, attrs, 0, 55 mWm.getDefaultDisplayContentLocked(), 0); 56 } 57} 58