1 /* 2 * Copyright (C) 2024 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.wm.shell.flicker.pip 18 19 import android.platform.test.annotations.Presubmit 20 import android.platform.test.annotations.RequiresFlagsDisabled 21 import android.tools.flicker.junit.FlickerParametersRunnerFactory 22 import android.tools.flicker.legacy.FlickerBuilder 23 import android.tools.flicker.legacy.LegacyFlickerTest 24 import android.tools.traces.component.ComponentNameMatcher 25 import com.android.server.wm.flicker.helpers.PipAppHelper 26 import com.android.wm.shell.Flags 27 import org.junit.FixMethodOrder 28 import org.junit.Test 29 import org.junit.runner.RunWith 30 import org.junit.runners.MethodSorters 31 import org.junit.runners.Parameterized 32 33 /** 34 * Test auto entering pip using a source rect hint. 35 * 36 * To run this test: `atest WMShellFlickerTestsPip:AutoEnterPipWithSourceRectHintTest` 37 * 38 * Actions: 39 * ``` 40 * Launch an app in full screen 41 * Select "Auto-enter PiP" radio button 42 * Press "Set SourceRectHint" to create a temporary view that is used as the source rect hint 43 * Press Home button or swipe up to go Home and put [pipApp] in pip mode 44 * ``` 45 * 46 * Notes: 47 * ``` 48 * 1. All assertions are inherited from [AutoEnterPipOnGoToHomeTest] 49 * 2. Part of the test setup occurs automatically via 50 * [android.tools.flicker.legacy.runner.TransitionRunner], 51 * including configuring navigation mode, initial orientation and ensuring no 52 * apps are running before setup 53 * ``` 54 */ 55 @RunWith(Parameterized::class) 56 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) 57 @FixMethodOrder(MethodSorters.NAME_ASCENDING) 58 @RequiresFlagsDisabled(Flags.FLAG_ENABLE_PIP2) 59 class AutoEnterPipWithSourceRectHintTest(flicker: LegacyFlickerTest) : 60 AutoEnterPipOnGoToHomeTest(flicker) { 61 override val pipApp: PipAppHelper = PipAppHelper(instrumentation) 62 <lambda>null63 override val defaultEnterPip: FlickerBuilder.() -> Unit = { 64 setup { 65 pipApp.launchViaIntent(wmHelper) 66 pipApp.setSourceRectHint() 67 pipApp.enableAutoEnterForPipActivity() 68 } 69 } 70 71 @Presubmit 72 @Test pipOverlayNotShownnull73 fun pipOverlayNotShown() { 74 val overlay = ComponentNameMatcher.PIP_CONTENT_OVERLAY 75 flicker.assertLayers { this.notContains(overlay) } 76 } 77 @Presubmit 78 @Test pipOverlayLayerAppearThenDisappearnull79 override fun pipOverlayLayerAppearThenDisappear() { 80 // we don't use overlay when entering with sourceRectHint 81 } 82 83 @Presubmit 84 @Test pipLayerOrOverlayRemainInsideVisibleBoundsnull85 override fun pipLayerOrOverlayRemainInsideVisibleBounds() { 86 // TODO (b/323511194): Looks like there is some bounciness with pip when using 87 // auto enter and sourceRectHint that causes the app to move outside of the display 88 // bounds during the transition. 89 } 90 } 91