Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: content/browser/trace_subscriber_stdio_unittest.cc

Issue 9447003: Revert 123140 - Use SequencedWorkerPool for disk operations in TraceSubscriberStdio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/trace_subscriber_stdio.cc ('k') | content/common/child_trace_message_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/trace_subscriber_stdio.h" 5 #include "content/browser/trace_subscriber_stdio.h"
6 6
7 #include "base/message_loop.h"
8 #include "base/scoped_temp_dir.h" 7 #include "base/scoped_temp_dir.h"
9 #include "base/threading/sequenced_worker_pool.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
12 9
13 TEST(TraceSubscriberStdioTest, CanWriteDataToFile) { 10 namespace {
14 ScopedTempDir trace_dir;
15 ASSERT_TRUE(trace_dir.CreateUniqueTempDir());
16 FilePath trace_file(trace_dir.path().AppendASCII("trace.txt"));
17 {
18 content::TraceSubscriberStdio subscriber(trace_file);
19 11
20 std::string foo("foo"); 12 class TraceSubscriberStdioTest : public testing::Test {
21 subscriber.OnTraceDataCollected( 13 public:
22 make_scoped_refptr(base::RefCountedString::TakeString(&foo))); 14 virtual void SetUp() {
15 ASSERT_TRUE(trace_dir_.CreateUniqueTempDir());
16 trace_file_ = trace_dir_.path().AppendASCII("trace.txt");
17 }
23 18
24 std::string bar("bar"); 19 std::string ReadTraceFile() {
25 subscriber.OnTraceDataCollected( 20 std::string result;
26 make_scoped_refptr(base::RefCountedString::TakeString(&bar))); 21 EXPECT_TRUE(file_util::ReadFileToString(trace_file_, &result));
22 return result;
23 }
27 24
28 subscriber.OnEndTracingComplete(); 25 ScopedTempDir trace_dir_;
29 } 26 FilePath trace_file_;
30 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 27 };
31 std::string result; 28
32 EXPECT_TRUE(file_util::ReadFileToString(trace_file, &result)); 29 } // namespace
33 EXPECT_EQ("[foo,bar]", result); 30
31 TEST_F(TraceSubscriberStdioTest, CanWriteDataToFile) {
32 TraceSubscriberStdio subscriber(trace_file_);
33 subscriber.OnTraceDataCollected("[foo]");
34 subscriber.OnTraceDataCollected("[bar]");
35 EXPECT_TRUE(subscriber.IsValid());
36
37 subscriber.OnEndTracingComplete();
38 EXPECT_FALSE(subscriber.IsValid());
34 } 39 }
40
OLDNEW
« no previous file with comments | « content/browser/trace_subscriber_stdio.cc ('k') | content/common/child_trace_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698