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 android.tools.flicker.legacy
18 
19 import android.app.Instrumentation
20 import android.tools.traces.monitors.ITransitionMonitor
21 import android.tools.traces.parsers.WindowManagerStateHelper
22 import androidx.test.uiautomator.UiDevice
23 import java.io.File
24 
25 interface FlickerTestData {
26     /** Instrumentation to run the tests */
27     val instrumentation: Instrumentation
28     /** Test automation component used to interact with the device */
29     val device: UiDevice
30     /** Output directory for test results */
31     val outputDir: File
32     /** Enabled tracing monitors */
33     val traceMonitors: List<ITransitionMonitor>
34     /** Commands to be executed before the transition */
35     val transitionSetup: List<FlickerTestData.() -> Any>
36     /** Test commands */
37     val transitions: List<FlickerTestData.() -> Any>
38     /** Commands to be executed after the transition */
39     val transitionTeardown: List<FlickerTestData.() -> Any>
40     /** Helper object for WM Synchronization */
41     val wmHelper: WindowManagerStateHelper
42 
setAssertionsCheckedCallbacknull43     fun setAssertionsCheckedCallback(callback: (Boolean) -> Unit)
44 
45     fun setCreateTagListener(callback: (String) -> Unit)
46 
47     fun clearTagListener()
48 
49     /**
50      * Runs a set of commands and, at the end, creates a tag containing the device state
51      *
52      * @param tag Identifier for the tag to be created
53      * @param commands Commands to execute before creating the tag
54      * @throws IllegalArgumentException If [tag] cannot be converted to a valid filename
55      */
56     fun withTag(tag: String, commands: FlickerTestData.() -> Any)
57 
58     fun createTag(tag: String)
59 }
60