OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 import 'test_helper.dart'; | 9 import 'test_helper.dart'; |
10 | 10 |
11 var tests = [ | 11 var tests = [ |
12 // Write a file with the ? character in the filename. | 12 // Write a file with the ? character in the filename. |
13 (VM vm) async { | 13 (VM vm) async { |
14 var fsId = 'test'; | 14 var fsId = 'test'; |
15 var filePath = '/foo/bar?dat'; | 15 var filePath = '/foo/bar?dat'; |
16 var fileContents = BASE64.encode(UTF8.encode('fileContents')); | 16 var fileContents = BASE64.encode(UTF8.encode('fileContents')); |
17 | 17 |
18 var result; | 18 var result; |
19 // Create DevFS. | 19 // Create DevFS. |
20 result = await vm.invokeRpcNoUpgrade('_createDevFS', {'fsName': fsId}); | 20 result = await vm.invokeRpcNoUpgrade('_createDevFS', { 'fsName': fsId }); |
21 expect(result['type'], equals('FileSystem')); | 21 expect(result['type'], equals('FileSystem')); |
22 expect(result['name'], equals(fsId)); | 22 expect(result['name'], equals(fsId)); |
23 expect(result['uri'], new isInstanceOf<String>()); | 23 expect(result['uri'], new isInstanceOf<String>()); |
24 | 24 |
25 // Write the file. | 25 // Write the file. |
26 result = await vm.invokeRpcNoUpgrade('_writeDevFSFile', | 26 result = await vm.invokeRpcNoUpgrade('_writeDevFSFile', { |
27 {'fsName': fsId, 'path': filePath, 'fileContents': fileContents}); | 27 'fsName': fsId, |
| 28 'path': filePath, |
| 29 'fileContents': fileContents |
| 30 }); |
28 expect(result['type'], equals('Success')); | 31 expect(result['type'], equals('Success')); |
29 | 32 |
30 // Read the file back. | 33 // Read the file back. |
31 result = await vm.invokeRpcNoUpgrade('_readDevFSFile', { | 34 result = await vm.invokeRpcNoUpgrade('_readDevFSFile', { |
32 'fsName': fsId, | 35 'fsName': fsId, |
33 'path': filePath, | 36 'path': filePath, |
34 }); | 37 }); |
35 expect(result['type'], equals('FSFile')); | 38 expect(result['type'], equals('FSFile')); |
36 expect(result['fileContents'], equals(fileContents)); | 39 expect(result['fileContents'], equals(fileContents)); |
37 | 40 |
38 // List all the files in the file system. | 41 // List all the files in the file system. |
39 result = await vm.invokeRpcNoUpgrade('_listDevFSFiles', { | 42 result = await vm.invokeRpcNoUpgrade('_listDevFSFiles', { |
40 'fsName': fsId, | 43 'fsName': fsId, |
41 }); | 44 }); |
42 expect(result['type'], equals('FSFileList')); | 45 expect(result['type'], equals('FSFileList')); |
43 expect(result['files'].length, equals(1)); | 46 expect(result['files'].length, equals(1)); |
44 expect(result['files'][0]['name'], equals('/foo/bar?dat')); | 47 expect(result['files'][0]['name'], equals('/foo/bar?dat')); |
45 | 48 |
46 // Delete DevFS. | 49 // Delete DevFS. |
47 result = await vm.invokeRpcNoUpgrade('_deleteDevFS', { | 50 result = await vm.invokeRpcNoUpgrade('_deleteDevFS', { |
48 'fsName': fsId, | 51 'fsName': fsId, |
49 }); | 52 }); |
50 expect(result['type'], equals('Success')); | 53 expect(result['type'], equals('Success')); |
51 }, | 54 }, |
52 ]; | 55 ]; |
53 | 56 |
54 main(args) async => runVMTests(args, tests); | 57 main(args) async => runVMTests(args, tests); |
OLD | NEW |