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

Side by Side Diff: base/test/trace_event_analyzer_unittest.cc

Issue 10911268: Add some TraceAnalyzer utility methods to simplify test code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/test/trace_event_analyzer.cc ('k') | chrome/test/gpu/gpu_feature_browsertest.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) 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/test/trace_event_analyzer.h" 7 #include "base/test/trace_event_analyzer.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 other.category = "category2"; 121 other.category = "category2";
122 other.name = "name2"; 122 other.name = "name2";
123 other.id = "2"; 123 other.id = "2";
124 other.arg_numbers["num2"] = 8.0; 124 other.arg_numbers["num2"] = 8.0;
125 other.arg_strings["str2"] = "the string 2"; 125 other.arg_strings["str2"] = "the string 2";
126 126
127 event.other_event = &other; 127 event.other_event = &other;
128 ASSERT_TRUE(event.has_other_event()); 128 ASSERT_TRUE(event.has_other_event());
129 double duration = event.GetAbsTimeToOtherEvent(); 129 double duration = event.GetAbsTimeToOtherEvent();
130 130
131 Query event_pid = (Query::EventPid() == Query::Int(event.thread.process_id)); 131 Query event_pid = Query::EventPidIs(event.thread.process_id);
132 Query event_tid = (Query::EventTid() == Query::Int(event.thread.thread_id)); 132 Query event_tid = Query::EventTidIs(event.thread.thread_id);
133 Query event_time = (Query::EventTime() == Query::Double(event.timestamp)); 133 Query event_time = Query::EventTimeIs(event.timestamp);
134 Query event_duration = (Query::EventDuration() == Query::Double(duration)); 134 Query event_duration = Query::EventDurationIs(duration);
135 Query event_phase = (Query::EventPhase() == Query::Phase(event.phase)); 135 Query event_phase = Query::EventPhaseIs(event.phase);
136 Query event_category = 136 Query event_category = Query::EventCategoryIs(event.category);
137 (Query::EventCategory() == Query::String(event.category)); 137 Query event_name = Query::EventNameIs(event.name);
138 Query event_name = (Query::EventName() == Query::String(event.name)); 138 Query event_id = Query::EventIdIs(event.id);
139 Query event_id = (Query::EventId() == Query::String(event.id));
140 Query event_has_arg1 = Query::EventHasNumberArg("num"); 139 Query event_has_arg1 = Query::EventHasNumberArg("num");
141 Query event_has_arg2 = Query::EventHasStringArg("str"); 140 Query event_has_arg2 = Query::EventHasStringArg("str");
142 Query event_arg1 = 141 Query event_arg1 =
143 (Query::EventArg("num") == Query::Double(event.arg_numbers["num"])); 142 (Query::EventArg("num") == Query::Double(event.arg_numbers["num"]));
144 Query event_arg2 = 143 Query event_arg2 =
145 (Query::EventArg("str") == Query::String(event.arg_strings["str"])); 144 (Query::EventArg("str") == Query::String(event.arg_strings["str"]));
146 Query event_has_other = Query::EventHasOther(); 145 Query event_has_other = Query::EventHasOther();
147 Query other_pid = (Query::OtherPid() == Query::Int(other.thread.process_id)); 146 Query other_pid = Query::OtherPidIs(other.thread.process_id);
148 Query other_tid = (Query::OtherTid() == Query::Int(other.thread.thread_id)); 147 Query other_tid = Query::OtherTidIs(other.thread.thread_id);
149 Query other_time = (Query::OtherTime() == Query::Double(other.timestamp)); 148 Query other_time = Query::OtherTimeIs(other.timestamp);
150 Query other_phase = (Query::OtherPhase() == Query::Phase(other.phase)); 149 Query other_phase = Query::OtherPhaseIs(other.phase);
151 Query other_category = 150 Query other_category = Query::OtherCategoryIs(other.category);
152 (Query::OtherCategory() == Query::String(other.category)); 151 Query other_name = Query::OtherNameIs(other.name);
153 Query other_name = (Query::OtherName() == Query::String(other.name)); 152 Query other_id = Query::OtherIdIs(other.id);
154 Query other_id = (Query::OtherId() == Query::String(other.id));
155 Query other_has_arg1 = Query::OtherHasNumberArg("num2"); 153 Query other_has_arg1 = Query::OtherHasNumberArg("num2");
156 Query other_has_arg2 = Query::OtherHasStringArg("str2"); 154 Query other_has_arg2 = Query::OtherHasStringArg("str2");
157 Query other_arg1 = 155 Query other_arg1 =
158 (Query::OtherArg("num2") == Query::Double(other.arg_numbers["num2"])); 156 (Query::OtherArg("num2") == Query::Double(other.arg_numbers["num2"]));
159 Query other_arg2 = 157 Query other_arg2 =
160 (Query::OtherArg("str2") == Query::String(other.arg_strings["str2"])); 158 (Query::OtherArg("str2") == Query::String(other.arg_strings["str2"]));
161 159
162 EXPECT_TRUE(event_pid.Evaluate(event)); 160 EXPECT_TRUE(event_pid.Evaluate(event));
163 EXPECT_TRUE(event_tid.Evaluate(event)); 161 EXPECT_TRUE(event_tid.Evaluate(event));
164 EXPECT_TRUE(event_time.Evaluate(event)); 162 EXPECT_TRUE(event_time.Evaluate(event));
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true))); 816 EXPECT_EQ(num_events, CountMatches(event_ptrs, Query::Bool(true)));
819 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true), 817 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, Query::Bool(true),
820 1, num_events)); 818 1, num_events));
821 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one)); 819 EXPECT_EQ(1u, CountMatches(event_ptrs, query_one));
822 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one)); 820 EXPECT_EQ(num_events - 1, CountMatches(event_ptrs, !query_one));
823 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named)); 821 EXPECT_EQ(num_named, CountMatches(event_ptrs, query_named));
824 } 822 }
825 823
826 824
827 } // namespace trace_analyzer 825 } // namespace trace_analyzer
OLDNEW
« no previous file with comments | « base/test/trace_event_analyzer.cc ('k') | chrome/test/gpu/gpu_feature_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698