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.splitscreen.benchmark
18 
19 import android.tools.flicker.junit.FlickerParametersRunnerFactory
20 import android.tools.flicker.legacy.FlickerBuilder
21 import android.tools.flicker.legacy.LegacyFlickerTest
22 import android.tools.flicker.legacy.LegacyFlickerTestFactory
23 import androidx.test.filters.RequiresDevice
24 import com.android.server.wm.flicker.helpers.ImeAppHelper
25 import com.android.wm.shell.flicker.utils.SplitScreenUtils
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 @RequiresDevice
32 @RunWith(Parameterized::class)
33 @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
34 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
35 abstract class MultipleShowImeRequestsInSplitScreenBenchmark(
36         override val flicker: LegacyFlickerTest
37 ) : SplitScreenBase(flicker) {
38     override val primaryApp = ImeAppHelper(instrumentation)
39     override val defaultTeardown: FlickerBuilder.() -> Unit
<lambda>null40         get() = {
41             teardown {
42                 primaryApp.closeIME(wmHelper)
43                 super.defaultTeardown
44             }
45         }
46 
47     protected val thisTransition: FlickerBuilder.() -> Unit
<lambda>null48         get() = {
49             setup {
50                 SplitScreenUtils.enterSplit(
51                         wmHelper,
52                         tapl,
53                         device,
54                         primaryApp,
55                         secondaryApp,
56                         flicker.scenario.startRotation
57                 )
58                 // initially open the IME
59                 primaryApp.openIME(wmHelper)
60             }
61             transitions {
62                 for (i in 1..OPEN_IME_COUNT) {
63                     primaryApp.openIME(wmHelper)
64                 }
65             }
66         }
67 
68     companion object {
69         const val OPEN_IME_COUNT = 30
70 
71         @Parameterized.Parameters(name = "{0}")
72         @JvmStatic
getParamsnull73         fun getParams() = LegacyFlickerTestFactory.nonRotationTests()
74     }
75 }
76