Debian Codegraph @

tests/FlickerTests/src/com/android/server/wm/flicker/helpers/NewTasksAppHelper.kt

raw
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.server.wm.flicker.helpers
18
19 import android.app.Instrumentation
20 import android.support.test.launcherhelper.ILauncherStrategy
21 import android.support.test.launcherhelper.LauncherStrategyFactory
22 import androidx.test.uiautomator.By
23 import androidx.test.uiautomator.UiDevice
24 import androidx.test.uiautomator.Until
25 import com.android.server.wm.flicker.testapp.ActivityOptions
26 import com.android.server.wm.traces.common.FlickerComponentName
27 import com.android.server.wm.traces.parser.toFlickerComponent
28 import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
29
30 class NewTasksAppHelper @JvmOverloads constructor(
31 instr: Instrumentation,
32 launcherName: String = ActivityOptions.LAUNCH_NEW_TASK_ACTIVITY_LAUNCHER_NAME,
33 component: FlickerComponentName =
34 ActivityOptions.LAUNCH_NEW_TASK_ACTIVITY_COMPONENT_NAME.toFlickerComponent(),
35 launcherStrategy: ILauncherStrategy = LauncherStrategyFactory
36 .getInstance(instr)
37 .launcherStrategy
38 ) : StandardAppHelper(instr, launcherName, component, launcherStrategy) {
39 fun openNewTask(device: UiDevice, wmHelper: WindowManagerStateHelper) {
40 val button = device.wait(
41 Until.findObject(By.res(getPackage(), "launch_new_task")),
42 FIND_TIMEOUT)
43
44 require(button != null) {
45 "Button not found, this usually happens when the device " +
46 "was left in an unknown state (e.g. in split screen)"
47 }
48 button.click()
49 wmHelper.waitForAppTransitionIdle()
50 wmHelper.waitForFullScreenApp(component)
51 }
52 }