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

Unified Diff: base/debug/trace_event_unittest.cc

Issue 13590005: Add a ConvertableToTraceFormat type to the trace framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_unittest.cc
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index 782f07bdf40812c4a7598a08ece04b4f335ce8d4..c68221642e6c5b4391482e66d32727c35431ecab 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -1591,6 +1591,46 @@ TEST_F(TraceEventTestFixture, TraceSampling) {
EXPECT_TRUE(FindNamePhase("Things", "P"));
}
+class MyData : public base::debug::ConvertableToTraceFormat {
+ public:
+ MyData() {}
+ virtual ~MyData() {}
+
+ virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE {
+ out->append("{\"foo\":1}");
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MyData);
+};
+
+TEST_F(TraceEventTestFixture, ConvertableTypes) {
+ ManualTestSetUp();
+ TraceLog::GetInstance()->SetEnabled(true, TraceLog::RECORD_UNTIL_FULL);
+
+ scoped_ptr<MyData> data(new MyData());
+ TRACE_EVENT1("foo", "bar", "data",
+ data.PassAs<base::debug::ConvertableToTraceFormat>());
+ EndTraceAndFlush();
+
+ DictionaryValue* dict = FindNamePhase("bar", "B");
+ ASSERT_TRUE(dict);
+
+ const DictionaryValue* args_dict = NULL;
+ dict->GetDictionary("args", &args_dict);
+ ASSERT_TRUE(args_dict);
+
+ const Value* value = NULL;
+ const DictionaryValue* convertable_dict = NULL;
+ EXPECT_TRUE(args_dict->Get("data", &value));
+ ASSERT_TRUE(value->GetAsDictionary(&convertable_dict));
+
+ int foo_val;
+ EXPECT_TRUE(convertable_dict->GetInteger("foo", &foo_val));
+ EXPECT_EQ(1, foo_val);
+}
+
+
class TraceEventCallbackTest : public TraceEventTestFixture {
public:
virtual void SetUp() OVERRIDE {
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698