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

Unified Diff: base/trace_event/memory_dump_manager_unittest.cc

Issue 1095003002: [tracing] Simplify design of MemoryAllocatorDump (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@matr_2_sess
Patch Set: Rebase Created 5 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/trace_event/memory_dump_manager.cc ('k') | base/trace_event/memory_dump_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 638ae7db691495955d384591f93f11b7d7cc4e33..0de60b292eb24c0157cd33661a6a67eb40c94727 100644
--- a/base/trace_event/memory_dump_manager_unittest.cc
+++ b/base/trace_event/memory_dump_manager_unittest.cc
@@ -80,8 +80,16 @@ class MemoryDumpManagerTest : public testing::Test {
class MockDumpProvider : public MemoryDumpProvider {
public:
MockDumpProvider() {}
- MockDumpProvider(const scoped_refptr<SingleThreadTaskRunner>& task_runner)
+
+ explicit MockDumpProvider(
+ const scoped_refptr<SingleThreadTaskRunner>& task_runner)
: MemoryDumpProvider(task_runner) {}
+
+ // Ctor for the SharedSessionState test.
+ explicit MockDumpProvider(const std::string& id) {
+ DeclareAllocatorAttribute("allocator" + id, "attr" + id, "type" + id);
+ }
+
MOCK_METHOD1(DumpInto, bool(ProcessMemoryDump* pmd));
// DumpInto() override for the ActiveDumpProviderConsistency test.
@@ -98,6 +106,16 @@ class MockDumpProvider : public MemoryDumpProvider {
return true;
}
+ // DumpInto() override for the SharedSessionState test.
+ bool DumpIntoAndCheckSessionState(ProcessMemoryDump* pmd) {
+ EXPECT_TRUE(pmd->session_state());
+ const auto& attrs_type_info =
+ pmd->session_state()->allocators_attributes_type_info;
+ EXPECT_TRUE(attrs_type_info.Exists("allocator1", "attr1"));
+ EXPECT_TRUE(attrs_type_info.Exists("allocator2", "attr2"));
+ return true;
+ }
+
const char* GetFriendlyName() const override { return "MockDumpProvider"; }
};
@@ -128,6 +146,24 @@ TEST_F(MemoryDumpManagerTest, SingleDumper) {
TraceLog::GetInstance()->SetDisabled();
}
+TEST_F(MemoryDumpManagerTest, SharedSessionState) {
+ MockDumpProvider mdp1("1"); // Will declare an allocator property "attr1".
+ MockDumpProvider mdp2("2"); // Will declare an allocator property "attr2".
+ mdm_->RegisterDumpProvider(&mdp1);
+ mdm_->RegisterDumpProvider(&mdp2);
+
+ EnableTracing(kTraceCategory);
+ EXPECT_CALL(mdp1, DumpInto(_)).Times(2).WillRepeatedly(
+ Invoke(&mdp1, &MockDumpProvider::DumpIntoAndCheckSessionState));
+ EXPECT_CALL(mdp2, DumpInto(_)).Times(2).WillRepeatedly(
+ Invoke(&mdp2, &MockDumpProvider::DumpIntoAndCheckSessionState));
+
+ for (int i = 0; i < 2; ++i)
+ mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED);
+
+ DisableTracing();
+}
+
TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
MockDumpProvider mdp1;
MockDumpProvider mdp2;
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | base/trace_event/memory_dump_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698