OLD | NEW |
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 scoped_ptr<base::Value> parseTracedValue(PassRefPtr<TracedValue> value) | 13 scoped_ptr<base::Value> parseTracedValue(PassRefPtr<TracedValue> value) |
14 { | 14 { |
15 base::JSONReader reader; | 15 base::JSONReader reader; |
16 CString utf8 = value->asTraceFormat().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 RefPtr<TracedValue> value = TracedValue::create(); | 22 RefPtr<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"); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |