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

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

Issue 1354493003: [tracing] Don't use dot-based path expansion in TracedValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cc display list tracing Created 5 years, 3 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 | « base/trace_event/trace_event_argument.cc ('k') | cc/playback/display_item_list.cc » ('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 (c) 2014 The Chromium Authors. All rights reserved. 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 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 "base/trace_event/trace_event_argument.h" 5 #include "base/trace_event/trace_event_argument.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace base { 9 namespace base {
10 namespace trace_event { 10 namespace trace_event {
11 11
12 TEST(TraceEventArgumentTest, FlatDictionary) { 12 TEST(TraceEventArgumentTest, FlatDictionary) {
13 scoped_refptr<TracedValue> value = new TracedValue(); 13 scoped_refptr<TracedValue> value = new TracedValue();
14 value->SetInteger("int", 2014); 14 value->SetInteger("int", 2014);
15 value->SetDouble("double", 0.0); 15 value->SetDouble("double", 0.0);
16 value->SetBoolean("bool", true); 16 value->SetBoolean("bool", true);
17 value->SetString("string", "string"); 17 value->SetString("string", "string");
18 std::string json = "PREFIX"; 18 std::string json = "PREFIX";
19 value->AppendAsTraceFormat(&json); 19 value->AppendAsTraceFormat(&json);
20 EXPECT_EQ( 20 EXPECT_EQ(
21 "PREFIX{\"bool\":true,\"double\":0.0,\"int\":2014,\"string\":\"string\"}", 21 "PREFIX{\"bool\":true,\"double\":0.0,\"int\":2014,\"string\":\"string\"}",
22 json); 22 json);
23 } 23 }
24 24
25 TEST(TraceEventArgumentTest, NoDotPathExpansion) {
26 scoped_refptr<TracedValue> value = new TracedValue();
27 value->SetInteger("in.t", 2014);
28 value->SetDouble("doub.le", 0.0);
29 value->SetBoolean("bo.ol", true);
30 value->SetString("str.ing", "str.ing");
31 std::string json;
32 value->AppendAsTraceFormat(&json);
33 EXPECT_EQ(
34 "{\"bo.ol\":true,\"doub.le\":0.0,\"in.t\":2014,\"str.ing\":\"str.ing\"}",
35 json);
36 }
37
25 TEST(TraceEventArgumentTest, Hierarchy) { 38 TEST(TraceEventArgumentTest, Hierarchy) {
26 scoped_refptr<TracedValue> value = new TracedValue(); 39 scoped_refptr<TracedValue> value = new TracedValue();
27 value->SetInteger("i0", 2014); 40 value->SetInteger("i0", 2014);
28 value->BeginDictionary("dict1"); 41 value->BeginDictionary("dict1");
29 value->SetInteger("i1", 2014); 42 value->SetInteger("i1", 2014);
30 value->BeginDictionary("dict2"); 43 value->BeginDictionary("dict2");
31 value->SetBoolean("b2", false); 44 value->SetBoolean("b2", false);
32 value->EndDictionary(); 45 value->EndDictionary();
33 value->SetString("s1", "foo"); 46 value->SetString("s1", "foo");
34 value->EndDictionary(); 47 value->EndDictionary();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 nested_dict_value->SetInteger("f", 3); 150 nested_dict_value->SetInteger("f", 3);
138 nested_dict_value->BeginDictionary("g"); 151 nested_dict_value->BeginDictionary("g");
139 nested_dict_value->EndDictionary(); 152 nested_dict_value->EndDictionary();
140 json = ""; 153 json = "";
141 nested_dict_value->AppendAsTraceFormat(&json); 154 nested_dict_value->AppendAsTraceFormat(&json);
142 EXPECT_EQ("{\"b\":2,\"c\":[\"foo\"],\"f\":3,\"g\":{}}", json); 155 EXPECT_EQ("{\"b\":2,\"c\":[\"foo\"],\"f\":3,\"g\":{}}", json);
143 } 156 }
144 157
145 } // namespace trace_event 158 } // namespace trace_event
146 } // namespace base 159 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_argument.cc ('k') | cc/playback/display_item_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698