diff options
Diffstat (limited to 'base/properties_test.cpp')
-rw-r--r-- | base/properties_test.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/base/properties_test.cpp b/base/properties_test.cpp index e7d4880c2..c30c41e8a 100644 --- a/base/properties_test.cpp +++ b/base/properties_test.cpp @@ -230,3 +230,28 @@ TEST(properties, WaitForPropertyCreation_timeout) { GTEST_LOG_(INFO) << "This test does nothing on the host.\n"; #endif } + +TEST(properties, CachedProperty) { +#if defined(__BIONIC__) + android::base::CachedProperty cached_property("debug.libbase.CachedProperty_test"); + bool changed; + cached_property.Get(&changed); + + android::base::SetProperty("debug.libbase.CachedProperty_test", "foo"); + ASSERT_STREQ("foo", cached_property.Get(&changed)); + ASSERT_TRUE(changed); + + ASSERT_STREQ("foo", cached_property.Get(&changed)); + ASSERT_FALSE(changed); + + android::base::SetProperty("debug.libbase.CachedProperty_test", "bar"); + ASSERT_STREQ("bar", cached_property.Get(&changed)); + ASSERT_TRUE(changed); + + ASSERT_STREQ("bar", cached_property.Get(&changed)); + ASSERT_FALSE(changed); + +#else + GTEST_LOG_(INFO) << "This test does nothing on the host.\n"; +#endif +} |