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 17 package android.platform.test.flag.junit; 18 19 import android.platform.test.flag.junit.CheckFlagsRule; 20 import android.platform.test.flag.junit.IFlagsValueProvider; 21 22 /** 23 * Offer to create {@link CheckFlagsRule} instances that are useful on the Ravenwood deviceless 24 * testing environment. 25 * 26 * At the moment, default flag values are not available on Ravenwood, so the only options offered 27 * here are "all-on" and "all-off" options. Tests that want to exercise specific flag states should 28 * use {@link android.platform.test.flag.junit.SetFlagsRule}. 29 */ 30 public class RavenwoodFlagsValueProvider { 31 /** 32 * Create a {@link CheckFlagsRule} instance where flags are in an "all-on" state. 33 */ createAllOnCheckFlagsRule()34 public static CheckFlagsRule createAllOnCheckFlagsRule() { 35 return new CheckFlagsRule(new IFlagsValueProvider() { 36 @Override 37 public boolean getBoolean(String flag) { 38 return true; 39 } 40 }); 41 } 42 43 /** 44 * Create a {@link CheckFlagsRule} instance where flags are in an "all-off" state. 45 */ 46 public static CheckFlagsRule createAllOffCheckFlagsRule() { 47 return new CheckFlagsRule(new IFlagsValueProvider() { 48 @Override 49 public boolean getBoolean(String flag) { 50 return false; 51 } 52 }); 53 } 54 } 55