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

Side by Side Diff: pkg/watcher/test/utils.dart

Issue 441483004: pkg/watcher: prepare for 0.9.3 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 4 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
« pkg/watcher/pubspec.yaml ('K') | « pkg/watcher/test/ready/shared.dart ('k') | 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) 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 library watcher.test.utils; 5 library watcher.test.utils;
6 6
7 import 'dart:async';
8 import 'dart:io'; 7 import 'dart:io';
9 8
10 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
11 import 'package:scheduled_test/scheduled_stream.dart'; 10 import 'package:scheduled_test/scheduled_stream.dart';
12 import 'package:scheduled_test/scheduled_test.dart'; 11 import 'package:scheduled_test/scheduled_test.dart';
13 import 'package:unittest/compact_vm_config.dart'; 12 import 'package:unittest/compact_vm_config.dart';
14 import 'package:watcher/watcher.dart'; 13 import 'package:watcher/watcher.dart';
15 import 'package:watcher/src/stat.dart'; 14 import 'package:watcher/src/stat.dart';
16 import 'package:watcher/src/utils.dart'; 15 import 'package:watcher/src/utils.dart';
17 16
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 /// Returns a [Matcher] that matches a [WatchEvent] for a modification event for 242 /// Returns a [Matcher] that matches a [WatchEvent] for a modification event for
244 /// [path]. 243 /// [path].
245 Matcher isModifyEvent(String path) => isWatchEvent(ChangeType.MODIFY, path); 244 Matcher isModifyEvent(String path) => isWatchEvent(ChangeType.MODIFY, path);
246 245
247 /// Returns a [Matcher] that matches a [WatchEvent] for a removal event for 246 /// Returns a [Matcher] that matches a [WatchEvent] for a removal event for
248 /// [path]. 247 /// [path].
249 Matcher isRemoveEvent(String path) => isWatchEvent(ChangeType.REMOVE, path); 248 Matcher isRemoveEvent(String path) => isWatchEvent(ChangeType.REMOVE, path);
250 249
251 /// Expects that the next event emitted will be for an add event for [path]. 250 /// Expects that the next event emitted will be for an add event for [path].
252 void expectAddEvent(String path) => 251 void expectAddEvent(String path) =>
253 _expectOrCollect(isWatchEvent(ChangeType.ADD, path)); 252 _expectOrCollect(isWatchEvent(ChangeType.ADD, path));
254 253
255 /// Expects that the next event emitted will be for a modification event for 254 /// Expects that the next event emitted will be for a modification event for
256 /// [path]. 255 /// [path].
257 void expectModifyEvent(String path) => 256 void expectModifyEvent(String path) =>
258 _expectOrCollect(isWatchEvent(ChangeType.MODIFY, path)); 257 _expectOrCollect(isWatchEvent(ChangeType.MODIFY, path));
259 258
260 /// Expects that the next event emitted will be for a removal event for [path]. 259 /// Expects that the next event emitted will be for a removal event for [path].
261 void expectRemoveEvent(String path) => 260 void expectRemoveEvent(String path) =>
262 _expectOrCollect(isWatchEvent(ChangeType.REMOVE, path)); 261 _expectOrCollect(isWatchEvent(ChangeType.REMOVE, path));
263 262
264 /// Consumes an add event for [path] if one is emitted at this point in the 263 /// Consumes an add event for [path] if one is emitted at this point in the
265 /// schedule, but doesn't throw an error if it isn't. 264 /// schedule, but doesn't throw an error if it isn't.
266 /// 265 ///
267 /// If this is used at the end of a test, [startClosingEventStream] should be 266 /// If this is used at the end of a test, [startClosingEventStream] should be
268 /// called before it. 267 /// called before it.
269 void allowAddEvent(String path) => 268 void allowAddEvent(String path) =>
270 _expectOrCollect(allow(isWatchEvent(ChangeType.ADD, path))); 269 _expectOrCollect(allow(isWatchEvent(ChangeType.ADD, path)));
271 270
272 /// Consumes a modification event for [path] if one is emitted at this point in 271 /// Consumes a modification event for [path] if one is emitted at this point in
273 /// the schedule, but doesn't throw an error if it isn't. 272 /// the schedule, but doesn't throw an error if it isn't.
274 /// 273 ///
275 /// If this is used at the end of a test, [startClosingEventStream] should be 274 /// If this is used at the end of a test, [startClosingEventStream] should be
276 /// called before it. 275 /// called before it.
277 void allowModifyEvent(String path) => 276 void allowModifyEvent(String path) =>
278 _expectOrCollect(allow(isWatchEvent(ChangeType.MODIFY, path))); 277 _expectOrCollect(allow(isWatchEvent(ChangeType.MODIFY, path)));
279 278
280 /// Consumes a removal event for [path] if one is emitted at this point in the 279 /// Consumes a removal event for [path] if one is emitted at this point in the
281 /// schedule, but doesn't throw an error if it isn't. 280 /// schedule, but doesn't throw an error if it isn't.
282 /// 281 ///
283 /// If this is used at the end of a test, [startClosingEventStream] should be 282 /// If this is used at the end of a test, [startClosingEventStream] should be
284 /// called before it. 283 /// called before it.
285 void allowRemoveEvent(String path) => 284 void allowRemoveEvent(String path) =>
286 _expectOrCollect(allow(isWatchEvent(ChangeType.REMOVE, path))); 285 _expectOrCollect(allow(isWatchEvent(ChangeType.REMOVE, path)));
287 286
288 /// Schedules writing a file in the sandbox at [path] with [contents]. 287 /// Schedules writing a file in the sandbox at [path] with [contents].
289 /// 288 ///
290 /// If [contents] is omitted, creates an empty file. If [updatedModified] is 289 /// If [contents] is omitted, creates an empty file. If [updatedModified] is
291 /// `false`, the mock file modification time is not changed. 290 /// `false`, the mock file modification time is not changed.
292 void writeFile(String path, {String contents, bool updateModified}) { 291 void writeFile(String path, {String contents, bool updateModified}) {
293 if (contents == null) contents = ""; 292 if (contents == null) contents = "";
294 if (updateModified == null) updateModified = true; 293 if (updateModified == null) updateModified = true;
295 294
296 schedule(() { 295 schedule(() {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 var results = new Set(); 389 var results = new Set();
391 for (var i = 0; i < limit; i++) { 390 for (var i = 0; i < limit; i++) {
392 for (var j = 0; j < limit; j++) { 391 for (var j = 0; j < limit; j++) {
393 for (var k = 0; k < limit; k++) { 392 for (var k = 0; k < limit; k++) {
394 results.add(callback(i, j, k)); 393 results.add(callback(i, j, k));
395 } 394 }
396 } 395 }
397 } 396 }
398 return results; 397 return results;
399 } 398 }
OLDNEW
« pkg/watcher/pubspec.yaml ('K') | « pkg/watcher/test/ready/shared.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698