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 e8c33af3e06b935a80911bf049ff3d6e8c3c4b01..e3d43fdc60dc8ce4e217dd70f94b6d515c96401d 100644 |
| --- a/base/trace_event/memory_dump_manager_unittest.cc |
| +++ b/base/trace_event/memory_dump_manager_unittest.cc |
| @@ -118,7 +118,8 @@ void PostTaskAndWait(const tracked_objects::Location& from_here, |
| // requests locally to the MemoryDumpManager instead of performing IPC dances. |
| class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate { |
| public: |
| - MemoryDumpManagerDelegateForTesting() { |
| + MemoryDumpManagerDelegateForTesting(bool is_coordinator) |
| + : is_coordinator_(is_coordinator) { |
| ON_CALL(*this, RequestGlobalMemoryDump(_, _)) |
| .WillByDefault(Invoke( |
| this, &MemoryDumpManagerDelegateForTesting::CreateProcessDump)); |
| @@ -128,13 +129,16 @@ class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate { |
| void(const MemoryDumpRequestArgs& args, |
| const MemoryDumpCallback& callback)); |
| - uint64_t GetTracingProcessId() const override { |
| - NOTREACHED(); |
| - return MemoryDumpManager::kInvalidTracingProcessId; |
| + bool IsCoordinator() const override { return is_coordinator_; } |
| + void SetIsCoordinator(bool is_coordinator) { |
| + is_coordinator_ = is_coordinator; |
| } |
| // Promote the CreateProcessDump to public so it can be used by test fixtures. |
| using MemoryDumpManagerDelegate::CreateProcessDump; |
| + |
| + private: |
| + bool is_coordinator_; |
| }; |
| class MockMemoryDumpProvider : public MemoryDumpProvider { |
| @@ -219,13 +223,15 @@ class MemoryDumpManagerTest : public testing::Test { |
| mdm_.reset(new MemoryDumpManager()); |
| MemoryDumpManager::SetInstanceForTesting(mdm_.get()); |
| ASSERT_EQ(mdm_.get(), MemoryDumpManager::GetInstance()); |
| - delegate_.reset(new MemoryDumpManagerDelegateForTesting); |
| + delegate_for_mdm_.reset(new MemoryDumpManagerDelegateForTesting(false)); |
| + delegate_ = delegate_for_mdm_.get(); |
|
oystein (OOO til 10th of July)
2017/02/16 20:50:00
This is confusing to me, why are you storing the r
chiniforooshan
2017/02/16 22:54:15
It is because MDM assumes that the ownership of th
oystein (OOO til 10th of July)
2017/02/16 23:19:49
Can the MDM have a get_delegate_for_testing() whic
chiniforooshan
2017/02/17 17:20:42
How? That function would return a MemoryDumpManage
|
| } |
| void TearDown() override { |
| MemoryDumpManager::SetInstanceForTesting(nullptr); |
| + delegate_for_mdm_.reset(); |
| + delegate_ = nullptr; |
| mdm_.reset(); |
| - delegate_.reset(); |
| message_loop_.reset(); |
| TraceLog::DeleteForTesting(); |
| } |
| @@ -247,7 +253,8 @@ class MemoryDumpManagerTest : public testing::Test { |
| protected: |
| void InitializeMemoryDumpManager(bool is_coordinator) { |
| mdm_->set_dumper_registrations_ignored_for_testing(true); |
| - mdm_->Initialize(delegate_.get(), is_coordinator); |
| + delegate_for_mdm_->SetIsCoordinator(is_coordinator); |
|
oystein (OOO til 10th of July)
2017/02/16 20:50:00
Can you just create the MemoryDumpManagerDelegateF
chiniforooshan
2017/02/16 22:54:15
No, because of the test case "InitializedAfterStar
oystein (OOO til 10th of July)
2017/02/16 23:19:49
Okay, though that line seems to be testing the tes
chiniforooshan
2017/02/17 17:20:42
Agreed. Let me delete that EXPECT_CALL unless Prim
|
| + mdm_->Initialize(std::move(delegate_for_mdm_)); |
| } |
| void RequestGlobalDumpAndWait(MemoryDumpType dump_type, |
| @@ -286,7 +293,10 @@ class MemoryDumpManagerTest : public testing::Test { |
| const MemoryDumpProvider::Options kDefaultOptions; |
| std::unique_ptr<MemoryDumpManager> mdm_; |
| - std::unique_ptr<MemoryDumpManagerDelegateForTesting> delegate_; |
| + // The delegate that is going to be passed to MDM. |
| + std::unique_ptr<MemoryDumpManagerDelegateForTesting> delegate_for_mdm_; |
| + // A pointer to the delegate that is owned by MDM, after MD initialization. |
| + MemoryDumpManagerDelegateForTesting* delegate_; |
| bool last_callback_success_; |
| private: |