Index: base/debug/trace_event_unittest.cc |
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc |
index 0ccf440a5569782eacd486cac6603e5459db5934..2c57820fa2dde4f373e2398ec187657733522f2a 100644 |
--- a/base/debug/trace_event_unittest.cc |
+++ b/base/debug/trace_event_unittest.cc |
@@ -40,7 +40,7 @@ class TraceEventTestFixture : public testing::Test { |
// up multiple times when testing AtExit. Use ManualTestSetUp for this. |
void ManualTestSetUp(); |
void OnTraceDataCollected( |
- scoped_refptr<TraceLog::RefCountedString> json_events_str); |
+ scoped_refptr<TraceLog::RefCountedString> events_str); |
bool FindMatchingTraceEntry(const JsonKeyValue* key_values); |
bool FindNamePhase(const char* name, const char* phase); |
bool FindMatchingValue(const char* key, |
@@ -48,11 +48,9 @@ class TraceEventTestFixture : public testing::Test { |
bool FindNonMatchingValue(const char* key, |
const char* value); |
void Clear() { |
- trace_string_.clear(); |
trace_parsed_.Clear(); |
} |
- std::string trace_string_; |
ListValue trace_parsed_; |
private: |
@@ -73,12 +71,15 @@ void TraceEventTestFixture::ManualTestSetUp() { |
} |
void TraceEventTestFixture::OnTraceDataCollected( |
- scoped_refptr<TraceLog::RefCountedString> json_events_str) { |
+ scoped_refptr<TraceLog::RefCountedString> events_str) { |
AutoLock lock(lock_); |
- trace_string_ += json_events_str->data; |
+ std::string json_events; |
+ base::debug::TraceResultBuffer trace_buffer_; |
+ trace_buffer_.AddFragment(events_str->data); |
+ trace_buffer_.GetJSON(&json_events); |
scoped_ptr<Value> root; |
- root.reset(base::JSONReader::Read(json_events_str->data, false)); |
+ root.reset(base::JSONReader::Read(json_events, false)); |
ListValue* root_list = NULL; |
ASSERT_TRUE(root.get()); |
@@ -281,8 +282,7 @@ void TraceWithAllMacroVariants(WaitableEvent* task_complete_event) { |
task_complete_event->Signal(); |
} |
-void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed, |
- const std::string& trace_string) { |
+void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) { |
DictionaryValue* item = NULL; |
#define EXPECT_FIND_(string) \ |
@@ -345,7 +345,7 @@ void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed, |
} |
void TraceManyInstantEvents(int thread_id, int num_events, |
- WaitableEvent* task_complete_event) { |
+ WaitableEvent* task_complete_event) { |
for (int i = 0; i < num_events; i++) { |
TRACE_EVENT_INSTANT2("all", "multi thread event", |
"thread", thread_id, |
@@ -357,8 +357,8 @@ void TraceManyInstantEvents(int thread_id, int num_events, |
} |
void ValidateInstantEventPresentOnEveryThread(const ListValue& trace_parsed, |
- const std::string& trace_string, |
- int num_threads, int num_events) { |
+ int num_threads, |
+ int num_events) { |
std::map<int, std::map<int, bool> > results; |
size_t trace_parsed_count = trace_parsed.GetSize(); |
@@ -406,7 +406,7 @@ TEST_F(TraceEventTestFixture, DataCaptured) { |
TraceLog::GetInstance()->SetEnabled(false); |
- ValidateAllTraceMacrosCreatedData(trace_parsed_, trace_string_); |
+ ValidateAllTraceMacrosCreatedData(trace_parsed_); |
} |
// Test that categories work. |
@@ -687,7 +687,7 @@ TEST_F(TraceEventTestFixture, DataCapturedOnThread) { |
thread.Stop(); |
TraceLog::GetInstance()->SetEnabled(false); |
- ValidateAllTraceMacrosCreatedData(trace_parsed_, trace_string_); |
+ ValidateAllTraceMacrosCreatedData(trace_parsed_); |
} |
// Test that data sent from multiple threads is gathered |
@@ -720,7 +720,7 @@ TEST_F(TraceEventTestFixture, DataCapturedManyThreads) { |
TraceLog::GetInstance()->SetEnabled(false); |
- ValidateInstantEventPresentOnEveryThread(trace_parsed_, trace_string_, |
+ ValidateInstantEventPresentOnEveryThread(trace_parsed_, |
num_threads, num_events); |
} |
nduca
2011/10/20 00:28:03
I can haz a unit test for the trace buffer?
jbates
2011/10/20 22:18:49
Done.
|