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

Side by Side Diff: runtime/observatory/tests/service/isolate_lifecycle_test.dart

Issue 1143783003: Add the streamListen and streamCancel rpcs to the vm service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: before commit Created 5 years, 6 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
OLDNEW
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 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:isolate' as I; 7 import 'dart:isolate' as I;
8 8
9 import 'package:observatory/service_io.dart'; 9 import 'package:observatory/service_io.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 running++; 47 running++;
48 } 48 }
49 } 49 }
50 return running; 50 return running;
51 } 51 }
52 52
53 var tests = [ 53 var tests = [
54 (VM vm) async { 54 (VM vm) async {
55 // Wait for the testee to start all of the isolates. 55 // Wait for the testee to start all of the isolates.
56 if (vm.isolates.length != spawnCount + 1) { 56 if (vm.isolates.length != spawnCount + 1) {
57 await processServiceEvents(vm, (event, sub, completer) { 57 await processServiceEvents(vm, VM.kIsolateEventStreamId,
58 (event, sub, completer) {
58 if (event.eventType == ServiceEvent.kIsolateStart) { 59 if (event.eventType == ServiceEvent.kIsolateStart) {
59 if (vm.isolates.length == spawnCount + 1) { 60 if (vm.isolates.length == spawnCount + 1) {
60 sub.cancel(); 61 sub.cancel();
61 completer.complete(null); 62 completer.complete(null);
62 } 63 }
63 } 64 }
64 }); 65 });
65 } 66 }
66 expect(vm.isolates.length, spawnCount + 1); 67 expect(vm.isolates.length, spawnCount + 1);
67 }, 68 },
68 69
69 (VM vm) async { 70 (VM vm) async {
70 // Load each isolate. 71 // Load each isolate.
71 for (var isolate in vm.isolates) { 72 for (var isolate in vm.isolates) {
72 await isolate.load(); 73 await isolate.load();
73 } 74 }
74 }, 75 },
75 76
76 (VM vm) async { 77 (VM vm) async {
77 // Wait for all spawned isolates to hit pause-at-exit. 78 // Wait for all spawned isolates to hit pause-at-exit.
78 if (numPaused(vm) != spawnCount) { 79 if (numPaused(vm) != spawnCount) {
79 await processServiceEvents(vm, (event, sub, completer) { 80 await processServiceEvents(vm, VM.kDebugEventStreamId,
81 (event, sub, completer) {
80 if (event.eventType == ServiceEvent.kPauseExit) { 82 if (event.eventType == ServiceEvent.kPauseExit) {
81 if (numPaused(vm) == spawnCount) { 83 if (numPaused(vm) == spawnCount) {
82 sub.cancel(); 84 sub.cancel();
83 completer.complete(null); 85 completer.complete(null);
84 } 86 }
85 } 87 }
86 }); 88 });
87 } 89 }
88 expect(numPaused(vm), spawnCount); 90 expect(numPaused(vm), spawnCount);
89 expect(numRunning(vm), 1); 91 expect(numRunning(vm), 1);
90 }, 92 },
91 93
92 94
93 (VM vm) async { 95 (VM vm) async {
94 var resumedReceived = 0; 96 var resumedReceived = 0;
95 var eventsDone = processServiceEvents(vm, (event, sub, completer) { 97 var eventsDone = processServiceEvents(vm, VM.kIsolateEventStreamId,
98 (event, sub, completer) {
96 if (event.eventType == ServiceEvent.kIsolateExit) { 99 if (event.eventType == ServiceEvent.kIsolateExit) {
97 resumedReceived++; 100 resumedReceived++;
98 if (resumedReceived == resumeCount) { 101 if (resumedReceived == resumeCount) {
99 sub.cancel(); 102 sub.cancel();
100 completer.complete(null); 103 completer.complete(null);
101 } 104 }
102 } 105 }
103 }); 106 });
104 var resumesIssued = 0; 107 var resumesIssued = 0;
105 var isolateList = vm.isolates.toList(); 108 var isolateList = vm.isolates.toList();
(...skipping 15 matching lines...) Expand all
121 (VM vm) async { 124 (VM vm) async {
122 expect(numPaused(vm), spawnCount - resumeCount); 125 expect(numPaused(vm), spawnCount - resumeCount);
123 expect(numRunning(vm), 1); 126 expect(numRunning(vm), 1);
124 }, 127 },
125 ]; 128 ];
126 129
127 main(args) async => runVMTests(args, tests, 130 main(args) async => runVMTests(args, tests,
128 testeeBefore: before, 131 testeeBefore: before,
129 testeeConcurrent: during, 132 testeeConcurrent: during,
130 pause_on_exit: true); 133 pause_on_exit: true);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/graph_test.dart ('k') | runtime/observatory/tests/service/source_location_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698