Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Side by Side Diff: runtime/observatory/tests/service/dev_fs_uri_test.dart

Issue 2767533002: Revert "Fix observatory tests broken by running dartfmt." (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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:async'; 6 import 'dart:async';
7 import 'dart:convert'; 7 import 'dart:convert';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'package:observatory/service_io.dart'; 9 import 'package:observatory/service_io.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 import 'test_helper.dart'; 11 import 'test_helper.dart';
12 12
13 Future<String> readResponse(HttpClientResponse response) { 13 Future<String> readResponse(HttpClientResponse response) {
14 var completer = new Completer(); 14 var completer = new Completer();
15 var contents = new StringBuffer(); 15 var contents = new StringBuffer();
16 response.transform(UTF8.decoder).listen((String data) { 16 response.transform(UTF8.decoder).listen((String data) {
17 contents.write(data); 17 contents.write(data);
18 }, onDone: () => completer.complete(contents.toString())); 18 }, onDone: () => completer.complete(contents.toString()));
19 return completer.future; 19 return completer.future;
20 } 20 }
21 21
22
22 var tests = [ 23 var tests = [
23 // Write a file with the ? character in the filename. 24 // Write a file with the ? character in the filename.
24 (VM vm) async { 25 (VM vm) async {
25 var fsId = 'test'; 26 var fsId = 'test';
26 // NOTE: When using the URI encoding scheme, paths cannot be absolute. 27 // NOTE: When using the URI encoding scheme, paths cannot be absolute.
27 var filePath = 'foo/bar.dat'; 28 var filePath = 'foo/bar.dat';
28 var fileUri = Uri.parse(filePath); 29 var fileUri = Uri.parse(filePath);
29 var fileUriBase64 = BASE64.encode(UTF8.encode(fileUri.toString())); 30 var fileUriBase64 = BASE64.encode(UTF8.encode(fileUri.toString()));
30 var fileContents = [0, 1, 2, 3, 4, 5, 6, 255]; 31 var fileContents = [0, 1, 2, 3, 4, 5, 6, 255];
31 var fileContentsBase64 = BASE64.encode(fileContents); 32 var fileContentsBase64 = BASE64.encode(fileContents);
32 33
33 var filePath2 = 'baz/boo.dat'; 34 var filePath2 = 'baz/boo.dat';
34 var fileUri2 = Uri.parse(filePath2); 35 var fileUri2 = Uri.parse(filePath2);
35 36
36 var result; 37 var result;
37 // Create DevFS. 38 // Create DevFS.
38 result = await vm.invokeRpcNoUpgrade('_createDevFS', {'fsName': fsId}); 39 result = await vm.invokeRpcNoUpgrade('_createDevFS', { 'fsName': fsId });
39 expect(result['type'], equals('FileSystem')); 40 expect(result['type'], equals('FileSystem'));
40 expect(result['name'], equals(fsId)); 41 expect(result['name'], equals(fsId));
41 expect(result['uri'], new isInstanceOf<String>()); 42 expect(result['uri'], new isInstanceOf<String>());
42 43
43 // Write the file by issuing an HTTP PUT. 44 // Write the file by issuing an HTTP PUT.
44 HttpClient client = new HttpClient(); 45 HttpClient client = new HttpClient();
45 HttpClientRequest request = 46 HttpClientRequest request =
46 await client.putUrl(Uri.parse(serviceHttpAddress)); 47 await client.putUrl(Uri.parse(serviceHttpAddress));
47 request.headers.add('dev_fs_name', fsId); 48 request.headers.add('dev_fs_name', fsId);
48 request.headers.add('dev_fs_uri_b64', fileUriBase64); 49 request.headers.add('dev_fs_uri_b64', fileUriBase64);
(...skipping 11 matching lines...) Expand all
60 request.write(GZIP.encode(fileContents)); 61 request.write(GZIP.encode(fileContents));
61 response = await request.close(); 62 response = await request.close();
62 responseBody = await readResponse(response); 63 responseBody = await readResponse(response);
63 result = JSON.decode(responseBody); 64 result = JSON.decode(responseBody);
64 Map error = result['error']['data']; 65 Map error = result['error']['data'];
65 expect(error, isNotNull); 66 expect(error, isNotNull);
66 expect(error['details'].contains("expects the 'path' parameter"), isTrue); 67 expect(error['details'].contains("expects the 'path' parameter"), isTrue);
67 68
68 // Write the file again but this time with the true file contents. 69 // Write the file again but this time with the true file contents.
69 client = new HttpClient(); 70 client = new HttpClient();
70 request = await client.putUrl(Uri.parse(serviceHttpAddress)); 71 request =
72 await client.putUrl(Uri.parse(serviceHttpAddress));
71 request.headers.add('dev_fs_name', fsId); 73 request.headers.add('dev_fs_name', fsId);
72 request.headers.add('dev_fs_uri_b64', fileUriBase64); 74 request.headers.add('dev_fs_uri_b64', fileUriBase64);
73 request.add(GZIP.encode(fileContents)); 75 request.add(GZIP.encode(fileContents));
74 response = await request.close(); 76 response = await request.close();
75 responseBody = await readResponse(response); 77 responseBody = await readResponse(response);
76 result = JSON.decode(responseBody); 78 result = JSON.decode(responseBody);
77 expect(result['result']['type'], equals('Success')); 79 expect(result['result']['type'], equals('Success'));
78 80
79 // Close the HTTP client. 81 // Close the HTTP client.
80 client.close(); 82 client.close();
81 83
82 // Read the file back. 84 // Read the file back.
83 result = await vm.invokeRpcNoUpgrade('_readDevFSFile', { 85 result = await vm.invokeRpcNoUpgrade('_readDevFSFile', {
84 'fsName': fsId, 86 'fsName': fsId,
85 'uri': fileUri.toString(), 87 'uri': fileUri.toString(),
86 }); 88 });
87 expect(result['type'], equals('FSFile')); 89 expect(result['type'], equals('FSFile'));
88 expect(result['fileContents'], equals(fileContentsBase64)); 90 expect(result['fileContents'], equals(fileContentsBase64));
89 91
90 // Write a second file via URI. 92 // Write a second file via URI.
91 result = await vm.invokeRpcNoUpgrade('_writeDevFSFile', { 93 result = await vm.invokeRpcNoUpgrade('_writeDevFSFile', {
92 'fsName': fsId, 94 'fsName': fsId,
93 'uri': fileUri2.toString(), 95 'uri': fileUri2.toString(),
94 'fileContents': fileContentsBase64 96 'fileContents': fileContentsBase64
95 }); 97 });
96 98
97 // Read the second file back. 99 // Read the second file back.
98 result = await vm.invokeRpcNoUpgrade('_readDevFSFile', { 100 result = await vm.invokeRpcNoUpgrade('_readDevFSFile', {
99 'fsName': fsId, 101 'fsName': fsId,
100 'uri': fileUri2.toString(), 102 'uri': fileUri2.toString(),
101 }); 103 });
102 expect(result['type'], equals('FSFile')); 104 expect(result['type'], equals('FSFile'));
103 expect(result['fileContents'], equals(fileContentsBase64)); 105 expect(result['fileContents'], equals(fileContentsBase64));
104 106
105 // Delete DevFS. 107 // Delete DevFS.
106 result = await vm.invokeRpcNoUpgrade('_deleteDevFS', { 108 result = await vm.invokeRpcNoUpgrade('_deleteDevFS', {
107 'fsName': fsId, 109 'fsName': fsId,
108 }); 110 });
109 expect(result['type'], equals('Success')); 111 expect(result['type'], equals('Success'));
110 }, 112 },
111 ]; 113 ];
112 114
113 main(args) async => runVMTests(args, tests); 115 main(args) async => runVMTests(args, tests);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/dev_fs_test.dart ('k') | runtime/observatory/tests/service/dev_fs_weird_char_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698