Index: content/browser/trace_subscriber_stdio_unittest.cc |
diff --git a/content/browser/trace_subscriber_stdio_unittest.cc b/content/browser/trace_subscriber_stdio_unittest.cc |
index 92f360f3506f12213b4f9893d970b0b873c60e07..b35d05e7b8e0873d02bb76a67c0c7ba2403f8580 100644 |
--- a/content/browser/trace_subscriber_stdio_unittest.cc |
+++ b/content/browser/trace_subscriber_stdio_unittest.cc |
@@ -4,37 +4,31 @@ |
#include "content/browser/trace_subscriber_stdio.h" |
+#include "base/message_loop.h" |
#include "base/scoped_temp_dir.h" |
+#include "base/threading/sequenced_worker_pool.h" |
+#include "content/public/browser/browser_thread.h" |
#include "testing/gtest/include/gtest/gtest.h" |
-namespace { |
+TEST(TraceSubscriberStdioTest, CanWriteDataToFile) { |
+ ScopedTempDir trace_dir; |
+ ASSERT_TRUE(trace_dir.CreateUniqueTempDir()); |
+ FilePath trace_file(trace_dir.path().AppendASCII("trace.txt")); |
+ { |
+ content::TraceSubscriberStdio subscriber(trace_file); |
-class TraceSubscriberStdioTest : public testing::Test { |
- public: |
- virtual void SetUp() { |
- ASSERT_TRUE(trace_dir_.CreateUniqueTempDir()); |
- trace_file_ = trace_dir_.path().AppendASCII("trace.txt"); |
- } |
- |
- std::string ReadTraceFile() { |
- std::string result; |
- EXPECT_TRUE(file_util::ReadFileToString(trace_file_, &result)); |
- return result; |
- } |
- |
- ScopedTempDir trace_dir_; |
- FilePath trace_file_; |
-}; |
+ std::string foo("foo"); |
+ subscriber.OnTraceDataCollected( |
+ make_scoped_refptr(base::RefCountedString::TakeString(&foo))); |
-} // namespace |
+ std::string bar("bar"); |
+ subscriber.OnTraceDataCollected( |
+ make_scoped_refptr(base::RefCountedString::TakeString(&bar))); |
-TEST_F(TraceSubscriberStdioTest, CanWriteDataToFile) { |
- TraceSubscriberStdio subscriber(trace_file_); |
- subscriber.OnTraceDataCollected("[foo]"); |
- subscriber.OnTraceDataCollected("[bar]"); |
- EXPECT_TRUE(subscriber.IsValid()); |
- |
- subscriber.OnEndTracingComplete(); |
- EXPECT_FALSE(subscriber.IsValid()); |
+ subscriber.OnEndTracingComplete(); |
+ } |
+ content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
+ std::string result; |
+ EXPECT_TRUE(file_util::ReadFileToString(trace_file, &result)); |
+ EXPECT_EQ("[foo,bar]", result); |
} |
- |