aboutsummaryrefslogtreecommitdiffstats
path: root/ui/tests/autodrag.html
diff options
context:
space:
mode:
authorRichard Worth <rdworth@gmail.com>2008-05-26 20:29:22 +0000
committerRichard Worth <rdworth@gmail.com>2008-05-26 20:29:22 +0000
commit661f111abb344bfee1f1b9520de32ab5f6447409 (patch)
tree1361b218a700f0db084bdc8ffcd58199aa7fcbde /ui/tests/autodrag.html
parent48009db7e833e18f4400c05a57e1932aa42c674f (diff)
downloadjquery-ui-661f111abb344bfee1f1b9520de32ab5f6447409.tar.gz
jquery-ui-661f111abb344bfee1f1b9520de32ab5f6447409.zip
auto tests - now runs multiple tests with status
Diffstat (limited to 'ui/tests/autodrag.html')
-rw-r--r--ui/tests/autodrag.html99
1 files changed, 67 insertions, 32 deletions
diff --git a/ui/tests/autodrag.html b/ui/tests/autodrag.html
index 2f8f2b2b9..bb005b518 100644
--- a/ui/tests/autodrag.html
+++ b/ui/tests/autodrag.html
@@ -12,7 +12,13 @@
html, body { height: 100%; }
#main { height: 100%; }
-.drag { position: relative; margin: 10px; padding: 10px; border: 3px solid black; cursor: move; width: 200px; height: 40px; background: #eef; }
+
+#foo { position: relative; margin: 10px; padding: 10px; border: 3px solid gray; cursor: move; width: 200px; height: 100px; background: #eef; text-align: center; }
+.ui-draggable .msg-missing-class { display: none !important; background: red; color: white; font-weight: bold; }
+.ui-draggable .msg-enabled { display: block; }
+.ui-draggable .msg-disabled { display: none; }
+.ui-draggable-disabled .msg-enabled { display: none !important; }
+.ui-draggable-disabled .msg-disabled { display: block !important; }
</style>
@@ -24,46 +30,77 @@ html, body { height: 100%; }
<script type="text/javascript">
$(function() {
- $(".drag").draggable().testMouse({
- speed: "fast"
- });
+ var speed = "slow"
var queue;
var start = function() {
- queue = tests.slice(); // clone
+ queue = tests.slice().reverse(); // clone
$("#status").text("Running...");
nextTest();
}
var stop = function() {
$("#status").text("Ready");
+ teardown();
}
-
+
var tests = [];
var nextTest = function() {
if (queue.length) {
- queue.pop().apply();
+ var nTest = queue.pop();
+ teardown(function() {
+ setupAndRun(nTest);
+ });
} else {
stop();
}
}
-
+
+ var num = 0;
+
var addTest = function(fn) {
- tests.unshift(fn);
+ num += 1;
+ tests.push({
+ num: num,
+ fn: fn
+ });
}
-
- addTest(function() {
- $("#d1").testMouse("drag", 100, 0, nextTest);
- });
- addTest(function() {
- $("#d2").testMouse("drag", 100, 0, nextTest);
- });
-
- addTest(function() {
- $("#d3").testMouse("drag", 100, 0, nextTest);
- });
-
- $('#begin').click(function(e) {
+ var setupAndRun = function(nTest) {
+ $('#testnum').text(nTest.num);
+ $('#sandbox').hide().append('<div id="foo">' +
+ '<div class="msg-missing-class">THIS TEXT SHOULD NOT BE VISIBLE</div>' +
+ '<div class="msg-enabled">enabled</div>' +
+ '<div class="msg-disabled">disabled</div>' +
+ '</div>');
+ $('#foo').testMouse({
+ speed: speed,
+ complete: nextTest
+ });
+ $('#sandbox').show();
+ nTest.fn.apply(nTest.fn);
+ }
+
+ var teardown = function(fn) {
+ $('#sandbox').hide();
+ $('#foo').remove();
+ if ($.isFunction(fn)) fn.apply();
+ }
+ //1
+ addTest(function() { $("#foo").draggable().testMouse("drag", 100, 100); });
+ //2
+ addTest(function() { $("#foo").draggable({ disabled: true }).testMouse("drag", 100, 100); });
+ addTest(function() { $("#foo").draggable({ disabled: false }).testMouse("drag", 100, 100); });
+ //4
+ addTest(function() { $("#foo").draggable().draggable('disable').testMouse("drag", 100, 100); });
+ addTest(function() { $("#foo").draggable().draggable('enable').testMouse("drag", 100, 100); });
+ //6
+ addTest(function() { $("#foo").draggable().draggable('enable').draggable('disable').testMouse("drag", 100, 100); });
+ addTest(function() { $("#foo").draggable().draggable('disable').draggable('enable').testMouse("drag", 100, 100); });
+ //8
+ addTest(function() { $("#foo").draggable({ disabled: false }).draggable('disable').testMouse("drag", 100, 100); });
+ addTest(function() { $("#foo").draggable({ disabled: true }).draggable('enable').testMouse("drag", 100, 100); });
+
+ $('#begin').click(function() {
start();
});
@@ -77,20 +114,18 @@ $(function() {
<h1>jQuery UI Draggable - Automated Test</h1>
- Status: <span id="status">Ready</span>
-
- <div style="height: 3em;"><button id="begin">Run Test</button></div>
-
- <div class="drag" id="d1">
- Drag 1
+ <div>
+ Status: <span id="status">Ready</span>
</div>
- <div class="drag" id="d2">
- Drag 2
+ <div>
+ Test: <span id="testnum"></span>
</div>
- <div class="drag" id="d3">
- Drag 3
+ <div style="height: 3em;"><button id="begin">Run Test</button></div>
+
+ <div id="sandbox">
+
</div>
</div>