| 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=--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 'package:observatory/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'test_helper.dart'; | 8 import 'test_helper.dart'; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:isolate' as isolate; | 10 import 'dart:isolate' as isolate; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 expect(isolate.pauseEvent.kind, equals(ServiceEvent.kPauseBreakpoint)); | 42 expect(isolate.pauseEvent.kind, equals(ServiceEvent.kPauseBreakpoint)); |
| 43 }, | 43 }, |
| 44 | 44 |
| 45 // Get stack | 45 // Get stack |
| 46 (Isolate isolate) async { | 46 (Isolate isolate) async { |
| 47 var stack = await isolate.getStack(); | 47 var stack = await isolate.getStack(); |
| 48 expect(stack.type, equals('Stack')); | 48 expect(stack.type, equals('Stack')); |
| 49 | 49 |
| 50 // Sanity check. | 50 // Sanity check. |
| 51 expect(stack['frames'].length, greaterThanOrEqualTo(1)); | 51 expect(stack['frames'].length, greaterThanOrEqualTo(1)); |
| 52 Script script = stack['frames'][0]['script']; | 52 Script script = stack['frames'][0].location.script; |
| 53 expect(script.tokenToLine(stack['frames'][0]['tokenPos']), | 53 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), |
| 54 equals(stoppedAtLine)); | 54 equals(stoppedAtLine)); |
| 55 | 55 |
| 56 // Iterate over frames. | 56 // Iterate over frames. |
| 57 var frameDepth = 0; | 57 var frameDepth = 0; |
| 58 for (var frame in stack['frames']) { | 58 for (var frame in stack['frames']) { |
| 59 print('checking frame $frameDepth'); | 59 print('checking frame $frameDepth'); |
| 60 expect(frame.type, equals('Frame')); | 60 expect(frame.type, equals('Frame')); |
| 61 expect(frame['index'], equals(frameDepth++)); | 61 expect(frame.index, equals(frameDepth++)); |
| 62 expect(frame['code'].type, equals('Code')); | 62 expect(frame.code.type, equals('Code')); |
| 63 expect(frame['function'].type, equals('Function')); | 63 expect(frame.function.type, equals('Function')); |
| 64 expect(frame['script'].type, equals('Script')); | 64 expect(frame.location.type, equals('SourceLocation')); |
| 65 expect(frame['tokenPos'], isNotNull); | |
| 66 } | 65 } |
| 67 | 66 |
| 68 // Sanity check. | 67 // Sanity check. |
| 69 expect(stack['messages'].length, greaterThanOrEqualTo(1)); | 68 expect(stack['messages'].length, greaterThanOrEqualTo(1)); |
| 70 | 69 |
| 71 // Iterate over messages. | 70 // Iterate over messages. |
| 72 var messageDepth = 0; | 71 var messageDepth = 0; |
| 73 // objectId of message to be handled by msgHandler. | 72 // objectId of message to be handled by msgHandler. |
| 74 var msgHandlerObjectId; | 73 var msgHandlerObjectId; |
| 75 for (var message in stack['messages']) { | 74 for (var message in stack['messages']) { |
| 76 print('checking message $messageDepth'); | 75 print('checking message $messageDepth'); |
| 77 expect(message['index'], equals(messageDepth++)); | 76 expect(message.index, equals(messageDepth++)); |
| 78 expect(message['name'], isNotNull); | 77 expect(message.size, greaterThanOrEqualTo(1)); |
| 79 expect(message['size'], greaterThanOrEqualTo(1)); | 78 expect(message.handler.type, equals('Function')); |
| 80 expect(message['_priority'], isNotNull); | 79 expect(message.location.type, equals('SourceLocation')); |
| 81 expect(message['_destinationPort'], isNotNull); | 80 if (message.handler.name.contains('msgHandler')) { |
| 82 expect(message['handlerFunction'].type, equals('Function')); | 81 msgHandlerObjectId = message.messageObjectId; |
| 83 if (message['handlerFunction'].name.contains('msgHandler')) { | |
| 84 msgHandlerObjectId = message['messageObjectId']; | |
| 85 } | 82 } |
| 86 } | 83 } |
| 87 expect(msgHandlerObjectId, isNotNull); | 84 expect(msgHandlerObjectId, isNotNull); |
| 88 | 85 |
| 89 // Get object. | 86 // Get object. |
| 90 var object = await isolate.getObject(msgHandlerObjectId); | 87 var object = await isolate.getObject(msgHandlerObjectId); |
| 91 expect(object.valueAsString, equals('34')); | 88 expect(object.valueAsString, equals('34')); |
| 92 } | 89 } |
| 93 | 90 |
| 94 ]; | 91 ]; |
| 95 | 92 |
| 96 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); | 93 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); |
| OLD | NEW |