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

Unified Diff: client/tests/client/samples/dartcombat/dartcombat_tests.dart

Issue 8363040: Implement measurement using futures (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to all comments Created 9 years, 2 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: client/tests/client/samples/dartcombat/dartcombat_tests.dart
diff --git a/client/tests/client/samples/dartcombat/dartcombat_tests.dart b/client/tests/client/samples/dartcombat/dartcombat_tests.dart
index 8bd289b056d2b26eb160a74ef7aa93a739ad90b9..bd46a719306a3da2057d1b7dd1390bc5e89ee6ff 100644
--- a/client/tests/client/samples/dartcombat/dartcombat_tests.dart
+++ b/client/tests/client/samples/dartcombat/dartcombat_tests.dart
@@ -56,31 +56,33 @@ class DartCombatTests extends UnitTestSuite {
// 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];
- doMouseEvent("mousedown", startCell);
- doMouseEvent("mousemove", endCell);
- doMouseEvent("mouseup", endCell);
-
- // check that the boat was added:
- var boat = p1OwnBoard.nodes[1];
- Expect.setEquals(["icons", "boat4", "boatdir-left"], boat.classes);
-
- // check that the boat shows as sunk in player 1's board:
- // Note that the shoot order is respected: center, left, right, up, down,
- // left, right again, as if they progress in parallel.
- List<int> expectedShots = const [
- Constants.HIT, 3, 4, // initial shot (center)
- Constants.HIT, 2, 4, // left
- Constants.HIT, 4, 4, // right
- Constants.MISS, 3, 3, // up
- Constants.MISS, 3, 5, // down
- Constants.MISS, 1, 4, // left
- Constants.SUNK, 5, 4]; // right
- _expectShotSequence(expectedShots, p1OwnBoard, 1);
-
- // hit the boat from the enemy side.
- var p2EnemyBoard = document.query("#p2enemy");
- var hitCell = p2EnemyBoard.nodes[0].nodes[4].nodes[3];
- doMouseEvent("click", hitCell);
+ serialInvokeAsync([
+ () => doMouseEvent("mousedown", startCell),
+ () => doMouseEvent("mousemove", endCell),
+ () => doMouseEvent("mouseup", endCell),
+ () {
+ // check that the boat was added:
+ var boat = p1OwnBoard.nodes[1];
+ Expect.setEquals(["icons", "boat4", "boatdir-left"], boat.classes);
+
+ // check that the boat shows as sunk in player 1's board:
+ // Note that the shoot order is respected: center, left, right, up, down,
+ // left, right again, as if they progress in parallel.
+ List<int> expectedShots = const [
+ Constants.HIT, 3, 4, // initial shot (center)
+ Constants.HIT, 2, 4, // left
+ Constants.HIT, 4, 4, // right
+ Constants.MISS, 3, 3, // up
+ Constants.MISS, 3, 5, // down
+ Constants.MISS, 1, 4, // left
+ Constants.SUNK, 5, 4]; // right
+ _expectShotSequence(expectedShots, p1OwnBoard, 1);
+
+ // hit the boat from the enemy side.
+ var p2EnemyBoard = document.query("#p2enemy");
+ var hitCell = p2EnemyBoard.nodes[0].nodes[4].nodes[3];
+ doMouseEvent("click", hitCell);
+ }]);
}
void testSerialShoot() {
@@ -90,32 +92,34 @@ class DartCombatTests extends UnitTestSuite {
// 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];
- doMouseEvent("mousedown", startCell);
- doMouseEvent("mousemove", endCell);
- doMouseEvent("mouseup", endCell);
-
- // check that the boat was added:
- var boat = p2OwnBoard.nodes[1];
- Expect.setEquals(["icons", "boat5", "boatdir-down"], boat.classes);
-
- // check that the boat shows as sunk in player 2's board:
- // Note that the shoot order is respected: center, left, right, up, down
- // sequentially.
- List<int> expectedShots = const [
- Constants.HIT, 8, 4, // initial shot (center)
- Constants.MISS, 7, 4, // left (miss - stop this direction)
- Constants.MISS, 9, 4, // right (miss - stop this direction)
- Constants.HIT, 8, 3, // up
- Constants.MISS, 8, 2, // up (miss - stop this direction)
- Constants.HIT, 8, 5, // down
- Constants.HIT, 8, 6, // down
- Constants.SUNK, 8, 7]; // down (sunk - done)
- _expectShotSequence(expectedShots, p2OwnBoard, 2);
-
- // hit the boat from the enemy side.
- var p1EnemyBoard = document.query("#p1enemy");
- var hitCell = p1EnemyBoard.nodes[0].nodes[4].nodes[8];
- doMouseEvent("click", hitCell);
+ serialInvokeAsync([
+ () => doMouseEvent("mousedown", startCell),
+ () => doMouseEvent("mousemove", endCell),
+ () => doMouseEvent("mouseup", endCell),
+ () {
+ // check that the boat was added:
+ var boat = p2OwnBoard.nodes[1];
+ Expect.setEquals(["icons", "boat5", "boatdir-down"], boat.classes);
+
+ // check that the boat shows as sunk in player 2's board:
+ // Note that the shoot order is respected: center, left, right, up, down
+ // sequentially.
+ List<int> expectedShots = const [
+ Constants.HIT, 8, 4, // initial shot (center)
+ Constants.MISS, 7, 4, // left (miss - stop this direction)
+ Constants.MISS, 9, 4, // right (miss - stop this direction)
+ Constants.HIT, 8, 3, // up
+ Constants.MISS, 8, 2, // up (miss - stop this direction)
+ Constants.HIT, 8, 5, // down
+ Constants.HIT, 8, 6, // down
+ Constants.SUNK, 8, 7]; // down (sunk - done)
+ _expectShotSequence(expectedShots, p2OwnBoard, 2);
+
+ // hit the boat from the enemy side.
+ var p1EnemyBoard = document.query("#p1enemy");
+ var hitCell = p1EnemyBoard.nodes[0].nodes[4].nodes[8];
+ doMouseEvent("click", hitCell);
+ }]);
}
void _expectShotSequence(

Powered by Google App Engine
This is Rietveld 408576698