Files
build/tools/aconfig/tests/aconfig_test_test_variant.cpp
Mårten Kongstad 0b2a2a8c19 aconfig: adjust integration tests to correctly set flag values
With the introduction of a root release config, the
com.android.aconfig.test flags now have their values correctly assigned.
Update the integration tests accordingly.

Bug: 317178122
Test: atest :all
Merged-In: I1acdf9442a465f20f71bcda9b15eb69058aa4b3a
Change-Id: I1acdf9442a465f20f71bcda9b15eb69058aa4b3a
2023-12-21 09:00:48 +01:00

81 lines
2.2 KiB
C++

/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "com_android_aconfig_test.h"
#include "gtest/gtest.h"
using namespace com::android::aconfig::test;
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_F(AconfigTest, TestEnabledReadOnlyFlag) {
ASSERT_TRUE(com_android_aconfig_test_enabled_ro());
ASSERT_TRUE(provider_->enabled_ro());
ASSERT_TRUE(enabled_ro());
}
TEST_F(AconfigTest, TestDisabledReadWriteFlag) {
ASSERT_FALSE(com_android_aconfig_test_disabled_rw());
ASSERT_FALSE(provider_->disabled_rw());
ASSERT_FALSE(disabled_rw());
}
TEST_F(AconfigTest, TestEnabledReadWriteFlag) {
ASSERT_TRUE(com_android_aconfig_test_enabled_rw());
ASSERT_TRUE(provider_->enabled_rw());
ASSERT_TRUE(enabled_rw());
}
TEST_F(AconfigTest, TestEnabledFixedReadOnlyFlag) {
ASSERT_TRUE(com_android_aconfig_test_enabled_fixed_ro());
ASSERT_TRUE(provider_->enabled_fixed_ro());
ASSERT_TRUE(enabled_fixed_ro());
}
TEST_F(AconfigTest, OverrideFlagValue) {
ASSERT_FALSE(disabled_ro());
disabled_ro(true);
ASSERT_TRUE(disabled_ro());
}
TEST_F(AconfigTest, ResetFlagValue) {
ASSERT_FALSE(disabled_ro());
ASSERT_TRUE(enabled_ro());
disabled_ro(true);
enabled_ro(false);
ASSERT_TRUE(disabled_ro());
ASSERT_FALSE(enabled_ro());
reset_flags();
ASSERT_FALSE(disabled_ro());
ASSERT_TRUE(enabled_ro());
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}