Permalink
Browse files

Implementing waits! :D :D

  • Loading branch information...
1 parent dbbffa6 commit 92b26cd85ea1bdb74d3070e7d9347f12d5337c00 Caleb Cohoon committed Jan 29, 2012
@@ -30,6 +30,10 @@ function pressKey(key, duration, callback) {
new Simulate().keyPress(key, duration, callback);
}
+function waits(milliseconds, callback) {
+ new Simulate().waits(milliseconds, callback);
+}
+
// Spec DSL
function loadScene(name) {
sceneName = name;
@@ -22,4 +22,11 @@ class Simulate {
'callback': callback
});
}
+
+ function waits(duration, callback) {
+ Gunpowder.simulationsToRun.Push({
+ 'duration': duration,
+ 'callback': callback
+ });
+ }
}
View
@@ -13,78 +13,6 @@ class Specs extends Gunpowder {
});
});
- describe('helpers', function() {
- describe('find', function() {
- it('can find the game object', function() {
- expect(match(find('box')).toEqual(GameObject.Find('box'))).toPass();
- expect(match(find('box')).toEqual(GameObject.Find('ball'))).toFail();
- });
- });
-
- describe('move', function() {
- it('moves forward', function() {
- move('forward', 100, function() {
- expect(find('player')).toHavePosition(2.1, 0.5, -13.0, 0.5);
- });
- });
-
- it('moves backwards', function() {
- move('backward', 100, function() {
- expect(find('player')).toHavePosition(1.1, 0.5, -13.0, 0.5);
- });
- });
-
- it('moves right', function() {
- move('right', 100, function() {
- expect(find('player')).toHavePosition(1.6, 0.5, -12.5, 0.5);
- });
- });
-
- it('moves left', function() {
- move('left', 100, function() {
- expect(find('player')).toHavePosition(1.6, 0.5, -13.5, 0.5);
- });
- });
-
- it('can run multiple movements in a single spec', function() {
- move('backward', 100, function() {
- expect(find('player')).toHavePosition(1.1, 0.5, -13.0, 0.5);
- });
-
- move('left', 100, function() {
- expect(find('player')).toHavePosition(1.1, 0.5, -14.0, 0.5);
- });
- });
- });
-
- describe('buttonPress', function() {
- it('presses the "control" button', function() {
- expect(find('ball')).toBeVisible();
- pressButton('Fire1', 500, function() {
- expect(find('ball')).toBeHidden();
- });
- });
- });
-
- describe('keyPress', function() {
- it('presses the "control" key', function() {
- expect(find('box')).toBeVisible();
- pressKey('h', 500, function() {
- expect(find('box')).toBeHidden();
- });
- });
- });
-
- describe('moveTo', function() {
- it('moves the object to the correct location', function() {
- find('ball').moveTo(0, 3, 2);
- expect(find('ball').getGameObject().transform.position.x).toEqual(0);
- expect(find('ball').getGameObject().transform.position.y).toEqual(3);
- expect(find('ball').getGameObject().transform.position.z).toEqual(2);
- });
- });
- });
-
describe('matchers', function() {
describe('toBeTruthy', function() {
it('is true', function() {
@@ -185,6 +113,88 @@ class Specs extends Gunpowder {
});
});
+ describe('helpers', function() {
+ describe('find', function() {
+ it('can find the game object', function() {
+ expect(match(find('box')).toEqual(GameObject.Find('box'))).toPass();
+ expect(match(find('box')).toEqual(GameObject.Find('ball'))).toFail();
+ });
+ });
+
+ describe('move', function() {
+ it('moves forward', function() {
+ move('forward', 100, function() {
+ expect(find('player')).toHavePosition(2.1, 0.5, -13.0, 0.5);
+ });
+ });
+
+ it('moves backwards', function() {
+ move('backward', 100, function() {
+ expect(find('player')).toHavePosition(1.1, 0.5, -13.0, 0.5);
+ });
+ });
+
+ it('moves right', function() {
+ move('right', 100, function() {
+ expect(find('player')).toHavePosition(1.6, 0.5, -12.5, 0.5);
+ });
+ });
+
+ it('moves left', function() {
+ move('left', 100, function() {
+ expect(find('player')).toHavePosition(1.6, 0.5, -13.5, 0.5);
+ });
+ });
+
+ it('can run multiple movements in a single spec', function() {
+ move('backward', 100, function() {
+ expect(find('player')).toHavePosition(1.1, 0.5, -13.0, 0.5);
+ });
+
+ move('left', 100, function() {
+ expect(find('player')).toHavePosition(1.1, 0.5, -14.0, 0.5);
+ });
+ });
+ });
+
+ describe('buttonPress', function() {
+ it('presses the "control" button', function() {
+ expect(find('ball')).toBeVisible();
+ pressButton('Fire1', 500, function() {
+ expect(find('ball')).toBeHidden();
+ });
+ });
+ });
+
+ describe('keyPress', function() {
+ it('presses the "control" key', function() {
+ expect(find('box')).toBeVisible();
+ pressKey('h', 500, function() {
+ expect(find('box')).toBeHidden();
+ });
+ });
+ });
+
+ describe('moveTo', function() {
+ it('moves the object to the correct location', function() {
+ find('ball').moveTo(0, 3, 2);
+ expect(find('ball').getGameObject().transform.position.x).toEqual(0);
+ expect(find('ball').getGameObject().transform.position.y).toEqual(3);
+ expect(find('ball').getGameObject().transform.position.z).toEqual(2);
+ });
+ });
+
+ describe('waits', function() {
+ it('waits the specified time then runs the callback', function() {
+ find('cylinder').getGameObject().AddComponent(Rigidbody);
+ expect(find('plane')).toBeVisible();
+ waits(300, function() {
+ expect(find('plane')).toBeHidden();
+ });
+ });
+ });
+ });
+
describe('resetting the scene', function() {
context('a spec finishes', function() {
var boxPosition = find('box').getGameObject().transform.position;
View
@@ -0,0 +1,3 @@
+function OnCollisionEnter(collision : Collision) {
+ renderer.enabled = false;
+}
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.

0 comments on commit 92b26cd

Please sign in to comment.