Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / platform / TracedValueTest.cpp
blob135cbdbe06ddef54065f4c59315ce6be6a28f1b0
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
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "platform/TracedValue.h"
8 #include <gtest/gtest.h>
10 namespace blink {
12 TEST(TracedValueTest, FlatDictionary)
14 RefPtr<TracedValue> value = TracedValue::create();
15 value->setInteger("int", 2014);
16 value->setDouble("double", 0.0);
17 value->setBoolean("bool", true);
18 value->setString("string", "string");
19 String json = value->asTraceFormat();
20 EXPECT_EQ("{\"int\":2014,\"double\":0,\"bool\":true,\"string\":\"string\"}", json);
23 TEST(TracedValueTest, Hierarchy)
25 RefPtr<TracedValue> value = TracedValue::create();
26 value->setInteger("i0", 2014);
27 value->beginDictionary("dict1");
28 value->setInteger("i1", 2014);
29 value->beginDictionary("dict2");
30 value->setBoolean("b2", false);
31 value->endDictionary();
32 value->setString("s1", "foo");
33 value->endDictionary();
34 value->setDouble("d0", 0.0);
35 value->setBoolean("b0", true);
36 value->beginArray("a1");
37 value->pushInteger(1);
38 value->pushBoolean(true);
39 value->beginDictionary();
40 value->setInteger("i2", 3);
41 value->endDictionary();
42 value->endArray();
43 value->setString("s0", "foo");
44 String json = value->asTraceFormat();
45 EXPECT_EQ("{\"i0\":2014,\"dict1\":{\"i1\":2014,\"dict2\":{\"b2\":false},\"s1\":\"foo\"},\"d0\":0,\"b0\":true,\"a1\":[1,true,{\"i2\":3}],\"s0\":\"foo\"}", json);
48 TEST(TracedValueTest, Escape)
50 RefPtr<TracedValue> value = TracedValue::create();
51 value->setString("s0", "value0\\");
52 value->setString("s1", "value\n1");
53 value->setString("s2", "\"value2\"");
54 value->setString("s3\\", "value3");
55 value->setString("\"s4\"", "value4");
56 String json = value->asTraceFormat();
57 EXPECT_EQ("{\"s0\":\"value0\\\\\",\"s1\":\"value\\n1\",\"s2\":\"\\\"value2\\\"\",\"s3\\\\\":\"value3\",\"\\\"s4\\\"\":\"value4\"}", json);
60 } // namespace blink