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

Side by Side Diff: third_party/WebKit/Source/platform/TracedValueTest.cpp

Issue 1981823002: Remove OwnPtr::release() calls in platform/ (part 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/audio/FFTFrame.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "platform/TracedValue.h" 5 #include "platform/TracedValue.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 std::unique_ptr<base::Value> parseTracedValue(PassOwnPtr<TracedValue> value) 13 std::unique_ptr<base::Value> parseTracedValue(PassOwnPtr<TracedValue> value)
14 { 14 {
15 base::JSONReader reader; 15 base::JSONReader reader;
16 CString utf8 = value->toString().utf8(); 16 CString utf8 = value->toString().utf8();
17 return reader.Read(utf8.data()); 17 return reader.Read(utf8.data());
18 } 18 }
19 19
20 TEST(TracedValueTest, FlatDictionary) 20 TEST(TracedValueTest, FlatDictionary)
21 { 21 {
22 OwnPtr<TracedValue> value = TracedValue::create(); 22 OwnPtr<TracedValue> value = TracedValue::create();
23 value->setInteger("int", 2014); 23 value->setInteger("int", 2014);
24 value->setDouble("double", 0.0); 24 value->setDouble("double", 0.0);
25 value->setBoolean("bool", true); 25 value->setBoolean("bool", true);
26 value->setString("string", "string"); 26 value->setString("string", "string");
27 27
28 std::unique_ptr<base::Value> parsed = parseTracedValue(value.release()); 28 std::unique_ptr<base::Value> parsed = parseTracedValue(std::move(value));
29 base::DictionaryValue* dictionary; 29 base::DictionaryValue* dictionary;
30 ASSERT_TRUE(parsed->GetAsDictionary(&dictionary)); 30 ASSERT_TRUE(parsed->GetAsDictionary(&dictionary));
31 int intValue; 31 int intValue;
32 EXPECT_TRUE(dictionary->GetInteger("int", &intValue)); 32 EXPECT_TRUE(dictionary->GetInteger("int", &intValue));
33 EXPECT_EQ(2014, intValue); 33 EXPECT_EQ(2014, intValue);
34 double doubleValue; 34 double doubleValue;
35 EXPECT_TRUE(dictionary->GetDouble("double", &doubleValue)); 35 EXPECT_TRUE(dictionary->GetDouble("double", &doubleValue));
36 EXPECT_EQ(0.0, doubleValue); 36 EXPECT_EQ(0.0, doubleValue);
37 std::string stringValue; 37 std::string stringValue;
38 EXPECT_TRUE(dictionary->GetString("string", &stringValue)); 38 EXPECT_TRUE(dictionary->GetString("string", &stringValue));
(...skipping 15 matching lines...) Expand all
54 value->setBoolean("b0", true); 54 value->setBoolean("b0", true);
55 value->beginArray("a1"); 55 value->beginArray("a1");
56 value->pushInteger(1); 56 value->pushInteger(1);
57 value->pushBoolean(true); 57 value->pushBoolean(true);
58 value->beginDictionary(); 58 value->beginDictionary();
59 value->setInteger("i2", 3); 59 value->setInteger("i2", 3);
60 value->endDictionary(); 60 value->endDictionary();
61 value->endArray(); 61 value->endArray();
62 value->setString("s0", "foo"); 62 value->setString("s0", "foo");
63 63
64 std::unique_ptr<base::Value> parsed = parseTracedValue(value.release()); 64 std::unique_ptr<base::Value> parsed = parseTracedValue(std::move(value));
65 base::DictionaryValue* dictionary; 65 base::DictionaryValue* dictionary;
66 ASSERT_TRUE(parsed->GetAsDictionary(&dictionary)); 66 ASSERT_TRUE(parsed->GetAsDictionary(&dictionary));
67 int i0; 67 int i0;
68 EXPECT_TRUE(dictionary->GetInteger("i0", &i0)); 68 EXPECT_TRUE(dictionary->GetInteger("i0", &i0));
69 EXPECT_EQ(2014, i0); 69 EXPECT_EQ(2014, i0);
70 int i1; 70 int i1;
71 EXPECT_TRUE(dictionary->GetInteger("dict1.i1", &i1)); 71 EXPECT_TRUE(dictionary->GetInteger("dict1.i1", &i1));
72 EXPECT_EQ(2014, i1); 72 EXPECT_EQ(2014, i1);
73 bool b2; 73 bool b2;
74 EXPECT_TRUE(dictionary->GetBoolean("dict1.dict2.b2", &b2)); 74 EXPECT_TRUE(dictionary->GetBoolean("dict1.dict2.b2", &b2));
(...skipping 27 matching lines...) Expand all
102 102
103 TEST(TracedValueTest, Escape) 103 TEST(TracedValueTest, Escape)
104 { 104 {
105 OwnPtr<TracedValue> value = TracedValue::create(); 105 OwnPtr<TracedValue> value = TracedValue::create();
106 value->setString("s0", "value0\\"); 106 value->setString("s0", "value0\\");
107 value->setString("s1", "value\n1"); 107 value->setString("s1", "value\n1");
108 value->setString("s2", "\"value2\""); 108 value->setString("s2", "\"value2\"");
109 value->setString("s3\\", "value3"); 109 value->setString("s3\\", "value3");
110 value->setString("\"s4\"", "value4"); 110 value->setString("\"s4\"", "value4");
111 111
112 std::unique_ptr<base::Value> parsed = parseTracedValue(value.release()); 112 std::unique_ptr<base::Value> parsed = parseTracedValue(std::move(value));
113 base::DictionaryValue* dictionary; 113 base::DictionaryValue* dictionary;
114 ASSERT_TRUE(parsed->GetAsDictionary(&dictionary)); 114 ASSERT_TRUE(parsed->GetAsDictionary(&dictionary));
115 std::string s0; 115 std::string s0;
116 EXPECT_TRUE(dictionary->GetString("s0", &s0)); 116 EXPECT_TRUE(dictionary->GetString("s0", &s0));
117 EXPECT_EQ("value0\\", s0); 117 EXPECT_EQ("value0\\", s0);
118 std::string s1; 118 std::string s1;
119 EXPECT_TRUE(dictionary->GetString("s1", &s1)); 119 EXPECT_TRUE(dictionary->GetString("s1", &s1));
120 EXPECT_EQ("value\n1", s1); 120 EXPECT_EQ("value\n1", s1);
121 std::string s2; 121 std::string s2;
122 EXPECT_TRUE(dictionary->GetString("s2", &s2)); 122 EXPECT_TRUE(dictionary->GetString("s2", &s2));
123 EXPECT_EQ("\"value2\"", s2); 123 EXPECT_EQ("\"value2\"", s2);
124 std::string s3; 124 std::string s3;
125 EXPECT_TRUE(dictionary->GetString("s3\\", &s3)); 125 EXPECT_TRUE(dictionary->GetString("s3\\", &s3));
126 EXPECT_EQ("value3", s3); 126 EXPECT_EQ("value3", s3);
127 std::string s4; 127 std::string s4;
128 EXPECT_TRUE(dictionary->GetString("\"s4\"", &s4)); 128 EXPECT_TRUE(dictionary->GetString("\"s4\"", &s4));
129 EXPECT_EQ("value4", s4); 129 EXPECT_EQ("value4", s4);
130 } 130 }
131 131
132 } // namespace blink 132 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/audio/FFTFrame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698