changeset 8:203637e33feb

Added a line input test.
author Atul Varma <varmaa@toolness.com>
date Sun, 11 May 2008 13:11:14 -0700
parents 110233f31576
children 6913491b18c4
files test_engine_runner.js
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test_engine_runner.js	Sun May 11 12:56:56 2008 -0700
+++ b/test_engine_runner.js	Sun May 11 13:11:14 2008 -0700
@@ -15,6 +15,9 @@
 
             switch (self._step) {
             case 1:
+                effect = GNUSTO_EFFECT_INPUT;
+                break;
+            case 2:
                 effect = GNUSTO_EFFECT_QUIT;
                 break;
             default:
@@ -22,6 +25,11 @@
             }
 
             return effect.slice(1, -1);
+        },
+
+        answer: function(number, response) {
+            if (response != "hello")
+                throw Error('Unexpected response.');
         }
     };
 }
@@ -29,11 +37,17 @@
 function TestZui() {
     var self = this;
 
+    self.callbackCount = 0;
     self.hasQuit = false;
 
     this.__proto__ = {
         onQuit: function() {
             self.hasQuit = true;
+        },
+
+        onLineInput: function(callback) {
+            self.callbackCount += 1;
+            callback("hello");
         }
     };
 };
@@ -41,6 +55,8 @@
 var gZui = new TestZui();
 var gRunner = new EngineRunner(new FakeEngine(), gZui);
 gRunner.run();
+if (!gZui.callbackCount == 1)
+    throw Error('zui unexpected callback count: '+gZui.callbackCount);
 if (!gZui.hasQuit)
     throw Error('zui onQuit() not called.');
 print('Engine runner test run successfully.');