OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'package:scheduled_test/scheduled_test.dart'; |
| 6 import 'package:watcher/src/directory_watcher/linux.dart'; |
| 7 import 'package:watcher/watcher.dart'; |
| 8 |
| 9 import 'shared.dart'; |
| 10 import '../utils.dart'; |
| 11 |
| 12 main() { |
| 13 initConfig(); |
| 14 |
| 15 watcherFactory = (dir) => new LinuxDirectoryWatcher(dir); |
| 16 |
| 17 setUp(() { |
| 18 // Increase the timeout because closing a [Directory.watch] stream blocks |
| 19 // the main isolate for a very long time on Goobuntu, as of kernel |
| 20 // 3.2.5-gg1336 (see issue 14606). |
| 21 currentSchedule.timeout *= 3; |
| 22 |
| 23 createSandbox(); |
| 24 }); |
| 25 |
| 26 sharedTests(); |
| 27 |
| 28 test('DirectoryWatcher creates a LinuxDirectoryWatcher on Linux', () { |
| 29 expect(new DirectoryWatcher('.'), |
| 30 new isInstanceOf<LinuxDirectoryWatcher>()); |
| 31 }); |
| 32 |
| 33 test('notifies even if the file contents are unchanged', () { |
| 34 writeFile("a.txt", contents: "same"); |
| 35 writeFile("b.txt", contents: "before"); |
| 36 startWatcher(); |
| 37 writeFile("a.txt", contents: "same"); |
| 38 writeFile("b.txt", contents: "after"); |
| 39 expectModifyEvent("a.txt"); |
| 40 expectModifyEvent("b.txt"); |
| 41 }); |
| 42 |
| 43 test('emits events for many nested files moved out then immediately back in', |
| 44 () { |
| 45 withPermutations((i, j, k) => |
| 46 writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
| 47 startWatcher(dir: "dir"); |
| 48 |
| 49 renameDir("dir/sub", "sub"); |
| 50 renameDir("sub", "dir/sub"); |
| 51 |
| 52 inAnyOrder(() { |
| 53 withPermutations((i, j, k) => |
| 54 expectRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
| 55 }); |
| 56 |
| 57 inAnyOrder(() { |
| 58 withPermutations((i, j, k) => |
| 59 expectAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
| 60 }); |
| 61 }); |
| 62 } |
OLD | NEW |