speed: "fast"\r
});\r
\r
- $('#begin').click(function(e) {\r
+ var queue;\r
+ var start = function() {\r
+ queue = tests.slice(); // clone\r
$("#status").text("Running...");\r
- $(".drag:eq(0)").testMouse("drag", 100, 0, function() {\r
- $('#status').text("Ready");\r
- });\r
+ nextTest();\r
+ }\r
+ var stop = function() {\r
+ $("#status").text("Ready");\r
+ }\r
+\r
+ var tests = [];\r
+ var nextTest = function() {\r
+ if (queue.length) {\r
+ queue.pop().apply();\r
+ } else {\r
+ stop();\r
+ }\r
+ }\r
+\r
+ var addTest = function(fn) {\r
+ tests.unshift(fn);\r
+ }\r
+\r
+ addTest(function() {\r
+ $("#d1").testMouse("drag", 100, 0, nextTest);\r
+ });\r
+ \r
+ addTest(function() {\r
+ $("#d2").testMouse("drag", 100, 0, nextTest);\r
+ });\r
+\r
+ addTest(function() {\r
+ $("#d3").testMouse("drag", 100, 0, nextTest);\r
+ });\r
+\r
+ $('#begin').click(function(e) {\r
+ start();\r
});\r
\r
});\r
\r
<div style="height: 3em;"><button id="begin">Run Test</button></div>\r
\r
- <div class="drag">\r
+ <div class="drag" id="d1">\r
Drag 1\r
</div>\r
\r
- <div class="drag">\r
+ <div class="drag" id="d2">\r
Drag 2\r
</div>\r
\r
- <div class="drag">\r
+ <div class="drag" id="d3">\r
Drag 3\r
</div>\r
\r