| 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/scoped_temp_dir.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace { |
| 11 |
| 12 class TraceSubscriberStdioTest : public testing::Test { |
| 13 public: |
| 14 virtual void SetUp() { |
| 15 ASSERT_TRUE(trace_dir_.CreateUniqueTempDir()); |
| 16 trace_file_ = trace_dir_.path().AppendASCII("trace.txt"); |
| 17 } |
| 18 |
| 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 } // namespace |
| 30 |
| 31 TEST_F(TraceSubscriberStdioTest, CanWriteBracketedDataToFile) { |
| 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()); |
| 39 |
| 40 EXPECT_EQ("[foo,bar,]", ReadTraceFile()); |
| 41 } |
| 42 |
| OLD | NEW |