| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/debug/trace_event_unittest.h" | 6 #include "base/debug/trace_event_unittest.h" |
| 7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "base/test/trace_event_analyzer.h" | 8 #include "base/test/trace_event_analyzer.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 TraceEventVector found; | 79 TraceEventVector found; |
| 80 analyzer->FindEvents(Query::Bool(true), &found); | 80 analyzer->FindEvents(Query::Bool(true), &found); |
| 81 EXPECT_EQ(0u, found.size()); | 81 EXPECT_EQ(0u, found.size()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 TEST_F(TraceEventAnalyzerTest, TraceEvent) { | 84 TEST_F(TraceEventAnalyzerTest, TraceEvent) { |
| 85 ManualSetUp(); | 85 ManualSetUp(); |
| 86 | 86 |
| 87 int int_num = 2; | 87 int int_num = 2; |
| 88 double double_num = 3.5; | 88 double double_num = 3.5; |
| 89 const char* str = "the string"; | 89 const char str[] = "the string"; |
| 90 | 90 |
| 91 TraceEvent event; | 91 TraceEvent event; |
| 92 event.arg_numbers["false"] = 0.0; | 92 event.arg_numbers["false"] = 0.0; |
| 93 event.arg_numbers["true"] = 1.0; | 93 event.arg_numbers["true"] = 1.0; |
| 94 event.arg_numbers["int"] = static_cast<double>(int_num); | 94 event.arg_numbers["int"] = static_cast<double>(int_num); |
| 95 event.arg_numbers["double"] = double_num; | 95 event.arg_numbers["double"] = double_num; |
| 96 event.arg_strings["string"] = str; | 96 event.arg_strings["string"] = str; |
| 97 | 97 |
| 98 ASSERT_TRUE(event.HasNumberArg("false")); | 98 ASSERT_TRUE(event.HasNumberArg("false")); |
| 99 ASSERT_TRUE(event.HasNumberArg("true")); | 99 ASSERT_TRUE(event.HasNumberArg("true")); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 TraceEventVector found; | 501 TraceEventVector found; |
| 502 analyzer->FindEvents(Query::MatchBeginWithEnd(), &found); | 502 analyzer->FindEvents(Query::MatchBeginWithEnd(), &found); |
| 503 ASSERT_EQ(1u, found.size()); | 503 ASSERT_EQ(1u, found.size()); |
| 504 EXPECT_STREQ("name2", found[0]->name.c_str()); | 504 EXPECT_STREQ("name2", found[0]->name.c_str()); |
| 505 } | 505 } |
| 506 | 506 |
| 507 // Test MergeAssociatedEventArgs | 507 // Test MergeAssociatedEventArgs |
| 508 TEST_F(TraceEventAnalyzerTest, MergeAssociatedEventArgs) { | 508 TEST_F(TraceEventAnalyzerTest, MergeAssociatedEventArgs) { |
| 509 ManualSetUp(); | 509 ManualSetUp(); |
| 510 | 510 |
| 511 const char* arg_string = "arg_string"; | 511 const char arg_string[] = "arg_string"; |
| 512 BeginTracing(); | 512 BeginTracing(); |
| 513 { | 513 { |
| 514 TRACE_EVENT_BEGIN0("cat1", "name1"); | 514 TRACE_EVENT_BEGIN0("cat1", "name1"); |
| 515 TRACE_EVENT_END1("cat1", "name1", "arg", arg_string); | 515 TRACE_EVENT_END1("cat1", "name1", "arg", arg_string); |
| 516 } | 516 } |
| 517 EndTracing(); | 517 EndTracing(); |
| 518 | 518 |
| 519 scoped_ptr<TraceAnalyzer> | 519 scoped_ptr<TraceAnalyzer> |
| 520 analyzer(TraceAnalyzer::Create(output_.json_output)); | 520 analyzer(TraceAnalyzer::Create(output_.json_output)); |
| 521 ASSERT_TRUE(analyzer.get()); | 521 ASSERT_TRUE(analyzer.get()); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); | 886 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); |
| 887 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), | 887 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), |
| 888 1, num_events)); | 888 1, num_events)); |
| 889 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); | 889 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); |
| 890 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); | 890 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); |
| 891 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); | 891 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); |
| 892 } | 892 } |
| 893 | 893 |
| 894 | 894 |
| 895 } // namespace trace_analyzer | 895 } // namespace trace_analyzer |
| OLD | NEW |