aconfig: fix broken test 'aconfig.test.cpp.test_mode:AconfigTest#ResetFlagValue'
The aconfig.test.cpp.test_mode test cases modify the local flag
overrides, but was not resetting the values between tests. This meant
that
$ atest 'aconfig.test.cpp.test_mode:AconfigTest#ResetFlagValue'
would succeed, but
$ atest aconfig.test.cpp.test_mode
would fail. Fix this by calling reset_flags() as part of the per-test
setup.
Bug: N/A
Test: atest aconfig.test.cpp.test_mode
Change-Id: Ic8cffff0deb279b7ae103c05642c67230afc040f
diff --git a/tools/aconfig/tests/aconfig_test_test_variant.cpp b/tools/aconfig/tests/aconfig_test_test_variant.cpp
index aef6f38..8a745c5 100644
--- a/tools/aconfig/tests/aconfig_test_test_variant.cpp
+++ b/tools/aconfig/tests/aconfig_test_test_variant.cpp
@@ -19,13 +19,20 @@
using namespace com::android::aconfig::test;
-TEST(AconfigTest, TestDisabledReadOnlyFlag) {
+class AconfigTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ reset_flags();
+ }
+};
+
+TEST_F(AconfigTest, TestDisabledReadOnlyFlag) {
ASSERT_FALSE(com_android_aconfig_test_disabled_ro());
ASSERT_FALSE(provider_->disabled_ro());
ASSERT_FALSE(disabled_ro());
}
-TEST(AconfigTest, TestEnabledReadOnlyFlag) {
+TEST_F(AconfigTest, TestEnabledReadOnlyFlag) {
// TODO: change to assertTrue(enabledRo()) when the build supports reading tests/*.values
// (currently all flags are assigned the default READ_ONLY + DISABLED)
ASSERT_FALSE(com_android_aconfig_test_enabled_ro());
@@ -33,13 +40,13 @@
ASSERT_FALSE(enabled_ro());
}
-TEST(AconfigTest, TestDisabledReadWriteFlag) {
+TEST_F(AconfigTest, TestDisabledReadWriteFlag) {
ASSERT_FALSE(com_android_aconfig_test_disabled_rw());
ASSERT_FALSE(provider_->disabled_rw());
ASSERT_FALSE(disabled_rw());
}
-TEST(AconfigTest, TestEnabledReadWriteFlag) {
+TEST_F(AconfigTest, TestEnabledReadWriteFlag) {
// TODO: change to assertTrue(enabledRo()) when the build supports reading tests/*.values
// (currently all flags are assigned the default READ_ONLY + DISABLED)
ASSERT_FALSE(com_android_aconfig_test_enabled_rw());
@@ -47,7 +54,7 @@
ASSERT_FALSE(enabled_rw());
}
-TEST(AconfigTest, TestEnabledFixedReadOnlyFlag) {
+TEST_F(AconfigTest, TestEnabledFixedReadOnlyFlag) {
// TODO: change to assertTrue(enabledFixedRo()) when the build supports reading tests/*.values
// (currently all flags are assigned the default READ_ONLY + DISABLED)
ASSERT_FALSE(com_android_aconfig_test_enabled_fixed_ro());
@@ -55,13 +62,13 @@
ASSERT_FALSE(enabled_fixed_ro());
}
-TEST(AconfigTest, OverrideFlagValue) {
+TEST_F(AconfigTest, OverrideFlagValue) {
ASSERT_FALSE(disabled_ro());
disabled_ro(true);
ASSERT_TRUE(disabled_ro());
}
-TEST(AconfigTest, ResetFlagValue) {
+TEST_F(AconfigTest, ResetFlagValue) {
ASSERT_FALSE(disabled_ro());
ASSERT_FALSE(enabled_ro());
disabled_ro(true);