summaryrefslogtreecommitdiff
path: root/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-11-25 21:18:19 +0100
committerLeif Johansson <leifj@sunet.se>2011-11-25 21:18:19 +0100
commit3909e6d89e01e4cd8777377c63037896bb95aa2f (patch)
tree59679df287c2bee55087fb5afb8d42e7f93a44fb /src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog
parente5f94e9be5017f627c1ccd8c6306c5cc2e200432 (diff)
new jq layout
Diffstat (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog')
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/all.html30
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog.html60
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_core.js138
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_defaults.js34
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_events.js254
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_methods.js127
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_options.js444
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_tickets.js143
8 files changed, 1230 insertions, 0 deletions
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/all.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/all.html
new file mode 100644
index 0000000..e0416ec
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/all.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Dialog 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( "dialog" );
+ </script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Dialog 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/dialog/dialog.html b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog.html
new file mode 100644
index 0000000..94b20a2
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog.html
@@ -0,0 +1,60 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Dialog Test Suite</title>
+
+ <script src="../../jquery.js"></script>
+ <script src="../../../external/jquery.bgiframe-2.1.2.js"></script>
+ <script src="../../resource_loader.js"></script>
+ <script>
+ loadResources({
+ css: [ "ui.core", "ui.dialog" ],
+ js: [
+ "ui/jquery.ui.core.js",
+ "ui/jquery.ui.widget.js",
+ "ui/jquery.ui.position.js",
+ "ui/jquery.ui.mouse.js",
+ "ui/jquery.ui.draggable.js",
+ "ui/jquery.ui.resizable.js",
+ "ui/jquery.ui.dialog.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="dialog_core.js"></script>
+ <script src="dialog_defaults.js"></script>
+ <script src="dialog_events.js"></script>
+ <script src="dialog_methods.js"></script>
+ <script src="dialog_options.js"></script>
+ <script src="dialog_tickets.js"></script>
+
+ <script>
+ // disable this testsuite for testswarm only - until we fix it from freezing IE6
+ 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("dialog", function() { ok(true, "disabled dialog testsuite"); });
+ }
+ </script>
+ <script src="../swarminject.js"></script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Dialog 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/dialog/dialog_core.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_core.js
new file mode 100644
index 0000000..2003689
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_core.js
@@ -0,0 +1,138 @@
+/*
+ * dialog_core.js
+ */
+
+var el,
+ offsetBefore, offsetAfter,
+ heightBefore, heightAfter,
+ widthBefore, widthAfter,
+ dragged;
+
+function dlg() {
+ return el.dialog('widget');
+}
+
+function isOpen(why) {
+ ok(dlg().is(":visible"), why);
+}
+
+function isNotOpen(why) {
+ ok(!dlg().is(":visible"), why);
+}
+
+function drag(handle, dx, dy) {
+ var d = dlg();
+ offsetBefore = d.offset();
+ heightBefore = d.height();
+ widthBefore = d.width();
+ //this mouseover is to work around a limitation in resizable
+ //TODO: fix resizable so handle doesn't require mouseover in order to be used
+ $(handle, d).simulate("mouseover");
+ $(handle, d).simulate("drag", {
+ dx: dx || 0,
+ dy: dy || 0
+ });
+ dragged = { dx: dx, dy: dy };
+ offsetAfter = d.offset();
+ heightAfter = d.height();
+ widthAfter = d.width();
+}
+
+function moved(dx, dy, msg) {
+ msg = msg ? msg + "." : "";
+ var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) };
+ var expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) };
+ same(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
+}
+
+function shouldmove(why) {
+ var handle = $(".ui-dialog-titlebar", dlg());
+ drag(handle, 50, -50);
+ moved(50, -50, why);
+}
+
+function shouldnotmove(why) {
+ var handle = $(".ui-dialog-titlebar", dlg());
+ drag(handle, 50, -50);
+ moved(0, 0, why);
+}
+
+function resized(dw, dh, msg) {
+ msg = msg ? msg + "." : "";
+ var actual = { width: widthAfter, height: heightAfter };
+ var expected = { width: widthBefore + dw, height: heightBefore + dh };
+ same(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
+}
+
+function shouldresize(why) {
+ var handle = $(".ui-resizable-se", dlg());
+ drag(handle, 50, 50);
+ resized(50, 50, why);
+}
+
+function shouldnotresize(why) {
+ var handle = $(".ui-resizable-se", dlg());
+ drag(handle, 50, 50);
+ resized(0, 0, why);
+}
+
+function broder(el, side){
+ return parseInt(el.css('border-' + side + '-width'), 10);
+}
+
+function margin(el, side) {
+ return parseInt(el.css('margin-' + side), 10);
+}
+
+(function($) {
+
+module("dialog: core");
+
+test("title id", function() {
+ expect(3);
+
+ var titleId;
+
+ // reset the uuid so we know what values to expect
+ $.ui.dialog.uuid = 0;
+
+ el = $('<div></div>').dialog();
+ titleId = dlg().find('.ui-dialog-title').attr('id');
+ equals(titleId, 'ui-dialog-title-1', 'auto-numbered title id');
+ el.remove();
+
+ el = $('<div></div>').dialog();
+ titleId = dlg().find('.ui-dialog-title').attr('id');
+ equals(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
+ el.remove();
+
+ el = $('<div id="foo">').dialog();
+ titleId = dlg().find('.ui-dialog-title').attr('id');
+ equals(titleId, 'ui-dialog-title-foo', 'carried over title id');
+ el.remove();
+});
+
+test("ARIA", function() {
+ expect(4);
+
+ el = $('<div></div>').dialog();
+
+ equals(dlg().attr('role'), 'dialog', 'dialog role');
+
+ var labelledBy = dlg().attr('aria-labelledby');
+ ok(labelledBy.length > 0, 'has aria-labelledby attribute');
+ equals(dlg().find('.ui-dialog-title').attr('id'), labelledBy,
+ 'proper aria-labelledby attribute');
+
+ equals(dlg().find('.ui-dialog-titlebar-close').attr('role'), 'button',
+ 'close link role');
+
+ el.remove();
+});
+
+test("widget method", function() {
+ var dialog = $("<div>").appendTo("#main").dialog();
+ same(dialog.parent()[0], dialog.dialog("widget")[0]);
+});
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_defaults.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_defaults.js
new file mode 100644
index 0000000..9f2e4c6
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_defaults.js
@@ -0,0 +1,34 @@
+commonWidgetTests( "dialog", {
+ defaults: {
+ autoOpen: true,
+ buttons: {},
+ closeOnEscape: true,
+ closeText: 'close',
+ disabled: false,
+ dialogClass: '',
+ draggable: true,
+ height: 'auto',
+ hide: null,
+ maxHeight: false,
+ maxWidth: false,
+ minHeight: 150,
+ minWidth: 150,
+ modal: false,
+ position: {
+ my: 'center',
+ at: 'center',
+ of: window,
+ collision: 'fit',
+ using: $.ui.dialog.prototype.options.position.using
+ },
+ resizable: true,
+ show: null,
+ stack: true,
+ title: '',
+ width: 300,
+ zIndex: 1000,
+
+ // callbacks
+ create: null
+ }
+});
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_events.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_events.js
new file mode 100644
index 0000000..40a8575
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_events.js
@@ -0,0 +1,254 @@
+/*
+ * dialog_events.js
+ */
+(function($) {
+
+module("dialog: events");
+
+test("open", function() {
+ expect(13);
+
+ el = $("<div></div>");
+ el.dialog({
+ open: function(ev, ui) {
+ ok(el.data("dialog")._isOpen, "interal _isOpen flag is set");
+ ok(true, 'autoOpen: true fires open callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogopen', 'event type in callback');
+ same(ui, {}, 'ui hash in callback');
+ }
+ });
+ el.remove();
+
+ el = $("<div></div>");
+ el.dialog({
+ autoOpen: false,
+ open: function(ev, ui) {
+ ok(true, '.dialog("open") fires open callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogopen', 'event type in callback');
+ same(ui, {}, 'ui hash in callback');
+ }
+ }).bind('dialogopen', function(ev, ui) {
+ ok(el.data("dialog")._isOpen, "interal _isOpen flag is set");
+ ok(true, 'dialog("open") fires open event');
+ equals(this, el[0], 'context of event');
+ same(ui, {}, 'ui hash in event');
+ });
+ el.dialog("open");
+ el.remove();
+});
+
+test("dragStart", function() {
+ expect(9);
+
+ el = $('<div></div>').dialog({
+ dragStart: function(ev, ui) {
+ ok(true, 'dragging fires dragStart callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogdragstart', 'event type in callback');
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.offset !== undefined, "ui.offset in callback");
+ }
+ }).bind('dialogdragstart', function(ev, ui) {
+ ok(true, 'dragging fires dialogdragstart event');
+ equals(this, el[0], 'context of event');
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.offset !== undefined, "ui.offset in callback");
+ });
+ var handle = $(".ui-dialog-titlebar", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("drag", function() {
+ expect(9);
+ var hasDragged = false;
+
+ el = $('<div></div>').dialog({
+ drag: function(ev, ui) {
+ if (!hasDragged) {
+ ok(true, 'dragging fires drag callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogdrag', 'event type in callback');
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.offset !== undefined, "ui.offset in callback");
+
+ hasDragged = true;
+ }
+ }
+ }).one('dialogdrag', function(ev, ui) {
+ ok(true, 'dragging fires dialogdrag event');
+ equals(this, el[0], 'context of event');
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.offset !== undefined, "ui.offset in callback");
+ });
+ var handle = $(".ui-dialog-titlebar", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("dragStop", function() {
+ expect(9);
+
+ el = $('<div></div>').dialog({
+ dragStop: function(ev, ui) {
+ ok(true, 'dragging fires dragStop callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogdragstop', 'event type in callback');
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.offset !== undefined, "ui.offset in callback");
+ }
+ }).bind('dialogdragstop', function(ev, ui) {
+ ok(true, 'dragging fires dialogdragstop event');
+ equals(this, el[0], 'context of event');
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.offset !== undefined, "ui.offset in callback");
+ });
+ var handle = $(".ui-dialog-titlebar", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("resizeStart", function() {
+ expect(13);
+
+ el = $('<div></div>').dialog({
+ resizeStart: function(ev, ui) {
+ ok(true, 'resizing fires resizeStart callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogresizestart', 'event type in callback');
+ ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
+ ok(ui.originalSize !== undefined, "ui.originalSize in callback");
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.size !== undefined, "ui.size in callback");
+ }
+ }).bind('dialogresizestart', function(ev, ui) {
+ ok(true, 'resizing fires dialogresizestart event');
+ equals(this, el[0], 'context of event');
+ ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
+ ok(ui.originalSize !== undefined, "ui.originalSize in callback");
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.size !== undefined, "ui.size in callback");
+ });
+ var handle = $(".ui-resizable-se", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("resize", function() {
+ expect(13);
+ var hasResized = false;
+
+ el = $('<div></div>').dialog({
+ resize: function(ev, ui) {
+ if (!hasResized) {
+ ok(true, 'resizing fires resize callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogresize', 'event type in callback');
+ ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
+ ok(ui.originalSize !== undefined, "ui.originalSize in callback");
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.size !== undefined, "ui.size in callback");
+
+ hasResized = true;
+ }
+ }
+ }).one('dialogresize', function(ev, ui) {
+ ok(true, 'resizing fires dialogresize event');
+ equals(this, el[0], 'context of event');
+ ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
+ ok(ui.originalSize !== undefined, "ui.originalSize in callback");
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.size !== undefined, "ui.size in callback");
+ });
+ var handle = $(".ui-resizable-se", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("resizeStop", function() {
+ expect(13);
+
+ el = $('<div></div>').dialog({
+ resizeStop: function(ev, ui) {
+ ok(true, 'resizing fires resizeStop callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogresizestop', 'event type in callback');
+ ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
+ ok(ui.originalSize !== undefined, "ui.originalSize in callback");
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.size !== undefined, "ui.size in callback");
+ }
+ }).bind('dialogresizestop', function(ev, ui) {
+ ok(true, 'resizing fires dialogresizestop event');
+ equals(this, el[0], 'context of event');
+ ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
+ ok(ui.originalSize !== undefined, "ui.originalSize in callback");
+ ok(ui.position !== undefined, "ui.position in callback");
+ ok(ui.size !== undefined, "ui.size in callback");
+ });
+ var handle = $(".ui-resizable-se", dlg());
+ drag(handle, 50, 50);
+ el.remove();
+});
+
+test("close", function() {
+ expect(7);
+
+ el = $('<div></div>').dialog({
+ close: function(ev, ui) {
+ ok(true, '.dialog("close") fires close callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogclose', 'event type in callback');
+ same(ui, {}, 'ui hash in callback');
+ }
+ }).bind('dialogclose', function(ev, ui) {
+ ok(true, '.dialog("close") fires dialogclose event');
+ equals(this, el[0], 'context of event');
+ same(ui, {}, 'ui hash in event');
+ });
+ el.dialog('close');
+ el.remove();
+});
+
+test("beforeClose", function() {
+ expect(14);
+
+ el = $('<div></div>').dialog({
+ beforeClose: function(ev, ui) {
+ ok(true, '.dialog("close") fires beforeClose callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogbeforeclose', 'event type in callback');
+ same(ui, {}, 'ui hash in callback');
+ return false;
+ }
+ });
+ el.dialog('close');
+ isOpen('beforeClose callback should prevent dialog from closing');
+ el.remove();
+
+ el = $('<div></div>').dialog();
+ el.dialog('option', 'beforeClose', function(ev, ui) {
+ ok(true, '.dialog("close") fires beforeClose callback');
+ equals(this, el[0], "context of callback");
+ equals(ev.type, 'dialogbeforeclose', 'event type in callback');
+ same(ui, {}, 'ui hash in callback');
+ return false;
+ });
+ el.dialog('close');
+ isOpen('beforeClose callback should prevent dialog from closing');
+ el.remove();
+
+ el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
+ ok(true, '.dialog("close") triggers dialogbeforeclose event');
+ equals(this, el[0], "context of event");
+ same(ui, {}, 'ui hash in event');
+ return false;
+ });
+ el.dialog('close');
+ isOpen('dialogbeforeclose event should prevent dialog from closing');
+ el.remove();
+});
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_methods.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_methods.js
new file mode 100644
index 0000000..a961b4e
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_methods.js
@@ -0,0 +1,127 @@
+/*
+ * dialog_methods.js
+ */
+(function($) {
+
+module("dialog: methods", {
+ teardown: function() {
+ $("body>.ui-dialog").remove();
+ }
+});
+
+test("init", function() {
+ expect(6);
+
+ $("<div></div>").appendTo('body').dialog().remove();
+ ok(true, '.dialog() called on element');
+
+ $([]).dialog().remove();
+ ok(true, '.dialog() called on empty collection');
+
+ $('<div></div>').dialog().remove();
+ ok(true, '.dialog() called on disconnected DOMElement - never connected');
+
+ $('<div></div>').appendTo('body').remove().dialog().remove();
+ ok(true, '.dialog() called on disconnected DOMElement - removed');
+
+ el = $('<div></div>').dialog();
+ var foo = el.dialog("option", "foo");
+ el.remove();
+ ok(true, 'arbitrary option getter after init');
+
+ $('<div></div>').dialog().dialog("option", "foo", "bar").remove();
+ ok(true, 'arbitrary option setter after init');
+});
+
+test("destroy", function() {
+ $("<div></div>").appendTo('body').dialog().dialog("destroy").remove();
+ ok(true, '.dialog("destroy") called on element');
+
+ $([]).dialog().dialog("destroy").remove();
+ ok(true, '.dialog("destroy") called on empty collection');
+
+ $('<div></div>').dialog().dialog("destroy").remove();
+ ok(true, '.dialog("destroy") called on disconnected DOMElement');
+
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('destroy');
+ equals(actual, expected, 'destroy is chainable');
+});
+
+test("enable", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('enable');
+ equals(actual, expected, 'enable is chainable');
+
+ el = $('<div></div>').dialog({ disabled: true });
+ el.dialog('enable');
+ equals(el.dialog('option', 'disabled'), false, 'enable method sets disabled option to false');
+ ok(!dlg().hasClass('ui-dialog-disabled'), 'enable method removes ui-dialog-disabled class from ui-dialog element');
+});
+
+test("disable", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('disable');
+ equals(actual, expected, 'disable is chainable');
+
+ el = $('<div></div>').dialog({ disabled: false });
+ el.dialog('disable');
+ equals(el.dialog('option', 'disabled'), true, 'disable method sets disabled option to true');
+ ok(dlg().hasClass('ui-dialog-disabled'), 'disable method adds ui-dialog-disabled class to ui-dialog element');
+});
+
+test("close", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('close');
+ equals(actual, expected, 'close is chainable');
+
+ el = $('<div></div>').dialog();
+ ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog visible before close method called');
+ el.dialog('close');
+ ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog hidden after close method called');
+});
+
+test("isOpen", function() {
+ expect(4);
+
+ el = $('<div></div>').dialog();
+ equals(el.dialog('isOpen'), true, "dialog is open after init");
+ el.dialog('close');
+ equals(el.dialog('isOpen'), false, "dialog is closed");
+ el.remove();
+
+ el = $('<div></div>').dialog({autoOpen: false});
+ equals(el.dialog('isOpen'), false, "dialog is closed after init");
+ el.dialog('open');
+ equals(el.dialog('isOpen'), true, "dialog is open");
+ el.remove();
+});
+
+test("moveToTop", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('moveToTop');
+ equals(actual, expected, 'moveToTop is chainable');
+
+ var d1 = $('<div></div>').dialog(), dlg1 = d1.parents('.ui-dialog');
+ d1.dialog('close');
+ d1.dialog('open');
+ var d2 = $('<div></div>').dialog(), dlg2 = d2.parents('.ui-dialog');
+ d2.dialog('close');
+ d2.dialog('open');
+ ok(dlg1.css('zIndex') < dlg2.css('zIndex'), 'dialog 1 under dialog 2 before moveToTop method called');
+ d1.dialog('moveToTop');
+ ok(dlg1.css('zIndex') > dlg2.css('zIndex'), 'dialog 1 above dialog 2 after moveToTop method called');
+});
+
+test("open", function() {
+ var expected = $('<div></div>').dialog(),
+ actual = expected.dialog('open');
+ equals(actual, expected, 'open is chainable');
+
+ el = $('<div></div>').dialog({ autoOpen: false });
+ ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog hidden before open method called');
+ el.dialog('open');
+ ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog visible after open method called');
+});
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_options.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_options.js
new file mode 100644
index 0000000..eab577c
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_options.js
@@ -0,0 +1,444 @@
+/*
+ * dialog_options.js
+ */
+(function($) {
+
+module("dialog: options");
+
+test("autoOpen", function() {
+ expect(2);
+
+ el = $('<div></div>').dialog({ autoOpen: false });
+ isNotOpen('.dialog({ autoOpen: false })');
+ el.remove();
+
+ el = $('<div></div>').dialog({ autoOpen: true });
+ isOpen('.dialog({ autoOpen: true })');
+ el.remove();
+});
+
+test("buttons", function() {
+ expect(21);
+
+ var buttons = {
+ "Ok": function(ev, ui) {
+ ok(true, "button click fires callback");
+ equals(this, el[0], "context of callback");
+ equals(ev.target, btn[0], "event target");
+ },
+ "Cancel": function(ev, ui) {
+ ok(true, "button click fires callback");
+ equals(this, el[0], "context of callback");
+ equals(ev.target, btn[1], "event target");
+ }
+ };
+
+ el = $('<div></div>').dialog({ buttons: buttons });
+ var btn = $("button", dlg());
+ equals(btn.length, 2, "number of buttons");
+
+ var i = 0;
+ $.each(buttons, function(key, val) {
+ equals(btn.eq(i).text(), key, "text of button " + (i+1));
+ i++;
+ });
+
+ ok(btn.parent().hasClass('ui-dialog-buttonset'), "buttons in container");
+ ok(el.parent().hasClass('ui-dialog-buttons'), "dialog wrapper adds class about having buttons");
+
+ btn.trigger("click");
+
+ var newButtons = {
+ "Close": function(ev, ui) {
+ ok(true, "button click fires callback");
+ equals(this, el[0], "context of callback");
+ equals(ev.target, btn[0], "event target");
+ }
+ };
+
+ same(el.dialog("option", "buttons"), buttons, '.dialog("option", "buttons") getter');
+ el.dialog("option", "buttons", newButtons);
+ same(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter');
+
+ btn = $("button", dlg());
+ equals(btn.length, 1, "number of buttons after setter");
+ btn.trigger('click');
+
+ i = 0;
+ $.each(newButtons, function(key, val) {
+ equals(btn.eq(i).text(), key, "text of button " + (i+1));
+ i += 1;
+ });
+
+ el.dialog("option", "buttons", null);
+ btn = $("button", dlg());
+ equals(btn.length, 0, "all buttons have been removed");
+ equals(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed");
+ equals(el.parent().hasClass('ui-dialog-buttons'), false, "dialog wrapper removes class about having buttons");
+
+ el.remove();
+});
+
+test("buttons - advanced", function() {
+ expect(5);
+
+ el = $("<div></div>").dialog({
+ buttons: [
+ {
+ text: "a button",
+ "class": "additional-class",
+ id: "my-button-id",
+ click: function() {
+ equals(this, el[0], "correct context");
+ }
+ }
+ ]
+ });
+ var buttons = dlg().find("button");
+ equals(buttons.length, 1, "correct number of buttons");
+ equals(buttons.attr("id"), "my-button-id", "correct id");
+ equals(buttons.text(), "a button", "correct label");
+ ok(buttons.hasClass("additional-class"), "additional classes added");
+ buttons.click();
+
+ el.remove();
+});
+
+test("closeOnEscape", function() {
+ el = $('<div></div>').dialog({ closeOnEscape: false });
+ ok(true, 'closeOnEscape: false');
+ ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open before ESC');
+ el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE })
+ .simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE })
+ .simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE });
+ ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open after ESC');
+
+ el.remove();
+
+ el = $('<div></div>').dialog({ closeOnEscape: true });
+ ok(true, 'closeOnEscape: true');
+ ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open before ESC');
+ el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE })
+ .simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE })
+ .simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE });
+ ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog is closed after ESC');
+});
+
+test("closeText", function() {
+ expect(3);
+
+ el = $('<div></div>').dialog();
+ equals(dlg().find('.ui-dialog-titlebar-close span').text(), 'close',
+ 'default close text');
+ el.remove();
+
+ el = $('<div></div>').dialog({ closeText: "foo" });
+ equals(dlg().find('.ui-dialog-titlebar-close span').text(), 'foo',
+ 'closeText on init');
+ el.remove();
+
+ el = $('<div></div>').dialog().dialog('option', 'closeText', 'bar');
+ equals(dlg().find('.ui-dialog-titlebar-close span').text(), 'bar',
+ 'closeText via option method');
+ el.remove();
+});
+
+test("dialogClass", function() {
+ expect(4);
+
+ el = $('<div></div>').dialog();
+ equals(dlg().is(".foo"), false, 'dialogClass not specified. foo class added');
+ el.remove();
+
+ el = $('<div></div>').dialog({ dialogClass: "foo" });
+ equals(dlg().is(".foo"), true, 'dialogClass in init. foo class added');
+ el.remove();
+
+ el = $('<div></div>').dialog({ dialogClass: "foo bar" });
+ equals(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added');
+ equals(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added');
+ el.remove();
+});
+
+test("draggable", function() {
+ expect(4);
+
+ el = $('<div></div>').dialog({ draggable: false });
+ shouldnotmove();
+ el.dialog('option', 'draggable', true);
+ shouldmove();
+ el.remove();
+
+ el = $('<div></div>').dialog({ draggable: true });
+ shouldmove();
+ el.dialog('option', 'draggable', false);
+ shouldnotmove();
+ el.remove();
+});
+
+test("height", function() {
+ expect(3);
+
+ el = $('<div></div>').dialog();
+ equals(dlg().height(), 150, "default height");
+ el.remove();
+
+ el = $('<div></div>').dialog({ height: 237 });
+ equals(dlg().height(), 237, "explicit height");
+ el.remove();
+
+ el = $('<div></div>').dialog();
+ el.dialog('option', 'height', 238);
+ equals(dlg().height(), 238, "explicit height set after init");
+ el.remove();
+});
+
+test("maxHeight", function() {
+ expect(3);
+
+ el = $('<div></div>').dialog({ maxHeight: 200 });
+ drag('.ui-resizable-s', 1000, 1000);
+ equals(heightAfter, 200, "maxHeight");
+ el.remove();
+
+ el = $('<div></div>').dialog({ maxHeight: 200 });
+ drag('.ui-resizable-n', -1000, -1000);
+ equals(heightAfter, 200, "maxHeight");
+ el.remove();
+
+ el = $('<div></div>').dialog({ maxHeight: 200 }).dialog('option', 'maxHeight', 300);
+ drag('.ui-resizable-s', 1000, 1000);
+ equals(heightAfter, 300, "maxHeight");
+ el.remove();
+});
+
+test("maxWidth", function() {
+ expect(3);
+
+ el = $('<div></div>').dialog({ maxWidth: 200 });
+ drag('.ui-resizable-e', 1000, 1000);
+ equals(widthAfter, 200, "maxWidth");
+ el.remove();
+
+ el = $('<div></div>').dialog({ maxWidth: 200 });
+ drag('.ui-resizable-w', -1000, -1000);
+ equals(widthAfter, 200, "maxWidth");
+ el.remove();
+
+ el = $('<div></div>').dialog({ maxWidth: 200 }).dialog('option', 'maxWidth', 300);
+ drag('.ui-resizable-w', -1000, -1000);
+ equals(widthAfter, 300, "maxWidth");
+ el.remove();
+});
+
+test("minHeight", function() {
+ expect(3);
+
+ el = $('<div></div>').dialog({ minHeight: 10 });
+ drag('.ui-resizable-s', -1000, -1000);
+ equals(heightAfter, 10, "minHeight");
+ el.remove();
+
+ el = $('<div></div>').dialog({ minHeight: 10 });
+ drag('.ui-resizable-n', 1000, 1000);
+ equals(heightAfter, 10, "minHeight");
+ el.remove();
+
+ el = $('<div></div>').dialog({ minHeight: 10 }).dialog('option', 'minHeight', 30);
+ drag('.ui-resizable-n', 1000, 1000);
+ equals(heightAfter, 30, "minHeight");
+ el.remove();
+});
+
+test("minWidth", function() {
+ expect(3);
+
+ el = $('<div></div>').dialog({ minWidth: 10 });
+ drag('.ui-resizable-e', -1000, -1000);
+ equals(widthAfter, 10, "minWidth");
+ el.remove();
+
+ el = $('<div></div>').dialog({ minWidth: 10 });
+ drag('.ui-resizable-w', 1000, 1000);
+ equals(widthAfter, 10, "minWidth");
+ el.remove();
+
+ el = $('<div></div>').dialog({ minWidth: 30 }).dialog('option', 'minWidth', 30);
+ drag('.ui-resizable-w', 1000, 1000);
+ equals(widthAfter, 30, "minWidth");
+ el.remove();
+});
+
+test("position, default center on window", function() {
+ var el = $('<div></div>').dialog();
+ var dialog = el.dialog('widget');
+ var offset = dialog.offset();
+ same(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
+ same(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
+ el.remove();
+});
+
+test("position, top on window", function() {
+ var el = $('<div></div>').dialog({ position: "top" });
+ var dialog = el.dialog('widget');
+ var offset = dialog.offset();
+ same(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
+ same(offset.top, $(window).scrollTop());
+ el.remove();
+});
+
+test("position, left on window", function() {
+ var el = $('<div></div>').dialog({ position: "left" });
+ var dialog = el.dialog('widget');
+ var offset = dialog.offset();
+ same(offset.left, 0);
+ same(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
+ el.remove();
+});
+
+test("position, right bottom on window", function() {
+ var el = $('<div></div>').dialog({ position: "right bottom" });
+ var dialog = el.dialog('widget');
+ var offset = dialog.offset();
+ same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
+ same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
+ el.remove();
+});
+
+test("position, right bottom on window w/array", function() {
+ var el = $('<div></div>').dialog({ position: ["right", "bottom"] });
+ var dialog = el.dialog('widget');
+ var offset = dialog.offset();
+ same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
+ same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
+ el.remove();
+});
+
+test("position, offset from top left w/array", function() {
+ var el = $('<div></div>').dialog({ position: [10, 10] });
+ var dialog = el.dialog('widget');
+ var offset = dialog.offset();
+ same(offset.left, 10 + $(window).scrollLeft());
+ same(offset.top, 10 + $(window).scrollTop());
+ el.remove();
+});
+
+test("position, right bottom at right bottom via ui.position args", function() {
+ var el = $('<div></div>').dialog({
+ position: {
+ my: "right bottom",
+ at: "right bottom"
+ }
+ });
+
+ var dialog = el.dialog('widget');
+ var offset = dialog.offset();
+
+ same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
+ same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
+ el.remove();
+});
+
+test("position, at another element", function() {
+ var parent = $('<div></div>').css({
+ position: 'absolute',
+ top: 400,
+ left: 600,
+ height: 10,
+ width: 10
+ }).appendTo('body');
+
+ var el = $('<div></div>').dialog({
+ position: {
+ my: "left top",
+ at: "left top",
+ of: parent
+ }
+ });
+
+ var dialog = el.dialog('widget');
+ var offset = dialog.offset();
+
+ same(offset.left, 600);
+ same(offset.top, 400);
+
+ el.dialog('option', 'position', {
+ my: "left top",
+ at: "right bottom",
+ of: parent
+ });
+
+ var offset = dialog.offset();
+
+ same(offset.left, 610);
+ same(offset.top, 410);
+
+ el.remove();
+ parent.remove();
+});
+
+test("resizable", function() {
+ expect(4);
+
+ el = $('<div></div>').dialog();
+ shouldresize("[default]");
+ el.dialog('option', 'resizable', false);
+ shouldnotresize('disabled after init');
+ el.remove();
+
+ el = $('<div></div>').dialog({ resizable: false });
+ shouldnotresize("disabled in init options");
+ el.dialog('option', 'resizable', true);
+ shouldresize('enabled after init');
+ el.remove();
+});
+
+test("title", function() {
+ expect(9);
+
+ function titleText() {
+ return dlg().find(".ui-dialog-title").html();
+ }
+
+ el = $('<div></div>').dialog();
+ // some browsers return a non-breaking space and some return "&nbsp;"
+ // so we get the text to normalize to the actual non-breaking space
+ equals(dlg().find(".ui-dialog-title").text(), " ", "[default]");
+ equals(el.dialog("option", "title"), "", "option not changed");
+ el.remove();
+
+ el = $('<div title="foo">').dialog();
+ equals(titleText(), "foo", "title in element attribute");
+ equals(el.dialog("option", "title"), "foo", "option updated from attribute");
+ el.remove();
+
+ el = $('<div></div>').dialog({ title: 'foo' });
+ equals(titleText(), "foo", "title in init options");
+ equals(el.dialog("option", "title"), "foo", "opiton set from options hash");
+ el.remove();
+
+ el = $('<div title="foo">').dialog({ title: 'bar' });
+ equals(titleText(), "bar", "title in init options should override title in element attribute");
+ equals(el.dialog("option", "title"), "bar", "opiton set from options hash");
+ el.remove();
+
+ el = $('<div></div>').dialog().dialog('option', 'title', 'foo');
+ equals(titleText(), 'foo', 'title after init');
+ el.remove();
+});
+
+test("width", function() {
+ expect(3);
+
+ el = $('<div></div>').dialog();
+ equals(dlg().width(), 300, "default width");
+ el.remove();
+
+ el = $('<div></div>').dialog({width: 437 });
+ equals(dlg().width(), 437, "explicit width");
+ el.dialog('option', 'width', 438);
+ equals(dlg().width(), 438, 'explicit width after init');
+ el.remove();
+});
+
+})(jQuery);
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_tickets.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_tickets.js
new file mode 100644
index 0000000..b203ca7
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/dialog/dialog_tickets.js
@@ -0,0 +1,143 @@
+/*
+ * dialog_tickets.js
+ */
+(function($) {
+
+module( "dialog: tickets" );
+
+asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
+ expect( 3 );
+
+ var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
+ inputs = el.find( "input" ),
+ widget = el.dialog( "widget" );
+
+ inputs.eq( 1 ).focus();
+ equal( document.activeElement, inputs[1], "Focus set on second input" );
+ inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
+
+ setTimeout( checkTab, 2 );
+
+ function checkTab() {
+ ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
+
+ // check shift tab
+ $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
+ setTimeout( checkShiftTab, 2 );
+ }
+
+ function checkShiftTab() {
+ ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
+
+ el.remove();
+ start();
+ }
+});
+
+test("#4826: setting resizable false toggles resizable on dialog", function() {
+ expect(6);
+
+ el = $('<div></div>').dialog({ resizable: false });
+ shouldnotresize("[default]");
+ for (var i=0; i<2; i++) {
+ el.dialog('close').dialog('open');
+ shouldnotresize('initialized with resizable false toggle ('+ (i+1) +')');
+ }
+ el.remove();
+
+ el = $('<div></div>').dialog({ resizable: true });
+ shouldresize("[default]");
+ for (var i=0; i<2; i++) {
+ el.dialog('close').dialog('option', 'resizable', false).dialog('open');
+ shouldnotresize('set option resizable false toggle ('+ (i+1) +')');
+ }
+ el.remove();
+
+});
+
+test("#5184: isOpen in dialogclose event is true", function() {
+ expect( 3 );
+
+ el = $( "<div></div>" ).dialog({
+ close: function() {
+ ok( !el.dialog("isOpen"), "dialog is not open during close" );
+ }
+ });
+ ok( el.dialog("isOpen"), "dialog is open after init" );
+ el.dialog( "close" );
+ ok( !el.dialog("isOpen"), "dialog is not open after close" );
+ el.remove();
+});
+
+test("#5531: dialog width should be at least minWidth on creation", function () {
+ el = $('<div></div>').dialog({
+ width: 200,
+ minWidth: 300
+ });
+
+ equals(el.dialog('option', 'width'), 300, "width is minWidth");
+ el.dialog('option', 'width', 200);
+ equals(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth");
+ el.dialog('option', 'width', 320);
+ equals(el.dialog('option', 'width'), 320, "width changed if set to > minWidth");
+ el.remove();
+
+ el = $('<div></div>').dialog({
+ minWidth: 300
+ });
+ ok(el.dialog('option', 'width') >= 300, "width is at least 300");
+ el.remove();
+
+});
+
+test("#6137: dialog('open') causes form elements to reset on IE7", function() {
+ expect(2);
+
+ d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' +
+ '<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false});
+
+ d1.find('#b').prop( "checked", true );
+ equal($('input:checked').val(), 'b', "checkbox b is checked");
+
+ d1.dialog('open');
+ equal($('input:checked').val(), 'b', "checkbox b is checked");
+
+ d1.remove();
+});
+
+test("#6645: Missing element not found check in overlay", function(){
+ expect(2);
+ d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}});
+ equals($.ui.dialog.overlay.instances.length, 2, 'two overlays created');
+ d2.dialog('close');
+ equals($.ui.dialog.overlay.instances.length, 1, 'one overlay remains after closing the 2nd overlay');
+ d1.add(d2).remove();
+});
+
+test("#6966: Escape key closes all dialogs, not the top one", function(){
+ expect(8);
+ // test with close function removing dialog
+ d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}});
+ ok(d1.dialog("isOpen"), 'first dialog is open');
+ ok(d2.dialog("isOpen"), 'second dialog is open');
+ d2.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
+ ok(d1.dialog("isOpen"), 'first dialog still open');
+ ok(!d2.data('dialog'), 'second dialog is closed');
+ d2.remove();
+ d1.remove();
+
+ // test without close function removing dialog
+ d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true});
+ ok(d1.dialog("isOpen"), 'first dialog is open');
+ ok(d2.dialog("isOpen"), 'second dialog is open');
+ d2.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
+ ok(d1.dialog("isOpen"), 'first dialog still open');
+ ok(!d2.dialog("isOpen"), 'second dialog is closed');
+ d2.remove();
+ d1.remove();
+});
+
+})(jQuery);