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 package com.android.bedstead.harrier.annotations 17 18 /** 19 * Marks that the test requires a list of instrumented processes to be running. It assumes that 20 * instrumented apks are installed. If installed, it will start those instrumented processes 21 * irrespective of whether they are running or not. 22 */ 23 @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) 24 @Retention(AnnotationRetention.RUNTIME) 25 @UsesAnnotationExecutor(UsesAnnotationExecutor.MAIN) 26 annotation class EnsureInstrumented( 27 /** 28 * An array of [InstrumentationComponent], each containing a package name, runner class, and an 29 * optional parameter [broadcastReceiverIntentAction]. The test will start instrumented processes 30 * for these package names using the corresponding runner classes. The value of 31 * broadcastReceiverIntentAction should be unique. For components where this parameter is set, the 32 * executing thread will block until all the corresponding instrumented processes have sent a 33 * broadcast with the specified intent action. 34 */ 35 val value: Array<InstrumentationComponent>, 36 37 /** 38 * Priority sets the order that annotations will be resolved. 39 * 40 * Annotations with a lower priority will be resolved before annotations with a higher priority. 41 * 42 * If there is an order requirement between annotations, ensure that the priority of the 43 * annotation which must be resolved first is lower than the one which must be resolved later. 44 * 45 * Priority can be set to a [AnnotationPriorityRunPrecedence] constant, or to any [int]. 46 */ 47 val priority: Int = AnnotationPriorityRunPrecedence.LATE, 48 ) 49 50 /** 51 * Annotation class representing a pair of package name and runner class. 52 * 53 * @property packageName The package name of the instrumented APK. 54 * @property runnerClass The runner class which is a subclass of [AndroidJUnitRunner] to be used for 55 * instrumentation, specified as a string. 56 * @property broadcastReceiverIntentAction The optional [Intent] action for a broadcast receiver. 57 * After starting the instrumentation, if this param is set, then the executing thread will block 58 * until a broadcast with the specified intent action is received. 59 */ 60 annotation class InstrumentationComponent( 61 val packageName: String, 62 val runnerClass: String, 63 val broadcastReceiverIntentAction: String = "", 64 )