1 /* 2 * Copyright (C) 2023 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.wm; 18 19 import static android.server.wm.UiDeviceUtils.pressUnlockButton; 20 import static android.server.wm.UiDeviceUtils.pressWakeupButton; 21 import static android.server.wm.WindowManagerState.getLogicalDisplaySize; 22 23 import android.app.KeyguardManager; 24 import android.os.PowerManager; 25 import android.view.cts.surfacevalidator.CapturedActivity; 26 27 import androidx.test.rule.ActivityTestRule; 28 29 import org.junit.Before; 30 import org.junit.Rule; 31 import org.junit.Test; 32 import org.junit.rules.TestName; 33 34 import java.util.Objects; 35 36 public class SurfaceViewSyncContinuousTest { 37 @Rule 38 public TestName mName = new TestName(); 39 40 @Rule 41 public ActivityTestRule<CapturedActivity> mActivityRule = 42 new ActivityTestRule<>(CapturedActivity.class); 43 44 public CapturedActivity mCapturedActivity; 45 46 @Before setup()47 public void setup() { 48 mCapturedActivity = mActivityRule.getActivity(); 49 mCapturedActivity.setLogicalDisplaySize(getLogicalDisplaySize()); 50 51 final KeyguardManager km = mCapturedActivity.getSystemService(KeyguardManager.class); 52 if (km != null && km.isKeyguardLocked() || !Objects.requireNonNull( 53 mCapturedActivity.getSystemService(PowerManager.class)).isInteractive()) { 54 pressWakeupButton(); 55 pressUnlockButton(); 56 } 57 } 58 59 @Test testSurfaceViewSyncDuringResize()60 public void testSurfaceViewSyncDuringResize() throws Throwable { 61 mCapturedActivity.verifyTest(new SurfaceViewSyncValidatorTestCase(), mName); 62 } 63 } 64