From: Eduardo Lundgren Date: Sat, 24 May 2008 07:07:20 +0000 (+0000) Subject: Resizable automated tests prototype started X-Git-Tag: 1.5.1~328 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b5bc8683ef16b09d54483594fffec4f0e681236f;p=jquery-ui.git Resizable automated tests prototype started --- diff --git a/ui/tests/images/click.png b/ui/tests/images/click.png new file mode 100644 index 000000000..2b32f8d84 Binary files /dev/null and b/ui/tests/images/click.png differ diff --git a/ui/tests/resizable.html b/ui/tests/resizable.html new file mode 100644 index 000000000..7be13005b --- /dev/null +++ b/ui/tests/resizable.html @@ -0,0 +1,29 @@ + + + + + +Resizable Test Page + + + + + + + + + + + +

jQuery Test Suite

+ +

+ +
+
I'm a resizable.
+
+ +
    + + + diff --git a/ui/tests/resizable.js b/ui/tests/resizable.js new file mode 100644 index 000000000..1fd2a9b0b --- /dev/null +++ b/ui/tests/resizable.js @@ -0,0 +1,88 @@ +var num = function(i) { + return parseInt(i, 10); +}; + +var animateClick = function(co) { + var img = $("").appendTo("body") + .css({ position: "absolute", zIndex: 1000, left: co.x, top: co.y }) + .animate({ width: 80, height: 80, left: co.x-40, top: co.y-40, opacity: 'hide' }, 1000, function() { $(this).remove(); }); +}; + +var initMouseEvent = function(type, el, co) { + var evt = document.createEvent("MouseEvents"); + evt.initMouseEvent(type, true, true, window, 0, 0, 0, co.x, co.y, false, false, false, false, 0, null); + + el.dispatchEvent(evt); + + if (/^mouseup|mousedown|click$/i.test(type)) { + animateClick(co); + } + + return evt; +}; + + +$.fn.triggerMousedown = function(co) { + return initMouseEvent("mousedown", this[0], co); +}; + +$.fn.triggerMouseup = function(co) { + return initMouseEvent("mouseup", this[0], co); +}; + +$.fn.triggerMousemove = function(co, target) { + return initMouseEvent("mousemove", this[0], co); +}; + +var xy = function(el, offset) { + var o = el.offset(); + return { x: o.left + (offset || [0, 0])[0]||0, y: o.top + (offset || [0, 0])[1]||0 }; +}; + +$(document).ready(function() { + + $("#resizable1").resizable({ + + start: function(e, ui) { + console.log('start: [' + e.pageX + ', ' + e.pageY + ']' ) + console.log(ui.instance.size, ui.instance.position) + }, + + stop: function(e, ui) { + console.log('stop: [' + e.pageX + ', ' + e.pageY + ']' ) + console.log(ui.instance.size, ui.instance.position) + }, + + resize: function(e) { + console.log(e); + } + }); + + var handler = $(this).find('.ui-resizable-s'); + + handler.mousedown(function() { /*console.log('down')*/ }); + handler.mouseup(function() { /*console.log('up')*/ }); + + handler.triggerMousedown( xy(handler) ); + + for (var x = 0; x < 50; x += 10) { + var evt = $(handler).triggerMousemove( xy(handler, [x, x]) ); + console.log(evt) + } + + handler.triggerMouseup( xy(handler, [50, 50]) ); + + + + return; + + module("resizable: simple resize"); + + test("simple drag", function() { + + expect(1); + ok(true, "Resize element on the same position"); + + }); + +}); \ No newline at end of file