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

Side by Side Diff: content/browser/tracing/memory_tracing_browsertest.cc

Issue 2479563002: tracing: Bail out early in tracing tests when tracing is already enabled (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/trace_event/memory_dump_manager.h" 12 #include "base/trace_event/memory_dump_manager.h"
13 #include "base/trace_event/memory_dump_provider.h" 13 #include "base/trace_event/memory_dump_provider.h"
14 #include "base/trace_event/memory_dump_request_args.h" 14 #include "base/trace_event/memory_dump_request_args.h"
15 #include "base/trace_event/trace_config_memory_test_util.h" 15 #include "base/trace_event/trace_config_memory_test_util.h"
16 #include "base/trace_event/trace_log.h"
16 #include "content/public/browser/tracing_controller.h" 17 #include "content/public/browser/tracing_controller.h"
17 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
18 #include "content/public/test/browser_test_utils.h" 19 #include "content/public/test/browser_test_utils.h"
19 #include "content/public/test/content_browser_test.h" 20 #include "content/public/test/content_browser_test.h"
20 #include "content/public/test/content_browser_test_utils.h" 21 #include "content/public/test/content_browser_test_utils.h"
21 #include "content/shell/browser/shell.h" 22 #include "content/shell/browser/shell.h"
22 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
23 24
24 using base::trace_event::MemoryDumpArgs; 25 using base::trace_event::MemoryDumpArgs;
25 using base::trace_event::MemoryDumpLevelOfDetail; 26 using base::trace_event::MemoryDumpLevelOfDetail;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 103 }
103 104
104 void TearDown() override { 105 void TearDown() override {
105 MemoryDumpManager::GetInstance()->UnregisterDumpProvider( 106 MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
106 mock_dump_provider_.get()); 107 mock_dump_provider_.get());
107 mock_dump_provider_.reset(); 108 mock_dump_provider_.reset();
108 ContentBrowserTest::TearDown(); 109 ContentBrowserTest::TearDown();
109 } 110 }
110 111
111 void EnableMemoryTracing() { 112 void EnableMemoryTracing() {
113 CHECK(!base::trace_event::TraceLog::GetInstance()->IsEnabled())
114 << "Tracing seems to be already enabled. Very likely this is because "
115 "the startup tracing file has been leaked from a previous test.";
112 // Enable tracing without periodic dumps. 116 // Enable tracing without periodic dumps.
113 base::trace_event::TraceConfig trace_config( 117 base::trace_event::TraceConfig trace_config(
114 base::trace_event::TraceConfigMemoryTestUtil:: 118 base::trace_event::TraceConfigMemoryTestUtil::
115 GetTraceConfig_EmptyTriggers()); 119 GetTraceConfig_EmptyTriggers());
116 120
117 base::RunLoop run_loop; 121 base::RunLoop run_loop;
118 bool success = TracingController::GetInstance()->StartTracing( 122 bool success = TracingController::GetInstance()->StartTracing(
119 trace_config, run_loop.QuitClosure()); 123 trace_config, run_loop.QuitClosure());
120 EXPECT_TRUE(success); 124 EXPECT_TRUE(success);
121 run_loop.Run(); 125 run_loop.Run();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); 313 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */));
310 314
311 EnableMemoryTracing(); 315 EnableMemoryTracing();
312 RequestGlobalDumpAndWait(false /* from_renderer_thread */, 316 RequestGlobalDumpAndWait(false /* from_renderer_thread */,
313 MemoryDumpType::EXPLICITLY_TRIGGERED, 317 MemoryDumpType::EXPLICITLY_TRIGGERED,
314 MemoryDumpLevelOfDetail::DETAILED); 318 MemoryDumpLevelOfDetail::DETAILED);
315 DisableTracing(); 319 DisableTracing();
316 } 320 }
317 321
318 } // namespace content 322 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698