• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.enterprise.annotations
17 
18 import com.android.bedstead.harrier.UserType
19 import com.android.bedstead.harrier.annotations.AnnotationPriorityRunPrecedence
20 import com.android.bedstead.harrier.annotations.EnsureTestAppInstalled
21 import com.android.bedstead.harrier.annotations.UsesAnnotationExecutor
22 import com.android.queryable.annotations.Query
23 
24 /**
25  * Mark that a test requires the given test app to be installed on the given user and marked as primary.
26  * This testApp will be returned by calls to `DeviceState#dpc()`.
27  *
28  *
29  * You should use `DeviceState` to ensure that the device enters
30  * the correct state for the method.
31  *
32  *
33  * Only one policy manager per test should be marked as primary.
34  */
35 @Target(
36     AnnotationTarget.FUNCTION,
37     AnnotationTarget.CLASS
38 )
39 @Retention(
40     AnnotationRetention.RUNTIME
41 )
42 @JvmRepeatable(
43     EnsureTestAppInstalledAsPrimaryDPCGroup::class
44 )
45 @UsesAnnotationExecutor(UsesAnnotationExecutor.ENTERPRISE)
46 annotation class EnsureTestAppInstalledAsPrimaryDPC(
47     /**
48      * A key which uniquely identifies the test app for the test.
49      *
50      *
51      * This can be used with e.g. `DeviceState#testApp` and
52      * [AdditionalQueryParameters].
53      */
54     val key: String = EnsureTestAppInstalled.DEFAULT_KEY,
55     /**
56      * Query specifying the testapp. Defaults to any test app.
57      */
58     val query: Query = Query(),
59     /**
60      * The user the testApp should be installed on.
61      */
62     val onUser: UserType = UserType.INSTRUMENTED_USER,
63     /**
64      * Priority sets the order that annotations will be resolved.
65      *
66      *
67      * Annotations with a lower priority will be resolved before annotations with a higher
68      * priority.
69      *
70      *
71      * If there is an order requirement between annotations, ensure that the priority of the
72      * annotation which must be resolved first is lower than the one which must be resolved later.
73      *
74      *
75      * Priority can be set to a [AnnotationPriorityRunPrecedence] constant, or to any [int].
76      */
77     val priority: Int = AnnotationPriorityRunPrecedence.MIDDLE
78 ) {
79     companion object {
80         const val ENSURE_TEST_APP_INSTALLED_AS_PRIMARY_DPC_PRIORITY: Int =
81             AnnotationPriorityRunPrecedence.MIDDLE
82     }
83 }
84 
85