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

Side by Side Diff: tests/standalone/io/file_system_watcher_test.dart

Issue 52123002: Fire event and close the stream when the watched directory is moved. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Always listen for move self. Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file_system_watcher_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "dart:async"; 5 import "dart:async";
6 import "dart:io"; 6 import "dart:io";
7 7
8 import "package:async_helper/async_helper.dart"; 8 import "package:async_helper/async_helper.dart";
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import "package:path/path.dart"; 10 import "package:path/path.dart";
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 new Directory('__some_none_existing_dir__').watch() 293 new Directory('__some_none_existing_dir__').watch()
294 .listen((_) { 294 .listen((_) {
295 Expect.fail('unexpected error'); 295 Expect.fail('unexpected error');
296 }, onError: (e) { 296 }, onError: (e) {
297 asyncEnd(); 297 asyncEnd();
298 Expect.isTrue(e is FileSystemException); 298 Expect.isTrue(e is FileSystemException);
299 }); 299 });
300 } 300 }
301 301
302 302
303 void testWatchMoveSelf() {
304 // Windows keeps the directory handle open, even though it's deleted. It'll
305 // be flushed completely, once the watcher is closed as well.
306 if (Platform.isWindows) return;
307 var dir = Directory.systemTemp.createTempSync('dart_file_system_watcher');
308 var dir2 = new Directory(join(dir.path, 'dir'))..createSync();
309
310 var watcher = dir2.watch();
311
312 asyncStart();
313 var sub;
314 bool gotDelete = false;
315 sub = watcher.listen((event) {
316 if (event is FileSystemDeleteEvent) {
317 Expect.isTrue(event.path.endsWith('dir'));
318 gotDelete = true;
319 }
320 }, onDone: () {
321 Expect.isTrue(gotDelete);
322 dir.deleteSync(recursive: true);
323 asyncEnd();
324 });
325
326 dir2.renameSync(join(dir.path, 'new_dir'));
327 }
328
329
303 void main() { 330 void main() {
304 if (!FileSystemEntity.isWatchSupported) return; 331 if (!FileSystemEntity.isWatchSupported) return;
305 testWatchCreateFile(); 332 testWatchCreateFile();
306 testWatchCreateDir(); 333 testWatchCreateDir();
307 testWatchModifyFile(); 334 testWatchModifyFile();
308 testWatchMoveFile(); 335 testWatchMoveFile();
309 testWatchDeleteFile(); 336 testWatchDeleteFile();
310 testWatchDeleteDir(); 337 testWatchDeleteDir();
311 testWatchOnlyModifyFile(); 338 testWatchOnlyModifyFile();
312 testMultipleEvents(); 339 testMultipleEvents();
313 testWatchNonRecursive(); 340 testWatchNonRecursive();
314 testWatchNonExisting(); 341 testWatchNonExisting();
342 testWatchMoveSelf();
315 } 343 }
OLDNEW
« no previous file with comments | « runtime/bin/file_system_watcher_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698