OLD | NEW |
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 TracingController* controller = TracingController::GetInstance(); | 116 TracingController* controller = TracingController::GetInstance(); |
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 "", TracingController::DEFAULT_OPTIONS, callback); |
126 callback); | |
127 ASSERT_TRUE(result); | 126 ASSERT_TRUE(result); |
128 run_loop.Run(); | 127 run_loop.Run(); |
129 EXPECT_EQ(enable_recording_done_callback_count(), 1); | 128 EXPECT_EQ(enable_recording_done_callback_count(), 1); |
130 } | 129 } |
131 | 130 |
132 { | 131 { |
133 base::RunLoop run_loop; | 132 base::RunLoop run_loop; |
134 TracingController::TracingFileResultCallback callback = | 133 TracingController::TracingFileResultCallback callback = |
135 base::Bind(&TracingControllerTest::DisableRecordingDoneCallbackTest, | 134 base::Bind(&TracingControllerTest::DisableRecordingDoneCallbackTest, |
136 base::Unretained(this), | 135 base::Unretained(this), |
(...skipping 11 matching lines...) Expand all Loading... |
148 | 147 |
149 TracingController* controller = TracingController::GetInstance(); | 148 TracingController* controller = TracingController::GetInstance(); |
150 | 149 |
151 { | 150 { |
152 base::RunLoop run_loop; | 151 base::RunLoop run_loop; |
153 TracingController::EnableMonitoringDoneCallback callback = | 152 TracingController::EnableMonitoringDoneCallback callback = |
154 base::Bind(&TracingControllerTest::EnableMonitoringDoneCallbackTest, | 153 base::Bind(&TracingControllerTest::EnableMonitoringDoneCallbackTest, |
155 base::Unretained(this), | 154 base::Unretained(this), |
156 run_loop.QuitClosure()); | 155 run_loop.QuitClosure()); |
157 bool result = controller->EnableMonitoring( | 156 bool result = controller->EnableMonitoring( |
158 base::debug::CategoryFilter(""), TracingController::ENABLE_SAMPLING, | 157 "", TracingController::ENABLE_SAMPLING, callback); |
159 callback); | |
160 ASSERT_TRUE(result); | 158 ASSERT_TRUE(result); |
161 run_loop.Run(); | 159 run_loop.Run(); |
162 EXPECT_EQ(enable_monitoring_done_callback_count(), 1); | 160 EXPECT_EQ(enable_monitoring_done_callback_count(), 1); |
163 } | 161 } |
164 | 162 |
165 { | 163 { |
166 base::RunLoop run_loop; | 164 base::RunLoop run_loop; |
167 TracingController::TracingFileResultCallback callback = | 165 TracingController::TracingFileResultCallback callback = |
168 base::Bind(&TracingControllerTest:: | 166 base::Bind(&TracingControllerTest:: |
169 CaptureMonitoringSnapshotDoneCallbackTest, | 167 CaptureMonitoringSnapshotDoneCallbackTest, |
170 base::Unretained(this), | 168 base::Unretained(this), |
171 run_loop.QuitClosure()); | 169 run_loop.QuitClosure()); |
172 controller->CaptureMonitoringSnapshot(result_file_path, callback); | 170 ASSERT_TRUE(controller->CaptureMonitoringSnapshot(result_file_path, |
| 171 callback)); |
173 run_loop.Run(); | 172 run_loop.Run(); |
174 EXPECT_EQ(capture_monitoring_snapshot_done_callback_count(), 1); | 173 EXPECT_EQ(capture_monitoring_snapshot_done_callback_count(), 1); |
175 } | 174 } |
176 | 175 |
177 { | 176 { |
178 base::RunLoop run_loop; | 177 base::RunLoop run_loop; |
179 TracingController::DisableMonitoringDoneCallback callback = | 178 TracingController::DisableMonitoringDoneCallback callback = |
180 base::Bind(&TracingControllerTest::DisableMonitoringDoneCallbackTest, | 179 base::Bind(&TracingControllerTest::DisableMonitoringDoneCallbackTest, |
181 base::Unretained(this), | 180 base::Unretained(this), |
182 run_loop.QuitClosure()); | 181 run_loop.QuitClosure()); |
(...skipping 18 matching lines...) Expand all Loading... |
201 IN_PROC_BROWSER_TEST_F(TracingControllerTest, GetCategories) { | 200 IN_PROC_BROWSER_TEST_F(TracingControllerTest, GetCategories) { |
202 Navigate(shell()); | 201 Navigate(shell()); |
203 | 202 |
204 TracingController* controller = TracingController::GetInstance(); | 203 TracingController* controller = TracingController::GetInstance(); |
205 | 204 |
206 base::RunLoop run_loop; | 205 base::RunLoop run_loop; |
207 TracingController::GetCategoriesDoneCallback callback = | 206 TracingController::GetCategoriesDoneCallback callback = |
208 base::Bind(&TracingControllerTest::GetCategoriesDoneCallbackTest, | 207 base::Bind(&TracingControllerTest::GetCategoriesDoneCallbackTest, |
209 base::Unretained(this), | 208 base::Unretained(this), |
210 run_loop.QuitClosure()); | 209 run_loop.QuitClosure()); |
211 controller->GetCategories(callback); | 210 ASSERT_TRUE(controller->GetCategories(callback)); |
212 run_loop.Run(); | 211 run_loop.Run(); |
213 EXPECT_EQ(get_categories_done_callback_count(), 1); | 212 EXPECT_EQ(get_categories_done_callback_count(), 1); |
214 } | 213 } |
215 | 214 |
216 IN_PROC_BROWSER_TEST_F(TracingControllerTest, EnableAndDisableRecording) { | 215 IN_PROC_BROWSER_TEST_F(TracingControllerTest, EnableAndDisableRecording) { |
217 TestEnableAndDisableRecording(base::FilePath()); | 216 TestEnableAndDisableRecording(base::FilePath()); |
218 } | 217 } |
219 | 218 |
220 IN_PROC_BROWSER_TEST_F(TracingControllerTest, | 219 IN_PROC_BROWSER_TEST_F(TracingControllerTest, |
221 EnableAndDisableRecordingWithFilePath) { | 220 EnableAndDisableRecordingWithFilePath) { |
222 base::FilePath file_path; | 221 base::FilePath file_path; |
223 file_util::CreateTemporaryFile(&file_path); | 222 file_util::CreateTemporaryFile(&file_path); |
224 TestEnableAndDisableRecording(file_path); | 223 TestEnableAndDisableRecording(file_path); |
225 EXPECT_EQ(file_path.value(), last_actual_recording_file_path().value()); | 224 EXPECT_EQ(file_path.value(), last_actual_recording_file_path().value()); |
226 } | 225 } |
227 | 226 |
228 IN_PROC_BROWSER_TEST_F(TracingControllerTest, | 227 IN_PROC_BROWSER_TEST_F(TracingControllerTest, |
229 EnableAndDisableRecordingWithEmptyFileAndNullCallback) { | 228 EnableAndDisableRecordingWithEmptyFileAndNullCallback) { |
230 Navigate(shell()); | 229 Navigate(shell()); |
231 | 230 |
232 TracingController* controller = TracingController::GetInstance(); | 231 TracingController* controller = TracingController::GetInstance(); |
233 EXPECT_TRUE(controller->EnableRecording( | 232 EXPECT_TRUE(controller->EnableRecording( |
234 base::debug::CategoryFilter(""), TracingController::Options(), | 233 "", TracingController::DEFAULT_OPTIONS, |
235 TracingController::EnableRecordingDoneCallback())); | 234 TracingController::EnableRecordingDoneCallback())); |
236 EXPECT_TRUE(controller->DisableRecording( | 235 EXPECT_TRUE(controller->DisableRecording( |
237 base::FilePath(), TracingController::TracingFileResultCallback())); | 236 base::FilePath(), TracingController::TracingFileResultCallback())); |
238 base::RunLoop().RunUntilIdle(); | 237 base::RunLoop().RunUntilIdle(); |
239 } | 238 } |
240 | 239 |
241 IN_PROC_BROWSER_TEST_F(TracingControllerTest, | 240 IN_PROC_BROWSER_TEST_F(TracingControllerTest, |
242 EnableCaptureAndDisableMonitoring) { | 241 EnableCaptureAndDisableMonitoring) { |
243 TestEnableCaptureAndDisableMonitoring(base::FilePath()); | 242 TestEnableCaptureAndDisableMonitoring(base::FilePath()); |
244 } | 243 } |
245 | 244 |
246 IN_PROC_BROWSER_TEST_F(TracingControllerTest, | 245 IN_PROC_BROWSER_TEST_F(TracingControllerTest, |
247 EnableCaptureAndDisableMonitoringWithFilePath) { | 246 EnableCaptureAndDisableMonitoringWithFilePath) { |
248 base::FilePath file_path; | 247 base::FilePath file_path; |
249 file_util::CreateTemporaryFile(&file_path); | 248 file_util::CreateTemporaryFile(&file_path); |
250 TestEnableCaptureAndDisableMonitoring(file_path); | 249 TestEnableCaptureAndDisableMonitoring(file_path); |
251 EXPECT_EQ(file_path.value(), last_actual_monitoring_file_path().value()); | 250 EXPECT_EQ(file_path.value(), last_actual_monitoring_file_path().value()); |
252 } | 251 } |
253 | 252 |
254 IN_PROC_BROWSER_TEST_F( | 253 IN_PROC_BROWSER_TEST_F( |
255 TracingControllerTest, | 254 TracingControllerTest, |
256 EnableCaptureAndDisableMonitoringWithEmptyFileAndNullCallback) { | 255 EnableCaptureAndDisableMonitoringWithEmptyFileAndNullCallback) { |
257 Navigate(shell()); | 256 Navigate(shell()); |
258 | 257 |
259 TracingController* controller = TracingController::GetInstance(); | 258 TracingController* controller = TracingController::GetInstance(); |
260 EXPECT_TRUE(controller->EnableMonitoring( | 259 EXPECT_TRUE(controller->EnableMonitoring( |
261 base::debug::CategoryFilter(""), TracingController::ENABLE_SAMPLING, | 260 "", TracingController::ENABLE_SAMPLING, |
262 TracingController::EnableMonitoringDoneCallback())); | 261 TracingController::EnableMonitoringDoneCallback())); |
263 controller->CaptureMonitoringSnapshot( | 262 controller->CaptureMonitoringSnapshot( |
264 base::FilePath(), TracingController::TracingFileResultCallback()); | 263 base::FilePath(), TracingController::TracingFileResultCallback()); |
265 base::RunLoop().RunUntilIdle(); | 264 base::RunLoop().RunUntilIdle(); |
266 EXPECT_TRUE(controller->DisableMonitoring( | 265 EXPECT_TRUE(controller->DisableMonitoring( |
267 TracingController::DisableMonitoringDoneCallback())); | 266 TracingController::DisableMonitoringDoneCallback())); |
268 base::RunLoop().RunUntilIdle(); | 267 base::RunLoop().RunUntilIdle(); |
269 } | 268 } |
270 | 269 |
271 } // namespace content | 270 } // namespace content |
OLD | NEW |