diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-23 12:39:01 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-23 12:39:01 +0000 |
commit | f00768e58f44e2343b1ed6c0456a07dad5ec66ed (patch) | |
tree | 16d9a46fc3076e44d4342a6e0f0643bff3b18f28 /base/values_unittest.cc | |
parent | 7fd3fd82e83460bdc85da8ee4dd5ad06ce8426db (diff) | |
download | chromium_src-f00768e58f44e2343b1ed6c0456a07dad5ec66ed.zip chromium_src-f00768e58f44e2343b1ed6c0456a07dad5ec66ed.tar.gz chromium_src-f00768e58f44e2343b1ed6c0456a07dad5ec66ed.tar.bz2 |
Handle policy refresh internally in ConfigurationPolicyPrefStore.
This removes the final bits of thread-switching madness from PrefValueStore and also makes sure only the PrefStores and PrefService instances that are actually affected by a policy change get reconfigured.
BUG=67715
TEST=unit tests in configuration_policy_provider_unittest.cc
Review URL: http://codereview.chromium.org/6074003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values_unittest.cc')
-rw-r--r-- | base/values_unittest.cc | 133 |
1 files changed, 1 insertions, 132 deletions
diff --git a/base/values_unittest.cc b/base/values_unittest.cc index 13f0f19..adcd07e 100644 --- a/base/values_unittest.cc +++ b/base/values_unittest.cc @@ -10,27 +10,7 @@ #include "base/values.h" #include "testing/gtest/include/gtest/gtest.h" -class ValuesTest: public testing::Test { - protected: - void CompareDictionariesAndCheckResult( - const DictionaryValue* dict1, - const DictionaryValue* dict2, - const char* expected_paths[], - size_t expected_paths_count) { - std::vector<std::string> differing_paths; - std::vector<std::string> expected_paths_vector(expected_paths, - expected_paths+expected_paths_count); - // All comparisons should be commutative, check dict1 against dict2 - // and vice-versa. - dict1->GetDifferingPaths(dict2, &differing_paths); - ASSERT_EQ(expected_paths_count, differing_paths.size()); - EXPECT_TRUE(equal(differing_paths.begin(), differing_paths.end(), - expected_paths_vector.begin())); - dict2->GetDifferingPaths(dict1, &differing_paths); - ASSERT_EQ(expected_paths_count, differing_paths.size()); - EXPECT_TRUE(equal(differing_paths.begin(), differing_paths.end(), - expected_paths_vector.begin())); - } +class ValuesTest : public testing::Test { }; TEST_F(ValuesTest, Basic) { @@ -650,114 +630,3 @@ TEST_F(ValuesTest, MergeDictionary) { EXPECT_TRUE(res_sub_dict->GetString("sub_merge_key", &sub_merge_key_value)); EXPECT_EQ("sub_merge_key_value_merge", sub_merge_key_value); // Merged in. } - -TEST_F(ValuesTest, GetDifferingPaths) { - scoped_ptr<DictionaryValue> dict1(new DictionaryValue()); - scoped_ptr<DictionaryValue> dict2(new DictionaryValue()); - std::vector<std::string> differing_paths; - - // Test comparing empty dictionaries. - dict1->GetDifferingPaths(dict2.get(), &differing_paths); - EXPECT_EQ(differing_paths.size(), 0UL); - - // Compare an empty dictionary with various non-empty dictionaries. - static const char* expected_paths1[] = { - "segment1" - }; - dict1->SetString("segment1", "value1"); - CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths1, - arraysize(expected_paths1)); - - static const char* expected_paths2[] = { - "segment1", - "segment2", - "segment2.segment3" - }; - dict1->SetString("segment2.segment3", "value2"); - CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths2, - arraysize(expected_paths2)); - - static const char* expected_paths3[] = { - "segment1", - "segment2", - "segment2.segment3", - "segment4", - "segment4.segment5" - }; - dict1->SetString("segment4.segment5", "value3"); - CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths3, - arraysize(expected_paths3)); - - // Now various tests with two populated dictionaries. - static const char* expected_paths4[] = { - "segment1", - "segment2", - "segment2.segment3", - "segment4", - "segment4.segment5" - }; - dict2->Set("segment2", new DictionaryValue()); - CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths4, - arraysize(expected_paths4)); - - static const char* expected_paths5[] = { - "segment1", - "segment4", - "segment4.segment5" - }; - dict2->SetString("segment2.segment3", "value2"); - CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths5, - arraysize(expected_paths5)); - - dict2->SetBoolean("segment2.segment3", true); - CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths4, - arraysize(expected_paths4)); - - // Test two identical dictionaries. - dict2.reset(static_cast<DictionaryValue*>(dict1->DeepCopy())); - dict2->GetDifferingPaths(dict1.get(), &differing_paths); - EXPECT_EQ(differing_paths.size(), 0UL); - - // Test a deep dictionary structure. - static const char* expected_paths6[] = { - "s1", - "s1.s2", - "s1.s2.s3", - "s1.s2.s3.s4", - "s1.s2.s3.s4.s5" - }; - dict1.reset(new DictionaryValue()); - dict2.reset(new DictionaryValue()); - dict1->Set("s1.s2.s3.s4.s5", new DictionaryValue()); - CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths6, - arraysize(expected_paths6)); - - // Make sure disjoint dictionaries generate the right differing path list. - static const char* expected_paths7[] = { - "a", - "b", - "c", - "d" - }; - dict1.reset(new DictionaryValue()); - dict1->SetBoolean("a", true); - dict1->SetBoolean("c", true); - dict2.reset(new DictionaryValue()); - dict1->SetBoolean("b", true); - dict1->SetBoolean("d", true); - CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths7, - arraysize(expected_paths7)); - - // For code coverage completeness. Make sure that all branches - // that were not covered are executed. - static const char* expected_paths8[] = { - "s1", - "s1.s2" - }; - dict1.reset(new DictionaryValue()); - dict1->Set("s1.s2", new DictionaryValue()); - dict2.reset(new DictionaryValue()); - dict2->SetInteger("s1", 1); - CompareDictionariesAndCheckResult(dict1.get(), dict2.get(), expected_paths8, - arraysize(expected_paths8)); -} |