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

Unified Diff: test/backend/invoker_test.dart

Issue 1161873007: Refactor outstdanding callbacks in invoker.dart. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 7 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 | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/backend/invoker_test.dart
diff --git a/test/backend/invoker_test.dart b/test/backend/invoker_test.dart
index 05924569b767ba4f46078f464dbe0a6d185d4358..52ef5987c71aec69dbcb5287e7a8db4fda6b3b08 100644
--- a/test/backend/invoker_test.dart
+++ b/test/backend/invoker_test.dart
@@ -642,6 +642,42 @@ void main() {
});
});
});
+
+ group("waitForOutstandingCallbacks:", () {
+ test("waits for the wrapped function to complete", () async {
+ var functionCompleted = false;
+ await Invoker.current.waitForOutstandingCallbacks(() async {
+ await pumpEventQueue();
+ functionCompleted = true;
+ });
+
+ expect(functionCompleted, isTrue);
+ });
+
+ test("waits for registered callbacks in the wrapped function to run",
+ () async {
+ var callbackRun = false;
+ await Invoker.current.waitForOutstandingCallbacks(() {
+ pumpEventQueue().then(expectAsync((_) {
+ callbackRun = true;
+ }));
+ });
+
+ expect(callbackRun, isTrue);
+ });
+
+ test("doesn't automatically block the enclosing context", () async {
+ var innerFunctionCompleted = false;
+ await Invoker.current.waitForOutstandingCallbacks(() {
+ Invoker.current.waitForOutstandingCallbacks(() async {
+ await pumpEventQueue();
+ innerFunctionCompleted = true;
+ });
+ });
+
+ expect(innerFunctionCompleted, isFalse);
+ });
+ });
}
LocalTest _localTest(body(), {tearDown(), Metadata metadata}) {
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698