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

Unified Diff: base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc

Issue 2272843002: Heap Profiler: Add trace category group names as type names for allocations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_filter
Patch Set: Rebase. 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/heap_profiler_allocation_context_tracker_unittest.cc
diff --git a/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc b/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
index f423a74a8e94848dd9e3676b5f8d94f6c58577b6..39717ea152e9c557c4daa6e308f3bd9c2ec637b2 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
+++ b/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
@@ -251,7 +251,7 @@ TEST_F(AllocationContextTrackerTest, BacktraceTakesTop) {
}
}
-TEST_F(AllocationContextTrackerTest, TrackTaskContext) {
+TEST_F(AllocationContextTrackerTest, TrackCategoryName) {
const char kContext1[] = "context1";
const char kContext2[] = "context2";
{
@@ -270,6 +270,25 @@ TEST_F(AllocationContextTrackerTest, TrackTaskContext) {
ASSERT_EQ(kContext2, ctx2.type_name);
}
+ {
+ // Type should be category name of the last seen trace event.
+ TRACE_EVENT0("Testing", kCupcake);
+ AllocationContext ctx1 =
+ AllocationContextTracker::GetInstanceForCurrentThread()
+ ->GetContextSnapshot();
+ ASSERT_EQ("Testing", std::string(ctx1.type_name));
+
+ // Type should be category name of the last seen trace event, but the ones
+ // with "," should be ignored.
+ TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("Testing"), kCupcake);
+ TRACE_EVENT0("Other," TRACE_DISABLED_BY_DEFAULT("Other"), kCupcake);
+ AllocationContext ctx2 =
+ AllocationContextTracker::GetInstanceForCurrentThread()
+ ->GetContextSnapshot();
+ ASSERT_EQ(TRACE_DISABLED_BY_DEFAULT("Testing"),
+ std::string(ctx2.type_name));
+ }
+
// Type should be nullptr without task event.
AllocationContext ctx =
AllocationContextTracker::GetInstanceForCurrentThread()

Powered by Google App Engine
This is Rietveld 408576698