• 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.platform.test.annotations;
18 
19 import java.lang.annotation.ElementType;
20 import java.lang.annotation.Inherited;
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 import java.lang.annotation.Target;
24 
25 /**
26  * Indicates that a specific test or class should be run only if all of the given feature flags are
27  * enabled in the device's current state. Enforced by the {@code CheckFlagsRule}.
28  *
29  * <p>This annotation works together with {@link RequiresFlagsDisabled} to define the value that is
30  * required of the flag by the test for the test to run. It is an error for either a method or class
31  * to require that a particular flag be both enabled and disabled.
32  *
33  * <p>If the value of a particular flag is required (by either {@code RequiresFlagsEnabled} or
34  * {@code RequiresFlagsDisabled}) by both the class and test method, then the values must be
35  * consistent.
36  *
37  * <p>If the value of a one flag is required by an annotation on the class, and the value of a
38  * different flag is required by an annotation of the method, then both requirements apply.
39  *
40  * <p>With {@code CheckFlagsRule}, test(s) will be skipped with 'assumption failed' when any of the
41  * required flag on the target Android platform is disabled.
42  *
43  * <p>Both {@code SetFlagsRule} and {@code CheckFlagsRule} will fail the test if a particular flag
44  * is both set (with {@code EnableFlags} or {@code DisableFlags}) and required (with {@code
45  * RequiresFlagsEnabled} or {@code RequiresFlagsDisabled}).
46  *
47  * <p>{@link Inherited} so that subclasses will inherit superclass value, especially for benchmarks.
48  */
49 @Retention(RetentionPolicy.RUNTIME)
50 @Target({ElementType.METHOD, ElementType.TYPE})
51 @Inherited
52 public @interface RequiresFlagsEnabled {
53     /**
54      * The list of the feature flags that require to be enabled. Each item is the full flag name
55      * with the format {package_name}.{flag_name}.
56      */
value()57     String[] value();
58 }
59