From b5bc8683ef16b09d54483594fffec4f0e681236f Mon Sep 17 00:00:00 2001 From: Eduardo Lundgren Date: Sat, 24 May 2008 07:07:20 +0000 Subject: [PATCH] Resizable automated tests prototype started --- ui/tests/images/click.png | Bin 0 -> 1293 bytes ui/tests/resizable.html | 29 +++++++++++++ ui/tests/resizable.js | 88 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 ui/tests/images/click.png create mode 100644 ui/tests/resizable.html create mode 100644 ui/tests/resizable.js diff --git a/ui/tests/images/click.png b/ui/tests/images/click.png new file mode 100644 index 0000000000000000000000000000000000000000..2b32f8d8421c5cb86cefe6d795c3214f871bb352 GIT binary patch literal 1293 zcmV+o1@iidP)6E%nkrqwb^iYW*ZaVbe~Nhymgg3JulOhq)6aw%;e8!Jmx zTFlWho&Nvc|EuHW&71dp%iQ;eAM@Ssd&@a@IrrT2rqPV$-@81hE$9gbg3h2ETmsGo zr@*h^2k{wL3%&xs<@&{qb9iq%FcgdhSA%A0UfTk6@$T&htHB#!4fwNI4s-++;7)K+ z4js@2Ob|Q4i(nBrQ78w_0Z)K?!G$TF?*f~^HcgeIpjOY$0vCWznr6K;?PB!+^T6HU zN$^g-9q10`g8tt9D)1_J7i=*Gr_*eZ0E56taEsOobtPC1=76c-SbZNBW$=Zgz&g)( z8a`PIcN+L8L*rv{QNN{W*i%kfV=J^SI_B!Y6tGOgPyGd+Q%`Ze9?3%l`v%+(u2FP~ z#r8%`w=;6!VHq2%T2bdw@Vm>uc7VYeQ5&9DXq2*Y;8rl*wD;)4KXio^_l#%2L=%l# zf!D#snL5x7EcA?L&wuTTr^R5r9HK46_Mp z$3Y)mb7vf@zokzPT7O2k6bS`*68 zS9JW>f!1cbKB;6XME&i}jDfKOSAnLw$<_X`3s)=5=5{R)Np#?P^MVcL1tDsO)~Hiz z(Jj&;Bi2?Iwz#?OHSG>`puM^AqYGcv_E;KuSzb*EII!PbC+NU==02Ldym#or3kWO(F5V2V1z9Jw8Sa7&h z*GH_ac3WOzMxhCK!DUvxF0|N@Q%#$7qMuVaz{>L@CZQVu9&2FZ%UrU|8J`$=7MN96 zVicDzo;U4EuiR4Xq-`*Y-oQ#i0=uJ7fJzZ}Zqx&o88ltup%ZK;4 z(~G%vs!^8zE740mGop^?Ra!sQI_cGDloL8hl`Efbk>b4!k8>2p4`*snw*P9tp&qFo z + + + + +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