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

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, 4 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
(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, FlatDictionary) {
willchan no longer on Chromium 2014/07/30 15:56:16 If the test fixture is just going to be empty, you
yurys 2014/07/31 12:06:09 Done.
14 scoped_refptr<TracedValue> value = new TracedValue();
15 value->SetInteger("int", 2014);
16 value->SetDouble("double", 0.0);
17 value->SetBoolean("bool", true);
18 value->SetString("string", "string");
19 std::string json;
20 value->AppendAsTraceFormat(&json);
21 EXPECT_EQ("{\"bool\":true,\"double\":0.0,\"int\":2014,\"string\":\"string\"}",
22 json);
23 }
24
25 TEST_F(TraceEventArgumentTest, Hierarchy) {
26 scoped_refptr<TracedValue> value = new TracedValue();
27 value->SetInteger("i0", 2014);
28 value->BeginDictionary("dict1");
29 value->SetInteger("i1", 2014);
30 value->BeginDictionary("dict2");
31 value->SetBoolean("b2", false);
32 value->EndDictionary();
33 value->SetString("s1", "foo");
34 value->EndDictionary();
35 value->SetDouble("d0", 0.0);
36 value->SetBoolean("b0", true);
37 value->BeginArray("a1");
38 value->AppendInteger(1);
39 value->AppendBoolean(true);
40 value->BeginDictionary();
41 value->SetInteger("i2", 3);
42 value->EndDictionary();
43 value->EndArray();
44 value->SetString("s0", "foo");
45 std::string json;
46 value->AppendAsTraceFormat(&json);
47 EXPECT_EQ(
48 "{\"a1\":[1,true,{\"i2\":3}],\"b0\":true,\"d0\":0.0,\"dict1\":{\"dict2\":"
49 "{\"b2\":false},\"i1\":2014,\"s1\":\"foo\"},\"i0\":2014,\"s0\":"
50 "\"foo\"}",
51 json);
52 }
53
54 } // namespace debug
55 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698