| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.test.file_system.memory_file_system_test; | 5 library analyzer.test.file_system.memory_file_system_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:core' hide Resource; | 8 import 'dart:core' hide Resource; |
| 9 | 9 |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 expect(file.toString(), '/foo/bar/file.txt'); | 204 expect(file.toString(), '/foo/bar/file.txt'); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void test_toUri() { | 207 void test_toUri() { |
| 208 String path = '/foo/file.txt'; | 208 String path = '/foo/file.txt'; |
| 209 File file = provider.newFile(path, ''); | 209 File file = provider.newFile(path, ''); |
| 210 expect(file.toUri(), new Uri.file(path, windows: false)); | 210 expect(file.toUri(), new Uri.file(path, windows: false)); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void test_writeAsBytesSync_existing() { | 213 void test_writeAsBytesSync_existing() { |
| 214 File file = provider.newFileWithBytes('/foo/file.bin', <int>[1, 2]); | 214 List<int> content = <int>[1, 2]; |
| 215 expect(file.readAsBytesSync(), <int>[1, 2]); | 215 File file = provider.newFileWithBytes('/foo/file.bin', content); |
| 216 expect(file.readAsBytesSync(), content); |
| 216 // write new bytes | 217 // write new bytes |
| 217 file.writeAsBytesSync(<int>[10, 20]); | 218 content = <int>[10, 20]; |
| 218 expect(file.readAsBytesSync(), <int>[10, 20]); | 219 file.writeAsBytesSync(content); |
| 220 expect(file.readAsBytesSync(), content); |
| 219 } | 221 } |
| 220 | 222 |
| 221 void test_writeAsBytesSync_new() { | 223 void test_writeAsBytesSync_new() { |
| 222 File file = provider.getFile('/foo/file.bin'); | 224 File file = provider.getFile('/foo/file.bin'); |
| 223 expect(file.exists, false); | 225 expect(file.exists, false); |
| 224 // write new bytes | 226 // write new bytes |
| 225 file.writeAsBytesSync(<int>[10, 20]); | 227 List<int> content = <int>[10, 20]; |
| 228 file.writeAsBytesSync(content); |
| 226 expect(file.exists, true); | 229 expect(file.exists, true); |
| 227 expect(file.readAsBytesSync(), <int>[10, 20]); | 230 expect(file.readAsBytesSync(), content); |
| 231 } |
| 232 |
| 233 void test_writeAsStringSync_existing() { |
| 234 String content = 'ab'; |
| 235 File file = provider.newFile('/foo/file.txt', content); |
| 236 expect(file.readAsStringSync(), content); |
| 237 // write new bytes |
| 238 content = 'CD'; |
| 239 file.writeAsStringSync(content); |
| 240 expect(file.readAsStringSync(), content); |
| 241 } |
| 242 |
| 243 void test_writeAsStringSync_new() { |
| 244 File file = provider.getFile('/foo/file.txt'); |
| 245 expect(file.exists, false); |
| 246 // write new bytes |
| 247 String content = 'ef'; |
| 248 file.writeAsStringSync(content); |
| 249 expect(file.exists, true); |
| 250 expect(file.readAsStringSync(), content); |
| 228 } | 251 } |
| 229 } | 252 } |
| 230 | 253 |
| 231 @reflectiveTest | 254 @reflectiveTest |
| 232 class FolderTest { | 255 class FolderTest { |
| 233 static const String path = '/foo/bar'; | 256 static const String path = '/foo/bar'; |
| 234 | 257 |
| 235 MemoryResourceProvider provider = new MemoryResourceProvider(); | 258 MemoryResourceProvider provider = new MemoryResourceProvider(); |
| 236 Folder folder; | 259 Folder folder; |
| 237 | 260 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 return new Future.delayed(Duration.ZERO, computation); | 726 return new Future.delayed(Duration.ZERO, computation); |
| 704 } | 727 } |
| 705 | 728 |
| 706 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) { | 729 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) { |
| 707 Folder folder = provider.getResource(path); | 730 Folder folder = provider.getResource(path); |
| 708 var changesReceived = <WatchEvent>[]; | 731 var changesReceived = <WatchEvent>[]; |
| 709 folder.changes.listen(changesReceived.add); | 732 folder.changes.listen(changesReceived.add); |
| 710 return test(changesReceived); | 733 return test(changesReceived); |
| 711 } | 734 } |
| 712 } | 735 } |
| OLD | NEW |