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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: base/debug/trace_event_argument_unittest.cc
diff --git a/base/debug/trace_event_argument_unittest.cc b/base/debug/trace_event_argument_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0da4a812eca92215f5bb6203d3aabdbb6c0dd142
--- /dev/null
+++ b/base/debug/trace_event_argument_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/debug/trace_event_argument.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace base {
+namespace debug {
+
+class TraceEventArgumentTest : public testing::Test {};
+
+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.
+ scoped_refptr<TracedValue> value = new TracedValue();
+ value->SetInteger("int", 2014);
+ value->SetDouble("double", 0.0);
+ value->SetBoolean("bool", true);
+ value->SetString("string", "string");
+ std::string json;
+ value->AppendAsTraceFormat(&json);
+ EXPECT_EQ("{\"bool\":true,\"double\":0.0,\"int\":2014,\"string\":\"string\"}",
+ json);
+}
+
+TEST_F(TraceEventArgumentTest, Hierarchy) {
+ scoped_refptr<TracedValue> value = new TracedValue();
+ value->SetInteger("i0", 2014);
+ value->BeginDictionary("dict1");
+ value->SetInteger("i1", 2014);
+ value->BeginDictionary("dict2");
+ value->SetBoolean("b2", false);
+ value->EndDictionary();
+ value->SetString("s1", "foo");
+ value->EndDictionary();
+ value->SetDouble("d0", 0.0);
+ value->SetBoolean("b0", true);
+ value->BeginArray("a1");
+ value->AppendInteger(1);
+ value->AppendBoolean(true);
+ value->BeginDictionary();
+ value->SetInteger("i2", 3);
+ value->EndDictionary();
+ value->EndArray();
+ value->SetString("s0", "foo");
+ std::string json;
+ value->AppendAsTraceFormat(&json);
+ EXPECT_EQ(
+ "{\"a1\":[1,true,{\"i2\":3}],\"b0\":true,\"d0\":0.0,\"dict1\":{\"dict2\":"
+ "{\"b2\":false},\"i1\":2014,\"s1\":\"foo\"},\"i0\":2014,\"s0\":"
+ "\"foo\"}",
+ json);
+}
+
+} // namespace debug
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698