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

Side by Side Diff: base/debug/trace_event_argument_unittest.cc

Issue 380763002: Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « base/debug/trace_event_argument.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 #include "base/debug/trace_event_argument.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace base {
9 namespace debug {
10
11 class TraceEventArgumentTest : public testing::Test {};
12
13 TEST_F(TraceEventArgumentTest, FlatDitctionary) {
14 TracedValue value;
15 value.SetInteger("int", 2014)
16 .SetDouble("double", 0.0)
17 .SetBoolean("bool", true)
18 .SetString("string", "string");
19 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_value(
20 value.finish());
21 std::string json;
22 convertable_value->AppendAsTraceFormat(&json);
23 EXPECT_EQ("{\"bool\":true,\"double\":0.0,\"int\":2014,\"string\":\"string\"}",
24 json);
25 }
26
27 TEST_F(TraceEventArgumentTest, Hierarchy) {
28 TracedValue value;
29 value.SetInteger("i0", 2014)
30 .BeginDictionary("dict1")
31 .SetInteger("i1", 2014)
alph 2014/07/09 15:03:53 Maybe use paddings to express the structure.
yurys 2014/07/09 15:04:54 I would love to do so but 'git cl format' produced
32 .BeginDictionary("dict2")
33 .SetBoolean("b2", false)
34 .EndDictionary()
35 .SetString("s1", "foo")
36 .EndDictionary()
37 .SetDouble("d0", 0.0)
38 .SetBoolean("b0", true)
39 .BeginArray("a1")
40 .PushInteger(1)
41 .PushBoolean(2)
42 .BeginDictionary()
43 .SetInteger("i2", 3)
44 .EndDictionary()
45 .EndArray()
46 .SetString("s0", "foo");
47 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_value(
48 value.finish());
49 std::string json;
50 convertable_value->AppendAsTraceFormat(&json);
51 EXPECT_EQ(
52 "{\"a1\":[1,true,{\"i2\":3}],\"b0\":true,\"d0\":0.0,\"dict1\":{\"dict2\":"
53 "{\"b2\":false},\"i1\":2014,\"s1\":\"foo\"},\"i0\":2014,\"s0\":"
54 "\"foo\"}",
55 json);
56 }
57
58 } // namespace debug
59 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event_argument.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698