| Index: base/test/trace_event_analyzer_unittest.cc
|
| diff --git a/base/test/trace_event_analyzer_unittest.cc b/base/test/trace_event_analyzer_unittest.cc
|
| index 8ff611f2cb6520d2a66bbe53b9c86e3b4f0990c8..e533c4932a7493760de36fd484a176189b27ed2c 100644
|
| --- a/base/test/trace_event_analyzer_unittest.cc
|
| +++ b/base/test/trace_event_analyzer_unittest.cc
|
| @@ -447,7 +447,8 @@ TEST_F(TraceEventAnalyzerTest, MergeAssociatedEventArgs) {
|
| const char* arg_string = "arg_string";
|
| BeginTracing();
|
| {
|
| - TRACE_EVENT1("cat1", "name1", "arg", arg_string);
|
| + TRACE_EVENT_BEGIN0("cat1", "name1");
|
| + TRACE_EVENT_END1("cat1", "name1", "arg", arg_string);
|
| }
|
| EndTracing();
|
|
|
| @@ -457,8 +458,7 @@ TEST_F(TraceEventAnalyzerTest, MergeAssociatedEventArgs) {
|
| analyzer->AssociateBeginEndEvents();
|
|
|
| TraceEventVector found;
|
| - analyzer->FindEvents(Query::EventName() == Query::String("name1") &&
|
| - Query::EventPhase() == Query::Phase(TRACE_EVENT_PHASE_END), &found);
|
| + analyzer->FindEvents(Query::MatchBeginName("name1"), &found);
|
| ASSERT_EQ(1u, found.size());
|
| std::string arg_actual;
|
| EXPECT_FALSE(found[0]->GetArgAsString("arg", &arg_actual));
|
| @@ -468,35 +468,87 @@ TEST_F(TraceEventAnalyzerTest, MergeAssociatedEventArgs) {
|
| EXPECT_STREQ(arg_string, arg_actual.c_str());
|
| }
|
|
|
| -// Test AssociateStartFinishEvents
|
| -TEST_F(TraceEventAnalyzerTest, StartFinishAssocations) {
|
| +// Test AssociateAsyncBeginEndEvents
|
| +TEST_F(TraceEventAnalyzerTest, AsyncBeginEndAssocations) {
|
| ManualSetUp();
|
|
|
| BeginTracing();
|
| {
|
| - TRACE_EVENT_FINISH0("cat1", "name1", 0xA); // does not match / out of order
|
| - TRACE_EVENT_START0("cat1", "name1", 0xB);
|
| - TRACE_EVENT_START0("cat1", "name1", 0xC);
|
| + TRACE_EVENT_ASYNC_END0("cat1", "name1", 0xA); // no match / out of order
|
| + TRACE_EVENT_ASYNC_BEGIN0("cat1", "name1", 0xB);
|
| + TRACE_EVENT_ASYNC_BEGIN0("cat1", "name1", 0xC);
|
| TRACE_EVENT_INSTANT0("cat1", "name1"); // noise
|
| TRACE_EVENT0("cat1", "name1"); // noise
|
| - TRACE_EVENT_FINISH0("cat1", "name1", 0xB);
|
| - TRACE_EVENT_FINISH0("cat1", "name1", 0xC);
|
| - TRACE_EVENT_START0("cat1", "name1", 0xA); // does not match / out of order
|
| + TRACE_EVENT_ASYNC_END0("cat1", "name1", 0xB);
|
| + TRACE_EVENT_ASYNC_END0("cat1", "name1", 0xC);
|
| + TRACE_EVENT_ASYNC_BEGIN0("cat1", "name1", 0xA); // no match / out of order
|
| }
|
| EndTracing();
|
|
|
| scoped_ptr<TraceAnalyzer>
|
| analyzer(TraceAnalyzer::Create(output_.json_output));
|
| ASSERT_TRUE(analyzer.get());
|
| - analyzer->AssociateStartFinishEvents();
|
| + analyzer->AssociateAsyncBeginEndEvents();
|
|
|
| TraceEventVector found;
|
| - analyzer->FindEvents(Query::MatchStartWithFinish(), &found);
|
| + analyzer->FindEvents(Query::MatchAsyncBeginWithNext(), &found);
|
| ASSERT_EQ(2u, found.size());
|
| EXPECT_STRCASEEQ("B", found[0]->id.c_str());
|
| EXPECT_STRCASEEQ("C", found[1]->id.c_str());
|
| }
|
|
|
| +// Test AssociateAsyncBeginEndEvents
|
| +TEST_F(TraceEventAnalyzerTest, AsyncBeginEndAssocationsWithSteps) {
|
| + ManualSetUp();
|
| +
|
| + BeginTracing();
|
| + {
|
| + TRACE_EVENT_ASYNC_STEP0("c", "n", 0xA);
|
| + TRACE_EVENT_ASYNC_END0("c", "n", 0xA);
|
| + TRACE_EVENT_ASYNC_BEGIN0("c", "n", 0xB);
|
| + TRACE_EVENT_ASYNC_BEGIN0("c", "n", 0xC);
|
| + TRACE_EVENT_ASYNC_STEP0("c", "n", 0xB);
|
| + TRACE_EVENT_ASYNC_STEP0("c", "n", 0xC);
|
| + TRACE_EVENT_ASYNC_STEP1("c", "n", 0xC, "a", 1);
|
| + TRACE_EVENT_ASYNC_END0("c", "n", 0xB);
|
| + TRACE_EVENT_ASYNC_END0("c", "n", 0xC);
|
| + TRACE_EVENT_ASYNC_BEGIN0("c", "n", 0xA);
|
| + TRACE_EVENT_ASYNC_STEP0("c", "n", 0xA);
|
| + }
|
| + EndTracing();
|
| +
|
| + scoped_ptr<TraceAnalyzer>
|
| + analyzer(TraceAnalyzer::Create(output_.json_output));
|
| + ASSERT_TRUE(analyzer.get());
|
| + analyzer->AssociateAsyncBeginEndEvents();
|
| +
|
| + TraceEventVector found;
|
| + analyzer->FindEvents(Query::MatchAsyncBeginWithNext(), &found);
|
| + ASSERT_EQ(3u, found.size());
|
| +
|
| + EXPECT_STRCASEEQ("B", found[0]->id.c_str());
|
| + EXPECT_EQ(TRACE_EVENT_PHASE_ASYNC_STEP, found[0]->other_event->phase);
|
| + EXPECT_TRUE(found[0]->other_event->other_event);
|
| + EXPECT_EQ(TRACE_EVENT_PHASE_ASYNC_END,
|
| + found[0]->other_event->other_event->phase);
|
| +
|
| + EXPECT_STRCASEEQ("C", found[1]->id.c_str());
|
| + EXPECT_EQ(TRACE_EVENT_PHASE_ASYNC_STEP, found[1]->other_event->phase);
|
| + EXPECT_TRUE(found[1]->other_event->other_event);
|
| + EXPECT_EQ(TRACE_EVENT_PHASE_ASYNC_STEP,
|
| + found[1]->other_event->other_event->phase);
|
| + double arg_actual = 0;
|
| + EXPECT_TRUE(found[1]->other_event->other_event->GetArgAsNumber(
|
| + "a", &arg_actual));
|
| + EXPECT_EQ(1.0, arg_actual);
|
| + EXPECT_TRUE(found[1]->other_event->other_event->other_event);
|
| + EXPECT_EQ(TRACE_EVENT_PHASE_ASYNC_END,
|
| + found[1]->other_event->other_event->other_event->phase);
|
| +
|
| + EXPECT_STRCASEEQ("A", found[2]->id.c_str());
|
| + EXPECT_EQ(TRACE_EVENT_PHASE_ASYNC_STEP, found[2]->other_event->phase);
|
| +}
|
| +
|
| // Test that the TraceAnalyzer custom associations work.
|
| TEST_F(TraceEventAnalyzerTest, CustomAssociations) {
|
| ManualSetUp();
|
| @@ -541,25 +593,25 @@ TEST_F(TraceEventAnalyzerTest, CustomAssociations) {
|
| !Query::EventHasOther(), &found);
|
| EXPECT_EQ(1u, found.size());
|
|
|
| - // cat2 and cat4 are a associated.
|
| + // cat2 and cat4 are associated.
|
| analyzer->FindEvents(Query::EventCategory() == Query::String("cat2") &&
|
| Query::OtherCategory() == Query::String("cat4"), &found);
|
| EXPECT_EQ(1u, found.size());
|
|
|
| - // cat4 and cat2 are a associated.
|
| + // cat4 and cat2 are not associated.
|
| analyzer->FindEvents(Query::EventCategory() == Query::String("cat4") &&
|
| Query::OtherCategory() == Query::String("cat2"), &found);
|
| - EXPECT_EQ(1u, found.size());
|
| + EXPECT_EQ(0u, found.size());
|
|
|
| - // cat3 and cat5 are a associated.
|
| + // cat3 and cat5 are associated.
|
| analyzer->FindEvents(Query::EventCategory() == Query::String("cat3") &&
|
| Query::OtherCategory() == Query::String("cat5"), &found);
|
| EXPECT_EQ(1u, found.size());
|
|
|
| - // cat5 and cat3 are a associated.
|
| + // cat5 and cat3 are not associated.
|
| analyzer->FindEvents(Query::EventCategory() == Query::String("cat5") &&
|
| Query::OtherCategory() == Query::String("cat3"), &found);
|
| - EXPECT_EQ(1u, found.size());
|
| + EXPECT_EQ(0u, found.size());
|
| }
|
|
|
| // Verify that Query literals and types are properly casted.
|
|
|