OLD | NEW |
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 'package:scheduled_test/scheduled_test.dart'; | 5 import 'package:scheduled_test/scheduled_test.dart'; |
6 import 'package:watcher/src/directory_watcher/linux.dart'; | 6 import 'package:watcher/src/directory_watcher/linux.dart'; |
7 import 'package:watcher/watcher.dart'; | 7 import 'package:watcher/watcher.dart'; |
8 | 8 |
9 import 'shared.dart'; | 9 import 'shared.dart'; |
10 import '../utils.dart'; | 10 import '../utils.dart'; |
11 | 11 |
12 main() { | 12 main() { |
13 initConfig(); | 13 initConfig(); |
14 | 14 |
15 watcherFactory = (dir) => new LinuxDirectoryWatcher(dir); | 15 watcherFactory = (dir) => new LinuxDirectoryWatcher(dir); |
16 | 16 |
17 setUp(createSandbox); | 17 setUp(createSandbox); |
18 | 18 |
19 sharedTests(); | 19 sharedTests(); |
20 | 20 |
21 test('DirectoryWatcher creates a LinuxDirectoryWatcher on Linux', () { | 21 test('DirectoryWatcher creates a LinuxDirectoryWatcher on Linux', () { |
22 expect(new DirectoryWatcher('.'), | 22 expect(new DirectoryWatcher('.'), |
23 new isInstanceOf<LinuxDirectoryWatcher>()); | 23 new isInstanceOf<LinuxDirectoryWatcher>()); |
24 }); | 24 }); |
25 | 25 |
26 test('notifies even if the file contents are unchanged', () { | |
27 writeFile("a.txt", contents: "same"); | |
28 writeFile("b.txt", contents: "before"); | |
29 startWatcher(); | |
30 writeFile("a.txt", contents: "same"); | |
31 writeFile("b.txt", contents: "after"); | |
32 expectModifyEvent("a.txt"); | |
33 expectModifyEvent("b.txt"); | |
34 }); | |
35 | |
36 test('emits events for many nested files moved out then immediately back in', | 26 test('emits events for many nested files moved out then immediately back in', |
37 () { | 27 () { |
38 withPermutations((i, j, k) => | 28 withPermutations((i, j, k) => |
39 writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt")); | 29 writeFile("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
40 startWatcher(dir: "dir"); | 30 startWatcher(dir: "dir"); |
41 | 31 |
42 renameDir("dir/sub", "sub"); | 32 renameDir("dir/sub", "sub"); |
43 renameDir("sub", "dir/sub"); | 33 renameDir("sub", "dir/sub"); |
44 | 34 |
45 inAnyOrder(() { | 35 inAnyOrder(() { |
46 withPermutations((i, j, k) => | 36 withPermutations((i, j, k) => |
47 expectRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); | 37 expectRemoveEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
48 }); | 38 }); |
49 | 39 |
50 inAnyOrder(() { | 40 inAnyOrder(() { |
51 withPermutations((i, j, k) => | 41 withPermutations((i, j, k) => |
52 expectAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); | 42 expectAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
53 }); | 43 }); |
54 }); | 44 }); |
55 } | 45 } |
OLD | NEW |