Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Side by Side Diff: extensions/browser/value_store/value_store_change_unittest.cc

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/json/json_writer.h" 6 #include "base/json/json_writer.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "extensions/browser/value_store/value_store_change.h" 9 #include "extensions/browser/value_store/value_store_change.h"
10 #include "extensions/common/value_builder.h" 10 #include "extensions/common/value_builder.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using base::DictionaryValue; 13 using base::DictionaryValue;
14 using base::Value; 14 using base::Value;
15 using extensions::DictionaryBuilder; 15 using extensions::DictionaryBuilder;
16 using extensions::ListBuilder; 16 using extensions::ListBuilder;
17 17
18 namespace { 18 namespace {
19 19
20 TEST(ValueStoreChangeTest, NullOldValue) { 20 TEST(ValueStoreChangeTest, NullOldValue) {
21 ValueStoreChange change("key", NULL, base::Value::CreateStringValue("value")); 21 ValueStoreChange change("key", NULL, new base::StringValue("value"));
22 22
23 EXPECT_EQ("key", change.key()); 23 EXPECT_EQ("key", change.key());
24 EXPECT_EQ(NULL, change.old_value()); 24 EXPECT_EQ(NULL, change.old_value());
25 { 25 {
26 scoped_ptr<base::Value> expected(base::Value::CreateStringValue("value")); 26 scoped_ptr<base::Value> expected(new base::StringValue("value"));
27 EXPECT_TRUE(change.new_value()->Equals(expected.get())); 27 EXPECT_TRUE(change.new_value()->Equals(expected.get()));
28 } 28 }
29 } 29 }
30 30
31 TEST(ValueStoreChangeTest, NullNewValue) { 31 TEST(ValueStoreChangeTest, NullNewValue) {
32 ValueStoreChange change("key", base::Value::CreateStringValue("value"), NULL); 32 ValueStoreChange change("key", new base::StringValue("value"), NULL);
33 33
34 EXPECT_EQ("key", change.key()); 34 EXPECT_EQ("key", change.key());
35 { 35 {
36 scoped_ptr<base::Value> expected(base::Value::CreateStringValue("value")); 36 scoped_ptr<base::Value> expected(new base::StringValue("value"));
37 EXPECT_TRUE(change.old_value()->Equals(expected.get())); 37 EXPECT_TRUE(change.old_value()->Equals(expected.get()));
38 } 38 }
39 EXPECT_EQ(NULL, change.new_value()); 39 EXPECT_EQ(NULL, change.new_value());
40 } 40 }
41 41
42 TEST(ValueStoreChangeTest, NonNullValues) { 42 TEST(ValueStoreChangeTest, NonNullValues) {
43 ValueStoreChange change("key", 43 ValueStoreChange change("key",
44 base::Value::CreateStringValue("old_value"), 44 new base::StringValue("old_value"),
45 base::Value::CreateStringValue("new_value")); 45 new base::StringValue("new_value"));
46 46
47 EXPECT_EQ("key", change.key()); 47 EXPECT_EQ("key", change.key());
48 { 48 {
49 scoped_ptr<base::Value> expected( 49 scoped_ptr<base::Value> expected(new base::StringValue("old_value"));
50 base::Value::CreateStringValue("old_value"));
51 EXPECT_TRUE(change.old_value()->Equals(expected.get())); 50 EXPECT_TRUE(change.old_value()->Equals(expected.get()));
52 } 51 }
53 { 52 {
54 scoped_ptr<base::Value> expected( 53 scoped_ptr<base::Value> expected(new base::StringValue("new_value"));
55 base::Value::CreateStringValue("new_value"));
56 EXPECT_TRUE(change.new_value()->Equals(expected.get())); 54 EXPECT_TRUE(change.new_value()->Equals(expected.get()));
57 } 55 }
58 } 56 }
59 57
60 TEST(ValueStoreChangeTest, ToJson) { 58 TEST(ValueStoreChangeTest, ToJson) {
61 // Create a mildly complicated structure that has dots in it. 59 // Create a mildly complicated structure that has dots in it.
62 scoped_ptr<base::DictionaryValue> value = DictionaryBuilder() 60 scoped_ptr<base::DictionaryValue> value = DictionaryBuilder()
63 .Set("key", "value") 61 .Set("key", "value")
64 .Set("key.with.dots", "value.with.dots") 62 .Set("key.with.dots", "value.with.dots")
65 .Set("tricked", DictionaryBuilder() 63 .Set("tricked", DictionaryBuilder()
(...skipping 21 matching lines...) Expand all
87 .Set("newValue", v2)) 85 .Set("newValue", v2))
88 .Set("key.with.dots", DictionaryBuilder() 86 .Set("key.with.dots", DictionaryBuilder()
89 .Set("oldValue", v3) 87 .Set("oldValue", v3)
90 .Set("newValue", v4)) 88 .Set("newValue", v4))
91 .Build(); 89 .Build();
92 90
93 EXPECT_TRUE(from_json->Equals(expected_from_json.get())); 91 EXPECT_TRUE(from_json->Equals(expected_from_json.get()));
94 } 92 }
95 93
96 } // namespace 94 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698