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

Unified Diff: pkg/watcher/test/directory_watcher/linux_test.dart

Issue 46843003: Wrap Directory.watch on linux for the watcher package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/watcher/lib/watcher.dart ('k') | pkg/watcher/test/directory_watcher/polling_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/watcher/test/directory_watcher/linux_test.dart
diff --git a/pkg/watcher/test/directory_watcher/linux_test.dart b/pkg/watcher/test/directory_watcher/linux_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ba695698b64c4b7a5e9d6d431343b87db2b638b9
--- /dev/null
+++ b/pkg/watcher/test/directory_watcher/linux_test.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:scheduled_test/scheduled_test.dart';
+import 'package:watcher/src/directory_watcher/linux.dart';
+import 'package:watcher/watcher.dart';
+
+import 'shared.dart';
+import '../utils.dart';
+
+main() {
+ initConfig();
+
+ watcherFactory = (dir) => new LinuxDirectoryWatcher(dir);
+
+ setUp(() {
+ // Increase the timeout because closing a [Directory.watch] stream blocks
+ // the main isolate for a very long time on Goobuntu, as of kernel
+ // 3.2.5-gg1336 (see issue 14606).
+ currentSchedule.timeout *= 3;
+
+ createSandbox();
+ });
+
+ sharedTests();
+
+ test('DirectoryWatcher creates a LinuxDirectoryWatcher on Linux', () {
+ expect(new DirectoryWatcher('.'),
+ new isInstanceOf<LinuxDirectoryWatcher>());
+ });
+
+ test('notifies even if the file contents are unchanged', () {
+ writeFile("a.txt", contents: "same");
+ writeFile("b.txt", contents: "before");
+ startWatcher();
+ writeFile("a.txt", contents: "same");
+ writeFile("b.txt", contents: "after");
+ expectModifyEvent("a.txt");
+ expectModifyEvent("b.txt");
+ });
+
+ test('emits events for many nested files moved out then immediately back in',
+ () {
+ withPermutations((i, j, k) =>
+ writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt"));
+ startWatcher(dir: "dir");
+
+ renameDir("dir/sub", "sub");
+ renameDir("sub", "dir/sub");
+
+ inAnyOrder(() {
+ withPermutations((i, j, k) =>
+ expectRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt"));
+ });
+
+ inAnyOrder(() {
+ withPermutations((i, j, k) =>
+ expectAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt"));
+ });
+ });
+}
« no previous file with comments | « pkg/watcher/lib/watcher.dart ('k') | pkg/watcher/test/directory_watcher/polling_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698