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 17 package com.android.server.cts; 18 19 import com.android.server.wm.AppTransitionProto; 20 import com.android.server.wm.IdentifierProto; 21 import com.android.server.wm.RootWindowContainerProto; 22 import com.android.server.wm.WindowManagerPolicyProto; 23 import com.android.server.wm.WindowManagerServiceDumpProto; 24 25 /** 26 * Tests for the WindowManagerService proto dump. 27 */ 28 public class WindowManagerIncidentTest extends ProtoDumpTestCase { 29 static void verifyWindowManagerServiceDumpProto(WindowManagerServiceDumpProto dump, final int filterLevel) throws Exception { 30 verifyWindowManagerPolicyProto(dump.getPolicy(), filterLevel); 31 verifyRootWindowContainerProto(dump.getRootWindowContainer(), filterLevel); 32 verifyIdentifierProto(dump.getFocusedWindow(), filterLevel); 33 verifyIdentifierProto(dump.getInputMethodWindow(), filterLevel); 34 verifyAppTransitionProto(dump.getAppTransition(), filterLevel); 35 } 36 37 private static void verifyWindowManagerPolicyProto(WindowManagerPolicyProto wmp, final int filterLevel) throws Exception { 38 assertTrue(WindowManagerPolicyProto.UserRotationMode.getDescriptor().getValues() 39 .contains(wmp.getRotationMode().getValueDescriptor())); 40 verifyIdentifierProto(wmp.getFocusedWindow(), filterLevel); 41 verifyIdentifierProto(wmp.getTopFullscreenOpaqueWindow(), filterLevel); 42 verifyIdentifierProto(wmp.getTopFullscreenOpaqueOrDimmingWindow(), filterLevel); 43 } 44 45 private static void verifyIdentifierProto(IdentifierProto ip, final int filterLevel) throws Exception { 46 if (filterLevel == PRIVACY_AUTO) { 47 assertTrue(ip.getTitle().isEmpty()); 48 } 49 } 50 51 private static void verifyRootWindowContainerProto(RootWindowContainerProto rwcp, final int filterLevel) throws Exception { 52 for (IdentifierProto ip : rwcp.getWindowsList()) { 53 verifyIdentifierProto(ip, filterLevel); 54 } 55 } 56 57 private static void verifyAppTransitionProto(AppTransitionProto atp, final int filterLevel) throws Exception { 58 assertTrue(AppTransitionProto.AppState.getDescriptor().getValues() 59 .contains(atp.getAppTransitionState().getValueDescriptor())); 60 assertTrue(AppTransitionProto.TransitionType.getDescriptor().getValues() 61 .contains(atp.getLastUsedAppTransition().getValueDescriptor())); 62 } 63 } 64