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

Unified Diff: samples/tests/samples/src/dartcombat/DartCombatTest.dart

Issue 10031022: step 1 in making unittest platform independent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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
Index: samples/tests/samples/src/dartcombat/DartCombatTest.dart
diff --git a/samples/tests/samples/src/dartcombat/DartCombatTest.dart b/samples/tests/samples/src/dartcombat/DartCombatTest.dart
index 106980815e3c5dd03e032943a450e759d5d7c037..d50adcfb7a17e4e50d7dd8afb04c3565324f3edc 100644
--- a/samples/tests/samples/src/dartcombat/DartCombatTest.dart
+++ b/samples/tests/samples/src/dartcombat/DartCombatTest.dart
@@ -46,7 +46,7 @@ main() {
// add a boat of length 4 using mousedown/mousemove/mouseup
var startCell = p1OwnBoard.nodes[0].nodes[4].nodes[2];
var endCell = p1OwnBoard.nodes[0].nodes[4].nodes[5];
- serialInvokeAsync([
+ _serialInvokeAsync([
() => doMouseEvent("mousedown", startCell),
() => doMouseEvent("mousemove", endCell),
() => doMouseEvent("mouseup", endCell),
@@ -82,7 +82,7 @@ main() {
// add a boat of length 4 using mousedown/mousemove/mouseup
var startCell = p2OwnBoard.nodes[0].nodes[3].nodes[8];
var endCell = p2OwnBoard.nodes[0].nodes[7].nodes[8];
- serialInvokeAsync([
+ _serialInvokeAsync([
() => doMouseEvent("mousedown", startCell),
() => doMouseEvent("mousemove", endCell),
() => doMouseEvent("mouseup", endCell),
@@ -148,3 +148,18 @@ doMouseEvent(String type, var targetCell) {
relatedTarget: targetCell);
targetCell.on[type].dispatch(e);
}
+
+void _serialInvokeAsync(List closures) {
+ final length = closures.length;
+ if (length > 0) {
+ int i = 0;
+ void invokeNext() {
+ closures[i]();
+ i++;
+ if (i < length) {
+ window.setTimeout(invokeNext, 0);
+ }
+ }
+ window.setTimeout(invokeNext, 0);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698