blob: 92f360f3506f12213b4f9893d970b0b873c60e07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// 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/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");
}
std::string ReadTraceFile() {
std::string result;
EXPECT_TRUE(file_util::ReadFileToString(trace_file_, &result));
return result;
}
ScopedTempDir trace_dir_;
FilePath trace_file_;
};
} // namespace
TEST_F(TraceSubscriberStdioTest, CanWriteDataToFile) {
TraceSubscriberStdio subscriber(trace_file_);
subscriber.OnTraceDataCollected("[foo]");
subscriber.OnTraceDataCollected("[bar]");
EXPECT_TRUE(subscriber.IsValid());
subscriber.OnEndTracingComplete();
EXPECT_FALSE(subscriber.IsValid());
}
|