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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/trace_subscriber_stdio.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,48 @@
+// 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 "testing/gtest/include/gtest/gtest.h"
+#include "testing/platform_test.h"
+
+namespace {
+
+const FilePath::CharType kFolderPrefix[] =
+ FILE_PATH_LITERAL("TraceSubscriberStdioTest");
+
+class TraceSubscriberStdioTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ 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
+ trace_file_ = trace_dir_.AppendASCII("trace.txt");
+ }
+ virtual void TearDown() {
+ if (!trace_dir_.empty()) {
+ file_util::Delete(trace_dir_, true);
+ trace_dir_.clear();
+ }
+ }
+ std::string ReadTraceFile() {
+ std::string result;
+ 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.
+ return result;
+ }
+
+ FilePath 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());
+}
+
+}
Paweł Hajdan Jr. 2011/05/18 20:00:46 nit: Add " // namespace"
lain Merrick 2011/05/19 15:49:00 Done.
Property changes on: content/browser/trace_subscriber_stdio_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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