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

Unified Diff: base/trace_event/memory_dump_manager_unittest.cc

Issue 1308403002: [Tracing] Disable registration of regular dump providers during tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reland-content-browsertest
Patch Set: Rename variable Created 5 years, 3 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') | content/browser/tracing/memory_tracing_browsertest.cc » ('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 af3287ddfdeb9146efbf9ef2b9ea21b3c53f86db..2cb32023861cb710f48f643bd82828e65f64cce1 100644
--- a/base/trace_event/memory_dump_manager_unittest.cc
+++ b/base/trace_event/memory_dump_manager_unittest.cc
@@ -92,21 +92,36 @@ 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);
}
void EnableTracingWithLegacyCategories(const char* category) {
+ bool registrations_ignored =
+ mdm_->dumper_registrations_ignored_for_testing();
Primiano Tucci (use gerrit) 2015/09/29 17:19:09 Why is this get and re-set needed?
Ruud van Asseldonk 2015/10/13 11:11:47 There should have been an additional disable there
TraceLog::GetInstance()->SetEnabled(TraceConfig(category, ""),
TraceLog::RECORDING_MODE);
+ mdm_->set_dumper_registrations_ignored_for_testing(registrations_ignored);
}
void EnableTracingWithTraceConfig(const std::string& trace_config) {
+ bool registrations_ignored =
+ mdm_->dumper_registrations_ignored_for_testing();
TraceLog::GetInstance()->SetEnabled(TraceConfig(trace_config),
TraceLog::RECORDING_MODE);
+ mdm_->set_dumper_registrations_ignored_for_testing(registrations_ignored);
}
void DisableTracing() { TraceLog::GetInstance()->SetDisabled(); }
+ void EnableMemoryDumpProviderRegistrations() {
Primiano Tucci (use gerrit) 2015/09/29 17:19:09 I'd like that we used a slightly different approac
Ruud van Asseldonk 2015/10/13 11:11:47 That is much cleaner, great idea.
+ mdm_->set_dumper_registrations_ignored_for_testing(false);
+ }
+
+ void DisableMemoryDumpProviderRegistrations() {
+ mdm_->set_dumper_registrations_ignored_for_testing(true);
+ }
+
bool IsPeriodicDumpingEnabled() const {
return mdm_->periodic_dump_timer_.IsRunning();
}
@@ -130,6 +145,7 @@ class MemoryDumpManagerTest : public testing::Test {
// called, but only when memory-infra is enabled.
TEST_F(MemoryDumpManagerTest, SingleDumper) {
InitializeMemoryDumpManager(false /* is_coordinator */);
+ EnableMemoryDumpProviderRegistrations();
MockMemoryDumpProvider mdp;
mdm_->RegisterDumpProvider(&mdp);
@@ -167,6 +183,7 @@ TEST_F(MemoryDumpManagerTest, SingleDumper) {
// the level of the detail properly to OnMemoryDump() call on dump providers.
TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) {
InitializeMemoryDumpManager(false /* is_coordinator */);
+ EnableMemoryDumpProviderRegistrations();
MockMemoryDumpProvider mdp;
mdm_->RegisterDumpProvider(&mdp);
@@ -193,6 +210,7 @@ TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) {
// Checks that the SharedSessionState object is acqually shared over time.
TEST_F(MemoryDumpManagerTest, SharedSessionState) {
InitializeMemoryDumpManager(false /* is_coordinator */);
+ EnableMemoryDumpProviderRegistrations();
MockMemoryDumpProvider mdp1;
MockMemoryDumpProvider mdp2;
mdm_->RegisterDumpProvider(&mdp1);
@@ -226,6 +244,7 @@ TEST_F(MemoryDumpManagerTest, SharedSessionState) {
// Checks that the (Un)RegisterDumpProvider logic behaves sanely.
TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
InitializeMemoryDumpManager(false /* is_coordinator */);
+ EnableMemoryDumpProviderRegistrations();
MockMemoryDumpProvider mdp1;
MockMemoryDumpProvider mdp2;
@@ -265,6 +284,7 @@ TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
// registration state and not on previous registrations and dumps.
TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
InitializeMemoryDumpManager(false /* is_coordinator */);
+ EnableMemoryDumpProviderRegistrations();
MockMemoryDumpProvider mdp;
mdm_->RegisterDumpProvider(&mdp);
@@ -326,6 +346,8 @@ TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) {
ScopedVector<Thread> threads;
ScopedVector<MockMemoryDumpProvider> mdps;
+ EnableMemoryDumpProviderRegistrations();
+
// Create the threads and setup the expectations. Given that at each iteration
// we will pop out one thread/MemoryDumpProvider, each MDP is supposed to be
// invoked a number of times equal to its index.
@@ -346,6 +368,7 @@ TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) {
}));
}
+ DisableMemoryDumpProviderRegistrations();
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
while (!threads.empty()) {
@@ -388,6 +411,7 @@ TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) {
// otherwise (e.g., if interleaved).
TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) {
InitializeMemoryDumpManager(false /* is_coordinator */);
+ EnableMemoryDumpProviderRegistrations();
MockMemoryDumpProvider mdp1;
MockMemoryDumpProvider mdp2;
@@ -422,6 +446,7 @@ TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) {
// dumping and expect it to take part in the already active tracing session.
TEST_F(MemoryDumpManagerTest, RegisterDumperWhileDumping) {
InitializeMemoryDumpManager(false /* is_coordinator */);
+ EnableMemoryDumpProviderRegistrations();
MockMemoryDumpProvider mdp1;
MockMemoryDumpProvider mdp2;
@@ -457,6 +482,7 @@ TEST_F(MemoryDumpManagerTest, RegisterDumperWhileDumping) {
// Like RegisterDumperWhileDumping, but unregister the dump provider instead.
TEST_F(MemoryDumpManagerTest, UnregisterDumperWhileDumping) {
InitializeMemoryDumpManager(false /* is_coordinator */);
+ EnableMemoryDumpProviderRegistrations();
MockMemoryDumpProvider mdp1;
MockMemoryDumpProvider mdp2;
@@ -500,7 +526,9 @@ TEST_F(MemoryDumpManagerTest, UnregisterDumperFromThreadWhileDumping) {
for (int i = 0; i < 2; i++) {
threads.push_back(new TestIOThread(TestIOThread::kAutoStart));
mdps.push_back(new MockMemoryDumpProvider());
+ EnableMemoryDumpProviderRegistrations();
mdm_->RegisterDumpProvider(mdps.back(), threads.back()->task_runner());
+ DisableMemoryDumpProviderRegistrations();
}
int on_memory_dump_call_count = 0;
@@ -551,6 +579,7 @@ TEST_F(MemoryDumpManagerTest, UnregisterDumperFromThreadWhileDumping) {
// tracing is not enabled.
TEST_F(MemoryDumpManagerTest, CallbackCalledOnFailure) {
InitializeMemoryDumpManager(false /* is_coordinator */);
+ EnableMemoryDumpProviderRegistrations();
MockMemoryDumpProvider mdp1;
mdm_->RegisterDumpProvider(&mdp1);
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | content/browser/tracing/memory_tracing_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698