• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import org.junit.rules.TestRule
25 
26 interface FlickerTestData {
27     /** Instrumentation to run the tests */
28     val instrumentation: Instrumentation
29     /** Test automation component used to interact with the device */
30     val device: UiDevice
31     /** Output directory for test results */
32     val outputDir: File
33     /** Enabled tracing monitors */
34     val traceMonitors: List<ITransitionMonitor>
35     /** Commands to be executed before the transition */
36     val transitionSetup: List<FlickerTestData.() -> Any>
37     /** Test commands */
38     val transitions: List<FlickerTestData.() -> Any>
39     /** Commands to be executed after the transition */
40     val transitionTeardown: List<FlickerTestData.() -> Any>
41     /** JUnit rules to be executed around transition */
42     val rules: List<TestRule>
43     /** Helper object for WM Synchronization */
44     val wmHelper: WindowManagerStateHelper
45 
setAssertionsCheckedCallbacknull46     fun setAssertionsCheckedCallback(callback: (Boolean) -> Unit)
47 
48     fun setCreateTagListener(callback: (String) -> Unit)
49 
50     fun clearTagListener()
51 
52     /**
53      * Runs a set of commands and, at the end, creates a tag containing the device state
54      *
55      * @param tag Identifier for the tag to be created
56      * @param commands Commands to execute before creating the tag
57      * @throws IllegalArgumentException If [tag] cannot be converted to a valid filename
58      */
59     fun withTag(tag: String, commands: FlickerTestData.() -> Any)
60 
61     fun createTag(tag: String)
62 }
63