Chromium Code Reviews| Index: content/browser/trace_subscriber_stdio_unittest.cc |
| =================================================================== |
| --- content/browser/trace_subscriber_stdio_unittest.cc (revision 0) |
| +++ content/browser/trace_subscriber_stdio_unittest.cc (revision 0) |
| @@ -0,0 +1,42 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/trace_subscriber_stdio.h" |
| + |
| +#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
|
| +#include "base/memory/scoped_temp_dir.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace { |
| + |
| +class TraceSubscriberStdioTest : public testing::Test { |
| + public: |
| + virtual void SetUp() { |
| + ASSERT_TRUE(trace_dir_.CreateUniqueTempDir()); |
| + trace_file_ = trace_dir_.path().AppendASCII("trace.txt"); |
| + } |
|
Paweł Hajdan Jr.
2011/05/19 16:45:58
nit: Add an empty line below.
lain Merrick
2011/05/19 16:51:01
Done.
|
| + std::string ReadTraceFile() { |
| + std::string result; |
| + EXPECT_TRUE(file_util::ReadFileToString(trace_file_, &result)); |
| + return result; |
| + } |
| + |
| + ScopedTempDir trace_dir_; |
| + FilePath trace_file_; |
| +}; |
| + |
| +TEST_F(TraceSubscriberStdioTest, CanWriteBracketedDataToFile) { |
| + TraceSubscriberStdio subscriber(trace_file_); |
| + subscriber.OnTraceDataCollected("[foo]"); |
| + subscriber.OnTraceDataCollected("[bar]"); |
| + EXPECT_TRUE(subscriber.IsValid()); |
| + |
| + subscriber.OnEndTracingComplete(); |
| + EXPECT_FALSE(subscriber.IsValid()); |
| + |
| + EXPECT_EQ("[foo,bar,]", ReadTraceFile()); |
| +} |
| + |
| +} // namespace |
| + |
| Property changes on: content/browser/trace_subscriber_stdio_unittest.cc |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |