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

Side by Side Diff: pkg/analyzer/test/file_system/memory_file_system_test.dart

Issue 2393663002: More fixes for testing under windows (Closed)
Patch Set: Created 4 years, 2 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) 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'; 8 import 'dart:core';
9 9
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 expect(exception.toString(), 42 expect(exception.toString(),
43 'FileSystemException(path=/my/path; message=my message)'); 43 'FileSystemException(path=/my/path; message=my message)');
44 } 44 }
45 } 45 }
46 46
47 @reflectiveTest 47 @reflectiveTest
48 class FileTest { 48 class FileTest {
49 MemoryResourceProvider provider = new MemoryResourceProvider(); 49 MemoryResourceProvider provider = new MemoryResourceProvider();
50 50
51 void test_delete() { 51 void test_delete() {
52 File file = provider.newFile('/foo/file.txt', 'content'); 52 File file =
53 provider.newFile(provider.convertPath('/foo/file.txt'), 'content');
53 expect(file.exists, isTrue); 54 expect(file.exists, isTrue);
54 // delete 55 // delete
55 file.delete(); 56 file.delete();
56 expect(file.exists, isFalse); 57 expect(file.exists, isFalse);
57 } 58 }
58 59
59 void test_equals_beforeAndAfterCreate() { 60 void test_equals_beforeAndAfterCreate() {
60 String path = '/file.txt'; 61 String path = provider.convertPath('/file.txt');
61 File file1 = provider.getResource(path); 62 File file1 = provider.getResource(path);
62 provider.newFile(path, 'contents'); 63 provider.newFile(path, 'contents');
63 File file2 = provider.getResource(path); 64 File file2 = provider.getResource(path);
64 expect(file1 == file2, isTrue); 65 expect(file1 == file2, isTrue);
65 } 66 }
66 67
67 void test_equals_false() { 68 void test_equals_false() {
68 File fileA = provider.getResource('/fileA.txt'); 69 File fileA = provider.getResource(provider.convertPath('/fileA.txt'));
69 File fileB = provider.getResource('/fileB.txt'); 70 File fileB = provider.getResource(provider.convertPath('/fileB.txt'));
70 expect(fileA == new Object(), isFalse); 71 expect(fileA == new Object(), isFalse);
71 expect(fileA == fileB, isFalse); 72 expect(fileA == fileB, isFalse);
72 } 73 }
73 74
74 void test_equals_true() { 75 void test_equals_true() {
75 File file = provider.getResource('/file.txt'); 76 File file = provider.getResource(provider.convertPath('/file.txt'));
76 expect(file == file, isTrue); 77 expect(file == file, isTrue);
77 } 78 }
78 79
79 void test_exists_false() { 80 void test_exists_false() {
80 File file = provider.getResource('/file.txt'); 81 File file = provider.getResource(provider.convertPath('/file.txt'));
81 expect(file, isNotNull); 82 expect(file, isNotNull);
82 expect(file.exists, isFalse); 83 expect(file.exists, isFalse);
83 } 84 }
84 85
85 void test_exists_true() { 86 void test_exists_true() {
86 provider.newFile('/foo/file.txt', 'qwerty'); 87 String path = provider.convertPath('/foo/file.txt');
87 File file = provider.getResource('/foo/file.txt'); 88 provider.newFile(path, 'qwerty');
89 File file = provider.getResource(path);
88 expect(file, isNotNull); 90 expect(file, isNotNull);
89 expect(file.exists, isTrue); 91 expect(file.exists, isTrue);
90 } 92 }
91 93
92 void test_fullName() { 94 void test_fullName() {
93 File file = provider.getResource('/foo/bar/file.txt'); 95 String path = provider.convertPath('/foo/bar/file.txt');
94 expect(file.path, '/foo/bar/file.txt'); 96 File file = provider.getResource(path);
97 expect(file.path, path);
95 } 98 }
96 99
97 void test_hashCode() { 100 void test_hashCode() {
98 String path = '/foo/bar/file.txt'; 101 String path = provider.convertPath('/foo/bar/file.txt');
99 File file1 = provider.getResource(path); 102 File file1 = provider.getResource(path);
100 provider.newFile(path, 'contents'); 103 provider.newFile(path, 'contents');
101 File file2 = provider.getResource(path); 104 File file2 = provider.getResource(path);
102 expect(file1.hashCode, equals(file2.hashCode)); 105 expect(file1.hashCode, equals(file2.hashCode));
103 } 106 }
104 107
105 void test_isOrContains() { 108 void test_isOrContains() {
106 String path = '/foo/bar/file.txt'; 109 String path = provider.convertPath('/foo/bar/file.txt');
107 File file = provider.getResource(path); 110 File file = provider.getResource(path);
108 expect(file.isOrContains(path), isTrue); 111 expect(file.isOrContains(path), isTrue);
109 expect(file.isOrContains('/foo/bar'), isFalse); 112 expect(file.isOrContains(provider.convertPath('/foo/bar')), isFalse);
110 } 113 }
111 114
112 void test_modificationStamp_doesNotExist() { 115 void test_modificationStamp_doesNotExist() {
113 String path = '/foo/bar/file.txt'; 116 String path = provider.convertPath('/foo/bar/file.txt');
114 File file = provider.newFile(path, 'qwerty'); 117 File file = provider.newFile(path, 'qwerty');
115 provider.deleteFile(path); 118 provider.deleteFile(path);
116 expect(() { 119 expect(() {
117 file.modificationStamp; 120 file.modificationStamp;
118 }, throwsA(_isFileSystemException)); 121 }, throwsA(_isFileSystemException));
119 } 122 }
120 123
121 void test_modificationStamp_exists() { 124 void test_modificationStamp_exists() {
122 String path = '/foo/bar/file.txt'; 125 String path = provider.convertPath('/foo/bar/file.txt');
123 File file = provider.newFile(path, 'qwerty'); 126 File file = provider.newFile(path, 'qwerty');
124 expect(file.modificationStamp, isNonNegative); 127 expect(file.modificationStamp, isNonNegative);
125 } 128 }
126 129
127 void test_parent() { 130 void test_parent() {
128 provider.newFile('/foo/bar/file.txt', 'content'); 131 String path = provider.convertPath('/foo/bar/file.txt');
129 File file = provider.getResource('/foo/bar/file.txt'); 132 provider.newFile(path, 'content');
133 File file = provider.getResource(path);
130 Resource parent = file.parent; 134 Resource parent = file.parent;
131 expect(parent, new isInstanceOf<Folder>()); 135 expect(parent, new isInstanceOf<Folder>());
132 expect(parent.path, equals('/foo/bar')); 136 expect(parent.path, equals(provider.convertPath('/foo/bar')));
133 } 137 }
134 138
135 void test_readAsBytesSync_doesNotExist() { 139 void test_readAsBytesSync_doesNotExist() {
136 File file = provider.getResource('/test.bin'); 140 File file = provider.getResource(provider.convertPath('/test.bin'));
137 expect(() { 141 expect(() {
138 file.readAsBytesSync(); 142 file.readAsBytesSync();
139 }, throwsA(_isFileSystemException)); 143 }, throwsA(_isFileSystemException));
140 } 144 }
141 145
142 void test_readAsBytesSync_exists() { 146 void test_readAsBytesSync_exists() {
143 List<int> bytes = <int>[1, 2, 3, 4, 5]; 147 List<int> bytes = <int>[1, 2, 3, 4, 5];
144 File file = provider.newFileWithBytes('/file.bin', bytes); 148 File file =
149 provider.newFileWithBytes(provider.convertPath('/file.bin'), bytes);
145 expect(file.readAsBytesSync(), bytes); 150 expect(file.readAsBytesSync(), bytes);
146 } 151 }
147 152
148 void test_readAsStringSync_doesNotExist() { 153 void test_readAsStringSync_doesNotExist() {
149 File file = provider.getResource('/test.txt'); 154 File file = provider.getResource(provider.convertPath('/test.txt'));
150 expect(() { 155 expect(() {
151 file.readAsStringSync(); 156 file.readAsStringSync();
152 }, throwsA(_isFileSystemException)); 157 }, throwsA(_isFileSystemException));
153 } 158 }
154 159
155 void test_readAsStringSync_exists() { 160 void test_readAsStringSync_exists() {
156 File file = provider.newFile('/file.txt', 'abc'); 161 File file = provider.newFile(provider.convertPath('/file.txt'), 'abc');
157 expect(file.readAsStringSync(), 'abc'); 162 expect(file.readAsStringSync(), 'abc');
158 } 163 }
159 164
160 void test_renameSync_newDoesNotExist() { 165 void test_renameSync_newDoesNotExist() {
161 String oldPath = '/foo/bar/file.txt'; 166 String oldPath = provider.convertPath('/foo/bar/file.txt');
162 String newPath = '/foo/bar/new-file.txt'; 167 String newPath = provider.convertPath('/foo/bar/new-file.txt');
163 File file = provider.newFile(oldPath, 'text'); 168 File file = provider.newFile(oldPath, 'text');
164 File newFile = file.renameSync(newPath); 169 File newFile = file.renameSync(newPath);
165 expect(file.path, oldPath); 170 expect(file.path, oldPath);
166 expect(file.exists, isFalse); 171 expect(file.exists, isFalse);
167 expect(newFile.path, newPath); 172 expect(newFile.path, newPath);
168 expect(newFile.exists, isTrue); 173 expect(newFile.exists, isTrue);
169 expect(newFile.readAsStringSync(), 'text'); 174 expect(newFile.readAsStringSync(), 'text');
170 } 175 }
171 176
172 void test_renameSync_newExists_file() { 177 void test_renameSync_newExists_file() {
173 String oldPath = '/foo/bar/file.txt'; 178 String oldPath = provider.convertPath('/foo/bar/file.txt');
174 String newPath = '/foo/bar/new-file.txt'; 179 String newPath = provider.convertPath('/foo/bar/new-file.txt');
175 File file = provider.newFile(oldPath, 'text'); 180 File file = provider.newFile(oldPath, 'text');
176 provider.newFile(newPath, 'new text'); 181 provider.newFile(newPath, 'new text');
177 File newFile = file.renameSync(newPath); 182 File newFile = file.renameSync(newPath);
178 expect(file.path, oldPath); 183 expect(file.path, oldPath);
179 expect(file.exists, isFalse); 184 expect(file.exists, isFalse);
180 expect(newFile.path, newPath); 185 expect(newFile.path, newPath);
181 expect(newFile.exists, isTrue); 186 expect(newFile.exists, isTrue);
182 expect(newFile.readAsStringSync(), 'text'); 187 expect(newFile.readAsStringSync(), 'text');
183 } 188 }
184 189
185 void test_renameSync_newExists_folder() { 190 void test_renameSync_newExists_folder() {
186 String oldPath = '/foo/bar/file.txt'; 191 String oldPath = provider.convertPath('/foo/bar/file.txt');
187 String newPath = '/foo/bar/baz'; 192 String newPath = provider.convertPath('/foo/bar/baz');
188 File file = provider.newFile(oldPath, 'text'); 193 File file = provider.newFile(oldPath, 'text');
189 provider.newFolder(newPath); 194 provider.newFolder(newPath);
190 expect(() { 195 expect(() {
191 file.renameSync(newPath); 196 file.renameSync(newPath);
192 }, throwsA(_isFileSystemException)); 197 }, throwsA(_isFileSystemException));
193 expect(file.path, oldPath); 198 expect(file.path, oldPath);
194 expect(file.exists, isTrue); 199 expect(file.exists, isTrue);
195 } 200 }
196 201
197 void test_resolveSymbolicLinksSync() { 202 void test_resolveSymbolicLinksSync() {
198 File file = provider.newFile('/test.txt', 'text'); 203 File file = provider.newFile(provider.convertPath('/test.txt'), 'text');
199 expect(file.resolveSymbolicLinksSync(), file); 204 expect(file.resolveSymbolicLinksSync(), file);
200 } 205 }
201 206
202 void test_shortName() { 207 void test_shortName() {
203 File file = provider.getResource('/foo/bar/file.txt'); 208 File file = provider.getResource(provider.convertPath('/foo/bar/file.txt'));
204 expect(file.shortName, 'file.txt'); 209 expect(file.shortName, 'file.txt');
205 } 210 }
206 211
207 void test_toString() { 212 void test_toString() {
208 File file = provider.getResource('/foo/bar/file.txt'); 213 String path = provider.convertPath('/foo/bar/file.txt');
209 expect(file.toString(), '/foo/bar/file.txt'); 214 File file = provider.getResource(path);
215 expect(file.toString(), path);
210 } 216 }
211 217
212 void test_toUri() { 218 void test_toUri() {
213 String path = '/foo/file.txt'; 219 String path = provider.convertPath('/foo/file.txt');
214 File file = provider.newFile(path, ''); 220 File file = provider.newFile(path, '');
215 expect(file.toUri(), new Uri.file(path, windows: false)); 221 expect(file.toUri(), provider.pathContext.toUri(path));
216 } 222 }
217 223
218 void test_writeAsBytesSync_existing() { 224 void test_writeAsBytesSync_existing() {
219 List<int> content = <int>[1, 2]; 225 List<int> content = <int>[1, 2];
220 File file = provider.newFileWithBytes('/foo/file.bin', content); 226 File file = provider.newFileWithBytes(
227 provider.convertPath('/foo/file.bin'), content);
221 expect(file.readAsBytesSync(), content); 228 expect(file.readAsBytesSync(), content);
222 // write new bytes 229 // write new bytes
223 content = <int>[10, 20]; 230 content = <int>[10, 20];
224 file.writeAsBytesSync(content); 231 file.writeAsBytesSync(content);
225 expect(file.readAsBytesSync(), content); 232 expect(file.readAsBytesSync(), content);
226 } 233 }
227 234
228 void test_writeAsBytesSync_new() { 235 void test_writeAsBytesSync_new() {
229 File file = provider.getFile('/foo/file.bin'); 236 File file = provider.getFile(provider.convertPath('/foo/file.bin'));
230 expect(file.exists, false); 237 expect(file.exists, false);
231 // write new bytes 238 // write new bytes
232 List<int> content = <int>[10, 20]; 239 List<int> content = <int>[10, 20];
233 file.writeAsBytesSync(content); 240 file.writeAsBytesSync(content);
234 expect(file.exists, true); 241 expect(file.exists, true);
235 expect(file.readAsBytesSync(), content); 242 expect(file.readAsBytesSync(), content);
236 } 243 }
237 244
238 void test_writeAsStringSync_existing() { 245 void test_writeAsStringSync_existing() {
239 String content = 'ab'; 246 String content = 'ab';
240 File file = provider.newFile('/foo/file.txt', content); 247 File file =
248 provider.newFile(provider.convertPath('/foo/file.txt'), content);
241 expect(file.readAsStringSync(), content); 249 expect(file.readAsStringSync(), content);
242 // write new bytes 250 // write new bytes
243 content = 'CD'; 251 content = 'CD';
244 file.writeAsStringSync(content); 252 file.writeAsStringSync(content);
245 expect(file.readAsStringSync(), content); 253 expect(file.readAsStringSync(), content);
246 } 254 }
247 255
248 void test_writeAsStringSync_new() { 256 void test_writeAsStringSync_new() {
249 File file = provider.getFile('/foo/file.txt'); 257 File file = provider.getFile(provider.convertPath('/foo/file.txt'));
250 expect(file.exists, false); 258 expect(file.exists, false);
251 // write new bytes 259 // write new bytes
252 String content = 'ef'; 260 String content = 'ef';
253 file.writeAsStringSync(content); 261 file.writeAsStringSync(content);
254 expect(file.exists, true); 262 expect(file.exists, true);
255 expect(file.readAsStringSync(), content); 263 expect(file.readAsStringSync(), content);
256 } 264 }
257 } 265 }
258 266
259 @reflectiveTest 267 @reflectiveTest
260 class FolderTest { 268 class FolderTest {
261 static const String path = '/foo/bar';
262
263 MemoryResourceProvider provider = new MemoryResourceProvider(); 269 MemoryResourceProvider provider = new MemoryResourceProvider();
270 String path;
264 Folder folder; 271 Folder folder;
265 272
266 void setUp() { 273 void setUp() {
274 path = provider.convertPath('/foo/bar');
267 folder = provider.newFolder(path); 275 folder = provider.newFolder(path);
268 } 276 }
269 277
270 void test_canonicalizePath() { 278 void test_canonicalizePath() {
271 expect(folder.canonicalizePath('baz'), equals('/foo/bar/baz')); 279 expect(folder.canonicalizePath(provider.convertPath('baz')),
272 expect(folder.canonicalizePath('/baz'), equals('/baz')); 280 equals(provider.convertPath('/foo/bar/baz')));
273 expect(folder.canonicalizePath('../baz'), equals('/foo/baz')); 281 expect(folder.canonicalizePath(provider.convertPath('/baz')),
274 expect(folder.canonicalizePath('/a/b/../c'), equals('/a/c')); 282 equals(provider.convertPath('/baz')));
275 expect(folder.canonicalizePath('./baz'), equals('/foo/bar/baz')); 283 expect(folder.canonicalizePath(provider.convertPath('../baz')),
276 expect(folder.canonicalizePath('/a/b/./c'), equals('/a/b/c')); 284 equals(provider.convertPath('/foo/baz')));
285 expect(folder.canonicalizePath(provider.convertPath('/a/b/../c')),
286 equals(provider.convertPath('/a/c')));
287 expect(folder.canonicalizePath(provider.convertPath('./baz')),
288 equals(provider.convertPath('/foo/bar/baz')));
289 expect(folder.canonicalizePath(provider.convertPath('/a/b/./c')),
290 equals(provider.convertPath('/a/b/c')));
277 } 291 }
278 292
279 void test_contains() { 293 void test_contains() {
280 expect(folder.contains('/foo/bar/aaa.txt'), isTrue); 294 expect(folder.contains(provider.convertPath('/foo/bar/aaa.txt')), isTrue);
281 expect(folder.contains('/foo/bar/aaa/bbb.txt'), isTrue); 295 expect(
282 expect(folder.contains('/baz.txt'), isFalse); 296 folder.contains(provider.convertPath('/foo/bar/aaa/bbb.txt')), isTrue);
283 expect(folder.contains('/foo/bar'), isFalse); 297 expect(folder.contains(provider.convertPath('/baz.txt')), isFalse);
298 expect(folder.contains(provider.convertPath('/foo/bar')), isFalse);
284 } 299 }
285 300
286 void test_delete() { 301 void test_delete() {
287 Folder folder = provider.newFolder('/foo'); 302 Folder folder = provider.newFolder(provider.convertPath('/foo'));
288 Folder barFolder = provider.newFolder('/foo/bar'); 303 Folder barFolder = provider.newFolder(provider.convertPath('/foo/bar'));
289 File aFile = provider.newFile('/foo/bar/a.txt', ''); 304 File aFile = provider.newFile(provider.convertPath('/foo/bar/a.txt'), '');
290 File bFile = provider.newFile('/foo/b.txt', ''); 305 File bFile = provider.newFile(provider.convertPath('/foo/b.txt'), '');
291 expect(folder.exists, isTrue); 306 expect(folder.exists, isTrue);
292 expect(barFolder.exists, isTrue); 307 expect(barFolder.exists, isTrue);
293 expect(aFile.exists, isTrue); 308 expect(aFile.exists, isTrue);
294 expect(bFile.exists, isTrue); 309 expect(bFile.exists, isTrue);
295 // delete 'folder' 310 // delete 'folder'
296 folder.delete(); 311 folder.delete();
297 expect(folder.exists, isFalse); 312 expect(folder.exists, isFalse);
298 expect(barFolder.exists, isFalse); 313 expect(barFolder.exists, isFalse);
299 expect(aFile.exists, isFalse); 314 expect(aFile.exists, isFalse);
300 expect(bFile.exists, isFalse); 315 expect(bFile.exists, isFalse);
301 } 316 }
302 317
303 void test_equal_false() { 318 void test_equal_false() {
304 String path2 = '/foo/baz'; 319 String path2 = provider.convertPath('/foo/baz');
305 Folder folder2 = provider.newFolder(path2); 320 Folder folder2 = provider.newFolder(path2);
306 expect(folder == folder2, isFalse); 321 expect(folder == folder2, isFalse);
307 } 322 }
308 323
309 void test_equal_true() { 324 void test_equal_true() {
310 Folder folder2 = provider.getResource(path); 325 Folder folder2 = provider.getResource(path);
311 expect(folder == folder2, isTrue); 326 expect(folder == folder2, isTrue);
312 } 327 }
313 328
314 void test_getChild_doesNotExist() { 329 void test_getChild_doesNotExist() {
315 File file = folder.getChild('file.txt'); 330 File file = folder.getChild('file.txt');
316 expect(file, isNotNull); 331 expect(file, isNotNull);
317 expect(file.exists, isFalse); 332 expect(file.exists, isFalse);
318 } 333 }
319 334
320 void test_getChild_file() { 335 void test_getChild_file() {
321 provider.newFile('/foo/bar/file.txt', 'content'); 336 provider.newFile(provider.convertPath('/foo/bar/file.txt'), 'content');
322 File child = folder.getChild('file.txt'); 337 File child = folder.getChild('file.txt');
323 expect(child, isNotNull); 338 expect(child, isNotNull);
324 expect(child.exists, isTrue); 339 expect(child.exists, isTrue);
325 } 340 }
326 341
327 void test_getChild_folder() { 342 void test_getChild_folder() {
328 provider.newFolder('/foo/bar/baz'); 343 provider.newFolder(provider.convertPath('/foo/bar/baz'));
329 Folder child = folder.getChild('baz'); 344 Folder child = folder.getChild('baz');
330 expect(child, isNotNull); 345 expect(child, isNotNull);
331 expect(child.exists, isTrue); 346 expect(child.exists, isTrue);
332 } 347 }
333 348
334 void test_getChildAssumingFile_doesNotExist() { 349 void test_getChildAssumingFile_doesNotExist() {
335 File child = folder.getChildAssumingFile('name'); 350 File child = folder.getChildAssumingFile('name');
336 expect(child, isNotNull); 351 expect(child, isNotNull);
337 expect(child.exists, isFalse); 352 expect(child.exists, isFalse);
338 } 353 }
339 354
340 void test_getChildAssumingFile_file() { 355 void test_getChildAssumingFile_file() {
341 provider.newFile('/foo/bar/name', 'content'); 356 provider.newFile(provider.convertPath('/foo/bar/name'), 'content');
342 File child = folder.getChildAssumingFile('name'); 357 File child = folder.getChildAssumingFile('name');
343 expect(child, isNotNull); 358 expect(child, isNotNull);
344 expect(child.exists, isTrue); 359 expect(child.exists, isTrue);
345 } 360 }
346 361
347 void test_getChildAssumingFile_folder() { 362 void test_getChildAssumingFile_folder() {
348 provider.newFolder('/foo/bar/name'); 363 provider.newFolder(provider.convertPath('/foo/bar/name'));
349 File child = folder.getChildAssumingFile('name'); 364 File child = folder.getChildAssumingFile('name');
350 expect(child, isNotNull); 365 expect(child, isNotNull);
351 expect(child.exists, isFalse); 366 expect(child.exists, isFalse);
352 } 367 }
353 368
354 void test_getChildAssumingFolder_doesNotExist() { 369 void test_getChildAssumingFolder_doesNotExist() {
355 Folder child = folder.getChildAssumingFolder('foldername'); 370 Folder child = folder.getChildAssumingFolder('foldername');
356 expect(child, isNotNull); 371 expect(child, isNotNull);
357 expect(child.exists, isFalse); 372 expect(child.exists, isFalse);
358 } 373 }
359 374
360 void test_getChildAssumingFolder_file() { 375 void test_getChildAssumingFolder_file() {
361 provider.newFile('/foo/bar/foldername', 'content'); 376 provider.newFile(provider.convertPath('/foo/bar/foldername'), 'content');
362 Folder child = folder.getChildAssumingFolder('foldername'); 377 Folder child = folder.getChildAssumingFolder('foldername');
363 expect(child, isNotNull); 378 expect(child, isNotNull);
364 expect(child.exists, isFalse); 379 expect(child.exists, isFalse);
365 } 380 }
366 381
367 void test_getChildAssumingFolder_folder() { 382 void test_getChildAssumingFolder_folder() {
368 provider.newFolder('/foo/bar/foldername'); 383 provider.newFolder(provider.convertPath('/foo/bar/foldername'));
369 Folder child = folder.getChildAssumingFolder('foldername'); 384 Folder child = folder.getChildAssumingFolder('foldername');
370 expect(child, isNotNull); 385 expect(child, isNotNull);
371 expect(child.exists, isTrue); 386 expect(child.exists, isTrue);
372 } 387 }
373 388
374 void test_getChildren_doesNotExist() { 389 void test_getChildren_doesNotExist() {
375 folder = folder.getChildAssumingFolder('no-such-folder'); 390 folder = folder.getChildAssumingFolder('no-such-folder');
376 expect(() { 391 expect(() {
377 folder.getChildren(); 392 folder.getChildren();
378 }, throwsA(_isFileSystemException)); 393 }, throwsA(_isFileSystemException));
379 } 394 }
380 395
381 void test_getChildren_exists() { 396 void test_getChildren_exists() {
382 provider.newFile('/foo/bar/a.txt', 'aaa'); 397 provider.newFile(provider.convertPath('/foo/bar/a.txt'), 'aaa');
383 provider.newFolder('/foo/bar/bFolder'); 398 provider.newFolder(provider.convertPath('/foo/bar/bFolder'));
384 provider.newFile('/foo/bar/c.txt', 'ccc'); 399 provider.newFile(provider.convertPath('/foo/bar/c.txt'), 'ccc');
385 // prepare 3 children 400 // prepare 3 children
386 List<Resource> children = folder.getChildren(); 401 List<Resource> children = folder.getChildren();
387 expect(children, hasLength(3)); 402 expect(children, hasLength(3));
388 children.sort((a, b) => a.shortName.compareTo(b.shortName)); 403 children.sort((a, b) => a.shortName.compareTo(b.shortName));
389 // check that each child exists 404 // check that each child exists
390 children.forEach((child) { 405 children.forEach((child) {
391 expect(child.exists, true); 406 expect(child.exists, true);
392 }); 407 });
393 // check names 408 // check names
394 expect(children[0].shortName, 'a.txt'); 409 expect(children[0].shortName, 'a.txt');
395 expect(children[1].shortName, 'bFolder'); 410 expect(children[1].shortName, 'bFolder');
396 expect(children[2].shortName, 'c.txt'); 411 expect(children[2].shortName, 'c.txt');
397 // check types 412 // check types
398 expect(children[0], _isFile); 413 expect(children[0], _isFile);
399 expect(children[1], _isFolder); 414 expect(children[1], _isFolder);
400 expect(children[2], _isFile); 415 expect(children[2], _isFile);
401 } 416 }
402 417
403 void test_hashCode() { 418 void test_hashCode() {
404 Folder folder2 = provider.getResource(path); 419 Folder folder2 = provider.getResource(path);
405 expect(folder.hashCode, folder2.hashCode); 420 expect(folder.hashCode, folder2.hashCode);
406 } 421 }
407 422
408 void test_isOrContains() { 423 void test_isOrContains() {
409 expect(folder.isOrContains('/foo/bar'), isTrue); 424 expect(folder.isOrContains(provider.convertPath('/foo/bar')), isTrue);
410 expect(folder.isOrContains('/foo/bar/aaa.txt'), isTrue); 425 expect(
411 expect(folder.isOrContains('/foo/bar/aaa/bbb.txt'), isTrue); 426 folder.isOrContains(provider.convertPath('/foo/bar/aaa.txt')), isTrue);
412 expect(folder.isOrContains('/baz.txt'), isFalse); 427 expect(folder.isOrContains(provider.convertPath('/foo/bar/aaa/bbb.txt')),
428 isTrue);
429 expect(folder.isOrContains(provider.convertPath('/baz.txt')), isFalse);
413 } 430 }
414 431
415 void test_parent() { 432 void test_parent() {
416 Resource parent1 = folder.parent; 433 Resource parent1 = folder.parent;
417 expect(parent1, new isInstanceOf<Folder>()); 434 expect(parent1, new isInstanceOf<Folder>());
418 expect(parent1.path, equals('/foo')); 435 expect(parent1.path, equals(provider.convertPath('/foo')));
419 Resource parent2 = parent1.parent; 436 Resource parent2 = parent1.parent;
420 expect(parent2, new isInstanceOf<Folder>()); 437 expect(parent2, new isInstanceOf<Folder>());
421 expect(parent2.path, equals('/')); 438 expect(parent2.path, equals(provider.convertPath('/')));
422 expect(parent2.parent, isNull); 439 expect(parent2.parent, isNull);
423 } 440 }
424 441
425 void test_toUri() { 442 void test_toUri() {
426 String path = '/foo/directory'; 443 String path = provider.convertPath('/foo/directory');
427 Folder folder = provider.newFolder(path); 444 Folder folder = provider.newFolder(path);
428 expect(folder.toUri(), new Uri.directory(path, windows: false)); 445 expect(folder.toUri(), provider.pathContext.toUri(path));
429 } 446 }
430 } 447 }
431 448
432 @reflectiveTest 449 @reflectiveTest
433 class MemoryFileSourceExistingTest { 450 class MemoryFileSourceExistingTest {
434 MemoryResourceProvider provider = new MemoryResourceProvider(); 451 MemoryResourceProvider provider = new MemoryResourceProvider();
452 String path;
435 Source source; 453 Source source;
436 454
437 setUp() { 455 setUp() {
438 File file = provider.newFile('/foo/test.dart', 'library test;'); 456 path = provider.convertPath('/foo/test.dart');
457 File file = provider.newFile(path, 'library test;');
439 source = file.createSource(); 458 source = file.createSource();
440 } 459 }
441 460
442 void test_contents() { 461 void test_contents() {
443 TimestampedData<String> contents = source.contents; 462 TimestampedData<String> contents = source.contents;
444 expect(contents.data, 'library test;'); 463 expect(contents.data, 'library test;');
445 } 464 }
446 465
447 void test_encoding() { 466 void test_encoding() {
448 expect(source.encoding, 'file:///foo/test.dart'); 467 String expected = 'file:///foo/test.dart';
468 if (provider.pathContext == windows) {
469 expected = 'file:///C:/foo/test.dart';
470 }
471 expect(source.encoding, expected);
449 } 472 }
450 473
451 void test_equals_false_differentFile() { 474 void test_equals_false_differentFile() {
452 File fileA = provider.newFile('/foo/a.dart', ''); 475 File fileA = provider.newFile(provider.convertPath('/foo/a.dart'), '');
453 File fileB = provider.newFile('/foo/b.dart', ''); 476 File fileB = provider.newFile(provider.convertPath('/foo/b.dart'), '');
454 Source sourceA = fileA.createSource(); 477 Source sourceA = fileA.createSource();
455 Source sourceB = fileB.createSource(); 478 Source sourceB = fileB.createSource();
456 expect(sourceA == sourceB, isFalse); 479 expect(sourceA == sourceB, isFalse);
457 } 480 }
458 481
459 void test_equals_false_notMemorySource() { 482 void test_equals_false_notMemorySource() {
460 File file = provider.newFile('/foo/test.dart', ''); 483 File file = provider.newFile(path, '');
461 Source source = file.createSource(); 484 Source source = file.createSource();
462 expect(source == new Object(), isFalse); 485 expect(source == new Object(), isFalse);
463 } 486 }
464 487
465 void test_equals_true_sameFile() { 488 void test_equals_true_sameFile() {
466 File file = provider.newFile('/foo/test.dart', ''); 489 File file = provider.newFile(path, '');
467 Source sourceA = file.createSource(); 490 Source sourceA = file.createSource();
468 Source sourceB = file.createSource(); 491 Source sourceB = file.createSource();
469 expect(sourceA == sourceB, isTrue); 492 expect(sourceA == sourceB, isTrue);
470 } 493 }
471 494
472 void test_equals_true_self() { 495 void test_equals_true_self() {
473 File file = provider.newFile('/foo/test.dart', ''); 496 File file = provider.newFile(path, '');
474 Source source = file.createSource(); 497 Source source = file.createSource();
475 expect(source == source, isTrue); 498 expect(source == source, isTrue);
476 } 499 }
477 500
478 void test_exists() { 501 void test_exists() {
479 expect(source.exists(), isTrue); 502 expect(source.exists(), isTrue);
480 } 503 }
481 504
482 void test_fullName() { 505 void test_fullName() {
483 expect(source.fullName, '/foo/test.dart'); 506 expect(source.fullName, path);
484 } 507 }
485 508
486 void test_hashCode() { 509 void test_hashCode() {
487 source.hashCode; 510 source.hashCode;
488 } 511 }
489 512
490 void test_resolveRelative() { 513 void test_resolveRelative() {
491 Uri relative = resolveRelativeUri(source.uri, new Uri.file('bar/baz.dart')); 514 Uri relative = resolveRelativeUri(
492 expect(relative.path, '/foo/bar/baz.dart'); 515 source.uri,
516 provider.pathContext
517 .toUri(provider.pathContext.join('bar', 'baz.dart')));
518 expect(relative,
519 provider.pathContext.toUri(provider.convertPath('/foo/bar/baz.dart')));
493 } 520 }
494 521
495 void test_resolveRelative_dart() { 522 void test_resolveRelative_dart() {
496 File file = provider.newFile('/sdk/lib/core/core.dart', ''); 523 File file =
524 provider.newFile(provider.convertPath('/sdk/lib/core/core.dart'), '');
497 Source source = file.createSource(Uri.parse('dart:core')); 525 Source source = file.createSource(Uri.parse('dart:core'));
498 Uri resolved = resolveRelativeUri(source.uri, Uri.parse('int.dart')); 526 Uri resolved = resolveRelativeUri(source.uri, Uri.parse('int.dart'));
499 expect(resolved.toString(), 'dart:core/int.dart'); 527 expect(resolved.toString(), 'dart:core/int.dart');
500 } 528 }
501 529
502 void test_shortName() { 530 void test_shortName() {
503 expect(source.shortName, 'test.dart'); 531 expect(source.shortName, 'test.dart');
504 } 532 }
505 } 533 }
506 534
507 @reflectiveTest 535 @reflectiveTest
508 class MemoryFileSourceNotExistingTest { 536 class MemoryFileSourceNotExistingTest {
509 MemoryResourceProvider provider = new MemoryResourceProvider(); 537 MemoryResourceProvider provider = new MemoryResourceProvider();
538 String path;
510 Source source; 539 Source source;
511 540
512 setUp() { 541 setUp() {
513 File file = provider.getResource('/foo/test.dart'); 542 path = provider.convertPath('/foo/test.dart');
543 File file = provider.getResource(path);
514 source = file.createSource(); 544 source = file.createSource();
515 } 545 }
516 546
517 void test_contents() { 547 void test_contents() {
518 expect(() { 548 expect(() {
519 source.contents; 549 source.contents;
520 }, throwsA(_isFileSystemException)); 550 }, throwsA(_isFileSystemException));
521 } 551 }
522 552
523 void test_encoding() { 553 void test_encoding() {
524 expect(source.encoding, 'file:///foo/test.dart'); 554 String expected = 'file:///foo/test.dart';
555 if (provider.pathContext == windows) {
556 expected = 'file:///C:/foo/test.dart';
557 }
558 expect(source.encoding, expected);
525 } 559 }
526 560
527 void test_exists() { 561 void test_exists() {
528 expect(source.exists(), isFalse); 562 expect(source.exists(), isFalse);
529 } 563 }
530 564
531 void test_fullName() { 565 void test_fullName() {
532 expect(source.fullName, '/foo/test.dart'); 566 expect(source.fullName, path);
533 } 567 }
534 568
535 void test_modificationStamp() { 569 void test_modificationStamp() {
536 expect(source.modificationStamp, -1); 570 expect(source.modificationStamp, -1);
537 } 571 }
538 572
539 void test_resolveRelative() { 573 void test_resolveRelative() {
540 Uri relative = resolveRelativeUri(source.uri, new Uri.file('bar/baz.dart')); 574 Uri relative = resolveRelativeUri(
541 expect(relative.path, '/foo/bar/baz.dart'); 575 source.uri,
576 provider.pathContext
577 .toUri(provider.pathContext.join('bar', 'baz.dart')));
578 expect(relative,
579 provider.pathContext.toUri(provider.convertPath('/foo/bar/baz.dart')));
542 } 580 }
543 581
544 void test_shortName() { 582 void test_shortName() {
545 expect(source.shortName, 'test.dart'); 583 expect(source.shortName, 'test.dart');
546 } 584 }
547 } 585 }
548 586
549 @reflectiveTest 587 @reflectiveTest
550 class MemoryResourceProviderTest { 588 class MemoryResourceProviderTest {
551 MemoryResourceProvider provider = new MemoryResourceProvider(); 589 MemoryResourceProvider provider = new MemoryResourceProvider();
552 590
553 void test_deleteFile_folder() { 591 void test_deleteFile_folder() {
554 String path = '/my/file'; 592 String path = provider.convertPath('/my/file');
555 provider.newFolder(path); 593 provider.newFolder(path);
556 expect(() { 594 expect(() {
557 provider.deleteFile(path); 595 provider.deleteFile(path);
558 }, throwsA(new isInstanceOf<ArgumentError>())); 596 }, throwsA(new isInstanceOf<ArgumentError>()));
559 expect(provider.getResource(path), new isInstanceOf<Folder>()); 597 expect(provider.getResource(path), new isInstanceOf<Folder>());
560 } 598 }
561 599
562 void test_deleteFile_notExistent() { 600 void test_deleteFile_notExistent() {
563 String path = '/my/file'; 601 String path = provider.convertPath('/my/file');
564 expect(() { 602 expect(() {
565 provider.deleteFile(path); 603 provider.deleteFile(path);
566 }, throwsA(new isInstanceOf<ArgumentError>())); 604 }, throwsA(new isInstanceOf<ArgumentError>()));
567 Resource file = provider.getResource(path); 605 Resource file = provider.getResource(path);
568 expect(file, isNotNull); 606 expect(file, isNotNull);
569 expect(file.exists, isFalse); 607 expect(file.exists, isFalse);
570 } 608 }
571 609
572 void test_deleteFile_success() { 610 void test_deleteFile_success() {
573 String path = '/my/file'; 611 String path = provider.convertPath('/my/file');
574 provider.newFile(path, 'contents'); 612 provider.newFile(path, 'contents');
575 Resource file = provider.getResource(path); 613 Resource file = provider.getResource(path);
576 expect(file, new isInstanceOf<File>()); 614 expect(file, new isInstanceOf<File>());
577 expect(file.exists, isTrue); 615 expect(file.exists, isTrue);
578 provider.deleteFile(path); 616 provider.deleteFile(path);
579 expect(file.exists, isFalse); 617 expect(file.exists, isFalse);
580 } 618 }
581 619
582 test_getModificationTimes() async { 620 test_getModificationTimes() async {
583 File file = provider.newFile('/test.dart', ''); 621 File file = provider.newFile(provider.convertPath('/test.dart'), '');
584 Source source = file.createSource(); 622 Source source = file.createSource();
585 List<int> times = await provider.getModificationTimes([source]); 623 List<int> times = await provider.getModificationTimes([source]);
586 expect(times, [source.modificationStamp]); 624 expect(times, [source.modificationStamp]);
587 } 625 }
588 626
589 void test_getStateLocation_uniqueness() { 627 void test_getStateLocation_uniqueness() {
590 String idOne = 'one'; 628 String idOne = 'one';
591 Folder folderOne = provider.getStateLocation(idOne); 629 Folder folderOne = provider.getStateLocation(idOne);
592 expect(folderOne, isNotNull); 630 expect(folderOne, isNotNull);
593 String idTwo = 'two'; 631 String idTwo = 'two';
594 Folder folderTwo = provider.getStateLocation(idTwo); 632 Folder folderTwo = provider.getStateLocation(idTwo);
595 expect(folderTwo, isNotNull); 633 expect(folderTwo, isNotNull);
596 expect(folderTwo, isNot(equals(folderOne))); 634 expect(folderTwo, isNot(equals(folderOne)));
597 expect(provider.getStateLocation(idOne), equals(folderOne)); 635 expect(provider.getStateLocation(idOne), equals(folderOne));
598 } 636 }
599 637
600 void test_modifyFile_isFolder() { 638 void test_modifyFile_isFolder() {
601 String path = '/my/file'; 639 String path = provider.convertPath('/my/file');
602 provider.newFolder(path); 640 provider.newFolder(path);
603 expect(() { 641 expect(() {
604 provider.modifyFile(path, 'contents'); 642 provider.modifyFile(path, 'contents');
605 }, throwsA(new isInstanceOf<ArgumentError>())); 643 }, throwsA(new isInstanceOf<ArgumentError>()));
606 expect(provider.getResource(path), new isInstanceOf<Folder>()); 644 expect(provider.getResource(path), new isInstanceOf<Folder>());
607 } 645 }
608 646
609 void test_modifyFile_notExistent() { 647 void test_modifyFile_notExistent() {
610 String path = '/my/file'; 648 String path = provider.convertPath('/my/file');
611 expect(() { 649 expect(() {
612 provider.modifyFile(path, 'contents'); 650 provider.modifyFile(path, 'contents');
613 }, throwsA(new isInstanceOf<ArgumentError>())); 651 }, throwsA(new isInstanceOf<ArgumentError>()));
614 Resource file = provider.getResource(path); 652 Resource file = provider.getResource(path);
615 expect(file, isNotNull); 653 expect(file, isNotNull);
616 expect(file.exists, isFalse); 654 expect(file.exists, isFalse);
617 } 655 }
618 656
619 void test_modifyFile_success() { 657 void test_modifyFile_success() {
620 String path = '/my/file'; 658 String path = provider.convertPath('/my/file');
621 provider.newFile(path, 'contents 1'); 659 provider.newFile(path, 'contents 1');
622 Resource file = provider.getResource(path); 660 Resource file = provider.getResource(path);
623 expect(file, new isInstanceOf<File>()); 661 expect(file, new isInstanceOf<File>());
624 Source source = (file as File).createSource(); 662 Source source = (file as File).createSource();
625 expect(source.contents.data, equals('contents 1')); 663 expect(source.contents.data, equals('contents 1'));
626 provider.modifyFile(path, 'contents 2'); 664 provider.modifyFile(path, 'contents 2');
627 expect(source.contents.data, equals('contents 2')); 665 expect(source.contents.data, equals('contents 2'));
628 } 666 }
629 667
630 void test_newFileWithBytes() { 668 void test_newFileWithBytes() {
631 String path = '/my/file'; 669 String path = provider.convertPath('/my/file');
632 List<int> bytes = <int>[1, 2, 3, 4, 5]; 670 List<int> bytes = <int>[1, 2, 3, 4, 5];
633 provider.newFileWithBytes(path, bytes); 671 provider.newFileWithBytes(path, bytes);
634 File file = provider.getResource(path); 672 File file = provider.getResource(path);
635 expect(file, isNotNull); 673 expect(file, isNotNull);
636 expect(file.exists, isTrue); 674 expect(file.exists, isTrue);
637 expect(file.readAsBytesSync(), bytes); 675 expect(file.readAsBytesSync(), bytes);
638 } 676 }
639 677
640 void test_newFolder_alreadyExists_asFile() { 678 void test_newFolder_alreadyExists_asFile() {
641 provider.newFile('/my/file', 'qwerty'); 679 provider.newFile(provider.convertPath('/my/file'), 'qwerty');
642 expect(() { 680 expect(() {
643 provider.newFolder('/my/file'); 681 provider.newFolder(provider.convertPath('/my/file'));
644 }, throwsA(new isInstanceOf<ArgumentError>())); 682 }, throwsA(new isInstanceOf<ArgumentError>()));
645 } 683 }
646 684
647 void test_newFolder_alreadyExists_asFolder() { 685 void test_newFolder_alreadyExists_asFolder() {
648 Folder folder = provider.newFolder('/my/folder'); 686 String path = provider.convertPath('/my/folder');
649 Folder newFolder = provider.newFolder('/my/folder'); 687 Folder folder = provider.newFolder(path);
688 Folder newFolder = provider.newFolder(path);
650 expect(newFolder, folder); 689 expect(newFolder, folder);
651 } 690 }
652 691
653 void test_newFolder_emptyPath() { 692 void test_newFolder_emptyPath() {
654 expect(() { 693 expect(() {
655 provider.newFolder(''); 694 provider.newFolder('');
656 }, throwsA(new isInstanceOf<ArgumentError>())); 695 }, throwsA(new isInstanceOf<ArgumentError>()));
657 } 696 }
658 697
659 void test_newFolder_notAbsolute() { 698 void test_newFolder_notAbsolute() {
660 expect(() { 699 expect(() {
661 provider.newFolder('not/absolute'); 700 provider.newFolder('not/absolute');
662 }, throwsA(new isInstanceOf<ArgumentError>())); 701 }, throwsA(new isInstanceOf<ArgumentError>()));
663 } 702 }
664 703
665 test_watch_createFile() { 704 test_watch_createFile() {
666 String rootPath = '/my/path'; 705 String rootPath = provider.convertPath('/my/path');
667 provider.newFolder(rootPath); 706 provider.newFolder(rootPath);
668 return _watchingFolder(rootPath, (changesReceived) { 707 return _watchingFolder(rootPath, (changesReceived) {
669 expect(changesReceived, hasLength(0)); 708 expect(changesReceived, hasLength(0));
670 String path = posix.join(rootPath, 'foo'); 709 String path = provider.pathContext.join(rootPath, 'foo');
671 provider.newFile(path, 'contents'); 710 provider.newFile(path, 'contents');
672 return _delayed(() { 711 return _delayed(() {
673 expect(changesReceived, hasLength(1)); 712 expect(changesReceived, hasLength(1));
674 expect(changesReceived[0].type, equals(ChangeType.ADD)); 713 expect(changesReceived[0].type, equals(ChangeType.ADD));
675 expect(changesReceived[0].path, equals(path)); 714 expect(changesReceived[0].path, equals(path));
676 }); 715 });
677 }); 716 });
678 } 717 }
679 718
680 test_watch_deleteFile() { 719 test_watch_deleteFile() {
681 String rootPath = '/my/path'; 720 String rootPath = provider.convertPath('/my/path');
682 provider.newFolder(rootPath); 721 provider.newFolder(rootPath);
683 String path = posix.join(rootPath, 'foo'); 722 String path = provider.pathContext.join(rootPath, 'foo');
684 provider.newFile(path, 'contents 1'); 723 provider.newFile(path, 'contents 1');
685 return _watchingFolder(rootPath, (changesReceived) { 724 return _watchingFolder(rootPath, (changesReceived) {
686 expect(changesReceived, hasLength(0)); 725 expect(changesReceived, hasLength(0));
687 provider.deleteFile(path); 726 provider.deleteFile(path);
688 return _delayed(() { 727 return _delayed(() {
689 expect(changesReceived, hasLength(1)); 728 expect(changesReceived, hasLength(1));
690 expect(changesReceived[0].type, equals(ChangeType.REMOVE)); 729 expect(changesReceived[0].type, equals(ChangeType.REMOVE));
691 expect(changesReceived[0].path, equals(path)); 730 expect(changesReceived[0].path, equals(path));
692 }); 731 });
693 }); 732 });
694 } 733 }
695 734
696 test_watch_modifyFile() { 735 test_watch_modifyFile() {
697 String rootPath = '/my/path'; 736 String rootPath = provider.convertPath('/my/path');
698 provider.newFolder(rootPath); 737 provider.newFolder(rootPath);
699 String path = posix.join(rootPath, 'foo'); 738 String path = provider.pathContext.join(rootPath, 'foo');
700 provider.newFile(path, 'contents 1'); 739 provider.newFile(path, 'contents 1');
701 return _watchingFolder(rootPath, (changesReceived) { 740 return _watchingFolder(rootPath, (changesReceived) {
702 expect(changesReceived, hasLength(0)); 741 expect(changesReceived, hasLength(0));
703 provider.modifyFile(path, 'contents 2'); 742 provider.modifyFile(path, 'contents 2');
704 return _delayed(() { 743 return _delayed(() {
705 expect(changesReceived, hasLength(1)); 744 expect(changesReceived, hasLength(1));
706 expect(changesReceived[0].type, equals(ChangeType.MODIFY)); 745 expect(changesReceived[0].type, equals(ChangeType.MODIFY));
707 expect(changesReceived[0].path, equals(path)); 746 expect(changesReceived[0].path, equals(path));
708 }); 747 });
709 }); 748 });
710 } 749 }
711 750
712 test_watch_modifyFile_inSubDir() { 751 test_watch_modifyFile_inSubDir() {
713 String rootPath = '/my/path'; 752 String rootPath = provider.convertPath('/my/path');
714 provider.newFolder(rootPath); 753 provider.newFolder(rootPath);
715 String subdirPath = posix.join(rootPath, 'foo'); 754 String subdirPath = provider.pathContext.join(rootPath, 'foo');
716 provider.newFolder(subdirPath); 755 provider.newFolder(subdirPath);
717 String path = posix.join(rootPath, 'bar'); 756 String path = provider.pathContext.join(rootPath, 'bar');
718 provider.newFile(path, 'contents 1'); 757 provider.newFile(path, 'contents 1');
719 return _watchingFolder(rootPath, (changesReceived) { 758 return _watchingFolder(rootPath, (changesReceived) {
720 expect(changesReceived, hasLength(0)); 759 expect(changesReceived, hasLength(0));
721 provider.modifyFile(path, 'contents 2'); 760 provider.modifyFile(path, 'contents 2');
722 return _delayed(() { 761 return _delayed(() {
723 expect(changesReceived, hasLength(1)); 762 expect(changesReceived, hasLength(1));
724 expect(changesReceived[0].type, equals(ChangeType.MODIFY)); 763 expect(changesReceived[0].type, equals(ChangeType.MODIFY));
725 expect(changesReceived[0].path, equals(path)); 764 expect(changesReceived[0].path, equals(path));
726 }); 765 });
727 }); 766 });
728 } 767 }
729 768
730 Future _delayed(computation()) { 769 Future _delayed(computation()) {
731 return new Future.delayed(Duration.ZERO, computation); 770 return new Future.delayed(Duration.ZERO, computation);
732 } 771 }
733 772
734 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) { 773 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) {
735 Folder folder = provider.getResource(path); 774 Folder folder = provider.getResource(path);
736 var changesReceived = <WatchEvent>[]; 775 var changesReceived = <WatchEvent>[];
737 folder.changes.listen(changesReceived.add); 776 folder.changes.listen(changesReceived.add);
738 return test(changesReceived); 777 return test(changesReceived);
739 } 778 }
740 } 779 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/file_system/memory_file_system.dart ('k') | pkg/analyzer/test/file_system/resource_uri_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698