Use CheckFlagsRule when the test requires the device's implementation

Bug: 341699461
Test: atest com.android.settings.accessibility on next-userdebug build
Flag: TEST_ONLY
Change-Id: I348252519a8af4b7c890b4e8a03752c918c94b94
This commit is contained in:
Chun-Ku Lin
2024-05-29 01:32:47 +00:00
parent f91bd7ba24
commit 0122f8a1dc

View File

@@ -25,9 +25,10 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.Settings;
import android.view.accessibility.Flags;
@@ -61,7 +62,7 @@ public class PreferredShortcutsTest {
private static final ContentResolver sContentResolver =
ApplicationProvider.getApplicationContext().getContentResolver();
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
private final Context mContext = ApplicationProvider.getApplicationContext();
@Before
@@ -174,7 +175,7 @@ public class PreferredShortcutsTest {
}
@Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
@RequiresFlagsEnabled(Flags.FLAG_A11Y_QS_SHORTCUT)
public void updatePreferredShortcutFromSettings_colorInversionWithQsAndSoftwareShortcut_preferredShortcutsMatches() {
String target = COLOR_INVERSION_COMPONENT_NAME.flattenToString();
Settings.Secure.putString(sContentResolver,
@@ -192,7 +193,7 @@ public class PreferredShortcutsTest {
}
@Test
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
@RequiresFlagsDisabled(Flags.FLAG_A11Y_QS_SHORTCUT)
public void updatePreferredShortcutFromSettings_colorInversionWithQsAndHardwareShortcut_qsShortcutNotSaved() {
String target = COLOR_INVERSION_COMPONENT_NAME.flattenToString();
Settings.Secure.putString(sContentResolver,