summaryrefslogtreecommitdiffstats
path: root/base/values_unittest.cc
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-27 01:38:24 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-27 01:38:24 +0000
commitaa328339ae43ec67bab64fa26bf5b68f7902b9c1 (patch)
tree29b65f26021c062dfad773a1b5fc6e942aef306f /base/values_unittest.cc
parentf0fa95012ce88263ca65e8cf5fb4e7667bfc54e6 (diff)
downloadchromium_src-aa328339ae43ec67bab64fa26bf5b68f7902b9c1.zip
chromium_src-aa328339ae43ec67bab64fa26bf5b68f7902b9c1.tar.gz
chromium_src-aa328339ae43ec67bab64fa26bf5b68f7902b9c1.tar.bz2
Remove JsonPrefStore pruning of empty values on write.
Written from https://codereview.chromium.org/12092021 The entire source code was surveyed for existing list/dict prefs for which this change could be problematic, it doesn't look like anything is relying on this internal detail of the API, see this for details: https://docs.google.com/a/chromium.org/spreadsheet/ccc?key=0AtwXJ4IPPZBAdG9rX3RTc3k5Z1pyN3U4b3d4Tkota3c#gid=0 TBR=joth (for minor android_webview side-effects) BUG=323346 Review URL: https://codereview.chromium.org/81183005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values_unittest.cc')
-rw-r--r--base/values_unittest.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 733c485..70acdfd 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -323,6 +323,31 @@ TEST(ValuesTest, DictionaryWithoutPathExpansion) {
EXPECT_EQ(Value::TYPE_NULL, value4->GetType());
}
+TEST(ValuesTest, DictionaryRemovePath) {
+ DictionaryValue dict;
+ dict.Set("a.long.way.down", Value::CreateIntegerValue(1));
+ dict.Set("a.long.key.path", Value::CreateBooleanValue(true));
+
+ scoped_ptr<Value> removed_item;
+ EXPECT_TRUE(dict.RemovePath("a.long.way.down", &removed_item));
+ ASSERT_TRUE(removed_item);
+ EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_INTEGER));
+ EXPECT_FALSE(dict.HasKey("a.long.way.down"));
+ EXPECT_FALSE(dict.HasKey("a.long.way"));
+ EXPECT_TRUE(dict.Get("a.long.key.path", NULL));
+
+ removed_item.reset();
+ EXPECT_FALSE(dict.RemovePath("a.long.way.down", &removed_item));
+ EXPECT_FALSE(removed_item);
+ EXPECT_TRUE(dict.Get("a.long.key.path", NULL));
+
+ removed_item.reset();
+ EXPECT_TRUE(dict.RemovePath("a.long.key.path", &removed_item));
+ ASSERT_TRUE(removed_item);
+ EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_BOOLEAN));
+ EXPECT_TRUE(dict.empty());
+}
+
TEST(ValuesTest, DeepCopy) {
DictionaryValue original_dict;
Value* original_null = Value::CreateNullValue();