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

Side by Side Diff: base/debug/trace_event_unittest.cc

Issue 8915024: Retry 114494 - Remove BindStateHolder and have Bind() return a Callback<> object directly." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years 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 | « base/debug/trace_event.cc ('k') | base/test/trace_event_analyzer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/debug/trace_event.h" 5 #include "base/debug/trace_event.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 24 matching lines...) Expand all
35 const char* value; 35 const char* value;
36 CompareOp op; 36 CompareOp op;
37 }; 37 };
38 38
39 class TraceEventTestFixture : public testing::Test { 39 class TraceEventTestFixture : public testing::Test {
40 public: 40 public:
41 // This fixture does not use SetUp() because the fixture must be manually set 41 // This fixture does not use SetUp() because the fixture must be manually set
42 // up multiple times when testing AtExit. Use ManualTestSetUp for this. 42 // up multiple times when testing AtExit. Use ManualTestSetUp for this.
43 void ManualTestSetUp(); 43 void ManualTestSetUp();
44 void OnTraceDataCollected( 44 void OnTraceDataCollected(
45 scoped_refptr<TraceLog::RefCountedString> events_str); 45 const scoped_refptr<TraceLog::RefCountedString>& events_str);
46 DictionaryValue* FindMatchingTraceEntry(const JsonKeyValue* key_values); 46 DictionaryValue* FindMatchingTraceEntry(const JsonKeyValue* key_values);
47 DictionaryValue* FindNamePhase(const char* name, const char* phase); 47 DictionaryValue* FindNamePhase(const char* name, const char* phase);
48 DictionaryValue* FindNamePhaseKeyValue(const char* name, 48 DictionaryValue* FindNamePhaseKeyValue(const char* name,
49 const char* phase, 49 const char* phase,
50 const char* key, 50 const char* key,
51 const char* value); 51 const char* value);
52 bool FindMatchingValue(const char* key, 52 bool FindMatchingValue(const char* key,
53 const char* value); 53 const char* value);
54 bool FindNonMatchingValue(const char* key, 54 bool FindNonMatchingValue(const char* key,
55 const char* value); 55 const char* value);
(...skipping 26 matching lines...) Expand all
82 TraceLog* tracelog = TraceLog::GetInstance(); 82 TraceLog* tracelog = TraceLog::GetInstance();
83 ASSERT_TRUE(tracelog); 83 ASSERT_TRUE(tracelog);
84 ASSERT_FALSE(tracelog->IsEnabled()); 84 ASSERT_FALSE(tracelog->IsEnabled());
85 tracelog->SetOutputCallback( 85 tracelog->SetOutputCallback(
86 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, 86 base::Bind(&TraceEventTestFixture::OnTraceDataCollected,
87 base::Unretained(this))); 87 base::Unretained(this)));
88 trace_buffer_.SetOutputCallback(json_output_.GetCallback()); 88 trace_buffer_.SetOutputCallback(json_output_.GetCallback());
89 } 89 }
90 90
91 void TraceEventTestFixture::OnTraceDataCollected( 91 void TraceEventTestFixture::OnTraceDataCollected(
92 scoped_refptr<TraceLog::RefCountedString> events_str) { 92 const scoped_refptr<TraceLog::RefCountedString>& events_str) {
93 AutoLock lock(lock_); 93 AutoLock lock(lock_);
94 json_output_.json_output.clear(); 94 json_output_.json_output.clear();
95 trace_buffer_.Start(); 95 trace_buffer_.Start();
96 trace_buffer_.AddFragment(events_str->data); 96 trace_buffer_.AddFragment(events_str->data);
97 trace_buffer_.Finish(); 97 trace_buffer_.Finish();
98 98
99 scoped_ptr<Value> root; 99 scoped_ptr<Value> root;
100 root.reset(base::JSONReader::Read(json_output_.json_output, false)); 100 root.reset(base::JSONReader::Read(json_output_.json_output, false));
101 101
102 ListValue* root_list = NULL; 102 ListValue* root_list = NULL;
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 Clear(); 1146 Clear();
1147 1147
1148 trace_buffer_.Start(); 1148 trace_buffer_.Start();
1149 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4"); 1149 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4");
1150 trace_buffer_.Finish(); 1150 trace_buffer_.Finish();
1151 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]"); 1151 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]");
1152 } 1152 }
1153 1153
1154 } // namespace debug 1154 } // namespace debug
1155 } // namespace base 1155 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event.cc ('k') | base/test/trace_event_analyzer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698