aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Lundgren <eduardolundgren@gmail.com>2008-05-31 15:54:53 +0000
committerEduardo Lundgren <eduardolundgren@gmail.com>2008-05-31 15:54:53 +0000
commit106d24a3a4d97d2fd7e532b3b1a434798bbaef7a (patch)
tree5735b6a6d7ef122b465eb2bf36ab89c4724475fe
parent320e7a560de4c80e1163e5e6afe8e7fc8fa49a3e (diff)
downloadjquery-ui-106d24a3a4d97d2fd7e532b3b1a434798bbaef7a.tar.gz
jquery-ui-106d24a3a4d97d2fd7e532b3b1a434798bbaef7a.zip
Resizable basic tests using userAction
-rw-r--r--ui/tests/jquery.useraction.js8
-rw-r--r--ui/tests/resizable.js138
2 files changed, 128 insertions, 18 deletions
diff --git a/ui/tests/jquery.useraction.js b/ui/tests/jquery.useraction.js
index b3b2d508e..878f77b29 100644
--- a/ui/tests/jquery.useraction.js
+++ b/ui/tests/jquery.useraction.js
@@ -151,10 +151,10 @@ $.extend($.userAction.prototype, {
if (/^sync$/i.test(o.speed)) {
self.down(target);
- for (var dt = 1; dt <= dx; dt++) {
- var x = center.x + (dt <= Math.abs(dx) ? dt : 0),
- y = center.y + (dt <= Math.abs(dy) ? dt : 0);
-
+ var mdx = Math.abs(dx)||0, mdy = Math.abs(dy)||0, range = Math.max(mdx, mdy);
+
+ for (var dt = 1; dt <= range; dt++) {
+ var x = center.x + (dx/mdx)*(dt <= mdx ? dt : 0), y = center.y + (dy/mdy)*(dt <= mdy ? dt : 0);
this.move(target, x, y, o.drag);
}
self.up(target);
diff --git a/ui/tests/resizable.js b/ui/tests/resizable.js
index 1cd3a4816..943e226ce 100644
--- a/ui/tests/resizable.js
+++ b/ui/tests/resizable.js
@@ -21,38 +21,148 @@ $(document).ready(function() {
// speed = sync -> Drag syncrhonously.
// speed = fast|slow -> Drag asyncrhonously - animated.
- $(el).userAction("drag", {
- dx: dx, dy: dy, speed: 'sync', complete: complete
+ return $(el).userAction("drag", {
+ dx: dx||0, dy: dy||0, speed: 'sync', complete: complete
});
};
- $('#resizable1').resizable({
- resize: function() {
- console.log('resize')
- }
+ module("simple resize");
+
+ test("ui-resizable-e resize x", function() {
+
+ var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' });
+
+ expect(2);
+
+ drag(handle, 50);
+
+ equals( 149, target.width(), "compare width");
+
+ drag(handle, -50);
+
+ equals( 100, target.width(), "compare width" );
+
});
- module("Test 1");
+ test("ui-resizable-w resize x", function() {
+
+ var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' });
+
+ expect(2);
+
+ drag(handle, -50);
+
+ equals( 149, target.width(), "compare width" );
+
+ drag(handle, 50);
+
+ equals( 100, target.width(), "compare width" );
+
+ });
- test("simple resize tests", function() {
+ test("ui-resizable-n resize y", function() {
+
+ var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' });
+
+ expect(2);
+
+ drag(handle, 0, -50);
- drag('.ui-resizable-se', 100, 50);
+ equals( 149, target.height(), "compare height" );
+
+ drag(handle, 0, 50);
+
+ equals( 100, target.height(), "compare height" );
});
+ test("ui-resizable-s resize y", function() {
+
+ var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' });
+
+ expect(2);
+
+ drag(handle, 0, 50);
+
+ equals( 149, target.height(), "compare height" );
+
+ drag(handle, 0, -50);
+
+ equals( 100, target.height(), "compare height" );
+
+ });
- test("simple resize tests 2", function() {
+ test("ui-resizable-se resize xy", function() {
- //drag('.ui-resizable-se', 0, 1000);
+ var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' });
+
+ expect(4);
+
+ drag(handle, 50, 50);
+
+ equals( 149, target.width(), "compare width" );
+ equals( 149, target.height(), "compare height" );
+
+ drag(handle, -50, -50);
+
+ equals( 100, target.width(), "compare width" );
+ equals( 100, target.height(), "compare height" );
+
+ });
+
+ test("ui-resizable-sw resize xy", function() {
+
+ var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' });
+
+ expect(4);
+
+ drag(handle, -50, -50);
+
+ equals( 149, target.width(), "compare width" );
+ equals( 51, target.height(), "compare height" );
+
+ drag(handle, 50, 50);
+
+ equals( 100, target.width(), "compare width" );
+ equals( 100, target.height(), "compare height" );
});
- module("Test 2");
+ test("ui-resizable-ne resize xy", function() {
+
+ var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all' });
+
+ expect(4);
+
+ drag(handle, -50, -50);
+
+ equals( 51, target.width(), "compare width" );
+ equals( 149, target.height(), "compare height" );
+
+ drag(handle, 50, 50);
+
+ equals( 100, target.width(), "compare width" );
+ equals( 100, target.height(), "compare height" );
+
+ });
- test("simple resize tests", function() {
+ test("ui-resizable-nw resize xy", function() {
+
+ var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' });
+
+ expect(4);
+
+ drag(handle, -50, -50);
- //drag('.ui-resizable-se', 15, 0);
+ equals( 149, target.width(), "compare width" );
+ equals( 149, target.height(), "compare height" );
+
+ drag(handle, 50, 50);
+
+ equals( 100, target.width(), "compare width" );
+ equals( 100, target.height(), "compare height" );
});
+
}); \ No newline at end of file