OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/utils.dart'; | 6 import 'package:watcher/src/utils.dart'; |
7 | 7 |
8 import '../utils.dart'; | 8 import '../utils.dart'; |
9 | 9 |
10 void sharedTests() { | 10 void sharedTests() { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 expectAddEvent("dir/new.txt"); | 114 expectAddEvent("dir/new.txt"); |
115 }); | 115 }); |
116 | 116 |
117 test('notifies when a file is moved outside the watched directory', () { | 117 test('notifies when a file is moved outside the watched directory', () { |
118 writeFile("dir/old.txt"); | 118 writeFile("dir/old.txt"); |
119 startWatcher(dir: "dir"); | 119 startWatcher(dir: "dir"); |
120 | 120 |
121 renameFile("dir/old.txt", "new.txt"); | 121 renameFile("dir/old.txt", "new.txt"); |
122 expectRemoveEvent("dir/old.txt"); | 122 expectRemoveEvent("dir/old.txt"); |
123 }); | 123 }); |
| 124 |
| 125 test('notifies when a file is moved onto an existing one', () { |
| 126 writeFile("from.txt"); |
| 127 writeFile("to.txt"); |
| 128 startWatcher(); |
| 129 |
| 130 renameFile("from.txt", "to.txt"); |
| 131 inAnyOrder([ |
| 132 isRemoveEvent("from.txt"), |
| 133 isModifyEvent("to.txt") |
| 134 ]); |
| 135 }); |
124 }); | 136 }); |
125 | 137 |
126 // Most of the time, when multiple filesystem actions happen in sequence, | 138 // Most of the time, when multiple filesystem actions happen in sequence, |
127 // they'll be batched together and the watcher will see them all at once. | 139 // they'll be batched together and the watcher will see them all at once. |
128 // These tests verify that the watcher normalizes and combine these events | 140 // These tests verify that the watcher normalizes and combine these events |
129 // properly. However, very occasionally the events will be reported in | 141 // properly. However, very occasionally the events will be reported in |
130 // separate batches, and the watcher will report them as though they occurred | 142 // separate batches, and the watcher will report them as though they occurred |
131 // far apart in time, so each of these tests has a "backup case" to allow for | 143 // far apart in time, so each of these tests has a "backup case" to allow for |
132 // that as well. | 144 // that as well. |
133 group("clustered changes", () { | 145 group("clustered changes", () { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 deleteFile("dir/sub"); | 301 deleteFile("dir/sub"); |
290 renameDir("old", "dir/sub"); | 302 renameDir("old", "dir/sub"); |
291 | 303 |
292 var events = withPermutations((i, j, k) => | 304 var events = withPermutations((i, j, k) => |
293 isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); | 305 isAddEvent("dir/sub/sub-$i/sub-$j/file-$k.txt")); |
294 events.add(isRemoveEvent("dir/sub")); | 306 events.add(isRemoveEvent("dir/sub")); |
295 inAnyOrder(events); | 307 inAnyOrder(events); |
296 }); | 308 }); |
297 }); | 309 }); |
298 } | 310 } |
OLD | NEW |