| Index: runtime/observatory/tests/service/add_breakpoint_rpc_test.dart
|
| diff --git a/runtime/observatory/tests/service/add_breakpoint_rpc_test.dart b/runtime/observatory/tests/service/add_breakpoint_rpc_test.dart
|
| index b735254e5432d828452c2a2ee2838df5137b6035..781408f099055200d7808daf95896d6c1d23915b 100644
|
| --- a/runtime/observatory/tests/service/add_breakpoint_rpc_test.dart
|
| +++ b/runtime/observatory/tests/service/add_breakpoint_rpc_test.dart
|
| @@ -21,9 +21,9 @@ int incValue(int amount) {
|
| }
|
|
|
| Future testMain() async {
|
| - incValue(incValue(1)); // line A.
|
| + incValue(incValue(1)); // line A.
|
|
|
| - incValue(incValue(1)); // line B.
|
| + incValue(incValue(1)); // line B.
|
|
|
| await deferredLib.loadLibrary();
|
| deferredLib.deferredTest();
|
| @@ -52,21 +52,8 @@ var tests = [
|
| expect(await futureBpt2.location.getLine(), equals(LINE_A));
|
| expect(await futureBpt2.location.getColumn(), equals(3));
|
|
|
| - var stream = await isolate.vm.getEventStream(VM.kDebugStream);
|
| - Completer completer = new Completer();
|
| - var subscription;
|
| - var resolvedCount = 0;
|
| - subscription = stream.listen((ServiceEvent event) async {
|
| - if (event.kind == ServiceEvent.kBreakpointResolved) {
|
| - resolvedCount++;
|
| - }
|
| - if (event.kind == ServiceEvent.kPauseBreakpoint) {
|
| - subscription.cancel();
|
| - completer.complete(null);
|
| - }
|
| - });
|
| - await isolate.resume();
|
| - await completer.future;
|
| + int resolvedCount =
|
| + await resumeAndCountResolvedBreakpointsUntilPause(isolate);
|
|
|
| // After resolution the breakpoints have assigned line & column.
|
| expect(resolvedCount, equals(2));
|
| @@ -80,25 +67,17 @@ var tests = [
|
| // The first breakpoint hits before value is modified.
|
| expect((await rootLib.evaluate('value')).valueAsString, equals('0'));
|
|
|
| - stream = await isolate.vm.getEventStream(VM.kDebugStream);
|
| - completer = new Completer();
|
| - subscription = stream.listen((ServiceEvent event) async {
|
| - if (event.kind == ServiceEvent.kPauseBreakpoint) {
|
| - subscription.cancel();
|
| - completer.complete(null);
|
| - }
|
| - });
|
| - await isolate.resume();
|
| - await completer.future;
|
| + isolate.resume();
|
| + await hasStoppedAtBreakpoint(isolate);
|
|
|
| // The second breakpoint hits after value has been modified once.
|
| expect((await rootLib.evaluate('value')).valueAsString, equals('1'));
|
|
|
| // Remove the breakpoints.
|
| - expect((await isolate.removeBreakpoint(futureBpt1)).type,
|
| - equals('Success'));
|
| - expect((await isolate.removeBreakpoint(futureBpt2)).type,
|
| - equals('Success'));
|
| + expect(
|
| + (await isolate.removeBreakpoint(futureBpt1)).type, equals('Success'));
|
| + expect(
|
| + (await isolate.removeBreakpoint(futureBpt2)).type, equals('Success'));
|
| },
|
|
|
| // Test breakpoints in deferred libraries (latent breakpoints).
|
| @@ -106,7 +85,7 @@ var tests = [
|
| var rootLib = isolate.rootLibrary;
|
| var uri = rootLib.scripts[0].uri;
|
| var lastSlashPos = uri.lastIndexOf('/');
|
| - var deferredUri =uri.substring(0, lastSlashPos) + '/deferred_library.dart';
|
| + var deferredUri = uri.substring(0, lastSlashPos) + '/deferred_library.dart';
|
|
|
| // Latent breakpoint.
|
| var latentBpt1 = await isolate.addBreakpointByScriptUri(deferredUri, 15);
|
| @@ -116,28 +95,14 @@ var tests = [
|
| expect(await latentBpt1.location.getColumn(), equals(null));
|
|
|
| // Latent breakpoint with specific column.
|
| - var latentBpt2 =
|
| - await isolate.addBreakpointByScriptUri(deferredUri, 15, 3);
|
| + var latentBpt2 = await isolate.addBreakpointByScriptUri(deferredUri, 15, 3);
|
| expect(latentBpt2.number, equals(4));
|
| expect(latentBpt2.resolved, isFalse);
|
| expect(await latentBpt2.location.getLine(), equals(15));
|
| expect(await latentBpt2.location.getColumn(), equals(3));
|
|
|
| - var stream = await isolate.vm.getEventStream(VM.kDebugStream);
|
| - Completer completer = new Completer();
|
| - var subscription;
|
| - var resolvedCount = 0;
|
| - subscription = stream.listen((ServiceEvent event) async {
|
| - if (event.kind == ServiceEvent.kBreakpointResolved) {
|
| - resolvedCount++;
|
| - }
|
| - if (event.kind == ServiceEvent.kPauseBreakpoint) {
|
| - subscription.cancel();
|
| - completer.complete(null);
|
| - }
|
| - });
|
| - await isolate.resume();
|
| - await completer.future;
|
| + int resolvedCount =
|
| + await resumeAndCountResolvedBreakpointsUntilPause(isolate);
|
|
|
| // After resolution the breakpoints have assigned line & column.
|
| expect(resolvedCount, equals(2));
|
| @@ -150,31 +115,22 @@ var tests = [
|
|
|
| // The first breakpoint hits before value is modified.
|
| expect((await rootLib.evaluate('deferredLib.value')).valueAsString,
|
| - equals('0'));
|
| -
|
| - stream = await isolate.vm.getEventStream(VM.kDebugStream);
|
| - completer = new Completer();
|
| - subscription = stream.listen((ServiceEvent event) async {
|
| - if (event.kind == ServiceEvent.kPauseBreakpoint) {
|
| - subscription.cancel();
|
| - completer.complete(null);
|
| - }
|
| - });
|
| - await isolate.resume();
|
| - await completer.future;
|
| + equals('0'));
|
| +
|
| + isolate.resume();
|
| + await hasStoppedAtBreakpoint(isolate);
|
|
|
| // The second breakpoint hits after value has been modified once.
|
| expect((await rootLib.evaluate('deferredLib.value')).valueAsString,
|
| - equals('-1'));
|
| + equals('-1'));
|
|
|
| // Remove the breakpoints.
|
| - expect((await isolate.removeBreakpoint(latentBpt1)).type,
|
| - equals('Success'));
|
| - expect((await isolate.removeBreakpoint(latentBpt2)).type,
|
| - equals('Success'));
|
| + expect(
|
| + (await isolate.removeBreakpoint(latentBpt1)).type, equals('Success'));
|
| + expect(
|
| + (await isolate.removeBreakpoint(latentBpt2)).type, equals('Success'));
|
| },
|
|
|
| -
|
| // Test resolution of column breakpoints.
|
| (Isolate isolate) async {
|
| var script = isolate.rootLibrary.scripts[0];
|
| @@ -202,17 +158,34 @@ var tests = [
|
| var caughtException = false;
|
| try {
|
| await isolate.addBreakpoint(script, 20, 0);
|
| - expect(false, isTrue, reason:'Unreachable');
|
| - } on ServerRpcException catch(e) {
|
| + expect(false, isTrue, reason: 'Unreachable');
|
| + } on ServerRpcException catch (e) {
|
| caughtException = true;
|
| expect(e.code, equals(ServerRpcException.kInvalidParams));
|
| - expect(e.message,
|
| - "addBreakpoint: invalid 'column' parameter: 0");
|
| + expect(e.message, "addBreakpoint: invalid 'column' parameter: 0");
|
| }
|
| expect(caughtException, isTrue);
|
| },
|
| ];
|
|
|
| +Future<int> resumeAndCountResolvedBreakpointsUntilPause(Isolate isolate) async {
|
| + var stream = await isolate.vm.getEventStream(VM.kDebugStream);
|
| + Completer completer = new Completer();
|
| + var subscription;
|
| + int resolvedCount = 0;
|
| + subscription = stream.listen((ServiceEvent event) async {
|
| + if (event.kind == ServiceEvent.kBreakpointResolved) {
|
| + resolvedCount++;
|
| + }
|
| + if (event.kind == ServiceEvent.kPauseBreakpoint) {
|
| + subscription.cancel();
|
| + completer.complete();
|
| + }
|
| + });
|
| + await isolate.resume();
|
| + await completer.future;
|
| + return resolvedCount;
|
| +}
|
| +
|
| main(args) => runIsolateTests(args, tests,
|
| - testeeConcurrent: testMain,
|
| - pause_on_start: true);
|
| + testeeConcurrent: testMain, pause_on_start: true);
|
|
|