]> source.dussan.org Git - jquery-ui.git/commitdiff
autodrag - Added simple test queue
authorRichard Worth <rdworth@gmail.com>
Mon, 26 May 2008 14:30:37 +0000 (14:30 +0000)
committerRichard Worth <rdworth@gmail.com>
Mon, 26 May 2008 14:30:37 +0000 (14:30 +0000)
ui/tests/autodrag.html

index 044716f667d8b11d11ff737239daeff4bfb9d9e1..2f8f2b2b9b743c412f71d05b4771893cde2e0793 100644 (file)
@@ -28,11 +28,43 @@ $(function() {
                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
@@ -49,15 +81,15 @@ $(function() {
 \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