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