| 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 // VMOptions=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
| 5 | 5 |
| 6 import 'package:observatory/models.dart' as M; |
| 6 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 8 import 'service_test_common.dart'; | 9 import 'service_test_common.dart'; |
| 9 import 'test_helper.dart'; | 10 import 'test_helper.dart'; |
| 10 import 'dart:async'; | 11 import 'dart:async'; |
| 11 import 'dart:isolate' as isolate; | 12 import 'dart:isolate' as isolate; |
| 12 import 'dart:developer' as developer; | 13 import 'dart:developer' as developer; |
| 13 | 14 |
| 14 int counter = 0; | 15 int counter = 0; |
| 15 const stoppedAtLine = 24; | 16 const stoppedAtLine = 25; |
| 16 var port = new isolate.RawReceivePort(msgHandler); | 17 var port = new isolate.RawReceivePort(msgHandler); |
| 17 | 18 |
| 18 // This name is used in a test below. | 19 // This name is used in a test below. |
| 19 void msgHandler(_) { } | 20 void msgHandler(_) { } |
| 20 | 21 |
| 21 void periodicTask(_) { | 22 void periodicTask(_) { |
| 22 port.sendPort.send(34); | 23 port.sendPort.send(34); |
| 23 developer.debugger(message: "fo", when: true); // We will be at the next line. | 24 developer.debugger(message: "fo", when: true); // We will be at the next line. |
| 24 counter++; | 25 counter++; |
| 25 if (counter % 300 == 0) { | 26 if (counter % 300 == 0) { |
| 26 print('counter = $counter'); | 27 print('counter = $counter'); |
| 27 } | 28 } |
| 28 } | 29 } |
| 29 | 30 |
| 30 void startTimer() { | 31 void startTimer() { |
| 31 new Timer.periodic(const Duration(milliseconds:10), periodicTask); | 32 new Timer.periodic(const Duration(milliseconds:10), periodicTask); |
| 32 } | 33 } |
| 33 | 34 |
| 34 var tests = [ | 35 var tests = [ |
| 35 | 36 |
| 36 // Initial data fetch and verify we've hit the breakpoint. | 37 // Initial data fetch and verify we've hit the breakpoint. |
| 37 (Isolate isolate) async { | 38 (Isolate isolate) async { |
| 38 await isolate.rootLibrary.load(); | 39 await isolate.rootLibrary.load(); |
| 39 var script = isolate.rootLibrary.scripts[0]; | 40 var script = isolate.rootLibrary.scripts[0]; |
| 40 await script.load(); | 41 await script.load(); |
| 41 await hasStoppedAtBreakpoint(isolate); | 42 await hasStoppedAtBreakpoint(isolate); |
| 42 // Sanity check. | 43 // Sanity check. |
| 43 expect(isolate.pauseEvent.kind, equals(ServiceEvent.kPauseBreakpoint)); | 44 expect(isolate.pauseEvent is M.PauseBreakpointEvent, isTrue); |
| 44 }, | 45 }, |
| 45 | 46 |
| 46 // Get stack | 47 // Get stack |
| 47 (Isolate isolate) async { | 48 (Isolate isolate) async { |
| 48 var stack = await isolate.getStack(); | 49 var stack = await isolate.getStack(); |
| 49 expect(stack.type, equals('Stack')); | 50 expect(stack.type, equals('Stack')); |
| 50 | 51 |
| 51 // Sanity check. | 52 // Sanity check. |
| 52 expect(stack['frames'].length, greaterThanOrEqualTo(1)); | 53 expect(stack['frames'].length, greaterThanOrEqualTo(1)); |
| 53 Script script = stack['frames'][0].location.script; | 54 Script script = stack['frames'][0].location.script; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 expect(msgHandlerObjectId, isNotNull); | 86 expect(msgHandlerObjectId, isNotNull); |
| 86 | 87 |
| 87 // Get object. | 88 // Get object. |
| 88 var object = await isolate.getObject(msgHandlerObjectId); | 89 var object = await isolate.getObject(msgHandlerObjectId); |
| 89 expect(object.valueAsString, equals('34')); | 90 expect(object.valueAsString, equals('34')); |
| 90 } | 91 } |
| 91 | 92 |
| 92 ]; | 93 ]; |
| 93 | 94 |
| 94 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); | 95 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); |
| OLD | NEW |