Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/trace_subscriber_stdio.h" | |
| 6 | |
| 7 #include "base/memory/scoped_ptr.h" | |
|
Paweł Hajdan Jr.
2011/05/19 16:45:58
nit: Now scoped_ptr doesn't seem to be used, pleas
lain Merrick
2011/05/19 16:51:01
Oops, fixed. I should have done another pass mysel
| |
| 8 #include "base/memory/scoped_temp_dir.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 class TraceSubscriberStdioTest : public testing::Test { | |
| 14 public: | |
| 15 virtual void SetUp() { | |
| 16 ASSERT_TRUE(trace_dir_.CreateUniqueTempDir()); | |
| 17 trace_file_ = trace_dir_.path().AppendASCII("trace.txt"); | |
| 18 } | |
|
Paweł Hajdan Jr.
2011/05/19 16:45:58
nit: Add an empty line below.
lain Merrick
2011/05/19 16:51:01
Done.
| |
| 19 std::string ReadTraceFile() { | |
| 20 std::string result; | |
| 21 EXPECT_TRUE(file_util::ReadFileToString(trace_file_, &result)); | |
| 22 return result; | |
| 23 } | |
| 24 | |
| 25 ScopedTempDir trace_dir_; | |
| 26 FilePath trace_file_; | |
| 27 }; | |
| 28 | |
| 29 TEST_F(TraceSubscriberStdioTest, CanWriteBracketedDataToFile) { | |
| 30 TraceSubscriberStdio subscriber(trace_file_); | |
| 31 subscriber.OnTraceDataCollected("[foo]"); | |
| 32 subscriber.OnTraceDataCollected("[bar]"); | |
| 33 EXPECT_TRUE(subscriber.IsValid()); | |
| 34 | |
| 35 subscriber.OnEndTracingComplete(); | |
| 36 EXPECT_FALSE(subscriber.IsValid()); | |
| 37 | |
| 38 EXPECT_EQ("[foo,bar,]", ReadTraceFile()); | |
| 39 } | |
| 40 | |
| 41 } // namespace | |
| 42 | |
| OLD | NEW |