OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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/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 | 9 |
10 var tests = [ | 10 var tests = [ |
11 (Isolate isolate) async { | 11 (Isolate isolate) async { |
12 bool caughtException; | 12 bool caughtException; |
13 try { | 13 try { |
14 await isolate.invokeRpc('_respondWithMalformedObject', {}); | 14 await isolate.invokeRpc('_respondWithMalformedObject', {}); |
15 expect(false, isTrue, reason: 'Unreachable'); | 15 expect(false, isTrue, reason:'Unreachable'); |
16 } on MalformedResponseRpcException catch (e) { | 16 } on MalformedResponseRpcException catch (e) { |
17 caughtException = true; | 17 caughtException = true; |
18 expect(e.message, equals("Response is missing the 'type' field")); | 18 expect(e.message, equals("Response is missing the 'type' field")); |
19 } | 19 } |
20 expect(caughtException, isTrue); | 20 expect(caughtException, isTrue); |
21 }, | 21 }, |
22 | 22 |
23 // Do this test last... it kills the vm connection. | 23 // Do this test last... it kills the vm connection. |
24 (Isolate isolate) async { | 24 (Isolate isolate) async { |
25 bool caughtException; | 25 bool caughtException; |
26 try { | 26 try { |
27 await isolate.invokeRpc('_respondWithMalformedJson', {}); | 27 await isolate.invokeRpc('_respondWithMalformedJson', {}); |
28 expect(false, isTrue, reason: 'Unreachable'); | 28 expect(false, isTrue, reason:'Unreachable'); |
29 } on NetworkRpcException catch (e) { | 29 } on NetworkRpcException catch (e) { |
30 caughtException = true; | 30 caughtException = true; |
31 expect( | 31 expect(e.message, |
32 e.message, | 32 startsWith("Canceling request: " |
33 startsWith("Canceling request: " | 33 "Connection saw corrupt JSON message: " |
34 "Connection saw corrupt JSON message: " | 34 "FormatException: Unexpected character")); |
35 "FormatException: Unexpected character")); | |
36 } | 35 } |
37 expect(caughtException, isTrue); | 36 expect(caughtException, isTrue); |
38 }, | 37 }, |
39 ]; | 38 ]; |
40 | 39 |
41 main(args) => runIsolateTests(args, tests); | 40 main(args) => runIsolateTests(args, tests); |
OLD | NEW |