1 /*
2  * Copyright (C) 2021 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.RequiresFlagsDisabled
20 import android.tools.flicker.junit.FlickerParametersRunnerFactory
21 import android.tools.flicker.legacy.FlickerBuilder
22 import android.tools.flicker.legacy.LegacyFlickerTest
23 import com.android.server.wm.flicker.helpers.PipAppHelper
24 import com.android.wm.shell.Flags
25 import com.android.wm.shell.flicker.pip.common.ExitPipToAppTransition
26 import org.junit.FixMethodOrder
27 import org.junit.runner.RunWith
28 import org.junit.runners.MethodSorters
29 import org.junit.runners.Parameterized
30 
31 /**
32  * Test expanding a pip window back to full screen via the expand button
33  *
34  * To run this test: `atest WMShellFlickerTestsPip:ExitPipToAppViaExpandButtonTest`
35  *
36  * Actions:
37  * ```
38  *     Launch an app in pip mode [pipApp],
39  *     Launch another full screen mode [testApp]
40  *     Expand [pipApp] app to full screen by clicking on the pip window and
41  *     then on the expand button
42  * ```
43  *
44  * Notes:
45  * ```
46  *     1. Some default assertions (e.g., nav bar, status bar and screen covered)
47  *        are inherited [PipTransition]
48  *     2. Part of the test setup occurs automatically via
49  *        [android.tools.flicker.legacy.runner.TransitionRunner],
50  *        including configuring navigation mode, initial orientation and ensuring no
51  *        apps are running before setup
52  * ```
53  */
54 @RunWith(Parameterized::class)
55 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
56 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
57 @RequiresFlagsDisabled(Flags.FLAG_ENABLE_PIP2)
58 class ExitPipToAppViaExpandButtonTest(flicker: LegacyFlickerTest) :
59     ExitPipToAppTransition(flicker) {
60     override val pipApp: PipAppHelper = PipAppHelper(instrumentation)
61 
<lambda>null62     override val thisTransition: FlickerBuilder.() -> Unit = {
63         setup {
64             // launch an app behind the pip one
65             testApp.launchViaIntent(wmHelper)
66         }
67         transitions {
68             // This will bring PipApp to fullscreen
69             pipApp.expandPipWindowToApp(wmHelper)
70             // Wait until the other app is no longer visible
71             wmHelper.StateSyncBuilder().withWindowSurfaceDisappeared(testApp).waitForAndVerify()
72         }
73     }
74 }
75