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

Unified Diff: test/utils.dart

Issue 916533003: Add an Invoker class that manages a running test. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/invoker_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/utils.dart
diff --git a/test/utils.dart b/test/utils.dart
new file mode 100644
index 0000000000000000000000000000000000000000..17caceade76d789046cb438d4b71d0700521b302
--- /dev/null
+++ b/test/utils.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library unittest.test.utils;
+
+import 'dart:async';
+
+import 'package:unittest/unittest.dart';
+
+/// Returns a matcher that matches a [TestFailure] with the given [message].
+Matcher isTestFailure(String message) => predicate(
+ (error) => error is TestFailure && error.message == message,
+ 'is a TestFailure with message "$message"');
+
+/// Returns a [Future] that completes after pumping the event queue [times]
+/// times.
+///
+/// By default, this should pump the event queue enough times to allow any code
+/// to run, as long as it's not waiting on some external event.
+Future pumpEventQueue([int times=20]) {
+ if (times == 0) return new Future.value();
+ // Use [new Future] future to allow microtask events to finish. The [new
+ // Future.value] constructor uses scheduleMicrotask itself and would therefore
+ // not wait for microtask callbacks that are scheduled after invoking this
+ // method.
+ return new Future(() => pumpEventQueue(times - 1));
+}
« no previous file with comments | « test/invoker_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698