summaryrefslogtreecommitdiff
path: root/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/menu')
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/all.html30
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu.html258
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_core.js41
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_defaults.js14
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_events.js431
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_methods.js15
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_options.js10
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_test_helpers.js14
8 files changed, 813 insertions, 0 deletions
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/all.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/all.html
new file mode 100644
index 0000000..38b7603
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/all.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Menu 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( "menu" );
+ </script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Menu 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/menu/menu.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu.html
new file mode 100644
index 0000000..76f4a7a
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu.html
@@ -0,0 +1,258 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Menu Test Suite</title>
+
+ <script src="../../jquery.js"></script>
+ <script src="../../resource_loader.js"></script>
+ <script>
+ loadResources({
+ css: [ "ui.core", "ui.menu" ],
+ js: [
+ "ui/jquery.ui.core.js",
+ "ui/jquery.ui.widget.js",
+ "ui/jquery.ui.menu.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="menu_test_helpers.js"></script>
+ <script src="menu_core.js"></script>
+ <script src="menu_defaults.js"></script>
+ <script src="menu_events.js"></script>
+ <script src="menu_methods.js"></script>
+ <script src="menu_options.js"></script>
+
+ <script src="../swarminject.js"></script>
+ <style>
+ .ui-menu {
+ font-size: 15px;
+ }
+ #menu3 {
+ height: 250px;
+ overflow: auto;
+ }
+ #menu4, #menu4 ul {
+ height: 250px;
+ overflow: auto;
+ }
+ </style>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Menu 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">
+
+<ul class="foo" id="menu1">
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li class="foo"><a class="foo" href="#">Adelphi</a></li>
+</ul>
+
+<ul id="menu2">
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li>
+ <a href="#">Delphi</a>
+ <ul>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Saarland</a></li>
+ <li class="foo"><a class="foo" href="#">Salzburg</a></li>
+ </ul>
+ </li>
+ <li class="foo"><a class="foo" href="#">Saarland</a></li>
+ <li>
+ <a href="#">Salzburg</a>
+ <ul>
+ <li>
+ <a href="#">Delphi</a>
+ <ul>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Saarland</a></li>
+ <li class="foo"><a class="foo" href="#">Salzburg</a></li>
+ </ul>
+ </li>
+ <li>
+ <a href="#">Delphi</a>
+ <ul>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Saarland</a></li>
+ <li class="foo"><a class="foo" href="#">Salzburg</a></li>
+ </ul>
+ </li>
+ <li class="foo"><a class="foo" href="#">Perch</a></li>
+ </ul>
+ </li>
+</ul>
+
+<ul class="foo" id="menu3">
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li class="foo"><a class="foo" href="#">Adelphi</a></li>
+ <li class="foo"><a class="foo" href="#">Adena</a></li>
+ <li class="foo"><a class="foo" href="#">Adrian</a></li>
+ <li class="foo"><a class="foo" href="#">Akron</a></li>
+ <li class="foo"><a class="foo" href="#">Albany</a></li>
+ <li class="foo"><a class="foo" href="#">Alexandria</a></li>
+ <li class="foo"><a class="foo" href="#">Alger</a></li>
+ <li class="foo"><a class="foo" href="#">Alledonia</a></li>
+ <li class="foo"><a class="foo" href="#">Alliance</a></li>
+ <li class="foo"><a class="foo" href="#">Alpha</a></li>
+ <li class="foo"><a class="foo" href="#">Alvada</a></li>
+ <li class="foo"><a class="foo" href="#">Alvordton</a></li>
+ <li class="foo"><a class="foo" href="#">Amanda</a></li>
+ <li class="foo"><a class="foo" href="#">Amelia</a></li>
+ <li class="foo"><a class="foo" href="#">Amesville</a></li>
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li class="foo"><a class="foo" href="#">Adelphi</a></li>
+ <li class="foo"><a class="foo" href="#">Adena</a></li>
+ <li class="foo"><a class="foo" href="#">Adrian</a></li>
+ <li class="foo"><a class="foo" href="#">Akron</a></li>
+ <li class="foo"><a class="foo" href="#">Albany</a></li>
+ <li class="foo"><a class="foo" href="#">Alexandria</a></li>
+ <li class="foo"><a class="foo" href="#">Alger</a></li>
+ <li class="foo"><a class="foo" href="#">Alledonia</a></li>
+ <li class="foo"><a class="foo" href="#">Alliance</a></li>
+ <li class="foo"><a class="foo" href="#">Alpha</a></li>
+ <li class="foo"><a class="foo" href="#">Alvada</a></li>
+ <li class="foo"><a class="foo" href="#">Alvordton</a></li>
+ <li class="foo"><a class="foo" href="#">Amanda</a></li>
+ <li class="foo"><a class="foo" href="#">Amelia</a></li>
+ <li class="foo"><a class="foo" href="#">Amesville</a></li>
+</ul>
+
+<ul class="foo" id="menu4">
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo">
+ <a class="foo" href="#">Ada</a>
+ <ul class="foo">
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li class="foo"><a class="foo" href="#">Adelphi</a></li>
+ <li class="foo"><a class="foo" href="#">Adena</a></li>
+ <li class="foo"><a class="foo" href="#">Adrian</a></li>
+ <li class="foo"><a class="foo" href="#">Akron</a></li>
+ <li class="foo"><a class="foo" href="#">Albany</a></li>
+ <li class="foo"><a class="foo" href="#">Alexandria</a></li>
+ <li class="foo"><a class="foo" href="#">Alger</a></li>
+ <li class="foo"><a class="foo" href="#">Alledonia</a></li>
+ <li class="foo"><a class="foo" href="#">Alliance</a></li>
+ <li class="foo"><a class="foo" href="#">Alpha</a></li>
+ <li class="foo"><a class="foo" href="#">Alvada</a></li>
+ <li class="foo"><a class="foo" href="#">Alvordton</a></li>
+ <li class="foo"><a class="foo" href="#">Amanda</a></li>
+ <li class="foo"><a class="foo" href="#">Amelia</a></li>
+ <li class="foo"><a class="foo" href="#">Amesville</a></li>
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li class="foo"><a class="foo" href="#">Adelphi</a></li>
+ <li class="foo"><a class="foo" href="#">Adena</a></li>
+ <li class="foo"><a class="foo" href="#">Adrian</a></li>
+ <li class="foo"><a class="foo" href="#">Akron</a></li>
+ <li class="foo"><a class="foo" href="#">Albany</a></li>
+ </ul>
+ </li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li class="foo"><a class="foo" href="#">Adelphi</a></li>
+ <li class="foo"><a class="foo" href="#">Adena</a></li>
+ <li class="foo"><a class="foo" href="#">Adrian</a></li>
+ <li class="foo"><a class="foo" href="#">Akron</a></li>
+ <li class="foo"><a class="foo" href="#">Albany</a></li>
+ <li class="foo"><a class="foo" href="#">Alexandria</a></li>
+ <li class="foo"><a class="foo" href="#">Alger</a></li>
+ <li class="foo"><a class="foo" href="#">Alledonia</a></li>
+ <li class="foo"><a class="foo" href="#">Alliance</a></li>
+ <li class="foo"><a class="foo" href="#">Alpha</a></li>
+ <li class="foo"><a class="foo" href="#">Alvada</a></li>
+ <li class="foo"><a class="foo" href="#">Alvordton</a></li>
+ <li class="foo"><a class="foo" href="#">Amanda</a></li>
+ <li class="foo"><a class="foo" href="#">Amelia</a></li>
+ <li class="foo"><a class="foo" href="#">Amesville</a></li>
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li class="foo"><a class="foo" href="#">Adelphi</a></li>
+ <li class="foo"><a class="foo" href="#">Adena</a></li>
+ <li class="foo"><a class="foo" href="#">Adrian</a></li>
+ <li class="foo"><a class="foo" href="#">Akron</a></li>
+ <li class="foo"><a class="foo" href="#">Albany</a></li>
+ <li class="foo"><a class="foo" href="#">Alexandria</a></li>
+ <li class="foo"><a class="foo" href="#">Alger</a></li>
+ <li class="foo"><a class="foo" href="#">Alledonia</a></li>
+ <li class="foo"><a class="foo" href="#">Alliance</a></li>
+ <li class="foo"><a class="foo" href="#">Alpha</a></li>
+ <li class="foo"><a class="foo" href="#">Alvada</a></li>
+ <li class="foo"><a class="foo" href="#">Alvordton</a></li>
+ <li class="foo"><a class="foo" href="#">Amanda</a></li>
+ <li class="foo"><a class="foo" href="#">Amelia</a></li>
+ <li class="foo"><a class="foo" href="#">Amesville</a></li>
+</ul>
+
+<div id="menu5">
+ <blockquote><a href="#">Aberdeen</a></blockquote>
+ <blockquote><a href="#">Ada</a></blockquote>
+ <blockquote><a href="#">Adamsville</a></blockquote>
+ <blockquote><a href="#">Addyston</a></blockquote>
+ <blockquote>
+ <a href="#">Delphi</a>
+ <div>
+ <blockquote><a href="#">Ada</a></blockquote>
+ <blockquote><a href="#">Saarland</a></blockquote>
+ <blockquote><a href="#">Salzburg</a></blockquote>
+ </div>
+ </blockquote>
+ <blockquote><a href="#">Saarland</a></blockquote>
+ <blockquote>
+ <a href="#">Salzburg</a>
+ <div>
+ <blockquote>
+ <a href="#">Delphi</a>
+ <div>
+ <blockquote><a href="#">Ada</a></blockquote>
+ <blockquote><a href="#">Saarland</a></blockquote>
+ <blockquote><a href="#">Salzburg</a></blockquote>
+ </div>
+ </blockquote>
+ <blockquote>
+ <a href="#">Delphi</a>
+ <div>
+ <blockquote><a href="#">Ada</a></blockquote>
+ <blockquote><a href="#">Saarland</a></blockquote>
+ <blockquote><a href="#">Salzburg</a></blockquote>
+ </div>
+ </blockquote>
+ <blockquote><a href="#">Perch</a></blockquote>
+ </div>
+ </blockquote>
+</div>
+
+<div id="log"></div>
+
+</div>
+</body>
+</html>
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_core.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_core.js
new file mode 100644
index 0000000..c0feae7
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_core.js
@@ -0,0 +1,41 @@
+/*
+ * menu_core.js
+ */
+
+
+(function($) {
+
+module("menu: core");
+
+test("accessibility", function () {
+ expect(5);
+ var ac = $('#menu1').menu();
+ var item0 = $("li:eq(0) a");
+
+ ok( ac.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class");
+ equals( ac.attr("role"), "menu", "main role");
+ ok( !ac.attr("aria-activedescendant"), "aria attribute not yet active");
+
+ var item = ac.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
+ ac.menu( "focus", $.Event(), item );
+ equals( ac.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
+
+ var item = ac.find( "li:last" );
+ ac.menu( "focus", $.Event(), item );
+ equals( ac.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
+});
+
+test("items class and role", function () {
+ var ac = $('#menu1').menu();
+ expect(1 + 5 * $("li",ac).length);
+ ok( ($("li",ac).length > 0 ), "number of menu items");
+ $("li",ac).each(function(item) {
+ ok( $(this).hasClass("ui-menu-item"), "menu item ("+ item + ") class for item");
+ equals( $(this).attr("role"), "presentation", "menu item ("+ item + ") role");
+ equals( $("a", this).attr("role"), "menuitem", "menu item ("+ item + ") role");
+ ok( $("a",this).hasClass("ui-corner-all"), "a element class for menu item ("+ item + ") ");
+ equals( $("a",this).attr("tabindex"), "-1", "a element tabindex for menu item ("+ item + ") ");
+ });
+});
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_defaults.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_defaults.js
new file mode 100644
index 0000000..a559a3d
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_defaults.js
@@ -0,0 +1,14 @@
+commonWidgetTests( "menu", {
+ defaults: {
+ disabled: false,
+ position: {
+ my: "left top",
+ at: "right top"
+ },
+ items: "ul",
+ trigger: null,
+
+ // callbacks
+ create: null
+ }
+});
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_events.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_events.js
new file mode 100644
index 0000000..55ec1e2
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_events.js
@@ -0,0 +1,431 @@
+/*
+ * menu_events.js
+ */
+(function($) {
+
+module("menu: events");
+
+test("handle click on menu", function() {
+ expect(1);
+ var ac = $('#menu1').menu({
+ select: function(event, ui) {
+ menu_log();
+ }
+ });
+ menu_log("click",true);
+ menu_click($('#menu1'),"1");
+ menu_log("afterclick");
+ menu_click( ac,"2");
+ menu_click($('#menu1'),"3");
+ menu_click( ac,"1");
+ equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
+});
+
+test("handle click on custom item menu", function() {
+ expect(1);
+ var ac = $('#menu5').menu({
+ select: function(event, ui) {
+ menu_log();
+ },
+ items: "div"
+ });
+ menu_log("click",true);
+ menu_click($('#menu5'),"1");
+ menu_log("afterclick");
+ menu_click( ac,"2");
+ menu_click($('#menu5'),"3");
+ menu_click( ac,"1");
+ equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
+});
+
+test( "handle blur: click", function() {
+ expect( 4 );
+ var $menu = $( "#menu1" ).menu({
+ focus: function( event, ui ) {
+ equal( event.originalEvent.type, "click", "focus triggered 'click'" );
+ equal( event.type, "menufocus", "focus event.type is 'menufocus'" );
+
+ },
+ blur: function( event, ui ) {
+ equal( event.originalEvent.type, "click", "blur triggered 'click'" );
+ equal( event.type, "menublur", "blur event.type is 'menublur'" );
+ }
+ });
+
+ $menu.find( "li a:first" ).trigger( "click" );
+ $( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" );
+
+ $("#remove").remove();
+});
+
+test( "handle blur on custom item menu: click", function() {
+ expect( 4 );
+ var $menu = $( "#menu5" ).menu({
+ focus: function( event, ui ) {
+ equal( event.originalEvent.type, "click", "focus triggered 'click'" );
+ equal( event.type, "menufocus", "focus event.type is 'menufocus'" );
+
+ },
+ blur: function( event, ui ) {
+ equal( event.originalEvent.type, "click", "blur triggered 'click'" );
+ equal( event.type, "menublur", "blur event.type is 'menublur'" );
+ },
+ items: "div"
+ });
+
+ menu_click($('#menu5'),"1");
+ $( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" );
+
+ $("#remove").remove();
+});
+
+asyncTest( "handle submenu auto collapse: mouseleave", function() {
+ expect( 4 );
+ var $menu = $( "#menu2" ).menu();
+
+ $menu.find( "li:nth-child(7)" ).trigger( "mouseover" );
+ setTimeout(function() {
+ equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "first submenu expanded" );
+ $menu.find( "li:nth-child(7) li:first" ).trigger( "mouseover" );
+ setTimeout(function() {
+ equal( $menu.find( "ul[aria-expanded='true']" ).length, 2, "second submenu expanded" );
+ $menu.find( "ul[aria-expanded='true']:first" ).trigger( "mouseleave" );
+ equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
+ $menu.trigger( "mouseleave" );
+ equal( $menu.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
+ start();
+ }, 400);
+ }, 200);
+});
+
+asyncTest( "handle custom menu item submenu auto collapse: mouseleave", function() {
+ expect( 5 );
+ var $menu = $( "#menu5" ).menu( { items: "div" } );
+
+ $menu.children( ":nth-child(7)" ).trigger( "mouseover" );
+ setTimeout(function() {
+ equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "first submenu expanded" );
+ $menu.children( ":nth-child(7)" ).find( "div:first" ).children( ":first" ).trigger( "mouseover" );
+ setTimeout(function() {
+ equal( $menu.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" );
+ $menu.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" );
+ equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
+
+ $menu.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN });
+ ok( $menu.find( ".ui-state-active" ).is( "#menu5 :nth-child(7) a" ),
+ "down keypress selected an item from the first submenu" );
+
+ $menu.trigger( "mouseleave" );
+ equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
+ start();
+ }, 400);
+ }, 200);
+});
+
+
+test("handle keyboard navigation on menu without scroll and without submenus", function() {
+ expect(12);
+ var element = $('#menu1').menu({
+ select: function(event, ui) {
+ menu_log($(ui.item[0]).text());
+ },
+ focus: function( event, ui ) {
+ menu_log($(event.target).find(".ui-state-focus").parent().index());
+ }
+ });
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
+ equals( $("#log").html(), "0,keydown,", "Keydown UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
+ equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
+ equals( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
+ equals( $("#log").html(), "4,keydown,", "Keydown PAGE_DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
+ equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
+ equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
+ equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
+ equals( $("#log").html(), "4,keydown,", "Keydown END");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
+ equals( $("#log").html(), "0,keydown,", "Keydown HOME");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
+ equals( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
+});
+
+asyncTest("handle keyboard navigation on menu without scroll and with submenus", function() {
+ expect(14);
+ var element = $('#menu2').menu({
+ select: function(event, ui) {
+ menu_log($(ui.item[0]).text());
+ },
+ focus: function( event, ui ) {
+ menu_log($(event.target).find(".ui-state-focus").parent().index());
+ }
+ });
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
+ equals( $("#log").html(), "0,keydown,", "Keydown UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
+ equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
+
+ setTimeout( function() {
+ equals( $("#log").html(), "0,4,3,2,1,keydown,", "Keydown RIGHT (open submenu)");
+ }, 50);
+
+ setTimeout( function() {
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
+ equals( $("#log").html(), "4,keydown,", "Keydown LEFT (close submenu)");
+
+ //re-open submenu
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
+
+ setTimeout( function() {
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
+ equals( $("#log").html(), "2,keydown,", "Keydown PAGE_DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
+ equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
+ equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
+ equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
+ equals( $("#log").html(), "2,keydown,", "Keydown END");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
+ equals( $("#log").html(), "0,keydown,", "Keydown HOME");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
+ equals( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+
+ setTimeout( function() {
+ equals( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ equals( $("#log").html(), "Ada,keydown,", "Keydown ENTER (select item)");
+
+ start();
+ }, 200);
+ }, 150);
+ }, 100);
+
+});
+
+test("handle keyboard navigation on menu with scroll and without submenus", function() {
+ expect(14);
+ var element = $('#menu3').menu({
+ select: function(event, ui) {
+ menu_log($(ui.item[0]).text());
+ },
+ focus: function( event, ui ) {
+ menu_log($(event.target).find(".ui-state-focus").parent().index());
+ }
+ });
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
+ equals( $("#log").html(), "0,keydown,", "Keydown UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
+ equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
+ equals( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
+ equals( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
+ equals( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
+ equals( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
+ equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
+ equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
+ equals( $("#log").html(), "37,keydown,", "Keydown END");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
+ equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
+ equals( $("#log").html(), "0,keydown,", "Keydown HOME");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
+ equals( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
+});
+
+asyncTest("handle keyboard navigation on menu with scroll and with submenus", function() {
+ expect(14);
+ var element = $('#menu4').menu({
+ select: function(event, ui) {
+ menu_log($(ui.item[0]).text());
+ },
+ focus: function( event, ui ) {
+ menu_log($(event.target).find(".ui-state-focus").parent().index());
+ }
+ });
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
+ equals( $("#log").html(), "0,keydown,", "Keydown UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
+ equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
+
+ setTimeout( function() {
+ equals( $("#log").html(), "0,1,keydown,", "Keydown RIGHT (open submenu)");
+ }, 50);
+
+ setTimeout( function() {
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
+ equals( $("#log").html(), "1,keydown,", "Keydown LEFT (close submenu)");
+
+ //re-open submenu
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
+
+ setTimeout( function() {
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
+ equals( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
+ equals( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
+ equals( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
+ equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
+ equals( $("#log").html(), "27,keydown,", "Keydown END");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
+ equals( $("#log").html(), "0,keydown,", "Keydown HOME");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
+ equals( $("#log").html(), "1,keydown,", "Keydown ESCAPE (close submenu)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+
+ setTimeout( function() {
+ equals( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER (select item)");
+
+ start();
+ }, 200);
+ }, 150);
+ }, 100);
+
+});
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_methods.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_methods.js
new file mode 100644
index 0000000..0ecaf73
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_methods.js
@@ -0,0 +1,15 @@
+/*
+ * menu_methods.js
+ */
+(function($) {
+
+module("menu: methods");
+
+test("destroy", function() {
+ domEqual("#menu1", function() {
+ $("#menu1").menu().menu("destroy");
+ });
+});
+
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_options.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_options.js
new file mode 100644
index 0000000..03822fd
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_options.js
@@ -0,0 +1,10 @@
+/*
+ * menu_options.js
+ */
+(function($) {
+
+module("menu: options");
+
+
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_test_helpers.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_test_helpers.js
new file mode 100644
index 0000000..e83795e
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/menu/menu_test_helpers.js
@@ -0,0 +1,14 @@
+function menu_log( message, clear ) {
+ if ( clear ) {
+ $( "#log" ).empty();
+ }
+ if ( message === undefined ) {
+ message = $( "#log" ).data( "lastItem" );
+ }
+ $( "#log" ).prepend( $.trim( message ) + "," );
+}
+
+function menu_click( menu, item ) {
+ $( "#log" ).data( "lastItem", item );
+ menu.children( ":eq(" + item + ")" ).find( "a:first" ).trigger( "click" );
+} \ No newline at end of file