aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2008-11-21 19:40:45 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2008-11-21 19:40:45 +0000
commit0036aaf4b67d55e621ac2e4553a98dc80d2ca727 (patch)
treee5766688341a3e3fea2453e91e1443b1e5780ade /tests
parent65289463debbc3d32cf4de045372bc7e076f7e0c (diff)
downloadjquery-ui-0036aaf4b67d55e621ac2e4553a98dc80d2ca727.tar.gz
jquery-ui-0036aaf4b67d55e621ac2e4553a98dc80d2ca727.zip
draggable: added missing default for zIndex and cursorAt, added missing scroll tests (unfortunately showing big regressions that need to be fixed prior to 1.6)
Diffstat (limited to 'tests')
-rw-r--r--tests/draggable.js241
-rw-r--r--tests/droppable.html8
2 files changed, 193 insertions, 56 deletions
diff --git a/tests/draggable.js b/tests/draggable.js
index 31a820613..4c62d45a2 100644
--- a/tests/draggable.js
+++ b/tests/draggable.js
@@ -476,85 +476,196 @@ test("callbacks occurance count", function() {
module("draggable: Scroll offsets");
+
+function testScroll(position) {
+ $("#main").css('position', position);
+ drag(el, 50, 50);
+ moved(50, 50, position+' parent');
+
+}
+
+function setScroll(what) {
+ if(what) {
+ $(document).scrollTop(100); $(document).scrollLeft(100);
+ } else {
+ $("#main")[0].scrollTop = 100; $("#main")[0].scrollLeft = 100;
+ }
+}
+
+function restoreScroll(what) {
+ if(what) {
+ $(document).scrollTop(0); $(document).scrollLeft(0);
+ } else {
+ $("#main")[0].scrollTop = 0; $("#main")[0].scrollLeft = 0;
+ }
+}
+
test("{ helper: 'original' }, relative, with scroll offset on parent", function() {
+
el = $("#draggable1").draggable({ helper: "original" });
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ testScroll('relative');
+
+ setScroll();
+ testScroll('static');
+
+ setScroll();
+ testScroll('absolute');
+
+ restoreScroll();
+
});
test("{ helper: 'original' }, relative, with scroll offset on root", function() {
+
el = $("#draggable1").draggable({ helper: "original" });
- $(document).scrollTop(100);
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
+
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll('root');
+ testScroll('static');
+
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll('root');
+
});
test("{ helper: 'original' }, relative, with scroll offset on root and parent", function() {
+
el = $("#draggable1").draggable({ helper: "original" });
- $(document).scrollTop(100);
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll();
+ setScroll('root');
+ testScroll('static');
+
+ setScroll();
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll();
+ restoreScroll('root');
+
});
test("{ helper: 'original' }, absolute, with scroll offset on parent", function() {
+
el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ testScroll('relative');
+
+ setScroll();
+ testScroll('static');
+
+ setScroll();
+ testScroll('absolute');
+
+ restoreScroll();
+
});
test("{ helper: 'original' }, absolute, with scroll offset on root", function() {
+
el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
- $(document).scrollTop(100);
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
+
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll('root');
+ testScroll('static');
+
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll('root');
+
});
test("{ helper: 'original' }, absolute, with scroll offset on root and parent", function() {
+
el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
- $(document).scrollTop(100);
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll();
+ setScroll('root');
+ testScroll('static');
+
+ setScroll();
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll();
+ restoreScroll('root');
+
});
//Fixed not for IE < 7
if(!($.browser.msie && $.browser.version < 7)) {
test("{ helper: 'original' }, fixed, with scroll offset on parent", function() {
+
el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ testScroll('relative');
+
+ setScroll();
+ testScroll('static');
+
+ setScroll();
+ testScroll('absolute');
+
+ restoreScroll();
+
});
test("{ helper: 'original' }, fixed, with scroll offset on root", function() {
+
el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
- $(document).scrollTop(100);
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
+
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll('root');
+ testScroll('static');
+
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll('root');
+
});
test("{ helper: 'original' }, fixed, with scroll offset on root and parent", function() {
+
el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
- $(document).scrollTop(100);
- $("#main")[0].scrollTop = 100;
- drag(el, 50, 50);
- moved(50, 50);
- $(document).scrollTop(0);
- $("#main")[0].scrollTop = 0;
+
+ setScroll();
+ setScroll('root');
+ testScroll('relative');
+
+ setScroll();
+ setScroll('root');
+ testScroll('static');
+
+ setScroll();
+ setScroll('root');
+ testScroll('absolute');
+
+ restoreScroll();
+ restoreScroll('root');
+
});
}
@@ -571,14 +682,13 @@ test("{ helper: 'clone' }, absolute", function() {
} });
drag(el, 1, 1);
-
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
});
test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
- $("#main")[0].scrollTop = 100;
+ setScroll();
var helperOffset = null;
var origOffset = $("#draggable1").offset();
@@ -586,34 +696,52 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
helperOffset = ui.helper.offset();
} });
+ $("#main").css('position', 'relative');
drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ $("#main").css('position', 'static');
+ drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
- $("#main")[0].scrollTop = 0;
+
+ $("#main").css('position', 'absolute');
+ drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
+ restoreScroll();
});
test("{ helper: 'clone' }, absolute with scroll offset on root", function() {
- $(document).scrollTop(100);
+ setScroll('root');
var helperOffset = null;
var origOffset = $("#draggable1").offset();
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset();
} });
-
+
+ $("#main").css('position', 'relative');
drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ $("#main").css('position', 'static');
+ drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
- $(document).scrollTop(0);
+
+ $("#main").css('position', 'absolute');
+ drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
+ restoreScroll('root');
});
test("{ helper: 'clone' }, absolute with scroll offset on root and parent", function() {
- $(document).scrollTop(100);
- $("#main")[0].scrollTop = 100;
+ setScroll('root');
+ setScroll();
var helperOffset = null;
var origOffset = $("#draggable1").offset();
@@ -621,11 +749,20 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func
helperOffset = ui.helper.offset();
} });
+ $("#main").css('position', 'relative');
drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ $("#main").css('position', 'static');
+ drag(el, 1, 1);
+ same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
+ $("#main").css('position', 'absolute');
+ drag(el, 1, 1);
same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
- $(document).scrollTop(0);
- $("#main")[0].scrollTop = 0;
+
+ restoreScroll('root');
+ restoreScroll();
});
diff --git a/tests/droppable.html b/tests/droppable.html
index ec4bb758b..d2a4e0beb 100644
--- a/tests/droppable.html
+++ b/tests/droppable.html
@@ -18,9 +18,8 @@
<style type="text/css">
html { border: 0; }
#main {
- position:absolute !important;
- top: -1000px !important;
- left: -1000px !important;
+ top: -1000px;
+ left: -1000px;
}
</style>
</head>
@@ -32,9 +31,10 @@
<ol id="tests"></ol>
-<div id="main">
+<div id="main" style='position: absolute; width: 300px; height: 300px; overflow: auto;'>
<div id="draggable1" style="width: 25px; height: 25px;">Draggable</div>
<div id="droppable1" style="width: 100px; height: 100px;">Droppable</div>
+ <div style='width:1000px;height:1000px;'>&nbsp;</div>
</div>
</body>