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

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

Issue 65343006: Use TracingController for startup tracing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "content/browser/tracing/tracing_controller_impl.h" 7 #include "content/browser/tracing/tracing_controller_impl.h"
8 #include "content/public/test/browser_test_utils.h" 8 #include "content/public/test/browser_test_utils.h"
9 #include "content/shell/browser/shell.h" 9 #include "content/shell/browser/shell.h"
10 #include "content/test/content_browser_test.h" 10 #include "content/test/content_browser_test.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 { 118 {
119 base::RunLoop run_loop; 119 base::RunLoop run_loop;
120 TracingController::EnableRecordingDoneCallback callback = 120 TracingController::EnableRecordingDoneCallback callback =
121 base::Bind(&TracingControllerTest::EnableRecordingDoneCallbackTest, 121 base::Bind(&TracingControllerTest::EnableRecordingDoneCallbackTest,
122 base::Unretained(this), 122 base::Unretained(this),
123 run_loop.QuitClosure()); 123 run_loop.QuitClosure());
124 bool result = controller->EnableRecording( 124 bool result = controller->EnableRecording(
125 base::debug::CategoryFilter(""), TracingController::Options(), 125 base::debug::CategoryFilter(""), TracingController::Options(),
126 callback); 126 callback);
127 EXPECT_TRUE(result); 127 ASSERT_TRUE(result);
128 run_loop.Run(); 128 run_loop.Run();
129 EXPECT_EQ(enable_recording_done_callback_count(), 1); 129 EXPECT_EQ(enable_recording_done_callback_count(), 1);
130 } 130 }
131 131
132 { 132 {
133 base::RunLoop run_loop; 133 base::RunLoop run_loop;
134 TracingController::TracingFileResultCallback callback = 134 TracingController::TracingFileResultCallback callback =
135 base::Bind(&TracingControllerTest::DisableRecordingDoneCallbackTest, 135 base::Bind(&TracingControllerTest::DisableRecordingDoneCallbackTest,
136 base::Unretained(this), 136 base::Unretained(this),
137 run_loop.QuitClosure()); 137 run_loop.QuitClosure());
138 bool result = controller->DisableRecording(result_file_path, callback); 138 bool result = controller->DisableRecording(result_file_path, callback);
139 EXPECT_TRUE(result); 139 ASSERT_TRUE(result);
140 run_loop.Run(); 140 run_loop.Run();
141 EXPECT_EQ(disable_recording_done_callback_count(), 1); 141 EXPECT_EQ(disable_recording_done_callback_count(), 1);
142 } 142 }
143 } 143 }
144 144
145 void TestEnableCaptureAndDisableMonitoring( 145 void TestEnableCaptureAndDisableMonitoring(
146 const base::FilePath& result_file_path) { 146 const base::FilePath& result_file_path) {
147 Navigate(shell()); 147 Navigate(shell());
148 148
149 TracingController* controller = TracingController::GetInstance(); 149 TracingController* controller = TracingController::GetInstance();
150 150
151 { 151 {
152 base::RunLoop run_loop; 152 base::RunLoop run_loop;
153 TracingController::EnableMonitoringDoneCallback callback = 153 TracingController::EnableMonitoringDoneCallback callback =
154 base::Bind(&TracingControllerTest::EnableMonitoringDoneCallbackTest, 154 base::Bind(&TracingControllerTest::EnableMonitoringDoneCallbackTest,
155 base::Unretained(this), 155 base::Unretained(this),
156 run_loop.QuitClosure()); 156 run_loop.QuitClosure());
157 bool result = controller->EnableMonitoring( 157 bool result = controller->EnableMonitoring(
158 base::debug::CategoryFilter(""), TracingController::ENABLE_SAMPLING, 158 base::debug::CategoryFilter(""), TracingController::ENABLE_SAMPLING,
159 callback); 159 callback);
160 EXPECT_TRUE(result); 160 ASSERT_TRUE(result);
161 run_loop.Run(); 161 run_loop.Run();
162 EXPECT_EQ(enable_monitoring_done_callback_count(), 1); 162 EXPECT_EQ(enable_monitoring_done_callback_count(), 1);
163 } 163 }
164 164
165 { 165 {
166 base::RunLoop run_loop; 166 base::RunLoop run_loop;
167 TracingController::TracingFileResultCallback callback = 167 TracingController::TracingFileResultCallback callback =
168 base::Bind(&TracingControllerTest:: 168 base::Bind(&TracingControllerTest::
169 CaptureMonitoringSnapshotDoneCallbackTest, 169 CaptureMonitoringSnapshotDoneCallbackTest,
170 base::Unretained(this), 170 base::Unretained(this),
171 run_loop.QuitClosure()); 171 run_loop.QuitClosure());
172 controller->CaptureMonitoringSnapshot(result_file_path, callback); 172 controller->CaptureMonitoringSnapshot(result_file_path, callback);
173 run_loop.Run(); 173 run_loop.Run();
174 EXPECT_EQ(capture_monitoring_snapshot_done_callback_count(), 1); 174 EXPECT_EQ(capture_monitoring_snapshot_done_callback_count(), 1);
175 } 175 }
176 176
177 { 177 {
178 base::RunLoop run_loop; 178 base::RunLoop run_loop;
179 TracingController::DisableMonitoringDoneCallback callback = 179 TracingController::DisableMonitoringDoneCallback callback =
180 base::Bind(&TracingControllerTest::DisableMonitoringDoneCallbackTest, 180 base::Bind(&TracingControllerTest::DisableMonitoringDoneCallbackTest,
181 base::Unretained(this), 181 base::Unretained(this),
182 run_loop.QuitClosure()); 182 run_loop.QuitClosure());
183 bool result = controller->DisableMonitoring(callback); 183 bool result = controller->DisableMonitoring(callback);
184 EXPECT_TRUE(result); 184 ASSERT_TRUE(result);
185 run_loop.Run(); 185 run_loop.Run();
186 EXPECT_EQ(disable_monitoring_done_callback_count(), 1); 186 EXPECT_EQ(disable_monitoring_done_callback_count(), 1);
187 } 187 }
188 } 188 }
189 189
190 private: 190 private:
191 int get_categories_done_callback_count_; 191 int get_categories_done_callback_count_;
192 int enable_recording_done_callback_count_; 192 int enable_recording_done_callback_count_;
193 int disable_recording_done_callback_count_; 193 int disable_recording_done_callback_count_;
194 int enable_monitoring_done_callback_count_; 194 int enable_monitoring_done_callback_count_;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 TracingController::EnableMonitoringDoneCallback())); 262 TracingController::EnableMonitoringDoneCallback()));
263 controller->CaptureMonitoringSnapshot( 263 controller->CaptureMonitoringSnapshot(
264 base::FilePath(), TracingController::TracingFileResultCallback()); 264 base::FilePath(), TracingController::TracingFileResultCallback());
265 base::RunLoop().RunUntilIdle(); 265 base::RunLoop().RunUntilIdle();
266 EXPECT_TRUE(controller->DisableMonitoring( 266 EXPECT_TRUE(controller->DisableMonitoring(
267 TracingController::DisableMonitoringDoneCallback())); 267 TracingController::DisableMonitoringDoneCallback()));
268 base::RunLoop().RunUntilIdle(); 268 base::RunLoop().RunUntilIdle();
269 } 269 }
270 270
271 } // namespace content 271 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/tracing/trace_message_filter.cc ('k') | content/browser/tracing/tracing_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698