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/core | |
parent | e5f94e9be5017f627c1ccd8c6306c5cc2e200432 (diff) |
new jq layout
Diffstat (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/core')
4 files changed, 560 insertions, 0 deletions
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/all.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/all.html new file mode 100644 index 0000000..e8d84e1 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Core 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( "core" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Core 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/core/core.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/core.html new file mode 100644 index 0000000..3b1dc1f --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/core.html @@ -0,0 +1,134 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Core Test Suite</title> + + <script src="../../jquery.js"></script> + <script src="../../resource_loader.js"></script> + <script> + loadResources({ + js: [ "ui/jquery.ui.core.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="core.js"></script> + <script src="selector.js"></script> + + <script src="../swarminject.js"></script> + <style> + .zindex { + z-index: 100; + } + .absolute { + position: absolute; + } + </style> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Core 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"> + +<img src="../images/jqueryui_32x32.png" usemap="#mymap" width="10", height="10"> +<map name="mymap"> + <area shape="rect" coords="0,0,1,1" id="areaCoordsNoHref"> + <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaCoordsHref"> + <area shape="rect" coords="0,0,0,0" href="foo.html" id="areaCoordsNoSizeHref"> + <area href="foo.html" id="areaNoCoordsHref"> +</map> +<map name="mymap2"> + <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaNoImg"> +</map> + +<form id="formNoTabindex"></form> +<form id="formTabindex" tabindex="1"></form> + +<div> + <input id="visibleAncestor-inputTypeNone"> + <input type="text" id="visibleAncestor-inputTypeText"> + <input type="checkbox" id="visibleAncestor-inputTypeCheckbox"> + <input type="radio" id="visibleAncestor-inputTypeRadio"> + <input type="button" id="visibleAncestor-inputTypeButton"> + <input type="hidden" id="visibleAncestor-inputTypeHidden"> + <button id="visibleAncestor-button">x</button> + <select id="visibleAncestor-select"> + <option>option</option> + </select> + <textarea id="visibleAncestor-textarea">x</textarea> + <object id="visibleAncestor-object" codebase="about:blank">xxx</object> + <a href="#" id="visibleAncestor-anchorWithHref">anchor</a> + <a id="visibleAncestor-anchorWithoutHref">anchor</a> + <span id="visibleAncestor-span">x</span> + <div id="visibleAncestor-div">x</div> + <span id="visibleAncestor-spanWithTabindex" tabindex="1">x</span> + <div id="visibleAncestor-divWithNegativeTabindex" tabindex="-1">x</div> +</div> + +<div> + <input id="disabledElement-inputTypeNone" disabled="disabled"> + <input type="text" id="disabledElement-inputTypeText" disabled="disabled"> + <input type="checkbox" id="disabledElement-inputTypeCheckbox" disabled="disabled"> + <input type="radio" id="disabledElement-inputTypeRadio" disabled="disabled"> + <input type="button" id="disabledElement-inputTypeButton" disabled="disabled"> + <input type="hidden" id="disabledElement-inputTypeHidden" disabled="disabled"> + <button id="disabledElement-button" disabled="disabled"></button> + <select id="disabledElement-select" disabled="disabled"></select> + <textarea id="disabledElement-textarea" disabled="disabled"></textarea> +</div> + +<div> + <div id="displayNoneAncestor" style="display: none;"> + <input id="displayNoneAncestor-input"> + <span tabindex="1" id="displayNoneAncestor-span">.</span> + </div> + + <div id="visibilityHiddenAncestor" style="visibility: hidden;"> + <input id="visibilityHiddenAncestor-input"> + <span tabindex="1" id="visibilityHiddenAncestor-span">.</span> + </div> + + <span tabindex="1" id="displayNone-span" style="display: none;">.</span> + <span tabindex="1" id="visibilityHidden-span" style="visibility: hidden;">.</span> + + <input id="displayNone-input" style="display: none;"> + <input id="visibilityHidden-input" style="visibility: hidden;"> +</div> + +<div> + <input id="inputTabindex0" tabindex="0"> + <input id="inputTabindex10" tabindex="10"> + <input id="inputTabindex-1" tabindex="-1"> + <input id="inputTabindex-50" tabindex="-50"> + + <span id="spanTabindex0" tabindex="0">.</span> + <span id="spanTabindex10" tabindex="10">.</span> + <span id="spanTabindex-1" tabindex="-1">.</span> + <span id="spanTabindex-50" tabindex="-50">.</span> +</div> + +<div id="zIndex100" style="z-index: 100; position: absolute"> + <div id="zIndexAutoWithParent">.</div> +</div> +<div id="zIndex100ViaCSS" class="zindex"> + <div id="zIndexAutoWithParentViaCSS">.</div> +</div> +<div id="zIndex100ViaCSSPositioned" class="zindex absolute"> + <div id="zIndexAutoWithParentViaCSSPositioned">.</div> +</div> +<div id="zIndexAutoNoParent"></div> + +<div id="dimensions" style="float: left; height: 50px; width: 100px; margin: 1px 12px 11px 2px; border-style: solid; border-width: 3px 14px 13px 4px; padding: 5px 16px 15px 6px;"></div> + +</div> +</body> +</html> diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/core.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/core.js new file mode 100644 index 0000000..03a7ab8 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/core.js @@ -0,0 +1,157 @@ +/* + * core unit tests + */ +(function($) { + +module('core - jQuery extensions'); + +test('focus - original functionality', function() { + expect(1); + + $('#inputTabindex0') + .focus(function() { + ok(true, 'event triggered'); + }) + .focus(); +}); + +asyncTest('focus', function() { + expect(2); + $('#inputTabindex0') + .focus(function() { + ok(true, 'event triggered'); + }) + .focus(500, function() { + ok(true, 'callback triggered'); + $(this).unbind('focus'); + start(); + }); +}); + +test('zIndex', function() { + var el = $('#zIndexAutoWithParent'), + parent = el.parent(); + equals(el.zIndex(), 100, 'zIndex traverses up to find value'); + equals(parent.zIndex(200), parent, 'zIndex setter is chainable'); + equals(el.zIndex(), 200, 'zIndex setter changed zIndex'); + + el = $('#zIndexAutoWithParentViaCSS'); + equals(el.zIndex(), 0, 'zIndex traverses up to find CSS value, not found because not positioned'); + + el = $('#zIndexAutoWithParentViaCSSPositioned'); + equals(el.zIndex(), 100, 'zIndex traverses up to find CSS value'); + el.parent().zIndex(200); + equals(el.zIndex(), 200, 'zIndex setter changed zIndex, overriding CSS'); + + equals($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy'); +}); + +test( "innerWidth - getter", function() { + var el = $( "#dimensions" ); + + equals( el.innerWidth(), 122, "getter passthru" ); + el.hide(); + equals( el.innerWidth(), 122, "getter passthru when hidden" ); +}); + +test( "innerWidth - setter", function() { + var el = $( "#dimensions" ); + + el.innerWidth( 120 ); + equals( el.width(), 98, "width set properly" ); + el.hide(); + el.innerWidth( 100 ); + equals( el.width(), 78, "width set properly when hidden" ); +}); + +test( "innerHeight - getter", function() { + var el = $( "#dimensions" ); + + equals( el.innerHeight(), 70, "getter passthru" ); + el.hide(); + equals( el.innerHeight(), 70, "getter passthru when hidden" ); +}); + +test( "innerHeight - setter", function() { + var el = $( "#dimensions" ); + + el.innerHeight( 60 ); + equals( el.height(), 40, "height set properly" ); + el.hide(); + el.innerHeight( 50 ); + equals( el.height(), 30, "height set properly when hidden" ); +}); + +test( "outerWidth - getter", function() { + var el = $( "#dimensions" ); + + equals( el.outerWidth(), 140, "getter passthru" ); + el.hide(); + equals( el.outerWidth(), 140, "getter passthru when hidden" ); +}); + +test( "outerWidth - setter", function() { + var el = $( "#dimensions" ); + + el.outerWidth( 130 ); + equals( el.width(), 90, "width set properly" ); + el.hide(); + el.outerWidth( 120 ); + equals( el.width(), 80, "width set properly when hidden" ); +}); + +test( "outerWidth(true) - getter", function() { + var el = $( "#dimensions" ); + + equals( el.outerWidth(true), 154, "getter passthru w/ margin" ); + el.hide(); + equals( el.outerWidth(true), 154, "getter passthru w/ margin when hidden" ); +}); + +test( "outerWidth(true) - setter", function() { + var el = $( "#dimensions" ); + + el.outerWidth( 130, true ); + equals( el.width(), 76, "width set properly" ); + el.hide(); + el.outerWidth( 120, true ); + equals( el.width(), 66, "width set properly when hidden" ); +}); + +test( "outerHeight - getter", function() { + var el = $( "#dimensions" ); + + equals( el.outerHeight(), 86, "getter passthru" ); + el.hide(); + equals( el.outerHeight(), 86, "getter passthru when hidden" ); +}); + +test( "outerHeight - setter", function() { + var el = $( "#dimensions" ); + + el.outerHeight( 80 ); + equals( el.height(), 44, "height set properly" ); + el.hide(); + el.outerHeight( 70 ); + equals( el.height(), 34, "height set properly when hidden" ); +}); + +test( "outerHeight(true) - getter", function() { + var el = $( "#dimensions" ); + + equals( el.outerHeight(true), 98, "getter passthru w/ margin" ); + el.hide(); + equals( el.outerHeight(true), 98, "getter passthru w/ margin when hidden" ); +}); + +test( "outerHeight(true) - setter", function() { + var el = $( "#dimensions" ); + + el.outerHeight( 90, true ); + equals( el.height(), 42, "height set properly" ); + el.hide(); + el.outerHeight( 80, true ); + equals( el.height(), 32, "height set properly when hidden" ); +}); + +})(jQuery); diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/selector.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/selector.js new file mode 100644 index 0000000..2fb7802 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/core/selector.js @@ -0,0 +1,239 @@ +/* + * selector unit tests + */ +(function($) { + +module("core - selectors"); + +function isFocusable(selector, msg) { + ok($(selector).is(':focusable'), msg + " - selector " + selector + " is focusable"); +} + +function isNotFocusable(selector, msg) { + ok($(selector).length && !$(selector).is(':focusable'), msg + " - selector " + selector + " is not focusable"); +} + +function isTabbable(selector, msg) { + ok($(selector).is(':tabbable'), msg + " - selector " + selector + " is tabbable"); +} + +function isNotTabbable(selector, msg) { + ok($(selector).length && !$(selector).is(':tabbable'), msg + " - selector " + selector + " is not tabbable"); +} + +test("data", function() { + expect(15); + + var el; + function shouldHaveData(msg) { + ok(el.is(':data(test)'), msg); + } + function shouldNotHaveData(msg) { + ok(!el.is(':data(test)'), msg); + } + + el = $('<div>'); + shouldNotHaveData('data never set'); + + el = $('<div>').data('test', null); + shouldNotHaveData('data is null'); + + el = $('<div>').data('test', true); + shouldHaveData('data set to true'); + + el = $('<div>').data('test', false); + shouldNotHaveData('data set to false'); + + el = $('<div>').data('test', 0); + shouldNotHaveData('data set to 0'); + + el = $('<div>').data('test', 1); + shouldHaveData('data set to 1'); + + el = $('<div>').data('test', ''); + shouldNotHaveData('data set to empty string'); + + el = $('<div>').data('test', 'foo'); + shouldHaveData('data set to string'); + + el = $('<div>').data('test', []); + shouldHaveData('data set to empty array'); + + el = $('<div>').data('test', [1]); + shouldHaveData('data set to array'); + + el = $('<div>').data('test', {}); + shouldHaveData('data set to empty object'); + + el = $('<div>').data('test', {foo: 'bar'}); + shouldHaveData('data set to object'); + + el = $('<div>').data('test', new Date()); + shouldHaveData('data set to date'); + + el = $('<div>').data('test', /test/); + shouldHaveData('data set to regexp'); + + el = $('<div>').data('test', function() {}); + shouldHaveData('data set to function'); +}); + +test("focusable - visible, enabled elements", function() { + expect(18); + + isNotFocusable('#formNoTabindex', 'form'); + isFocusable('#formTabindex', 'form with tabindex'); + isFocusable('#visibleAncestor-inputTypeNone', 'input, no type'); + isFocusable('#visibleAncestor-inputTypeText', 'input, type text'); + isFocusable('#visibleAncestor-inputTypeCheckbox', 'input, type checkbox'); + isFocusable('#visibleAncestor-inputTypeRadio', 'input, type radio'); + isFocusable('#visibleAncestor-inputTypeButton', 'input, type button'); + isNotFocusable('#visibleAncestor-inputTypeHidden', 'input, type hidden'); + isFocusable('#visibleAncestor-button', 'button'); + isFocusable('#visibleAncestor-select', 'select'); + isFocusable('#visibleAncestor-textarea', 'textarea'); + isFocusable('#visibleAncestor-object', 'object'); + isFocusable('#visibleAncestor-anchorWithHref', 'anchor with href'); + isNotFocusable('#visibleAncestor-anchorWithoutHref', 'anchor without href'); + isNotFocusable('#visibleAncestor-span', 'span'); + isNotFocusable('#visibleAncestor-div', 'div'); + isFocusable("#visibleAncestor-spanWithTabindex", 'span with tabindex'); + isFocusable("#visibleAncestor-divWithNegativeTabindex", 'div with tabindex'); +}); + +test("focusable - disabled elements", function() { + expect(9); + + isNotFocusable('#disabledElement-inputTypeNone', 'input, no type'); + isNotFocusable('#disabledElement-inputTypeText', 'input, type text'); + isNotFocusable('#disabledElement-inputTypeCheckbox', 'input, type checkbox'); + isNotFocusable('#disabledElement-inputTypeRadio', 'input, type radio'); + isNotFocusable('#disabledElement-inputTypeButton', 'input, type button'); + isNotFocusable('#disabledElement-inputTypeHidden', 'input, type hidden'); + isNotFocusable('#disabledElement-button', 'button'); + isNotFocusable('#disabledElement-select', 'select'); + isNotFocusable('#disabledElement-textarea', 'textarea'); +}); + +test("focusable - hidden styles", function() { + expect(8); + + isNotFocusable('#displayNoneAncestor-input', 'input, display: none parent'); + isNotFocusable('#displayNoneAncestor-span', 'span with tabindex, display: none parent'); + + isNotFocusable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent'); + isNotFocusable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent'); + + isNotFocusable('#displayNone-input', 'input, display: none'); + isNotFocusable('#visibilityHidden-input', 'input, visibility: hidden'); + + isNotFocusable('#displayNone-span', 'span with tabindex, display: none'); + isNotFocusable('#visibilityHidden-span', 'span with tabindex, visibility: hidden'); +}); + +test("focusable - natively focusable with various tabindex", function() { + expect(4); + + isFocusable('#inputTabindex0', 'input, tabindex 0'); + isFocusable('#inputTabindex10', 'input, tabindex 10'); + isFocusable('#inputTabindex-1', 'input, tabindex -1'); + isFocusable('#inputTabindex-50', 'input, tabindex -50'); +}); + +test("focusable - not natively focusable with various tabindex", function() { + expect(4); + + isFocusable('#spanTabindex0', 'span, tabindex 0'); + isFocusable('#spanTabindex10', 'span, tabindex 10'); + isFocusable('#spanTabindex-1', 'span, tabindex -1'); + isFocusable('#spanTabindex-50', 'span, tabindex -50'); +}); + +test("focusable - area elements", function() { + isNotFocusable('#areaCoordsNoHref', 'coords but no href'); + isFocusable('#areaCoordsHref', 'coords and href'); + isFocusable('#areaCoordsNoSizeHref', 'coords of zero px and href'); + isFocusable('#areaNoCoordsHref', 'href but no coords'); + isNotFocusable('#areaNoImg', 'not associated with an image'); +}); + +test("tabbable - visible, enabled elements", function() { + expect(18); + + isNotTabbable('#formNoTabindex', 'form'); + isTabbable('#formTabindex', 'form with tabindex'); + isTabbable('#visibleAncestor-inputTypeNone', 'input, no type'); + isTabbable('#visibleAncestor-inputTypeText', 'input, type text'); + isTabbable('#visibleAncestor-inputTypeCheckbox', 'input, type checkbox'); + isTabbable('#visibleAncestor-inputTypeRadio', 'input, type radio'); + isTabbable('#visibleAncestor-inputTypeButton', 'input, type button'); + isNotTabbable('#visibleAncestor-inputTypeHidden', 'input, type hidden'); + isTabbable('#visibleAncestor-button', 'button'); + isTabbable('#visibleAncestor-select', 'select'); + isTabbable('#visibleAncestor-textarea', 'textarea'); + isTabbable('#visibleAncestor-object', 'object'); + isTabbable('#visibleAncestor-anchorWithHref', 'anchor with href'); + isNotTabbable('#visibleAncestor-anchorWithoutHref', 'anchor without href'); + isNotTabbable('#visibleAncestor-span', 'span'); + isNotTabbable('#visibleAncestor-div', 'div'); + isTabbable("#visibleAncestor-spanWithTabindex", 'span with tabindex'); + isNotTabbable("#visibleAncestor-divWithNegativeTabindex", 'div with tabindex'); +}); + +test("tabbable - disabled elements", function() { + expect(9); + + isNotTabbable('#disabledElement-inputTypeNone', 'input, no type'); + isNotTabbable('#disabledElement-inputTypeText', 'input, type text'); + isNotTabbable('#disabledElement-inputTypeCheckbox', 'input, type checkbox'); + isNotTabbable('#disabledElement-inputTypeRadio', 'input, type radio'); + isNotTabbable('#disabledElement-inputTypeButton', 'input, type button'); + isNotTabbable('#disabledElement-inputTypeHidden', 'input, type hidden'); + isNotTabbable('#disabledElement-button', 'button'); + isNotTabbable('#disabledElement-select', 'select'); + isNotTabbable('#disabledElement-textarea', 'textarea'); +}); + +test("tabbable - hidden styles", function() { + expect(8); + + isNotTabbable('#displayNoneAncestor-input', 'input, display: none parent'); + isNotTabbable('#displayNoneAncestor-span', 'span with tabindex, display: none parent'); + + isNotTabbable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent'); + isNotTabbable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent'); + + isNotTabbable('#displayNone-input', 'input, display: none'); + isNotTabbable('#visibilityHidden-input', 'input, visibility: hidden'); + + isNotTabbable('#displayNone-span', 'span with tabindex, display: none'); + isNotTabbable('#visibilityHidden-span', 'span with tabindex, visibility: hidden'); +}); + +test("tabbable - natively tabbable with various tabindex", function() { + expect(4); + + isTabbable('#inputTabindex0', 'input, tabindex 0'); + isTabbable('#inputTabindex10', 'input, tabindex 10'); + isNotTabbable('#inputTabindex-1', 'input, tabindex -1'); + isNotTabbable('#inputTabindex-50', 'input, tabindex -50'); +}); + +test("tabbable - not natively tabbable with various tabindex", function() { + expect(4); + + isTabbable('#spanTabindex0', 'span, tabindex 0'); + isTabbable('#spanTabindex10', 'span, tabindex 10'); + isNotTabbable('#spanTabindex-1', 'span, tabindex -1'); + isNotTabbable('#spanTabindex-50', 'span, tabindex -50'); +}); + +test("tabbable - area elements", function() { + isNotTabbable('#areaCoordsNoHref', 'coords but no href'); + isTabbable('#areaCoordsHref', 'coords and href'); + isTabbable('#areaCoordsNoSizeHref', 'coords of zero px and href'); + isTabbable('#areaNoCoordsHref', 'href but no coords'); + isNotTabbable('#areaNoImg', 'not associated with an image'); +}); + +})(jQuery); |