Index: content/browser/trace_subscriber_stdio_unittest.cc |
=================================================================== |
--- content/browser/trace_subscriber_stdio_unittest.cc (revision 120564) |
+++ content/browser/trace_subscriber_stdio_unittest.cc (working copy) |
@@ -5,10 +5,27 @@ |
#include "content/browser/trace_subscriber_stdio.h" |
#include "base/scoped_temp_dir.h" |
+#include "base/threading/thread_restrictions.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace { |
+class ScopedDisallowIO { |
+ public: |
+ ScopedDisallowIO() { |
+ previous_value_ = base::ThreadRestrictions::SetIOAllowed(false); |
+ } |
+ |
+ ~ScopedDisallowIO() { |
+ base::ThreadRestrictions::SetIOAllowed(previous_value_); |
+ } |
+ |
+ private: |
+ bool previous_value_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedDisallowIO); |
+}; |
+ |
class TraceSubscriberStdioTest : public testing::Test { |
public: |
virtual void SetUp() { |
@@ -29,6 +46,10 @@ |
} // namespace |
TEST_F(TraceSubscriberStdioTest, CanWriteDataToFile) { |
+ // TraceSubscriber callbacks are documented to occur on the UI thread, |
+ // so this class must work with ThreadRestictions::SetIOAllowed(false); |
+ ScopedDisallowIO scoped_disallow_io; |
+ |
TraceSubscriberStdio subscriber(trace_file_); |
subscriber.OnTraceDataCollected("[foo]"); |
subscriber.OnTraceDataCollected("[bar]"); |
@@ -37,4 +58,3 @@ |
subscriber.OnEndTracingComplete(); |
EXPECT_FALSE(subscriber.IsValid()); |
} |
- |