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

Side by Side Diff: base/trace_event/memory_dump_manager_unittest.cc

Issue 952893003: Update from https://crrev.com/317530 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix gn for nacl Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | base/trace_event/process_memory_dump.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/trace_event/memory_dump_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include "base/trace_event/memory_dump_provider.h" 7 #include "base/trace_event/memory_dump_provider.h"
8 #include "base/trace_event/process_memory_dump.h" 8 #include "base/trace_event/process_memory_dump.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 using testing::_; 12 using testing::_;
13 13
14 namespace base { 14 namespace base {
15 namespace trace_event { 15 namespace trace_event {
16 16
17 class MemoryDumpManagerTest : public testing::Test { 17 class MemoryDumpManagerTest : public testing::Test {
18 public: 18 public:
19 void SetUp() override { 19 void SetUp() override {
20 mdm_.reset(new MemoryDumpManager());
21 MemoryDumpManager::SetInstanceForTesting(mdm_.get());
22 ASSERT_EQ(mdm_, MemoryDumpManager::GetInstance());
20 MemoryDumpManager::GetInstance()->Initialize(); 23 MemoryDumpManager::GetInstance()->Initialize();
21 mdm_ = MemoryDumpManager::GetInstance();
22 } 24 }
23 25
24 void TearDown() override { 26 void TearDown() override {
25 MemoryDumpManager::DeleteForTesting(); 27 MemoryDumpManager::SetInstanceForTesting(nullptr);
28 mdm_.reset();
26 TraceLog::DeleteForTesting(); 29 TraceLog::DeleteForTesting();
27 mdm_ = NULL;
28 } 30 }
29 31
30 protected: 32 protected:
31 const char* const kTraceCategory = MemoryDumpManager::kTraceCategory; 33 const char* const kTraceCategory = MemoryDumpManager::kTraceCategory;
32 34
33 void EnableTracing(const char* category) { 35 void EnableTracing(const char* category) {
34 TraceLog::GetInstance()->SetEnabled( 36 TraceLog::GetInstance()->SetEnabled(
35 CategoryFilter(category), TraceLog::RECORDING_MODE, TraceOptions()); 37 CategoryFilter(category), TraceLog::RECORDING_MODE, TraceOptions());
36 } 38 }
37 39
38 void DisableTracing() { TraceLog::GetInstance()->SetDisabled(); } 40 void DisableTracing() { TraceLog::GetInstance()->SetDisabled(); }
39 41
40 MemoryDumpManager* mdm_; 42 scoped_ptr<MemoryDumpManager> mdm_;
41 43
42 private: 44 private:
43 // We want our singleton torn down after each test. 45 // We want our singleton torn down after each test.
44 ShadowingAtExitManager at_exit_manager_; 46 ShadowingAtExitManager at_exit_manager_;
45 }; 47 };
46 48
47 class MockDumpProvider : public MemoryDumpProvider { 49 class MockDumpProvider : public MemoryDumpProvider {
48 public: 50 public:
49 MOCK_METHOD1(DumpInto, void(ProcessMemoryDump* pmd)); 51 MOCK_METHOD1(DumpInto, void(ProcessMemoryDump* pmd));
50 }; 52 };
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 mdm_->RegisterDumpProvider(&mdp1); 118 mdm_->RegisterDumpProvider(&mdp1);
117 EnableTracing(kTraceCategory); 119 EnableTracing(kTraceCategory);
118 EXPECT_CALL(mdp1, DumpInto(_)).Times(1); 120 EXPECT_CALL(mdp1, DumpInto(_)).Times(1);
119 EXPECT_CALL(mdp2, DumpInto(_)).Times(1); 121 EXPECT_CALL(mdp2, DumpInto(_)).Times(1);
120 mdm_->RequestDumpPoint(DumpPointType::EXPLICITLY_TRIGGERED); 122 mdm_->RequestDumpPoint(DumpPointType::EXPLICITLY_TRIGGERED);
121 DisableTracing(); 123 DisableTracing();
122 } 124 }
123 125
124 } // namespace trace_Event 126 } // namespace trace_Event
125 } // namespace base 127 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | base/trace_event/process_memory_dump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698