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, | 27 {'fsName': fsId, 'path': filePath, 'fileContents': fileContents}); |
28 'path': filePath, | |
29 'fileContents': fileContents | |
30 }); | |
31 expect(result['type'], equals('Success')); | 28 expect(result['type'], equals('Success')); |
32 | 29 |
33 // Read the file back. | 30 // Read the file back. |
34 result = await vm.invokeRpcNoUpgrade('_readDevFSFile', { | 31 result = await vm.invokeRpcNoUpgrade('_readDevFSFile', { |
35 'fsName': fsId, | 32 'fsName': fsId, |
36 'path': filePath, | 33 'path': filePath, |
37 }); | 34 }); |
38 expect(result['type'], equals('FSFile')); | 35 expect(result['type'], equals('FSFile')); |
39 expect(result['fileContents'], equals(fileContents)); | 36 expect(result['fileContents'], equals(fileContents)); |
40 | 37 |
41 // List all the files in the file system. | 38 // List all the files in the file system. |
42 result = await vm.invokeRpcNoUpgrade('_listDevFSFiles', { | 39 result = await vm.invokeRpcNoUpgrade('_listDevFSFiles', { |
43 'fsName': fsId, | 40 'fsName': fsId, |
44 }); | 41 }); |
45 expect(result['type'], equals('FSFileList')); | 42 expect(result['type'], equals('FSFileList')); |
46 expect(result['files'].length, equals(1)); | 43 expect(result['files'].length, equals(1)); |
47 expect(result['files'][0]['name'], equals('/foo/bar?dat')); | 44 expect(result['files'][0]['name'], equals('/foo/bar?dat')); |
48 | 45 |
49 // Delete DevFS. | 46 // Delete DevFS. |
50 result = await vm.invokeRpcNoUpgrade('_deleteDevFS', { | 47 result = await vm.invokeRpcNoUpgrade('_deleteDevFS', { |
51 'fsName': fsId, | 48 'fsName': fsId, |
52 }); | 49 }); |
53 expect(result['type'], equals('Success')); | 50 expect(result['type'], equals('Success')); |
54 }, | 51 }, |
55 ]; | 52 ]; |
56 | 53 |
57 main(args) async => runVMTests(args, tests); | 54 main(args) async => runVMTests(args, tests); |
OLD | NEW |