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

Unified Diff: base/trace_event/trace_event_unittest.cc

Issue 2253973003: Add an explicit way of making IDs local or global (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/trace_event_unittest.cc
diff --git a/base/trace_event/trace_event_unittest.cc b/base/trace_event/trace_event_unittest.cc
index ad3fe92baace2dd598443e495454e8782bfd3e16..969fd18168812a0374c9ac8ca0a005f1d6900a22 100644
--- a/base/trace_event/trace_event_unittest.cc
+++ b/base/trace_event/trace_event_unittest.cc
@@ -522,6 +522,13 @@ void TraceWithAllMacroVariants(WaitableEvent* task_complete_event) {
TRACE_BIND_IDS("all", "TRACE_BIND_IDS scoped call",
TRACE_ID_WITH_SCOPE("scope 1", 0x1000),
TRACE_ID_WITH_SCOPE("scope 2", 0x2000));
+
+ TRACE_EVENT_ASYNC_BEGIN0("all", "async default process scope", 0x1000);
+ TRACE_EVENT_ASYNC_BEGIN0("all", "async local id", TRACE_ID_LOCAL(0x2000));
+ TRACE_EVENT_ASYNC_BEGIN0("all", "async global id", TRACE_ID_GLOBAL(0x3000));
+ TRACE_EVENT_ASYNC_BEGIN0("all", "async global id with scope string",
+ TRACE_ID_WITH_SCOPE("scope string",
+ TRACE_ID_GLOBAL(0x4000)));
} // Scope close causes TRACE_EVENT0 etc to send their END events.
if (task_complete_event)
@@ -1001,6 +1008,63 @@ void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) {
EXPECT_EQ("0x2000", id);
}
+ EXPECT_FIND_("async default process scope");
+ {
+ std::string ph;
+ EXPECT_TRUE((item && item->GetString("ph", &ph)));
+ EXPECT_EQ("S", ph);
+
+ std::string id;
+ EXPECT_TRUE((item && item->GetString("id", &id)));
+ EXPECT_EQ("0x1000", id);
+ bool id_is_global;
+ EXPECT_FALSE((item && item->GetBoolean("id_is_global", &id_is_global)));
+ }
+
+ EXPECT_FIND_("async local id");
+ {
+ std::string ph;
+ EXPECT_TRUE((item && item->GetString("ph", &ph)));
+ EXPECT_EQ("S", ph);
+
+ std::string id;
+ EXPECT_TRUE((item && item->GetString("id", &id)));
+ EXPECT_EQ("0x2000", id);
+ bool id_is_global = true;
+ EXPECT_TRUE((item && item->GetBoolean("id_is_global", &id_is_global)));
+ EXPECT_FALSE(id_is_global);
+ }
+
+ EXPECT_FIND_("async global id");
+ {
+ std::string ph;
+ EXPECT_TRUE((item && item->GetString("ph", &ph)));
+ EXPECT_EQ("S", ph);
+
+ std::string id;
+ EXPECT_TRUE((item && item->GetString("id", &id)));
+ EXPECT_EQ("0x3000", id);
+ bool id_is_global = false;
+ EXPECT_TRUE((item && item->GetBoolean("id_is_global", &id_is_global)));
+ EXPECT_TRUE(id_is_global);
+ }
+
+ EXPECT_FIND_("async global id with scope string");
+ {
+ std::string ph;
+ EXPECT_TRUE((item && item->GetString("ph", &ph)));
+ EXPECT_EQ("S", ph);
+
+ std::string id;
+ EXPECT_TRUE((item && item->GetString("id", &id)));
+ EXPECT_EQ("0x4000", id);
+ bool id_is_global = false;
+ EXPECT_TRUE((item && item->GetBoolean("id_is_global", &id_is_global)));
+ EXPECT_TRUE(id_is_global);
+ std::string scope;
+ EXPECT_TRUE((item && item->GetString("scope", &scope)));
+ EXPECT_EQ("scope string", scope);
+ }
}
void TraceManyInstantEvents(int thread_id, int num_events,
« base/trace_event/trace_event_impl.cc ('K') | « base/trace_event/trace_event_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698