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 package com.android.bedstead.enterprise.annotations
17 
18 import com.android.bedstead.harrier.annotations.AnnotationPriorityRunPrecedence
19 import com.android.bedstead.harrier.annotations.meta.RequiresBedsteadJUnit4
20 import com.google.auto.value.AutoAnnotation
21 import kotlin.reflect.KClass
22 
23 /**
24  * Mark a test as testing the states where a policy is applied (by a Device Owner or Profile Owner)
25  * and it should apply to the user the test is running on.
26  *
27  *
28  * This will generated parameterized runs for all matching states.
29  */
30 @Target(AnnotationTarget.FUNCTION)
31 @Retention(AnnotationRetention.RUNTIME)
32 @RequiresBedsteadJUnit4
33 annotation class PolicyAppliesTest(
34     /**
35      * The policy being tested.
36      *
37      *
38      * If multiple policies are specified, then they will be merged so that all valid states for
39      * all specified policies are considered as valid.
40      *
41      *
42      * This is used to calculate which states are required to be tested.
43      */
44     val policy: Array<KClass<*>>,
45     /**
46      * Priority sets the order that annotations will be resolved.
47      *
48      *
49      * Annotations with a lower priority will be resolved before annotations with a higher
50      * priority.
51      *
52      *
53      * If there is an order requirement between annotations, ensure that the priority of the
54      * annotation which must be resolved first is lower than the one which must be resolved later.
55      *
56      *
57      * Priority can be set to a [AnnotationPriorityRunPrecedence] constant, or to any [int].
58      */
59     val priority: Int = AnnotationPriorityRunPrecedence.EARLY)
60 
61 @AutoAnnotation
policyAppliesTestnull62 fun policyAppliesTest(
63     policy: Array<Class<*>>,
64 ): PolicyAppliesTest {
65     return AutoAnnotation_PolicyAppliesTestKt_policyAppliesTest(policy)
66 }