summaryrefslogtreecommitdiffstats
path: root/content/browser/tracing/tracing_controller_browsertest.cc
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-20 01:21:49 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-20 01:21:49 +0000
commit5f0d8c08989b900b61f7be1ee97d3c237dba4a76 (patch)
tree314375c0211770fae660af8f503efb296365e387 /content/browser/tracing/tracing_controller_browsertest.cc
parent4d4fc8da097adf4693643c5bd8cfa02d453839a9 (diff)
downloadchromium_src-5f0d8c08989b900b61f7be1ee97d3c237dba4a76.zip
chromium_src-5f0d8c08989b900b61f7be1ee97d3c237dba4a76.tar.gz
chromium_src-5f0d8c08989b900b61f7be1ee97d3c237dba4a76.tar.bz2
Revert 236071 "Allow TracingController output trace data to spec..."
> Allow TracingController output trace data to specified file > > Sometimes we need to let TracingController output traces to specified > file, e.g. trace-startup (which will be migrated from TraceController > to TracingController). > > Also fixed the problem of IO operations in UI thread. > > BUG=none > TEST=TracingControllerTest.EnableAndDisableRecordingWithFilePath > TEST=TracingControllerTest.EnableCaptureAndDisableMonitoringWithFilePath > R=joi@chromium.org, nduca@chromium.org > > Review URL: https://codereview.chromium.org/66893003 TBR=wangxianzhu@chromium.org Review URL: https://codereview.chromium.org/77063003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/tracing/tracing_controller_browsertest.cc')
-rw-r--r--content/browser/tracing/tracing_controller_browsertest.cc205
1 files changed, 68 insertions, 137 deletions
diff --git a/content/browser/tracing/tracing_controller_browsertest.cc b/content/browser/tracing/tracing_controller_browsertest.cc
index 2f2031a..a3a589f 100644
--- a/content/browser/tracing/tracing_controller_browsertest.cc
+++ b/content/browser/tracing/tracing_controller_browsertest.cc
@@ -47,14 +47,13 @@ class TracingControllerTest : public ContentBrowserTest {
}
void DisableRecordingDoneCallbackTest(base::Closure quit_callback,
- const base::FilePath& file_path) {
+ scoped_ptr<base::FilePath> file_path) {
disable_recording_done_callback_count_++;
- EXPECT_TRUE(PathExists(file_path));
+ EXPECT_TRUE(PathExists(*file_path));
int64 file_size;
- file_util::GetFileSize(file_path, &file_size);
+ file_util::GetFileSize(*file_path, &file_size);
EXPECT_TRUE(file_size > 0);
quit_callback.Run();
- last_actual_recording_file_path_ = file_path;
}
void EnableMonitoringDoneCallbackTest(base::Closure quit_callback) {
@@ -68,14 +67,13 @@ class TracingControllerTest : public ContentBrowserTest {
}
void CaptureMonitoringSnapshotDoneCallbackTest(
- base::Closure quit_callback, const base::FilePath& file_path) {
+ base::Closure quit_callback, scoped_ptr<base::FilePath> file_path) {
capture_monitoring_snapshot_done_callback_count_++;
- EXPECT_TRUE(PathExists(file_path));
+ EXPECT_TRUE(PathExists(*file_path));
int64 file_size;
- file_util::GetFileSize(file_path, &file_size);
+ file_util::GetFileSize(*file_path, &file_size);
EXPECT_TRUE(file_size > 0);
quit_callback.Run();
- last_actual_monitoring_file_path_ = file_path;
}
int get_categories_done_callback_count() const {
@@ -102,91 +100,6 @@ class TracingControllerTest : public ContentBrowserTest {
return capture_monitoring_snapshot_done_callback_count_;
}
- base::FilePath last_actual_recording_file_path() const {
- return last_actual_recording_file_path_;
- }
-
- base::FilePath last_actual_monitoring_file_path() const {
- return last_actual_monitoring_file_path_;
- }
-
- void TestEnableAndDisableRecording(const base::FilePath& result_file_path) {
- Navigate(shell());
-
- TracingController* controller = TracingController::GetInstance();
-
- {
- base::RunLoop run_loop;
- TracingController::EnableRecordingDoneCallback callback =
- base::Bind(&TracingControllerTest::EnableRecordingDoneCallbackTest,
- base::Unretained(this),
- run_loop.QuitClosure());
- bool result = controller->EnableRecording(
- base::debug::CategoryFilter(""), TracingController::Options(),
- callback);
- EXPECT_TRUE(result);
- run_loop.Run();
- EXPECT_EQ(enable_recording_done_callback_count(), 1);
- }
-
- {
- base::RunLoop run_loop;
- TracingController::TracingFileResultCallback callback =
- base::Bind(&TracingControllerTest::DisableRecordingDoneCallbackTest,
- base::Unretained(this),
- run_loop.QuitClosure());
- bool result = controller->DisableRecording(result_file_path, callback);
- EXPECT_TRUE(result);
- run_loop.Run();
- EXPECT_EQ(disable_recording_done_callback_count(), 1);
- }
- }
-
- void TestEnableCaptureAndDisableMonitoring(
- const base::FilePath& result_file_path) {
- Navigate(shell());
-
- TracingController* controller = TracingController::GetInstance();
-
- {
- base::RunLoop run_loop;
- TracingController::EnableMonitoringDoneCallback callback =
- base::Bind(&TracingControllerTest::EnableMonitoringDoneCallbackTest,
- base::Unretained(this),
- run_loop.QuitClosure());
- bool result = controller->EnableMonitoring(
- base::debug::CategoryFilter(""), TracingController::ENABLE_SAMPLING,
- callback);
- EXPECT_TRUE(result);
- run_loop.Run();
- EXPECT_EQ(enable_monitoring_done_callback_count(), 1);
- }
-
- {
- base::RunLoop run_loop;
- TracingController::TracingFileResultCallback callback =
- base::Bind(&TracingControllerTest::
- CaptureMonitoringSnapshotDoneCallbackTest,
- base::Unretained(this),
- run_loop.QuitClosure());
- controller->CaptureMonitoringSnapshot(result_file_path, callback);
- run_loop.Run();
- EXPECT_EQ(capture_monitoring_snapshot_done_callback_count(), 1);
- }
-
- {
- base::RunLoop run_loop;
- TracingController::DisableMonitoringDoneCallback callback =
- base::Bind(&TracingControllerTest::DisableMonitoringDoneCallbackTest,
- base::Unretained(this),
- run_loop.QuitClosure());
- bool result = controller->DisableMonitoring(callback);
- EXPECT_TRUE(result);
- run_loop.Run();
- EXPECT_EQ(disable_monitoring_done_callback_count(), 1);
- }
- }
-
private:
int get_categories_done_callback_count_;
int enable_recording_done_callback_count_;
@@ -194,8 +107,6 @@ class TracingControllerTest : public ContentBrowserTest {
int enable_monitoring_done_callback_count_;
int disable_monitoring_done_callback_count_;
int capture_monitoring_snapshot_done_callback_count_;
- base::FilePath last_actual_recording_file_path_;
- base::FilePath last_actual_monitoring_file_path_;
};
IN_PROC_BROWSER_TEST_F(TracingControllerTest, GetCategories) {
@@ -214,58 +125,78 @@ IN_PROC_BROWSER_TEST_F(TracingControllerTest, GetCategories) {
}
IN_PROC_BROWSER_TEST_F(TracingControllerTest, EnableAndDisableRecording) {
- TestEnableAndDisableRecording(base::FilePath());
-}
-
-IN_PROC_BROWSER_TEST_F(TracingControllerTest,
- EnableAndDisableRecordingWithFilePath) {
- base::FilePath file_path;
- file_util::CreateTemporaryFile(&file_path);
- TestEnableAndDisableRecording(file_path);
- EXPECT_EQ(file_path.value(), last_actual_recording_file_path().value());
-}
-
-IN_PROC_BROWSER_TEST_F(TracingControllerTest,
- EnableAndDisableRecordingWithEmptyFileAndNullCallback) {
Navigate(shell());
TracingController* controller = TracingController::GetInstance();
- EXPECT_TRUE(controller->EnableRecording(
- base::debug::CategoryFilter(""), TracingController::Options(),
- TracingController::EnableRecordingDoneCallback()));
- EXPECT_TRUE(controller->DisableRecording(
- base::FilePath(), TracingController::TracingFileResultCallback()));
- base::RunLoop().RunUntilIdle();
-}
-IN_PROC_BROWSER_TEST_F(TracingControllerTest,
- EnableCaptureAndDisableMonitoring) {
- TestEnableCaptureAndDisableMonitoring(base::FilePath());
+ {
+ base::RunLoop run_loop;
+ TracingController::EnableRecordingDoneCallback callback =
+ base::Bind(&TracingControllerTest::EnableRecordingDoneCallbackTest,
+ base::Unretained(this),
+ run_loop.QuitClosure());
+ bool result = controller->EnableRecording(base::debug::CategoryFilter("*"),
+ TracingController::Options(), callback);
+ EXPECT_TRUE(result);
+ run_loop.Run();
+ EXPECT_EQ(enable_recording_done_callback_count(), 1);
+ }
+
+ {
+ base::RunLoop run_loop;
+ TracingController::TracingFileResultCallback callback =
+ base::Bind(&TracingControllerTest::DisableRecordingDoneCallbackTest,
+ base::Unretained(this),
+ run_loop.QuitClosure());
+ bool result = controller->DisableRecording(callback);
+ EXPECT_TRUE(result);
+ run_loop.Run();
+ EXPECT_EQ(disable_recording_done_callback_count(), 1);
+ }
}
IN_PROC_BROWSER_TEST_F(TracingControllerTest,
- EnableCaptureAndDisableMonitoringWithFilePath) {
- base::FilePath file_path;
- file_util::CreateTemporaryFile(&file_path);
- TestEnableCaptureAndDisableMonitoring(file_path);
- EXPECT_EQ(file_path.value(), last_actual_monitoring_file_path().value());
-}
-
-IN_PROC_BROWSER_TEST_F(
- TracingControllerTest,
- EnableCaptureAndDisableMonitoringWithEmptyFileAndNullCallback) {
+ EnableCaptureAndDisableMonitoring) {
Navigate(shell());
TracingController* controller = TracingController::GetInstance();
- EXPECT_TRUE(controller->EnableMonitoring(
- base::debug::CategoryFilter(""), TracingController::ENABLE_SAMPLING,
- TracingController::EnableMonitoringDoneCallback()));
- controller->CaptureMonitoringSnapshot(
- base::FilePath(), TracingController::TracingFileResultCallback());
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(controller->DisableMonitoring(
- TracingController::DisableMonitoringDoneCallback()));
- base::RunLoop().RunUntilIdle();
+
+ {
+ base::RunLoop run_loop;
+ TracingController::EnableMonitoringDoneCallback callback =
+ base::Bind(&TracingControllerTest::EnableMonitoringDoneCallbackTest,
+ base::Unretained(this),
+ run_loop.QuitClosure());
+ bool result = controller->EnableMonitoring(base::debug::CategoryFilter("*"),
+ TracingController::ENABLE_SAMPLING, callback);
+ EXPECT_TRUE(result);
+ run_loop.Run();
+ EXPECT_EQ(enable_monitoring_done_callback_count(), 1);
+ }
+
+ {
+ base::RunLoop run_loop;
+ TracingController::TracingFileResultCallback callback =
+ base::Bind(&TracingControllerTest::
+ CaptureMonitoringSnapshotDoneCallbackTest,
+ base::Unretained(this),
+ run_loop.QuitClosure());
+ controller->CaptureMonitoringSnapshot(callback);
+ run_loop.Run();
+ EXPECT_EQ(capture_monitoring_snapshot_done_callback_count(), 1);
+ }
+
+ {
+ base::RunLoop run_loop;
+ TracingController::DisableMonitoringDoneCallback callback =
+ base::Bind(&TracingControllerTest::DisableMonitoringDoneCallbackTest,
+ base::Unretained(this),
+ run_loop.QuitClosure());
+ bool result = controller->DisableMonitoring(callback);
+ EXPECT_TRUE(result);
+ run_loop.Run();
+ EXPECT_EQ(disable_monitoring_done_callback_count(), 1);
+ }
}
} // namespace content