Chromium Code Reviews| Index: base/trace_event/memory_dump_manager_unittest.cc |
| diff --git a/base/trace_event/memory_dump_manager_unittest.cc b/base/trace_event/memory_dump_manager_unittest.cc |
| index 2bbfd3b937c88726048e7f22080306a56deb662c..2744b73bec528af3a76d34c3881887d910ccaaab 100644 |
| --- a/base/trace_event/memory_dump_manager_unittest.cc |
| +++ b/base/trace_event/memory_dump_manager_unittest.cc |
| @@ -1109,6 +1109,48 @@ TEST_F(MemoryDumpManagerTest, DumpOnBehalfOfOtherProcess) { |
| ASSERT_EQ(events[0]->id, events[2]->id); |
| } |
| +TEST_F(MemoryDumpManagerTest, SummaryOnlyDumpsArentAddedToTrace) { |
| + using trace_analyzer::Query; |
| + |
| + InitializeMemoryDumpManager(false /* is_coordinator */); |
| + |
| + // Standard provider with default options (create dump for current process). |
| + MemoryDumpProvider::Options options; |
| + MockMemoryDumpProvider mdp; |
| + RegisterDumpProvider(&mdp, nullptr, options); |
| + |
| + EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
| + EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); |
| + EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(2).WillRepeatedly(Return(true)); |
| + RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, |
| + MemoryDumpLevelOfDetail::DETAILED); |
|
Primiano Tucci (use gerrit)
2017/04/25 18:02:22
i'd s/DETAILED/BACKGROUND/ just in case in future
hjd
2017/04/26 11:11:58
Done.
|
| + RequestGlobalDumpAndWait(MemoryDumpType::SUMMARY_ONLY, |
| + MemoryDumpLevelOfDetail::DETAILED); |
| + DisableTracing(); |
| + |
| + // Flush the trace into JSON. |
| + trace_event::TraceResultBuffer buffer; |
|
Primiano Tucci (use gerrit)
2017/04/25 18:02:22
maybe you can factor this and the one in DumpOnBeh
hjd
2017/04/26 11:11:58
Done.
|
| + TraceResultBuffer::SimpleOutput trace_output; |
| + buffer.SetOutputCallback(trace_output.GetCallback()); |
| + RunLoop run_loop; |
| + buffer.Start(); |
| + trace_event::TraceLog::GetInstance()->Flush( |
| + Bind(&OnTraceDataCollected, run_loop.QuitClosure(), Unretained(&buffer))); |
| + run_loop.Run(); |
| + buffer.Finish(); |
| + |
| + // Analyze the JSON. |
| + std::unique_ptr<trace_analyzer::TraceAnalyzer> analyzer = WrapUnique( |
| + trace_analyzer::TraceAnalyzer::Create(trace_output.json_output)); |
| + trace_analyzer::TraceEventVector events; |
| + analyzer->FindEvents(Query::EventPhaseIs(TRACE_EVENT_PHASE_MEMORY_DUMP), |
| + &events); |
| + |
| + ASSERT_EQ(1u, events.size()); |
| + ASSERT_EQ(1u, trace_analyzer::CountMatches( |
|
Primiano Tucci (use gerrit)
2017/04/25 18:02:22
I'd replace this with
ASSERT_TRUE(trace_analyzer:
hjd
2017/04/26 11:11:58
Done.
|
| + events, Query::EventPidIs(GetCurrentProcId()))); |
| +} |
| + |
| // Tests the basics of the UnregisterAndDeleteDumpProviderSoon(): the |
| // unregistration should actually delete the providers and not leak them. |
| TEST_F(MemoryDumpManagerTest, UnregisterAndDeleteDumpProviderSoon) { |