OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include <cstring> | 5 #include <cstring> |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 | 8 |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 TimelineEventFilter filter; | 230 TimelineEventFilter filter; |
231 recorder->PrintJSON(&js, &filter); | 231 recorder->PrintJSON(&js, &filter); |
232 // Check the type. This test will fail if we ever make Timeline public. | 232 // Check the type. This test will fail if we ever make Timeline public. |
233 EXPECT_SUBSTRING("\"type\":\"_Timeline\"", js.ToCString()); | 233 EXPECT_SUBSTRING("\"type\":\"_Timeline\"", js.ToCString()); |
234 // Check that there is a traceEvents array. | 234 // Check that there is a traceEvents array. |
235 EXPECT_SUBSTRING("\"traceEvents\":[", js.ToCString()); | 235 EXPECT_SUBSTRING("\"traceEvents\":[", js.ToCString()); |
236 } | 236 } |
237 | 237 |
238 | 238 |
239 // Count the number of each event type seen. | 239 // Count the number of each event type seen. |
240 class EventCounterRecorder : public TimelineEventStreamingRecorder { | 240 class EventCounterRecorder : public TimelineEventCallbackRecorder { |
241 public: | 241 public: |
242 EventCounterRecorder() { | 242 EventCounterRecorder() { |
243 for (intptr_t i = 0; i < TimelineEvent::kNumEventTypes; i++) { | 243 for (intptr_t i = 0; i < TimelineEvent::kNumEventTypes; i++) { |
244 counts_[i] = 0; | 244 counts_[i] = 0; |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 void StreamEvent(TimelineEvent* event) { | 248 void OnEvent(TimelineEvent* event) { |
249 counts_[event->event_type()]++; | 249 counts_[event->event_type()]++; |
250 } | 250 } |
251 | 251 |
252 intptr_t CountFor(TimelineEvent::EventType type) { | 252 intptr_t CountFor(TimelineEvent::EventType type) { |
253 return counts_[type]; | 253 return counts_[type]; |
254 } | 254 } |
255 | 255 |
256 private: | 256 private: |
257 intptr_t counts_[TimelineEvent::kNumEventTypes]; | 257 intptr_t counts_[TimelineEvent::kNumEventTypes]; |
258 }; | 258 }; |
259 | 259 |
260 | 260 |
261 TEST_CASE(TimelineEventStreamingRecorderBasic) { | 261 TEST_CASE(TimelineEventCallbackRecorderBasic) { |
262 EventCounterRecorder* recorder = new EventCounterRecorder(); | 262 EventCounterRecorder* recorder = new EventCounterRecorder(); |
263 TimelineRecorderOverride override(recorder); | 263 TimelineRecorderOverride override(recorder); |
264 | 264 |
265 // Initial counts are all zero. | 265 // Initial counts are all zero. |
266 for (intptr_t i = TimelineEvent::kNone + 1; | 266 for (intptr_t i = TimelineEvent::kNone + 1; |
267 i < TimelineEvent::kNumEventTypes; | 267 i < TimelineEvent::kNumEventTypes; |
268 i++) { | 268 i++) { |
269 EXPECT_EQ(0, recorder->CountFor(static_cast<TimelineEvent::EventType>(i))); | 269 EXPECT_EQ(0, recorder->CountFor(static_cast<TimelineEvent::EventType>(i))); |
270 } | 270 } |
271 | 271 |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 pauses.Setup(); | 852 pauses.Setup(); |
853 pauses.CalculatePauseTimesForThread(tid); | 853 pauses.CalculatePauseTimesForThread(tid); |
854 EXPECT(pauses.has_error()); | 854 EXPECT(pauses.has_error()); |
855 } | 855 } |
856 TimelineTestHelper::Clear(recorder); | 856 TimelineTestHelper::Clear(recorder); |
857 } | 857 } |
858 | 858 |
859 #endif // !PRODUCT | 859 #endif // !PRODUCT |
860 | 860 |
861 } // namespace dart | 861 } // namespace dart |
OLD | NEW |