OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 4 |
5 library vmservice_test_helper; | 5 library vmservice_test_helper; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:json' as JSON; | |
11 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
12 | 11 |
13 abstract class VmServiceRequestHelper { | 12 abstract class VmServiceRequestHelper { |
14 final Uri uri; | 13 final Uri uri; |
15 final HttpClient client; | 14 final HttpClient client; |
16 | 15 |
17 VmServiceRequestHelper(String url) : | 16 VmServiceRequestHelper(String url) : |
18 uri = Uri.parse(url), | 17 uri = Uri.parse(url), |
19 client = new HttpClient(); | 18 client = new HttpClient(); |
20 | 19 |
(...skipping 17 matching lines...) Expand all Loading... |
38 var replyAsString; | 37 var replyAsString; |
39 try { | 38 try { |
40 replyAsString = UTF8.decode(data); | 39 replyAsString = UTF8.decode(data); |
41 } catch (e) { | 40 } catch (e) { |
42 onRequestFailed(e); | 41 onRequestFailed(e); |
43 return; | 42 return; |
44 } | 43 } |
45 print('** Response: $replyAsString'); | 44 print('** Response: $replyAsString'); |
46 var reply; | 45 var reply; |
47 try { | 46 try { |
48 reply = JSON.parse(replyAsString); | 47 reply = JSON.decode(replyAsString); |
49 } catch (e) { | 48 } catch (e) { |
50 onRequestFailed(e); | 49 onRequestFailed(e); |
51 return; | 50 return; |
52 } | 51 } |
53 if (reply is! Map) { | 52 if (reply is! Map) { |
54 onRequestFailed('Reply was not a map: $reply'); | 53 onRequestFailed('Reply was not a map: $reply'); |
55 return; | 54 return; |
56 } | 55 } |
57 if (reply['type'] == null) { | 56 if (reply['type'] == null) { |
58 onRequestFailed('Reply does not contain a type key: $reply'); | 57 onRequestFailed('Reply does not contain a type key: $reply'); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 if (isolate['id'] == id) { | 172 if (isolate['id'] == id) { |
174 exists = true; | 173 exists = true; |
175 Expect.isTrue(isolate['name'].startsWith(name), | 174 Expect.isTrue(isolate['name'].startsWith(name), |
176 'Isolate $id does not have name prefix: $name' | 175 'Isolate $id does not have name prefix: $name' |
177 ' (was ${isolate['name']})'); | 176 ' (was ${isolate['name']})'); |
178 } | 177 } |
179 }); | 178 }); |
180 Expect.isTrue(exists, 'No isolate with id: $id'); | 179 Expect.isTrue(exists, 'No isolate with id: $id'); |
181 } | 180 } |
182 } | 181 } |
OLD | NEW |