diff options
author | Leif Johansson <leifj@sunet.se> | 2011-11-25 21:18:19 +0100 |
---|---|---|
committer | Leif Johansson <leifj@sunet.se> | 2011-11-25 21:18:19 +0100 |
commit | 3909e6d89e01e4cd8777377c63037896bb95aa2f (patch) | |
tree | 59679df287c2bee55087fb5afb8d42e7f93a44fb /src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable | |
parent | e5f94e9be5017f627c1ccd8c6306c5cc2e200432 (diff) |
new jq layout
Diffstat (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable')
8 files changed, 538 insertions, 0 deletions
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/all.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/all.html new file mode 100644 index 0000000..2f56d02 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Resizable Test Suite</title> + + <script src="../../../jquery-1.7.1.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "resizable" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Resizable Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/images/test.jpg b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/images/test.jpg Binary files differnew file mode 100644 index 0000000..0175b13 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/images/test.jpg diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable.html new file mode 100644 index 0000000..4e886d2 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable.html @@ -0,0 +1,58 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Resizable Test Suite</title> + + <script src="../../jquery.js"></script> + <script src="../../resource_loader.js"></script> + <script> + loadResources({ + css: [ "ui.core", "ui.resizable" ], + js: [ + "ui/jquery.ui.core.js", + "ui/jquery.ui.widget.js", + "ui/jquery.ui.mouse.js", + "ui/jquery.ui.resizable.js" + ] + }); + </script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="resizable_core.js"></script> + <script src="resizable_defaults.js"></script> + <script src="resizable_events.js"></script> + <script src="resizable_methods.js"></script> + <script src="resizable_options.js"></script> + + <script> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("resizable", function() { ok(true, "disabled resizable testsuite"); }); + } + </script> + <script src="../swarminject.js"></script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Resizable Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +<div id="resizable1" style="background: green; width: 100px; height: 100px;">I'm a resizable.</div> +<img src="images/test.jpg" id="resizable2" style="width: 100px; height: 100px;"> + +</div> +</body> +</html> diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_core.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_core.js new file mode 100644 index 0000000..33a3f72 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_core.js @@ -0,0 +1,148 @@ +/* + * resizable_core.js + */ + +var el; + +var drag = function(el, dx, dy, complete) { + + // speed = sync -> Drag syncrhonously. + // speed = fast|slow -> Drag asyncrhonously - animated. + + //this mouseover is to work around a limitation in resizable + //TODO: fix resizable so handle doesn't require mouseover in order to be used + $(el).simulate("mouseover"); + + return $(el).simulate("drag", { + dx: dx||0, dy: dy||0, speed: 'sync', complete: complete + }); +}; + +(function($) { + +module("resizable: core"); + +/* +test("element types", function() { + var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' + + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' + + ',acronym,code,samp,kbd,var,img,object,hr' + + ',input,button,label,select,iframe').split(','); + + $.each(typeNames, function(i) { + var typeName = typeNames[i]; + el = $(document.createElement(typeName)).appendTo('body'); + (typeName == 'table' && el.append("<tr><td>content</td></tr>")); + el.resizable(); + ok(true, '$("<' + typeName + '/>").resizable()'); + el.resizable("destroy"); + el.remove(); + }); +}); +*/ + +test("n", function() { + expect(2); + + var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, 0, -50); + equals( target.height(), 150, "compare height" ); + + drag(handle, 0, 50); + equals( target.height(), 100, "compare height" ); +}); + +test("s", function() { + expect(2); + + var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, 0, 50); + equals( target.height(), 150, "compare height" ); + + drag(handle, 0, -50); + equals( target.height(), 100, "compare height" ); +}); + +test("e", function() { + expect(2); + + var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, 50); + equals( target.width(), 150, "compare width"); + + drag(handle, -50); + equals( target.width(), 100, "compare width" ); +}); + +test("w", function() { + expect(2); + + var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, -50); + equals( target.width(), 150, "compare width" ); + + drag(handle, 50); + equals( target.width(), 100, "compare width" ); +}); + +test("ne", function() { + expect(4); + + var handle = '.ui-resizable-ne', target = $('#resizable1').css({ overflow: 'hidden' }).resizable({ handles: 'all' }); + + drag(handle, -50, -50); + equals( target.width(), 50, "compare width" ); + equals( target.height(), 150, "compare height" ); + + drag(handle, 50, 50); + equals( target.width(), 100, "compare width" ); + equals( target.height(), 100, "compare height" ); +}); + +test("se", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, 50, 50); + equals( target.width(), 150, "compare width" ); + equals( target.height(), 150, "compare height" ); + + drag(handle, -50, -50); + equals( target.width(), 100, "compare width" ); + equals( target.height(), 100, "compare height" ); +}); + +test("sw", function() { + expect(4); + + var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, -50, -50); + equals( target.width(), 150, "compare width" ); + equals( target.height(), 50, "compare height" ); + + drag(handle, 50, 50); + equals( target.width(), 100, "compare width" ); + equals( target.height(), 100, "compare height" ); +}); + +test("nw", function() { + expect(4); + + var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, -50, -50); + equals( target.width(), 150, "compare width" ); + equals( target.height(), 150, "compare height" ); + + drag(handle, 50, 50); + equals( target.width(), 100, "compare width" ); + equals( target.height(), 100, "compare height" ); +}); + +})(jQuery); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_defaults.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_defaults.js new file mode 100644 index 0000000..f69e521 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_defaults.js @@ -0,0 +1,28 @@ +/* + * resizable_defaults.js + */ + +var resizable_defaults = { + alsoResize: false, + animate: false, + animateDuration: 'slow', + animateEasing: 'swing', + aspectRatio: false, + autoHide: false, + cancel: ':input,option', + containment: false, + delay: 0, + disabled: false, + distance: 1, + ghost: false, + grid: false, + handles: 'e,s,se', + helper: false, + maxHeight: null, + maxWidth: null, + minHeight: 10, + minWidth: 10, + zIndex: 1000 +}; + +commonWidgetTests('resizable', { defaults: resizable_defaults }); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_events.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_events.js new file mode 100644 index 0000000..e8041f0 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_events.js @@ -0,0 +1,20 @@ +/* + * resizable_events.js + */ +(function($) { + +module("resizable: events"); + +test("start", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("resize", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("stop", function() { + ok(false, "missing test - untested code is broken code."); +}); + +})(jQuery); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_methods.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_methods.js new file mode 100644 index 0000000..6ac287f --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_methods.js @@ -0,0 +1,64 @@ +/* + * resizable_methods.js + */ +(function($) { + +module("resizable: methods"); + +test("init", function() { + expect(6); + + $("<div></div>").appendTo('body').resizable().remove(); + ok(true, '.resizable() called on element'); + + $([]).resizable().remove(); + ok(true, '.resizable() called on empty collection'); + + $('<div></div>').resizable().remove(); + ok(true, '.resizable() called on disconnected DOMElement'); + + $('<div></div>').resizable().resizable("foo").remove(); + ok(true, 'arbitrary method called after init'); + + el = $('<div></div>').resizable() + var foo = el.resizable("option", "foo"); + el.remove(); + ok(true, 'arbitrary option getter after init'); + + $('<div></div>').resizable().resizable("option", "foo", "bar").remove(); + ok(true, 'arbitrary option setter after init'); +}); + +test("destroy", function() { + $("<div></div>").appendTo('body').resizable().resizable("destroy").remove(); + ok(true, '.resizable("destroy") called on element'); + + $([]).resizable().resizable("destroy").remove(); + ok(true, '.resizable("destroy") called on empty collection'); + + $('<div></div>').resizable().resizable("destroy").remove(); + ok(true, '.resizable("destroy") called on disconnected DOMElement'); + + $('<div></div>').resizable().resizable("destroy").resizable("foo").remove(); + ok(true, 'arbitrary method called after destroy'); + + var expected = $('<div></div>').resizable(), + actual = expected.resizable('destroy'); + equals(actual, expected, 'destroy is chainable'); +}); + +test("enable", function() { + var expected = $('<div></div>').resizable(), + actual = expected.resizable('enable'); + equals(actual, expected, 'enable is chainable'); + ok(false, "missing test - untested code is broken code."); +}); + +test("disable", function() { + var expected = $('<div></div>').resizable(), + actual = expected.resizable('disable'); + equals(actual, expected, 'disable is chainable'); + ok(false, "missing test - untested code is broken code."); +}); + +})(jQuery); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_options.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_options.js new file mode 100644 index 0000000..389931f --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/resizable/resizable_options.js @@ -0,0 +1,190 @@ +/* + * resizable_options.js + */ +(function($) { + +module("resizable: options"); + +test("aspectRatio: 'preserve' (e)", function() { + expect(4); + + var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, -130); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (w)", function() { + expect(4); + + var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, -80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, 130); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (n)", function() { + expect(4); + + var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 0, -80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, 0, 80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (s)", function() { + expect(4); + + var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 0, 80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, 0, -80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (se)", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 80, 80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, -80, -80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (sw)", function() { + expect(4); + + var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, -80, 80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, 80, -80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (ne)", function() { + expect(4); + + var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 80, -80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, -80, 80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("grid", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', grid: [0, 20] }); + + drag(handle, 3, 9); + equals( target.width(), 103, "compare width"); + equals( target.height(), 100, "compare height"); + + drag(handle, 15, 11); + equals( target.width(), 118, "compare width"); + equals( target.height(), 120, "compare height"); +}); + +test("grid (wrapped)", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable2').resizable({ handles: 'all', grid: [0, 20] }); + + drag(handle, 3, 9); + equals( target.width(), 103, "compare width"); + equals( target.height(), 100, "compare height"); + + drag(handle, 15, 11); + equals( target.width(), 118, "compare width"); + equals( target.height(), 120, "compare height"); +}); + +test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + + drag(handle, -50, -50); + equals( target.width(), 60, "compare minWidth" ); + equals( target.height(), 60, "compare minHeight" ); + + drag(handle, 70, 70); + equals( target.width(), 100, "compare maxWidth" ); + equals( target.height(), 100, "compare maxHeight" ); +}); + +test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { + expect(4); + + var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + + drag(handle, 50, -50); + equals( target.width(), 60, "compare minWidth" ); + equals( target.height(), 60, "compare minHeight" ); + + drag(handle, -70, 70); + equals( target.width(), 100, "compare maxWidth" ); + equals( target.height(), 100, "compare maxHeight" ); +}); + +test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { + expect(4); + + var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + + drag(handle, -50, 50); + equals( target.width(), 60, "compare minWidth" ); + equals( target.height(), 60, "compare minHeight" ); + + drag(handle, 70, -70); + equals( target.width(), 100, "compare maxWidth" ); + equals( target.height(), 100, "compare maxHeight" ); +}); + +test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { + expect(4); + + var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + + drag(handle, 70, 70); + equals( target.width(), 60, "compare minWidth" ); + equals( target.height(), 60, "compare minHeight" ); + + drag(handle, -70, -70); + equals( target.width(), 100, "compare maxWidth" ); + equals( target.height(), 100, "compare maxHeight" ); +}); + +})(jQuery); |