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

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

Issue 7044010: TraceSubscriber implementation that writes to a file. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 7 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/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 #include "testing/gtest/include/gtest/gtest.h"
7 #include "testing/platform_test.h"
8
9 namespace {
10
11 const FilePath::CharType kFolderPrefix[] =
12 FILE_PATH_LITERAL("TraceSubscriberStdioTest");
13
14 class TraceSubscriberStdioTest : public testing::Test {
15 public:
16 virtual void SetUp() {
17 ASSERT_TRUE(file_util::CreateNewTempDirectory(kFolderPrefix, &trace_dir_));
Paweł Hajdan Jr. 2011/05/18 20:00:46 Oh, could you just use ScopedTempDir instead?
lain Merrick 2011/05/19 15:49:00 Done. I originally based this code on some existi
18 trace_file_ = trace_dir_.AppendASCII("trace.txt");
19 }
20 virtual void TearDown() {
21 if (!trace_dir_.empty()) {
22 file_util::Delete(trace_dir_, true);
23 trace_dir_.clear();
24 }
25 }
26 std::string ReadTraceFile() {
27 std::string result;
28 file_util::ReadFileToString(trace_file_, &result);
Paweł Hajdan Jr. 2011/05/18 20:00:46 How about checking the return value?
lain Merrick 2011/05/19 15:49:00 Done.
29 return result;
30 }
31
32 FilePath trace_dir_;
33 FilePath trace_file_;
34 };
35
36 TEST_F(TraceSubscriberStdioTest, CanWriteBracketedDataToFile) {
37 TraceSubscriberStdio subscriber(trace_file_);
38 subscriber.OnTraceDataCollected("[foo]");
39 subscriber.OnTraceDataCollected("[bar]");
40 EXPECT_TRUE(subscriber.IsValid());
41
42 subscriber.OnEndTracingComplete();
43 EXPECT_FALSE(subscriber.IsValid());
44
45 EXPECT_EQ("[foo,bar,]", ReadTraceFile());
46 }
47
48 }
Paweł Hajdan Jr. 2011/05/18 20:00:46 nit: Add " // namespace"
lain Merrick 2011/05/19 15:49:00 Done.
OLDNEW
« no previous file with comments | « content/browser/trace_subscriber_stdio.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698