Chromium Code Reviews| 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..768e62fd77d6edd17ee9fa31f904528fe83a9ec5 |
| --- /dev/null |
| +++ b/base/debug/trace_event_argument_unittest.cc |
| @@ -0,0 +1,59 @@ |
| +// 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, FlatDitctionary) { |
| + TracedValue value; |
| + value.SetInteger("int", 2014) |
| + .SetDouble("double", 0.0) |
| + .SetBoolean("bool", true) |
| + .SetString("string", "string"); |
| + scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_value( |
| + value.finish()); |
| + std::string json; |
| + convertable_value->AppendAsTraceFormat(&json); |
| + EXPECT_EQ("{\"bool\":true,\"double\":0.0,\"int\":2014,\"string\":\"string\"}", |
| + json); |
| +} |
| + |
| +TEST_F(TraceEventArgumentTest, Hierarchy) { |
| + TracedValue value; |
| + value.SetInteger("i0", 2014) |
| + .BeginDictionary("dict1") |
| + .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
|
| + .BeginDictionary("dict2") |
| + .SetBoolean("b2", false) |
| + .EndDictionary() |
| + .SetString("s1", "foo") |
| + .EndDictionary() |
| + .SetDouble("d0", 0.0) |
| + .SetBoolean("b0", true) |
| + .BeginArray("a1") |
| + .PushInteger(1) |
| + .PushBoolean(2) |
| + .BeginDictionary() |
| + .SetInteger("i2", 3) |
| + .EndDictionary() |
| + .EndArray() |
| + .SetString("s0", "foo"); |
| + scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_value( |
| + value.finish()); |
| + std::string json; |
| + convertable_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 |