Index: chrome/browser/extensions/settings/settings_storage_unittest.cc |
diff --git a/chrome/browser/extensions/settings/settings_storage_unittest.cc b/chrome/browser/extensions/settings/settings_storage_unittest.cc |
index 8f78abe4be12c28ab7de45186dba1665c706870e..e1e96748bb989461ba1059052f1e65498b0bb2af 100644 |
--- a/chrome/browser/extensions/settings/settings_storage_unittest.cc |
+++ b/chrome/browser/extensions/settings/settings_storage_unittest.cc |
@@ -14,6 +14,9 @@ using content::BrowserThread; |
namespace { |
+// To save typing SettingsStorage::DEFAULTS everywhere. |
+const SettingsStorage::WriteOptions DEFAULTS = SettingsStorage::DEFAULTS; |
+ |
// Gets the pretty-printed JSON for a value. |
std::string GetJSON(const Value& value) { |
std::string json; |
@@ -199,7 +202,8 @@ TEST_P(ExtensionSettingsStorageTest, GetWithSingleValue) { |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, NULL, val1_->DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(key1_, *val1_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Set(DEFAULTS, key1_, *val1_)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, *dict1_, storage_->Get(key1_)); |
@@ -215,7 +219,7 @@ TEST_P(ExtensionSettingsStorageTest, GetWithMultipleValues) { |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, NULL, val1_->DeepCopy())); |
changes.push_back(SettingChange(key2_, NULL, val2_->DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(*dict12_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, *dict12_)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, *dict1_, storage_->Get(key1_)); |
@@ -227,7 +231,7 @@ TEST_P(ExtensionSettingsStorageTest, GetWithMultipleValues) { |
TEST_P(ExtensionSettingsStorageTest, RemoveWhenEmpty) { |
EXPECT_PRED_FORMAT2(ChangesEq, |
- SettingChangeList(), storage_->Remove(key1_)); |
+ SettingChangeList(), storage_->Remove(DEFAULTS, key1_)); |
EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(key1_)); |
EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(list1_)); |
@@ -235,11 +239,11 @@ TEST_P(ExtensionSettingsStorageTest, RemoveWhenEmpty) { |
} |
TEST_P(ExtensionSettingsStorageTest, RemoveWithSingleValue) { |
- storage_->Set(*dict1_); |
+ storage_->Set(DEFAULTS, *dict1_); |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, val1_->DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(key1_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(DEFAULTS, key1_)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(key1_)); |
@@ -250,11 +254,11 @@ TEST_P(ExtensionSettingsStorageTest, RemoveWithSingleValue) { |
} |
TEST_P(ExtensionSettingsStorageTest, RemoveWithMultipleValues) { |
- storage_->Set(*dict123_); |
+ storage_->Set(DEFAULTS, *dict123_); |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key3_, val3_->DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(key3_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(DEFAULTS, key3_)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, *dict1_, storage_->Get(key1_)); |
@@ -270,7 +274,8 @@ TEST_P(ExtensionSettingsStorageTest, RemoveWithMultipleValues) { |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, val1_->DeepCopy(), NULL)); |
changes.push_back(SettingChange(key2_, val2_->DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(list12_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Remove(DEFAULTS, list12_)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(key1_)); |
@@ -284,13 +289,13 @@ TEST_P(ExtensionSettingsStorageTest, RemoveWithMultipleValues) { |
} |
TEST_P(ExtensionSettingsStorageTest, SetWhenOverwriting) { |
- storage_->Set(key1_, *val2_); |
+ storage_->Set(DEFAULTS, key1_, *val2_); |
{ |
SettingChangeList changes; |
changes.push_back( |
SettingChange(key1_, val2_->DeepCopy(), val1_->DeepCopy())); |
changes.push_back(SettingChange(key2_, NULL, val2_->DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(*dict12_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, *dict12_)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, *dict1_, storage_->Get(key1_)); |
@@ -305,7 +310,7 @@ TEST_P(ExtensionSettingsStorageTest, SetWhenOverwriting) { |
TEST_P(ExtensionSettingsStorageTest, ClearWhenEmpty) { |
EXPECT_PRED_FORMAT2(ChangesEq, |
- SettingChangeList(), storage_->Clear()); |
+ SettingChangeList(), storage_->Clear(DEFAULTS)); |
EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(key1_)); |
EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(empty_list_)); |
@@ -314,12 +319,12 @@ TEST_P(ExtensionSettingsStorageTest, ClearWhenEmpty) { |
} |
TEST_P(ExtensionSettingsStorageTest, ClearWhenNotEmpty) { |
- storage_->Set(*dict12_); |
+ storage_->Set(DEFAULTS, *dict12_); |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, val1_->DeepCopy(), NULL)); |
changes.push_back(SettingChange(key2_, val2_->DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear(DEFAULTS)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(key1_)); |
@@ -344,10 +349,11 @@ TEST_P(ExtensionSettingsStorageTest, DotsInKeyNames) { |
SettingChangeList changes; |
changes.push_back( |
SettingChange(dot_key, NULL, dot_value.DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(dot_key, dot_value)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Set(DEFAULTS, dot_key, dot_value)); |
} |
EXPECT_PRED_FORMAT2(ChangesEq, |
- SettingChangeList(), storage_->Set(dot_key, dot_value)); |
+ SettingChangeList(), storage_->Set(DEFAULTS, dot_key, dot_value)); |
EXPECT_PRED_FORMAT2(SettingsEq, dot_dict, storage_->Get(dot_key)); |
@@ -355,15 +361,16 @@ TEST_P(ExtensionSettingsStorageTest, DotsInKeyNames) { |
SettingChangeList changes; |
changes.push_back( |
SettingChange(dot_key, dot_value.DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(dot_key)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Remove(DEFAULTS, dot_key)); |
} |
EXPECT_PRED_FORMAT2(ChangesEq, |
- SettingChangeList(), storage_->Remove(dot_key)); |
+ SettingChangeList(), storage_->Remove(DEFAULTS, dot_key)); |
{ |
SettingChangeList changes; |
changes.push_back( |
SettingChange(dot_key, NULL, dot_value.DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(dot_dict)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, dot_dict)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, dot_dict, storage_->Get(dot_list)); |
@@ -373,7 +380,8 @@ TEST_P(ExtensionSettingsStorageTest, DotsInKeyNames) { |
SettingChangeList changes; |
changes.push_back( |
SettingChange(dot_key, dot_value.DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(dot_list)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Remove(DEFAULTS, dot_list)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(dot_key)); |
@@ -390,7 +398,8 @@ TEST_P(ExtensionSettingsStorageTest, DotsInKeyNamesWithDicts) { |
SettingChangeList changes; |
changes.push_back( |
SettingChange("foo", NULL, inner_dict->DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(outer_dict)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Set(DEFAULTS, outer_dict)); |
} |
EXPECT_PRED_FORMAT2(SettingsEq, outer_dict, storage_->Get("foo")); |
@@ -405,47 +414,49 @@ TEST_P(ExtensionSettingsStorageTest, ComplexChangedKeysScenarios) { |
std::vector<std::string> complex_list; |
DictionaryValue complex_changed_dict; |
- storage_->Set(key1_, *val1_); |
+ storage_->Set(DEFAULTS, key1_, *val1_); |
EXPECT_PRED_FORMAT2(ChangesEq, |
- SettingChangeList(), storage_->Set(key1_, *val1_)); |
+ SettingChangeList(), storage_->Set(DEFAULTS, key1_, *val1_)); |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange( |
key1_, val1_->DeepCopy(), val2_->DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(key1_, *val2_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Set(DEFAULTS, key1_, *val2_)); |
} |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, val2_->DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(key1_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(DEFAULTS, key1_)); |
EXPECT_PRED_FORMAT2(ChangesEq, |
- SettingChangeList(), storage_->Remove(key1_)); |
+ SettingChangeList(), storage_->Remove(DEFAULTS, key1_)); |
} |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, NULL, val1_->DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(key1_, *val1_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Set(DEFAULTS, key1_, *val1_)); |
} |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, val1_->DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear(DEFAULTS)); |
EXPECT_PRED_FORMAT2(ChangesEq, |
- SettingChangeList(), storage_->Clear()); |
+ SettingChangeList(), storage_->Clear(DEFAULTS)); |
} |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, NULL, val1_->DeepCopy())); |
changes.push_back(SettingChange(key2_, NULL, val2_->DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(*dict12_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, *dict12_)); |
EXPECT_PRED_FORMAT2(ChangesEq, |
- SettingChangeList(), storage_->Set(*dict12_)); |
+ SettingChangeList(), storage_->Set(DEFAULTS, *dict12_)); |
} |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key3_, NULL, val3_->DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(*dict123_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, *dict123_)); |
} |
{ |
DictionaryValue to_set; |
@@ -460,13 +471,14 @@ TEST_P(ExtensionSettingsStorageTest, ComplexChangedKeysScenarios) { |
changes.push_back(SettingChange("asdf", NULL, val1_->DeepCopy())); |
changes.push_back( |
SettingChange("qwerty", NULL, val3_->DeepCopy())); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(to_set)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, to_set)); |
} |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key1_, val2_->DeepCopy(), NULL)); |
changes.push_back(SettingChange(key2_, val2_->DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(list12_)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Remove(DEFAULTS, list12_)); |
} |
{ |
std::vector<std::string> to_remove; |
@@ -475,16 +487,17 @@ TEST_P(ExtensionSettingsStorageTest, ComplexChangedKeysScenarios) { |
SettingChangeList changes; |
changes.push_back(SettingChange("asdf", val1_->DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(to_remove)); |
+ EXPECT_PRED_FORMAT2(ChangesEq, |
+ changes, storage_->Remove(DEFAULTS, to_remove)); |
} |
{ |
SettingChangeList changes; |
changes.push_back(SettingChange(key3_, val3_->DeepCopy(), NULL)); |
changes.push_back( |
SettingChange("qwerty", val3_->DeepCopy(), NULL)); |
- EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); |
+ EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear(DEFAULTS)); |
EXPECT_PRED_FORMAT2(ChangesEq, |
- SettingChangeList(), storage_->Clear()); |
+ SettingChangeList(), storage_->Clear(DEFAULTS)); |
} |
} |