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