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