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

Unified Diff: runtime/observatory/tests/service/vm_timeline_events_test.dart

Issue 1765563002: Stream blocks of timeline events over the service protocol (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/observatory/tests/service/service_test_common.dart ('k') | runtime/vm/json_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/tests/service/vm_timeline_events_test.dart
diff --git a/runtime/observatory/tests/service/vm_timeline_events_test.dart b/runtime/observatory/tests/service/vm_timeline_events_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c84411e330c759755338460dfc4fecc0234659d5
--- /dev/null
+++ b/runtime/observatory/tests/service/vm_timeline_events_test.dart
@@ -0,0 +1,71 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// VMOptions=--error_on_bad_type --error_on_bad_override
+
+import 'dart:async';
+import 'dart:developer';
+import 'package:observatory/service_io.dart';
+import 'package:unittest/unittest.dart';
+import 'service_test_common.dart';
+import 'test_helper.dart';
+
+primeDartTimeline() {
+ while (true) {
+ Timeline.startSync('apple');
+ Timeline.finishSync();
+ }
+}
+
+bool isDart(Map event) => event['cat'] == 'Dart';
+
+List<Map> filterEvents(List<Map> events, filter) {
+ return events.where(filter).toList();
+}
+
+Completer completer = new Completer();
+int eventCount = 0;
+
+onTimelineEvent(ServiceEvent event) {
+ eventCount++;
+ expect(filterEvents(event.timelineEvents, isDart).length, greaterThan(0));
+ if (eventCount == 5) {
+ completer.complete(eventCount);
+ }
+}
+
+var tests = [
+ (Isolate isolate) async {
+ // Subscribe to the Timeline stream.
+ await subscribeToStream(isolate.vm, VM.kTimelineStream, onTimelineEvent);
+ },
+ (Isolate isolate) async {
+ // Ensure we don't get any events before enabling Dart.
+ await new Future.delayed(new Duration(seconds: 5));
+ expect(eventCount, 0);
+ },
+ (Isolate isolate) async {
+ // Get the flags.
+ Map flags = await isolate.vm.invokeRpcNoUpgrade('_getVMTimelineFlags', {});
+ expect(flags['type'], 'TimelineFlags');
+ // Confirm that 'Dart' is available.
+ expect(flags['availableStreams'].contains('Dart'), isTrue);
+ // Confirm that nothing is being recorded.
+ expect(flags['recordedStreams'].length, equals(0));
+ },
+ (Isolate isolate) async {
+ // Enable the Dart category.
+ await isolate.vm.invokeRpcNoUpgrade('_setVMTimelineFlags', {
+ "recordedStreams": ["Dart"]
+ });
+ },
+ (Isolate isolate) async {
+ // Wait to receive events.
+ await completer.future;
+ cancelStreamSubscription(VM.kTimelineStream);
+ },
+];
+
+main(args) async => runIsolateTests(args,
+ tests,
+ testeeConcurrent: primeDartTimeline);
« no previous file with comments | « runtime/observatory/tests/service/service_test_common.dart ('k') | runtime/vm/json_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698