Index: content/browser/tracing/tracing_controller_browsertest.cc |
diff --git a/content/browser/tracing/tracing_controller_browsertest.cc b/content/browser/tracing/tracing_controller_browsertest.cc |
index de6c4dc3120aecffdedfd45f61f8985496345cd2..7042db6781891c1f83e5828a3e4a6548b714ad3a 100644 |
--- a/content/browser/tracing/tracing_controller_browsertest.cc |
+++ b/content/browser/tracing/tracing_controller_browsertest.cc |
@@ -5,6 +5,7 @@ |
#include "base/files/file_util.h" |
#include "base/memory/ref_counted_memory.h" |
#include "base/run_loop.h" |
+#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/tracing_controller.h" |
#include "content/public/test/browser_test_utils.h" |
#include "content/public/test/content_browser_test.h" |
@@ -18,6 +19,37 @@ using base::trace_event::RECORD_UNTIL_FULL; |
namespace content { |
+class TracingControllerTestEndpoint |
+ : public TracingController::TraceDataEndpoint { |
+ public: |
+ TracingControllerTestEndpoint( |
+ base::Callback<void(base::RefCountedString*)> done_callback) |
+ : done_callback_(done_callback) {} |
+ |
+ void ReceiveTraceChunk(const std::string& chunk) override { |
+ EXPECT_FALSE(chunk.empty()); |
+ trace_ += chunk; |
+ } |
+ |
+ void ReceiveTraceFinalContents(const std::string& contents) override { |
+ EXPECT_EQ(trace_, contents); |
+ |
+ std::string tmp = contents; |
+ scoped_refptr<base::RefCountedString> chunk_ptr = |
+ base::RefCountedString::TakeString(&tmp); |
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind(done_callback_, chunk_ptr)); |
+ } |
+ |
+ protected: |
+ ~TracingControllerTestEndpoint() override {} |
+ |
+ std::string trace_; |
+ base::Callback<void(base::RefCountedString*)> done_callback_; |
+}; |
+ |
class TracingControllerTest : public ContentBrowserTest { |
public: |
TracingControllerTest() {} |
@@ -153,6 +185,37 @@ class TracingControllerTest : public ContentBrowserTest { |
} |
} |
+ void TestEnableAndDisableRecordingCompressed() { |
+ 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(CategoryFilter(), |
+ TraceOptions(), callback); |
+ ASSERT_TRUE(result); |
+ run_loop.Run(); |
+ EXPECT_EQ(enable_recording_done_callback_count(), 1); |
+ } |
+ |
+ { |
+ base::RunLoop run_loop; |
+ base::Callback<void(base::RefCountedString*)> callback = base::Bind( |
+ &TracingControllerTest::DisableRecordingStringDoneCallbackTest, |
+ base::Unretained(this), run_loop.QuitClosure()); |
+ bool result = controller->DisableRecording( |
+ TracingController::CreateCompressedStringSink( |
+ new TracingControllerTestEndpoint(callback))); |
+ ASSERT_TRUE(result); |
+ run_loop.Run(); |
+ EXPECT_EQ(disable_recording_done_callback_count(), 1); |
+ } |
+ } |
+ |
void TestEnableAndDisableRecordingFile( |
const base::FilePath& result_file_path) { |
Navigate(shell()); |
@@ -317,6 +380,11 @@ IN_PROC_BROWSER_TEST_F(TracingControllerTest, |
} |
IN_PROC_BROWSER_TEST_F(TracingControllerTest, |
+ EnableAndDisableRecordingWithCompression) { |
+ TestEnableAndDisableRecordingCompressed(); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(TracingControllerTest, |
EnableAndDisableRecordingWithEmptyFileAndNullCallback) { |
Navigate(shell()); |