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

Side by Side Diff: pkg/analysis_server/test/physical_resource_provider_test.dart

Issue 315953002: Give the watchers more time to detect changes, in physical_resource_provider_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months 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 | « no previous file | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library test.physical.resource.provider; 5 library test.physical.resource.provider;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 9
10 import 'package:analysis_server/src/resource.dart'; 10 import 'package:analysis_server/src/resource.dart';
(...skipping 15 matching lines...) Expand all
26 }); 26 });
27 27
28 tearDown(() { 28 tearDown(() {
29 tempDirectory.deleteSync(recursive: true); 29 tempDirectory.deleteSync(recursive: true);
30 }); 30 });
31 31
32 group('Watch', () { 32 group('Watch', () {
33 33
34 Future delayed(computation()) { 34 Future delayed(computation()) {
35 return new Future.delayed( 35 return new Future.delayed(
36 new Duration(milliseconds: 100), computation); 36 new Duration(seconds: 1), computation);
37 } 37 }
38 38
39 watchingFolder(String path, test(List<WatchEvent> changesReceived)) { 39 watchingFolder(String path, test(List<WatchEvent> changesReceived)) {
40 // Delay before we start watching the folder. This is necessary 40 // Delay before we start watching the folder. This is necessary
41 // because on MacOS, file modifications that occur just before we star t 41 // because on MacOS, file modifications that occur just before we
42 // watching are sometimes misclassified as happening just after we 42 // start watching are sometimes misclassified as happening just after
43 // start watching. 43 // we start watching.
44 return delayed(() { 44 return delayed(() {
45 Folder folder = PhysicalResourceProvider.INSTANCE.getResource(path); 45 Folder folder = PhysicalResourceProvider.INSTANCE.getResource(path);
46 var changesReceived = <WatchEvent>[]; 46 var changesReceived = <WatchEvent>[];
47 var subscription = folder.changes.listen(changesReceived.add); 47 var subscription = folder.changes.listen(changesReceived.add);
48 // Delay running the rest of the test to allow folder.changes to tak e 48 // Delay running the rest of the test to allow folder.changes to
49 // a snapshot of the current directory state. Otherwise it won't be 49 // take a snapshot of the current directory state. Otherwise it
50 // able to reliably distinguish new files from modified ones. 50 // won't be able to reliably distinguish new files from modified
51 // ones.
51 return delayed(() => test(changesReceived)).whenComplete(() { 52 return delayed(() => test(changesReceived)).whenComplete(() {
52 subscription.cancel(); 53 subscription.cancel();
53 }); 54 });
54 }); 55 });
55 } 56 }
56 57
57 test('create file', () => watchingFolder(tempPath, (changesReceived) { 58 test('create file', () => watchingFolder(tempPath, (changesReceived) {
58 expect(changesReceived, hasLength(0)); 59 expect(changesReceived, hasLength(0));
59 var path = join(tempPath, 'foo'); 60 var path = join(tempPath, 'foo');
60 new io.File(path).writeAsStringSync('contents'); 61 new io.File(path).writeAsStringSync('contents');
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 expect(children[1], _isFolder); 213 expect(children[1], _isFolder);
213 expect(children[2], _isFile); 214 expect(children[2], _isFile);
214 }); 215 });
215 }); 216 });
216 }); 217 });
217 } 218 }
218 219
219 var _isFile = new isInstanceOf<File>(); 220 var _isFile = new isInstanceOf<File>();
220 var _isFolder = new isInstanceOf<Folder>(); 221 var _isFolder = new isInstanceOf<Folder>();
221 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>(); 222 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698