upgrade to yui 2.5.1
This commit is contained in:
parent
e00050ad1c
commit
ff7d72becc
1632 changed files with 812103 additions and 0 deletions
104
www/extras/yui/tests/YUI.html
Normal file
104
www/extras/yui/tests/YUI.html
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>YUI Library Master Test Page</title>
|
||||
<link type="text/css" rel="stylesheet" href="../build/fonts/fonts.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="../build/json/json-beta.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<style>
|
||||
#out {
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body class="yui-skin-sam">
|
||||
<h1>YUI Library Master Test Page</h1>
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
|
||||
function log(msg) {
|
||||
var d=document, b=d.getElementById("out"), n=d.createElement("div");
|
||||
if (b) {
|
||||
n.appendChild(d.createTextNode(msg));
|
||||
b.appendChild(n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var TM = YAHOO.tool.TestManager;
|
||||
|
||||
YAHOO.util.Event.onDOMReady(function (){
|
||||
|
||||
YAHOO.tool.TestManager.setPages([
|
||||
"animation.html",
|
||||
"autocomplete.html",
|
||||
// "calendar.html",
|
||||
"cookie.html",
|
||||
"config.html",
|
||||
"datasource.html",
|
||||
"datemath.html",
|
||||
"dom.html",
|
||||
"dragdrop.html",
|
||||
// "editor.html",
|
||||
"element.html",
|
||||
"imageloader.html",
|
||||
"logger.html",
|
||||
"module.html",
|
||||
"profiler.html",
|
||||
"tabview.html",
|
||||
"yahoo.html",
|
||||
"yuiloader.html",
|
||||
"yuiloader_config.html",
|
||||
"yuiloader_rollup.html",
|
||||
"yuitest.html"
|
||||
]);
|
||||
|
||||
TM.subscribe(TM.TEST_MANAGER_COMPLETE_EVENT, function(o) {
|
||||
log("# of pages passed: " + o.passedPages.length);
|
||||
log("# of pages failed: " + o.failedPages.length + ": " + o.failedPages.join(", "));
|
||||
log("# of tests passed: " + o.passed);
|
||||
log("# of tests failed: " + o.failed);
|
||||
|
||||
// log("Passed: " + o.passed.join(", "));
|
||||
// log("Failed: " + o.failed.join(", "));
|
||||
//figure out if you want to report the results
|
||||
if (location.search.length > 0){
|
||||
var params = location.search.substring(1).split("&");
|
||||
var url = null;
|
||||
var format = YAHOO.tool.TestFormat.XML;
|
||||
|
||||
for (var i=0; i < params.length; i++){
|
||||
if (params[i].indexOf("report=") == 0){
|
||||
url = decodeURIComponent(params[i].substring(params[i].indexOf("=") + 1));
|
||||
} else if (params[i] == "format=json"){
|
||||
format = YAHOO.tool.TestFormat.JSON;
|
||||
}
|
||||
}
|
||||
|
||||
if (url !== null){
|
||||
var reporter = new YAHOO.tool.TestReporter(url, format);
|
||||
reporter.report(o);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
TM.start();
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<div id="out"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
111
www/extras/yui/tests/animation.html
Normal file
111
www/extras/yui/tests/animation.html
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Animation Test Suite</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css">
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/animation/animation.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
#foo,
|
||||
#bar {
|
||||
background:#ccc;
|
||||
height:100px;
|
||||
width:100px;
|
||||
overflow:hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var Y = YAHOO.util,
|
||||
tool = YAHOO.tool,
|
||||
suite = new tool.TestSuite("yuisuite");
|
||||
|
||||
Y.Event.onDOMReady(function() {
|
||||
var logger = new YAHOO.tool.TestLogger(null, { height: '80%' });
|
||||
|
||||
var animFoo = new Y.Anim('foo', { width: { to: 10 } });
|
||||
var elFoo = document.getElementById('foo');
|
||||
|
||||
var animBar = new Y.Motion('bar', { width: { by: 50 } });
|
||||
var elBar = document.getElementById('bar');
|
||||
|
||||
|
||||
suite.add( new tool.TestCase({
|
||||
name: 'YAHOO.util.Anim',
|
||||
|
||||
test_getEl: function() {
|
||||
YAHOO.util.Assert.areEqual(elFoo, animFoo.getEl(), 'incorrect element');
|
||||
},
|
||||
|
||||
test_isAnimated: function() {
|
||||
YAHOO.util.Assert.isFalse(animFoo.isAnimated(), 'isAnimated() should be false');
|
||||
animFoo.animate();
|
||||
|
||||
YAHOO.util.Assert.isTrue(animFoo.isAnimated(), 'isAnimated() should be true');
|
||||
animFoo.stop();
|
||||
},
|
||||
|
||||
test_stop: function() {
|
||||
animFoo.animate();
|
||||
animBar.animate();
|
||||
animFoo.stop();
|
||||
YAHOO.util.Assert.isFalse(animFoo.isAnimated(), 'isAnimated() should be false');
|
||||
YAHOO.util.Assert.isTrue(animBar.isAnimated(), 'isAnimated() should be false');
|
||||
animBar.stop();
|
||||
},
|
||||
|
||||
test_onStart: function() {
|
||||
var pass = false;
|
||||
var handler = function() {
|
||||
pass = true;
|
||||
this.onStart.unsubscribe(handler);
|
||||
};
|
||||
animFoo.onStart.subscribe(handler);
|
||||
animFoo.animate();
|
||||
animFoo.stop();
|
||||
YAHOO.util.Assert.isTrue(pass, 'onStart failed to fire');
|
||||
},
|
||||
|
||||
test_endValue: function() {
|
||||
var handler = function() {
|
||||
YAHOO.util.Assert.areEqual(10, elFoo.offsetWidth, 'incorrect "to" end value set');
|
||||
YAHOO.util.Assert.areEqual(150, elBar.offsetWidth, 'incorrect "by" end value set');
|
||||
this.onComplete.unsubscribe(handler);
|
||||
};
|
||||
|
||||
animBar.onComplete.subscribe(handler);
|
||||
animFoo.animate();
|
||||
animBar.animate();
|
||||
}
|
||||
}));
|
||||
tool.TestRunner.add(suite);
|
||||
|
||||
if (parent && parent != window) {
|
||||
tool.TestManager.load();
|
||||
} else {
|
||||
tool.TestRunner.run();
|
||||
}
|
||||
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body class="yui-skin-sam">
|
||||
<div id="doc">
|
||||
<div id="foo">foo</div>
|
||||
<div id="bar">bar</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
31
www/extras/yui/tests/assets/xframe.html
Normal file
31
www/extras/yui/tests/assets/xframe.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>xframe tester</title>
|
||||
<script type="text/javascript">
|
||||
function FakeArray() {
|
||||
// ok, if we put the index in the prototype we could fool
|
||||
// YAHOO.lang.isArray as long as the index is never
|
||||
// updated. This isn't likely to happen unless someone
|
||||
// is trying very hard to break it.
|
||||
this.index=0;
|
||||
}
|
||||
|
||||
FakeArray.prototype.splice = function() {
|
||||
return this;
|
||||
};
|
||||
|
||||
var str = "string",
|
||||
obj = {foo:"bar"},
|
||||
fun = function(){},
|
||||
arr = ["foo", "bar"],
|
||||
far = new FakeArray(),
|
||||
boo = false,
|
||||
num = 123.123,
|
||||
nul = null,
|
||||
und;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1></h1>
|
||||
</body>
|
||||
</html>
|
||||
169
www/extras/yui/tests/autocomplete.html
Normal file
169
www/extras/yui/tests/autocomplete.html
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>YUI AutoComplete Tests</title>
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/autocomplete/assets/autocomplete.css" />
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo-min.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom-min.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event-min.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
<script type="text/javascript" src="../build/autocomplete/autocomplete.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>AutoComplete Tests</h1>
|
||||
<p><input type="button" value="Run Tests" id="btnRun" disabled="true" /></p>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
|
||||
var Dom=YAHOO.util.Dom,
|
||||
Assert=YAHOO.util.Assert,
|
||||
ObjectAssert=YAHOO.util.ObjectAssert,
|
||||
ArrayAssert=YAHOO.util.ArrayAssert,
|
||||
DateAssert=YAHOO.util.DateAssert,
|
||||
UserAction=YAHOO.util.UserAction,
|
||||
TestCase = YAHOO.tool.TestCase,
|
||||
TestLogger = YAHOO.tool.TestLogger,
|
||||
TestRunner = YAHOO.tool.TestRunner,
|
||||
TestSuite = YAHOO.tool.TestSuite,
|
||||
|
||||
DS_JSArray = YAHOO.widget.DS_JSArray,
|
||||
DS_JSFunction = YAHOO.widget.DS_JSFunction,
|
||||
DS_XHR = YAHOO.widget.DS_XHR,
|
||||
AutoComplete = YAHOO.widget.AutoComplete;
|
||||
|
||||
function AutoCompleteTestCase(template) {
|
||||
AutoCompleteTestCase.superclass.constructor.call(this, template);
|
||||
};
|
||||
YAHOO.lang.extend(AutoCompleteTestCase, TestCase);
|
||||
|
||||
AutoCompleteTestCase.prototype.setUp = function() {
|
||||
this.count = 0;
|
||||
this.wrappers = [];
|
||||
this.inputs = [];
|
||||
this.containers = [];
|
||||
this.instances = [];
|
||||
|
||||
this.datasource = new DS_JSArray(["aaa","abc","axyz"]);
|
||||
};
|
||||
|
||||
AutoCompleteTestCase.prototype.tearDown = function() {
|
||||
if (this.wrappers != null && (this.wrappers.length > 0)) {
|
||||
for(var i=0; i<this.wrappers.length; i++) {
|
||||
YAHOO.util.Event.purgeElement(this.wrappers[i], true);
|
||||
document.body.removeChild(this.wrappers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.datasource = null;
|
||||
this.containers = null;
|
||||
this.inputs = null;
|
||||
this.wrappers = null;
|
||||
this.instances = null;
|
||||
};
|
||||
|
||||
AutoCompleteTestCase.prototype.createInstance = function(oConfig) {
|
||||
var nCount = this.count;
|
||||
this.count++;
|
||||
this.wrappers[nCount] = document.createElement("div");
|
||||
this.wrappers[nCount].id = "acWrapper"+nCount;
|
||||
document.body.appendChild(this.wrappers[nCount]);
|
||||
|
||||
this.inputs[nCount] = document.createElement("input");
|
||||
this.inputs[nCount].id = "acInput"+nCount;
|
||||
this.wrappers[nCount].appendChild(this.inputs[nCount]);
|
||||
|
||||
this.containers[nCount] = document.createElement("div");
|
||||
this.containers[nCount].id = "acContainer"+nCount;
|
||||
this.wrappers[nCount].appendChild(this.containers[nCount]);
|
||||
|
||||
this.instances[nCount] = new AutoComplete(this.inputs[nCount], this.containers[nCount], this.datasource, oConfig);
|
||||
return this.instances[nCount];
|
||||
};
|
||||
|
||||
var acApiTemplate = {
|
||||
name: "AutoComplete API Test Case",
|
||||
|
||||
testConstruction: function() {
|
||||
var ac = this.createInstance();
|
||||
Assert.isObject(ac, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(AutoComplete, ac, "Failed to create basic instance");
|
||||
},
|
||||
|
||||
testDestroy: function() {
|
||||
var ac = this.createInstance();
|
||||
ac.destroy();
|
||||
Assert.isNull(ac.dataSource, "Expected datasource to be null");
|
||||
Assert.isNull(ac._elContainer, "Expected container to be null");
|
||||
Assert.isNull(ac._elTextbox, "Expected textbox to be null");
|
||||
ac = null;
|
||||
},
|
||||
|
||||
testSetHeader: function() {
|
||||
var ac = this.createInstance();
|
||||
ac.setHeader("header");
|
||||
var el = YAHOO.util.Dom.getElementsByClassName("yui-ac-hd", "div", this.container)[0];
|
||||
Assert.areSame("header", el.innerHTML, "Expected header content to be \"header\"");
|
||||
ac = null;
|
||||
},
|
||||
|
||||
testSetBody: function() {
|
||||
var ac = this.createInstance();
|
||||
ac.setBody("body");
|
||||
var el = YAHOO.util.Dom.getElementsByClassName("yui-ac-bd", "div", this.container)[0];
|
||||
Assert.areSame("body", el.innerHTML, "Expected body content to be \"body\"");
|
||||
ac = null;
|
||||
},
|
||||
|
||||
testSetFooter: function() {
|
||||
var ac = this.createInstance();
|
||||
ac.setFooter("footer");
|
||||
var el = YAHOO.util.Dom.getElementsByClassName("yui-ac-ft", "div", this.container)[0];
|
||||
Assert.areSame("footer", el.innerHTML, "Expected footer content to be \"footer\"");
|
||||
ac = null;
|
||||
},
|
||||
|
||||
testGetListItems: function() {
|
||||
var ac = this.createInstance();
|
||||
ac.sendQuery("a");
|
||||
var els = ac.getListItems();
|
||||
Assert.areSame(10, els.length, "Expected 10 items");
|
||||
for(var i=0; i<els.length; i++) {
|
||||
Assert.areSame("li", els[i].tagName.toLowerCase(), "Expected an LI element");
|
||||
}
|
||||
|
||||
ac.maxResultsDisplayed = 5;
|
||||
ac.sendQuery("a");
|
||||
var els = ac.getListItems();
|
||||
Assert.areSame(5, els.length, "Expected 5 items");
|
||||
|
||||
ac = null;
|
||||
}
|
||||
};
|
||||
var acApiTest = new AutoCompleteTestCase(acApiTemplate);
|
||||
|
||||
YAHOO.util.Event.addListener(window, "load", function() {
|
||||
var logger = new TestLogger();
|
||||
|
||||
var acsuite = new TestSuite("AutoComplete Test Suite");
|
||||
acsuite.add(acApiTest);
|
||||
|
||||
TestRunner.add(acsuite);
|
||||
|
||||
YAHOO.util.Event.addListener("btnRun", "click", function(){TestRunner.run();});
|
||||
YAHOO.util.Dom.get("btnRun").disabled = false;
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1297
www/extras/yui/tests/calendar.html
Normal file
1297
www/extras/yui/tests/calendar.html
Normal file
File diff suppressed because it is too large
Load diff
149
www/extras/yui/tests/colorpicker.html
Normal file
149
www/extras/yui/tests/colorpicker.html
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Slider/ColorPicker Test Suite</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../build/colorpicker/assets/skins/sam/colorpicker.css">
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css">
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo-dom-event/yahoo-dom-event.js"></script>
|
||||
<script type="text/javascript" src="../build/element/element-beta-min.js"></script>
|
||||
<script type="text/javascript" src="../build/dragdrop/dragdrop-min.js"></script>
|
||||
<script type="text/javascript" src="../build/slider/slider.js"></script>
|
||||
<script type="text/javascript" src="../build/colorpicker/colorpicker-beta.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
#picker-container {
|
||||
background:#ccc;
|
||||
height:100px;
|
||||
width:100px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var Event = YAHOO.util.Event,
|
||||
Dom = YAHOO.util.Dom,
|
||||
tool = YAHOO.tool,
|
||||
Assert = YAHOO.util.Assert,
|
||||
ArrayAssert = YAHOO.util.ArrayAssert,
|
||||
UserAction = YAHOO.util.UserAction,
|
||||
suite = new tool.TestSuite("slider_and_picker_suite");
|
||||
|
||||
Event.onDOMReady(function() {
|
||||
var logger = new tool.TestLogger();
|
||||
picker = new YAHOO.widget.ColorPicker('picker-container', {
|
||||
"showhsvcontrols": true,
|
||||
"showhexcontrols": true
|
||||
}),
|
||||
elPicker = document.getElementById('picker-container');
|
||||
|
||||
var _verifyState = function(o) {
|
||||
o.r && Assert.areEqual(o.r, picker.get('red'), 'incorrect R');
|
||||
o.g && Assert.areEqual(o.g, picker.get('green'), 'incorrect G');
|
||||
o.b && Assert.areEqual(o.b, picker.get('blue'), 'incorrect B');
|
||||
o.h && Assert.areEqual(o.h, picker.get('hue'), 'incorrect H');
|
||||
o.s && Assert.areEqual(o.s, picker.get('saturation'), 'incorrect S');
|
||||
o.v && Assert.areEqual(o.v, picker.get('value'), 'incorrect V');
|
||||
o.hex && Assert.areEqual(o.hex, picker.get('hex'), 'incorrect hex');
|
||||
o.rgb && ArrayAssert.itemsAreEqual(o.rgb, picker.get('rgb'), 'incorrect rgb');
|
||||
o.websafe && ArrayAssert.itemsAreEqual(o.websafe, picker.get('websafe'), 'incorrect websafe');
|
||||
};
|
||||
|
||||
suite.add( new tool.TestCase({
|
||||
|
||||
name: 'slider_and_picker_test',
|
||||
|
||||
test_getElement: function() {
|
||||
Assert.areEqual(elPicker, picker.get('element'), 'incorrect element');
|
||||
},
|
||||
|
||||
test_setAttribute: function() {
|
||||
picker.set("red", 10);
|
||||
|
||||
_verifyState({
|
||||
r: 10, g: 255, b: 255, h: 180, s: 96, v: 100,
|
||||
hex: "0AFFFF", rgb: [10, 255, 255], websafe: [0, 255, 255]
|
||||
});
|
||||
},
|
||||
|
||||
test_updateField: function() {
|
||||
var el = Dom.get("yui-picker-g");
|
||||
el.value = 10;
|
||||
UserAction.keydown(el, {
|
||||
keyCode: 13
|
||||
});
|
||||
|
||||
_verifyState({
|
||||
r: 10, g: 10, b: 255, h: 240, s: 96, v: 100,
|
||||
hex: "0A0AFF", rgb: [10, 10, 255], websafe: [0, 0, 255]
|
||||
});
|
||||
},
|
||||
|
||||
test_setValue: function() {
|
||||
picker.setValue([45, 58, 42]);
|
||||
|
||||
_verifyState({
|
||||
r: 45, g: 58, b: 42, h: 109, s: 28, v: 23,
|
||||
hex: "2D3A2A", rgb: [45, 58, 42], websafe: [51, 51, 51]
|
||||
});
|
||||
},
|
||||
|
||||
test_websafeClick: function() {
|
||||
UserAction.click("yui-picker-websafe-swatch");
|
||||
|
||||
_verifyState({
|
||||
r: 51, g: 51, b: 51, h: 0, s: 0, v: 20,
|
||||
hex: "333333", rgb: [51, 51, 51], websafe: [51, 51, 51]
|
||||
});
|
||||
},
|
||||
|
||||
_test_pickerClick: function() {
|
||||
|
||||
|
||||
UserAction.mousedown("yui-picker-bg", {
|
||||
clientX: 50,
|
||||
clientY: 50
|
||||
});
|
||||
|
||||
UserAction.mousemove("yui-picker-bg", {
|
||||
clientX: 55,
|
||||
clientY: 55
|
||||
});
|
||||
|
||||
UserAction.mouseup("yui-picker-bg", {
|
||||
clientX: 60,
|
||||
clientY: 60
|
||||
});
|
||||
|
||||
_verifyState({
|
||||
r: 51, g: 51, b: 51, h: 0, s: 0, v: 20,
|
||||
hex: "333333", rgb: [51, 51, 51], websafe: [51, 51, 51]
|
||||
});
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
tool.TestRunner.add(suite);
|
||||
|
||||
if (parent && parent != window) {
|
||||
tool.TestManager.load();
|
||||
} else {
|
||||
tool.TestRunner.run();
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body class="yui-skin-sam">
|
||||
<div id="doc">
|
||||
<div id="picker-container">picker</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
243
www/extras/yui/tests/config.html
Normal file
243
www/extras/yui/tests/config.html
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo-dom-event/yahoo-dom-event.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
<script type="text/javascript" src="../build/container/container_core-min.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
|
||||
YAHOO.namespace("tests");
|
||||
|
||||
var TestCase = YAHOO.tool.TestCase,
|
||||
Assert=YAHOO.util.Assert,
|
||||
ObjectAssert=YAHOO.util.ObjectAssert,
|
||||
ArrayAssert=YAHOO.util.ArrayAssert;
|
||||
|
||||
var logger;
|
||||
|
||||
YAHOO.tests.ConfigOwner = function(test) {
|
||||
this.id = "ConfigOwner";
|
||||
this.cfg = new YAHOO.util.Config(this);
|
||||
|
||||
this.events = [];
|
||||
|
||||
this.clearEventLog = function() {
|
||||
this.events = [];
|
||||
};
|
||||
|
||||
this.getFiredEvents = function() {
|
||||
var handlers = [];
|
||||
for (var i = 0; i < this.events.length; i++) {
|
||||
handlers.push(this.events[i].type);
|
||||
}
|
||||
return handlers;
|
||||
};
|
||||
};
|
||||
|
||||
var configTemplate = {
|
||||
|
||||
name: "configtestcase",
|
||||
|
||||
setUp : function() {
|
||||
this.cfgOwner = new YAHOO.tests.ConfigOwner();
|
||||
|
||||
var h = this.genericCfgHandler;
|
||||
var o = this.cfgOwner;
|
||||
|
||||
o.cfg.addProperty("sONe", {value:"str1", handler:h, suppressEvent:true });
|
||||
o.cfg.addProperty("sTwO", {value:"str2", handler:h, suppressEvent:false });
|
||||
o.cfg.addProperty("sThree", {value:"str3", handler:h, supercedes:["STWO", "sone"] });
|
||||
|
||||
o.cfg.addProperty("nOnE", {value:777, handler:h, validator:o.cfg.checkNumber });
|
||||
o.cfg.addProperty("nTwo", {value:"Fourteen", handler:h, validator:o.cfg.checkNumber });
|
||||
|
||||
o.cfg.addProperty("bone", {value:false, handler:h, validator:o.cfg.checkBoolean });
|
||||
o.cfg.addProperty("bTWo", {value:true, handler:h, validator:o.cfg.checkBoolean });
|
||||
o.cfg.addProperty("BTHREE", {value:"CompletelyUnfounded", handler:h, validator:o.cfg.checkBoolean });
|
||||
|
||||
o.cfg.fireQueue();
|
||||
},
|
||||
|
||||
tearDown : function() {
|
||||
this.cfgOwner.cfg.destroy();
|
||||
this.cfgOwner.cfg = null;
|
||||
this.cfgOwner = null;
|
||||
},
|
||||
|
||||
genericCfgHandler : function(type, args, obj) {
|
||||
this.events.push({type:type, args:args, obj:obj});
|
||||
},
|
||||
|
||||
customCfgHandler : function(type, args, obj) {
|
||||
this.events.push({type:type+"_custom", args:args, obj:obj});
|
||||
},
|
||||
|
||||
testAddProperty : function() {
|
||||
var o = this.cfgOwner;
|
||||
|
||||
var expectedHandlers = ["sthree", "stwo", "none", "bone", "btwo"];
|
||||
var actualHandlers = o.getFiredEvents();
|
||||
ArrayAssert.itemsAreEqual(expectedHandlers, actualHandlers);
|
||||
},
|
||||
|
||||
testGetConfig : function() {
|
||||
// TODO
|
||||
},
|
||||
|
||||
testGetProperty : function() {
|
||||
var o = this.cfgOwner;
|
||||
o.clearEventLog();
|
||||
|
||||
Assert.areEqual("str1", o.cfg.getProperty("SOne"));
|
||||
Assert.areEqual("str2", o.cfg.getProperty("STWO"));
|
||||
Assert.areEqual("str3", o.cfg.getProperty("sThreE"));
|
||||
},
|
||||
|
||||
testQueueOrderAndValidation : function() {
|
||||
var o = this.cfgOwner;
|
||||
o.clearEventLog();
|
||||
|
||||
o.cfg.queueProperty("bTWO", "NotBoolean");
|
||||
o.cfg.queueProperty("SonE", "str11");
|
||||
o.cfg.queueProperty("StWo", "str22");
|
||||
o.cfg.queueProperty("None", 20);
|
||||
o.cfg.queueProperty("StHree", "str33"); // Should sthree's supercede ordering really change the order of sONE, sTWO?
|
||||
|
||||
o.cfg.fireQueue();
|
||||
|
||||
var expectedHandlers = ["none", "sthree", "stwo", "sone"];
|
||||
var actualHandlers = o.getFiredEvents();
|
||||
ArrayAssert.itemsAreEqual(expectedHandlers, actualHandlers);
|
||||
},
|
||||
|
||||
testRefireEvent : function() {
|
||||
var o = this.cfgOwner;
|
||||
o.clearEventLog();
|
||||
|
||||
o.cfg.refireEvent("STwo");
|
||||
o.cfg.refireEvent("Sone");
|
||||
o.cfg.refireEvent("NTwo"); // Value is invalid - should it really be firing?
|
||||
|
||||
var expectedHandlers = ["stwo", "sone", "ntwo"];
|
||||
var actualHandlers = o.getFiredEvents();
|
||||
ArrayAssert.itemsAreEqual(expectedHandlers, actualHandlers);
|
||||
},
|
||||
|
||||
testRefresh : function() {
|
||||
var o = this.cfgOwner;
|
||||
o.clearEventLog();
|
||||
|
||||
o.cfg.refresh();
|
||||
|
||||
var expectedHandlers = ["sone", "stwo", "sthree", "none", "ntwo", "bone", "btwo", "bthree"];
|
||||
var actualHandlers = o.getFiredEvents();
|
||||
ArrayAssert.itemsAreEqual(expectedHandlers, actualHandlers);
|
||||
},
|
||||
|
||||
testResetProperty : function() {
|
||||
var o = this.cfgOwner;
|
||||
o.clearEventLog();
|
||||
|
||||
// All properties should be set to values specified by ApplyConfig
|
||||
o.cfg.applyConfig({
|
||||
sOnE:"str1111",
|
||||
sTwo: "str2222",
|
||||
Sthree: "str3333",
|
||||
nONE:1111,
|
||||
nTWo:2222,
|
||||
bONE:true,
|
||||
btwo:true,
|
||||
bTHREE:true
|
||||
}, true);
|
||||
|
||||
|
||||
o.cfg.setProperty("sonE", "str11");
|
||||
o.cfg.setProperty("sTWO", "str22");
|
||||
o.cfg.setProperty("sTHREE", "str33");
|
||||
o.cfg.setProperty("nONE", 11);
|
||||
o.cfg.setProperty("nTWO", 22);
|
||||
o.cfg.setProperty("BOnE", false);
|
||||
o.cfg.setProperty("BTwO", false);
|
||||
o.cfg.setProperty("BthreE", false);
|
||||
|
||||
|
||||
o.cfg.resetProperty("soNe");
|
||||
o.cfg.resetProperty("stWo");
|
||||
o.cfg.resetProperty("stHree");
|
||||
o.cfg.resetProperty("nOnE");
|
||||
o.cfg.resetProperty("nTwO");
|
||||
o.cfg.resetProperty("bONE");
|
||||
o.cfg.resetProperty("bTWO");
|
||||
o.cfg.resetProperty("BTHREE");
|
||||
|
||||
|
||||
// Should values be reset to defaults and not applyConfig values
|
||||
Assert.areEqual("str1111", o.cfg.getProperty("sONE"));
|
||||
Assert.areEqual("str2222", o.cfg.getProperty("stWo"));
|
||||
Assert.areEqual("str3333", o.cfg.getProperty("sTHREE"));
|
||||
Assert.areEqual(1111, o.cfg.getProperty("NONE"));
|
||||
Assert.areEqual(2222, o.cfg.getProperty("NtWO"));
|
||||
Assert.areEqual(true, o.cfg.getProperty("bONE"));
|
||||
Assert.areEqual(true, o.cfg.getProperty("BtWO"));
|
||||
Assert.areEqual(true, o.cfg.getProperty("BThREE"));
|
||||
},
|
||||
|
||||
testSubscribeToConfigEvent : function() {
|
||||
var o = this.cfgOwner;
|
||||
o.clearEventLog();
|
||||
|
||||
o.cfg.subscribeToConfigEvent("sOne", this.customCfgHandler);
|
||||
o.cfg.setProperty("SOne", "str11111");
|
||||
|
||||
var expected = ["sone", "sone_custom"];
|
||||
var actual = o.getFiredEvents();
|
||||
|
||||
ArrayAssert.itemsAreEqual(expected, actual);
|
||||
|
||||
o.clearEventLog();
|
||||
|
||||
o.cfg.unsubscribeFromConfigEvent("sone", this.customCfgHandler);
|
||||
o.cfg.setProperty("sONe", "str11111");
|
||||
|
||||
expected = ["sone"];
|
||||
actual = o.getFiredEvents();
|
||||
|
||||
ArrayAssert.itemsAreEqual(expected, actual);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var configTestCase = new YAHOO.tool.TestCase(configTemplate);
|
||||
|
||||
function runTests() {
|
||||
|
||||
var logger = new YAHOO.tool.TestLogger();
|
||||
var testSuite=new YAHOO.tool.TestSuite("configsuite");
|
||||
testSuite.add(configTestCase);
|
||||
|
||||
logger.clearConsole();
|
||||
|
||||
YAHOO.tool.TestRunner.clear();
|
||||
YAHOO.tool.TestRunner.add(testSuite);
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
} else {
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
}
|
||||
|
||||
YAHOO.util.Event.addListener(window, "load", runTests);
|
||||
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1285
www/extras/yui/tests/cookie.html
Normal file
1285
www/extras/yui/tests/cookie.html
Normal file
File diff suppressed because it is too large
Load diff
435
www/extras/yui/tests/datasource.html
Normal file
435
www/extras/yui/tests/datasource.html
Normal file
|
|
@ -0,0 +1,435 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>YUI DataSource Tests</title>
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/skins/sam/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
<style type="text/css">
|
||||
.yui-skin-sam .yui-log {
|
||||
padding: 2.5em 1em 1em;
|
||||
height: 90%;
|
||||
}
|
||||
.yui-skin-sam .yui-log .yui-log-bd {
|
||||
width: auto;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body class="yui-skin-sam">
|
||||
<h1>DataSource Tests</h1>
|
||||
<p><input type="button" value="Run Tests" id="btnRun" disabled="true" /></p>
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
<script type="text/javascript" src="../build/json/json.js"></script>
|
||||
<script type="text/javascript" src="../build/datasource/datasource-beta-debug.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
|
||||
var Dom=YAHOO.util.Dom,
|
||||
Assert=YAHOO.util.Assert,
|
||||
ObjectAssert=YAHOO.util.ObjectAssert,
|
||||
ArrayAssert=YAHOO.util.ArrayAssert,
|
||||
DateAssert=YAHOO.util.DateAssert,
|
||||
UserAction=YAHOO.util.UserAction,
|
||||
TestCase = YAHOO.tool.TestCase,
|
||||
TestLogger = YAHOO.tool.TestLogger,
|
||||
TestRunner = YAHOO.tool.TestRunner,
|
||||
TestSuite = YAHOO.tool.TestSuite,
|
||||
lang = YAHOO.lang,
|
||||
|
||||
DataSource = YAHOO.util.DataSource;
|
||||
|
||||
|
||||
// Create utility function for pass-by-ref + reuse errors
|
||||
var cloneObject = function(o) {
|
||||
if (lang.isArray(o)) {
|
||||
var a = [];
|
||||
for (var i=0,l=o.length;i<l;i++) {
|
||||
a[i] = cloneObject(o[i]);
|
||||
}
|
||||
return a;
|
||||
} else if (typeof o === 'object' && o) {
|
||||
var c = {};
|
||||
for (var x in o) {
|
||||
if (lang.hasOwnProperty(o, x)) {
|
||||
c[x] = cloneObject(o[x]);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
else {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Base DataSource test case.
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DataSourceTestCase(template) {
|
||||
DataSourceTestCase.superclass.constructor.call(this, template);
|
||||
this.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
|
||||
};
|
||||
YAHOO.lang.extend(DataSourceTestCase, TestCase);
|
||||
|
||||
DataSourceTestCase.prototype.setUp = function() {
|
||||
};
|
||||
|
||||
DataSourceTestCase.prototype.tearDown = function() {
|
||||
};
|
||||
|
||||
DataSourceTestCase.prototype.createInstance = function(oConfigs) {
|
||||
ds = new DataSource((cloneObject(this.data)||["a","b","c"]), oConfigs);
|
||||
ds.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
|
||||
ds.responseSchema = {
|
||||
fields: ["a","b","c"]
|
||||
};
|
||||
return ds;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Base DataSource test template. Sets up values for a DataSource instance.
|
||||
*
|
||||
*
|
||||
*/
|
||||
var datasourceTemplate = {
|
||||
name: "DataSource Test",
|
||||
|
||||
testConstruction: function() {
|
||||
var ds = this.createInstance();
|
||||
Assert.isObject(ds, "Failed to create instance");
|
||||
Assert.isInstanceOf(DataSource, ds, "Failed to create instance");
|
||||
ds = null;
|
||||
}
|
||||
};
|
||||
var datasourceTest = new DataSourceTestCase(datasourceTemplate);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Tests array of JS objects.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
var dsComplexArrayTemplate = YAHOO.lang.merge(datasourceTemplate, {
|
||||
name:"Complex Array Test",
|
||||
data:[{a:"1a",b:"1b",c:"1c"}, {a:"2a",b:"2b",c:"2c"}, {a:"3a",b:"3b",c:"3c"}]
|
||||
});
|
||||
var dsComplexArrayTest = new DataSourceTestCase(dsComplexArrayTemplate);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Tests DataSource Cache.
|
||||
*
|
||||
*
|
||||
*/
|
||||
var dsCacheTemplate = {
|
||||
name: "Cache Test",
|
||||
|
||||
testDefault: function() {
|
||||
var ds = this.createInstance();
|
||||
Assert.areSame(null, ds._aCache, "Failed to NOT init cache (default)");
|
||||
ds = null;
|
||||
},
|
||||
|
||||
testViaConfig: function() {
|
||||
var ds = this.createInstance({maxCacheEntries:5});
|
||||
Assert.areSame(null, ds._aCache, "Cache should not be initialized yet");
|
||||
|
||||
ds.sendRequest("a", function() {
|
||||
Assert.areSame(true, YAHOO.lang.isArray(ds._aCache), "Failed to init cache (via constructor)");
|
||||
Assert.areSame(1, ds._aCache.length, "Cache should have one item");
|
||||
|
||||
ds.flushCache();
|
||||
Assert.areSame(0, ds._aCache.length, "Cache should be empty");
|
||||
|
||||
ds = null;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
testViaProperty: function() {
|
||||
var ds = this.createInstance();
|
||||
ds.maxCacheEntries = 5;
|
||||
ds.sendRequest("a", function() {
|
||||
Assert.areSame(true, YAHOO.lang.isArray(ds._aCache), "Failed to init cache (via property)");
|
||||
Assert.areSame(1, ds._aCache.length, "Cache should have one item");
|
||||
|
||||
ds.maxCacheEntries = 0;
|
||||
Assert.areSame(1, ds._aCache.length, "Cache should still have one item");
|
||||
|
||||
ds.sendRequest("a", function() {
|
||||
Assert.areSame(null, ds._aCache, "Cache should be destroyed");
|
||||
|
||||
ds = null;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
var dsCacheTest = new DataSourceTestCase(dsCacheTemplate);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Tests XHR.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
var dsXHRTemplate = YAHOO.lang.merge(datasourceTemplate, {
|
||||
name:"XHR Test",
|
||||
data:"path/to/proxy"
|
||||
});
|
||||
var dsXHRTest = new DataSourceTestCase(dsXHRTemplate);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Tests JSON parsing.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
var dsParseJSONTemplate = YAHOO.lang.merge(datasourceTemplate, {
|
||||
name:"Parse JSON Test",
|
||||
data: {"ResultSet":{
|
||||
"totalResultsAvailable":506,
|
||||
"totalResultsReturned":10,
|
||||
"first Result Position":1,
|
||||
"ResultSetMapUrl":"http:\/\/maps.yahoo.com\/broadband\/?q1=Sunnyvale%2C+CA+94089&tt=pizza&tp=1",
|
||||
"Result":[
|
||||
{Title:"Giovannis Pizzeria",MyArray:["1127 N Lawrence Expy"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[408,734,4221],"for":"37.397058","Longitude":"-121.996017","Nested":{"Average-Rating":"4","Total Ratings":"54","TotalReviews":"36",MyArray:["1201994139"]},"Distance":"0.62","Url":"http:\/\/local.yahoo.com\/details?id=21341983&stx=pizza&csz=Sunnyvale+CA&ed=MKz.rq160SwrCmnpe6IIB6SO8HQ4zpqeQiusehO32jPu0kFQONfQkxJV87YlenT7OdxlEDHPoHfJqkjm","ClickUrl":"http:\/\/local.yahoo.com\/details?id=21341983&stx=pizza&csz=Sunnyvale+CA&ed=MKz.rq160SwrCmnpe6IIB6SO8HQ4zpqeQiusehO32jPu0kFQONfQkxJV87YlenT7OdxlEDHPoHfJqkjm","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Giovannis+Pizzeria&desc=4087344221&csz=Sunnyvale+CA&qty=9&cs=9&ed=MKz.rq160SwrCmnpe6IIB6SO8HQ4zpqeQiusehO32jPu0kFQONfQkxJV87YlenT7OdxlEDHPoHfJqkjm&gid1=21341983","BusinessUrl":"","BusinessClickUrl":""},
|
||||
{Title:"Gumbas Cafe Italian Restaurant & Pizzeria",MyArray:["176 S Murphy Ave"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[408,737,8384],"for":"37.376442","Longitude":"-122.030102","Nested":{"Average-Rating":"4","Total Ratings":"38","TotalReviews":"26",MyArray:["1199489524"]},"Distance":"2.05","Url":"http:\/\/local.yahoo.com\/details?id=21337886&stx=pizza&csz=Sunnyvale+CA&ed=uj7cXq160SxhJq9XTxZy.yXDsYz0FRBPkLX2zpjvEH6o4FWX9XPNxDcQ6y3QcRkD8A_GfKyDEVY-","ClickUrl":"http:\/\/local.yahoo.com\/details?id=21337886&stx=pizza&csz=Sunnyvale+CA&ed=uj7cXq160SxhJq9XTxZy.yXDsYz0FRBPkLX2zpjvEH6o4FWX9XPNxDcQ6y3QcRkD8A_GfKyDEVY-","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Gumbas+Cafe+Italian+Restaurant+%26+Pizzeria&desc=4087378384&csz=Sunnyvale+CA&qty=9&cs=9&ed=uj7cXq160SxhJq9XTxZy.yXDsYz0FRBPkLX2zpjvEH6o4FWX9XPNxDcQ6y3QcRkD8A_GfKyDEVY-&gid1=21337886","BusinessUrl":"","BusinessClickUrl":""},
|
||||
{Title:"Vitos Famous Pizza",MyArray:["1155 Reed Ave"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[(408),246,8800],"for":"37.367029","Longitude":"-121.997904","Nested":{"Average-Rating":"4.5","Total Ratings":"16","TotalReviews":"13",MyArray:["1195089220"]},"Distance":"2.30","Url":"http:\/\/local.yahoo.com\/details?id=21332026&stx=pizza&csz=Sunnyvale+CA&ed=N38lFq160SymmdPNQF8OuFWLoPx_i.6GZDIVFehy9mWH6xbhRaqIfTx6ts8pKvY20AnKblM-","ClickUrl":"http:\/\/local.yahoo.com\/details?id=21332026&stx=pizza&csz=Sunnyvale+CA&ed=N38lFq160SymmdPNQF8OuFWLoPx_i.6GZDIVFehy9mWH6xbhRaqIfTx6ts8pKvY20AnKblM-","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Vitos+Famous+Pizza&desc=4082468800&csz=Sunnyvale+CA&qty=9&cs=9&ed=N38lFq160SymmdPNQF8OuFWLoPx_i.6GZDIVFehy9mWH6xbhRaqIfTx6ts8pKvY20AnKblM-&gid1=21332026","BusinessUrl":"http:\/\/vitosfamouspizza.com\/","BusinessClickUrl":"http:\/\/vitosfamouspizza.com\/"},
|
||||
{Title:"Domino's Pizza",MyArray:["615 Caliente Dr"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[(408), 732,3030],"for":"37.391271","Longitude":"-122.013742","Nested":{"Average-Rating":"4","Total Ratings":"5","TotalReviews":"0",MyArray:["1195089222"]},"Distance":"0.81","Url":"http:\/\/local.yahoo.com\/details?id=21335892&stx=pizza&csz=Sunnyvale+CA&ed=8AfC_K160Sxfwh8iare3qmr9FJ3PN3F1hAEsxLQGY7jUiik2FpVQoHyE7foPhoqHownL0ORw2A--","ClickUrl":"http:\/\/local.yahoo.com\/details?id=21335892&stx=pizza&csz=Sunnyvale+CA&ed=8AfC_K160Sxfwh8iare3qmr9FJ3PN3F1hAEsxLQGY7jUiik2FpVQoHyE7foPhoqHownL0ORw2A--","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Domino%27s+Pizza&desc=4087323030&csz=Sunnyvale+CA&qty=9&cs=9&ed=8AfC_K160Sxfwh8iare3qmr9FJ3PN3F1hAEsxLQGY7jUiik2FpVQoHyE7foPhoqHownL0ORw2A--&gid1=21335892","BusinessUrl":"http:\/\/www.dominos.com\/","BusinessClickUrl":"http:\/\/www.dominos.com\/"},
|
||||
{Title:"Domino's Pizza",MyArray:["992 W El Camino Real"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[(408),736,3666],"for":"37.371434","Longitude":"-122.047559","Nested":{"Average-Rating":"4","Total Ratings":"7","TotalReviews":"3",MyArray:["1127363766"]},"Distance":"2.80","Url":"http:\/\/local.yahoo.com\/details?id=21341882&stx=pizza&csz=Sunnyvale+CA&ed=q0udl6160Sx.AqTKVZbNw3XSw.U4VT.yixioJ6k.H7cOEZSOqMOl7Kf6Mc21zYe1tziGcwBKEW9HzCfs","ClickUrl":"http:\/\/local.yahoo.com\/details?id=21341882&stx=pizza&csz=Sunnyvale+CA&ed=q0udl6160Sx.AqTKVZbNw3XSw.U4VT.yixioJ6k.H7cOEZSOqMOl7Kf6Mc21zYe1tziGcwBKEW9HzCfs","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Domino%27s+Pizza&desc=4087363666&csz=Sunnyvale+CA&qty=9&cs=9&ed=q0udl6160Sx.AqTKVZbNw3XSw.U4VT.yixioJ6k.H7cOEZSOqMOl7Kf6Mc21zYe1tziGcwBKEW9HzCfs&gid1=21341882","BusinessUrl":"http:\/\/www.dominos.com\/","BusinessClickUrl":"http:\/\/www.dominos.com\/"},
|
||||
{Title:"Pizza Depot",MyArray:["919 E Duane Ave"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[(408),245,7760],"for":"37.388527","Longitude":"-122.004046","Nested":{"Average-Rating":"3.5","Total Ratings":"6","TotalReviews":"5",MyArray:["1161370760"]},"Distance":"0.93","Url":"http:\/\/local.yahoo.com\/details?id=21332021&stx=pizza&csz=Sunnyvale+CA&ed=7KK7mK160SzRB7AzH1MQcGzaJtl1F1AhRiRj3iKI5XIyMK5AKtQ2d5fqhwSD1KvtPBjDptclVg--","ClickUrl":"http:\/\/local.yahoo.com\/details?id=21332021&stx=pizza&csz=Sunnyvale+CA&ed=7KK7mK160SzRB7AzH1MQcGzaJtl1F1AhRiRj3iKI5XIyMK5AKtQ2d5fqhwSD1KvtPBjDptclVg--","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Pizza+Depot&desc=4082457760&csz=Sunnyvale+CA&qty=9&cs=9&ed=7KK7mK160SzRB7AzH1MQcGzaJtl1F1AhRiRj3iKI5XIyMK5AKtQ2d5fqhwSD1KvtPBjDptclVg--&gid1=21332021","BusinessUrl":"http:\/\/pizza-depot.com\/","BusinessClickUrl":"http:\/\/pizza-depot.com\/"},
|
||||
{Title:"Round Table Pizza Sunnyvale",MyArray:["665 S Bernardo Ave"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[(408),732,6670],"for":"37.372847","Longitude":"-122.056805","Nested":{"Average-Rating":"4","Total Ratings":"2","TotalReviews":"2",MyArray:["1186612286"]},"Distance":"3.05","Url":"http:\/\/local.yahoo.com\/details?id=21328190&stx=pizza&csz=Sunnyvale+CA&ed=7UuQPq160SyTLgsCywr8RVh7QMTEamkpxTk1eEvusFf6qe0s4ZWcRmYd.2M0jmVjLcEFk_Gf1v10hg--","ClickUrl":"http:\/\/local.yahoo.com\/details?id=21328190&stx=pizza&csz=Sunnyvale+CA&ed=7UuQPq160SyTLgsCywr8RVh7QMTEamkpxTk1eEvusFf6qe0s4ZWcRmYd.2M0jmVjLcEFk_Gf1v10hg--","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Round+Table+Pizza+Sunnyvale&desc=4087326670&csz=Sunnyvale+CA&qty=9&cs=9&ed=7UuQPq160SyTLgsCywr8RVh7QMTEamkpxTk1eEvusFf6qe0s4ZWcRmYd.2M0jmVjLcEFk_Gf1v10hg--&gid1=21328190","BusinessUrl":"http:\/\/www.roundtablepizza.com\/","BusinessClickUrl":"http:\/\/www.roundtablepizza.com\/"},
|
||||
{Title:"Big Bite Pizza",MyArray:["109 E Fremont Ave"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[(408),481,0666],"for":"37.352338","Longitude":"-122.031861","Nested":{"Average-Rating":"4","Total Ratings":"4","TotalReviews":"2",MyArray:["1190777914"]},"Distance":"3.42","Url":"http:\/\/local.yahoo.com\/details?id=25660586&stx=pizza&csz=Sunnyvale+CA&ed=XUNURa160SwU43kPscbu1nhShMQE1ZF7Bnnh8qSivRQ4ASxOcRXUml7KMN.4QoLsYF0xn5KhnpoW","ClickUrl":"http:\/\/local.yahoo.com\/details?id=25660586&stx=pizza&csz=Sunnyvale+CA&ed=XUNURa160SwU43kPscbu1nhShMQE1ZF7Bnnh8qSivRQ4ASxOcRXUml7KMN.4QoLsYF0xn5KhnpoW","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Big+Bite+Pizza&desc=4084810666&csz=Sunnyvale+CA&qty=9&cs=9&ed=XUNURa160SwU43kPscbu1nhShMQE1ZF7Bnnh8qSivRQ4ASxOcRXUml7KMN.4QoLsYF0xn5KhnpoW&gid1=25660586","BusinessUrl":"","BusinessClickUrl":""},
|
||||
{Title:"Pizza Hut",MyArray:["464 N Mathilda Ave"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[(408),735,1900],"for":"37.388298","Longitude":"-122.03056","Nested":{"Average-Rating":"2.5","Total Ratings":"8","TotalReviews":"5",MyArray:["1195096424"]},"Distance":"1.49","Url":"http:\/\/local.yahoo.com\/details?id=21340811&stx=pizza&csz=Sunnyvale+CA&ed=fg.eBq160Sw0QwGltksNXPMtnWxCI0URPWb4E5ZutY7RPm_Jjd5xK395KtaeM7l1A_hYAS0FkNn4","ClickUrl":"http:\/\/local.yahoo.com\/details?id=21340811&stx=pizza&csz=Sunnyvale+CA&ed=fg.eBq160Sw0QwGltksNXPMtnWxCI0URPWb4E5ZutY7RPm_Jjd5xK395KtaeM7l1A_hYAS0FkNn4","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Pizza+Hut&desc=4087351900&csz=Sunnyvale+CA&qty=9&cs=9&ed=fg.eBq160Sw0QwGltksNXPMtnWxCI0URPWb4E5ZutY7RPm_Jjd5xK395KtaeM7l1A_hYAS0FkNn4&gid1=21340811","BusinessUrl":"http:\/\/www.pizzahut.com\/","BusinessClickUrl":"http:\/\/www.pizzahut.com\/"},
|
||||
{Title:"Round Table Pizza",MyArray:["415 N Mary Ave"],"Hy-phenated":"Sunnyvale","State":"CA","Array Index":[(408),733,1365],"for":"37.390247","Longitude":"-122.041498","Nested":{"Average-Rating":"2.5","Total Ratings":"5","TotalReviews":"2",MyArray:["1155195814"]},"Distance":"1.86","Url":"http:\/\/local.yahoo.com\/details?id=21329046&stx=pizza&csz=Sunnyvale+CA&ed=uyby8a160Sy9qe0i.PcxDTgLyA.E934puXrbc.yiwzLvQHghOQRbey19BpfYd2SdELp9wnqw","ClickUrl":"http:\/\/local.yahoo.com\/details?id=21329046&stx=pizza&csz=Sunnyvale+CA&ed=uyby8a160Sy9qe0i.PcxDTgLyA.E934puXrbc.yiwzLvQHghOQRbey19BpfYd2SdELp9wnqw","MapUrl":"http:\/\/maps.yahoo.com\/maps_result?name=Round+Table+Pizza&desc=4087331365&csz=Sunnyvale+CA&qty=9&cs=9&ed=uyby8a160Sy9qe0i.PcxDTgLyA.E934puXrbc.yiwzLvQHghOQRbey19BpfYd2SdELp9wnqw&gid1=21329046","BusinessUrl":"http:\/\/www.roundtablepizza.com\/","BusinessClickUrl":"http:\/\/www.roundtablepizza.com\/"}
|
||||
]
|
||||
}},
|
||||
|
||||
testSchemaSyntaxes: function() {
|
||||
var ds = this.createInstance();
|
||||
ds.responseType = YAHOO.util.DataSource.TYPE_JSON;
|
||||
|
||||
// Simple shema
|
||||
ds.responseSchema = {
|
||||
resultsList: "ResultSet.Result",
|
||||
fields: ["Title","MyArray[0]","Hy-phenated","Array Index","for"]
|
||||
};
|
||||
var oCallback = {
|
||||
success:function(oRequest, oResponse, oPayload) {
|
||||
Assert.areSame(this.data.ResultSet.Result[9]["Title"], oResponse.results[9]["Title"], "Incorrect parsing of String");
|
||||
Assert.areSame(this.data.ResultSet.Result[9]["MyArray"][0], oResponse.results[9]["MyArray[0]"], "Incorrect parsing of Array index");
|
||||
Assert.areSame(this.data.ResultSet.Result[9]["for"], oResponse.results[9]["for"], "Incorrect parsing of reserved word");
|
||||
|
||||
// Verify invalids didn't parse
|
||||
Assert.isUndefined(oResponse.results[9]["Hy-phenated"], "Incorrect parsing of invalid dot syntax key with dash");
|
||||
Assert.isUndefined(oResponse.results[9]["Array Index"], "Incorrect parsing of invalid dot syntax key with empty space");
|
||||
},
|
||||
scope:this
|
||||
};
|
||||
ds.sendRequest(null,oCallback);
|
||||
|
||||
// Nested schema
|
||||
ds.responseSchema.fields = ["Nested.TotalReviews","Nested.Average-Rating","Nested.Total Ratings","Nested.MyArray[0]"];
|
||||
var oCallback = {
|
||||
success:function(oRequest, oResponse, oPayload) {
|
||||
Assert.areSame(this.data.ResultSet.Result[9]["Nested"]["TotalReviews"], oResponse.results[9]["Nested.TotalReviews"], "Incorrect parsing of nested String");
|
||||
ArrayAssert.itemsAreSame(this.data.ResultSet.Result[9]["Nested"]["MyArray"][0], oResponse.results[9]["Nested.MyArray[0]"], "Incorrect parsing of nested Array index");
|
||||
|
||||
// Verify invalids didn't parse
|
||||
Assert.isUndefined(oResponse.results[9]["Nested.Average-Rating"], "Incorrect parsing of invalid nested key containing hyphen");
|
||||
Assert.isUndefined(oResponse.results[9]["Nested.Total Ratings"], "Incorrect parsing of invalid dot syntax key containing empty space");
|
||||
},
|
||||
scope:this
|
||||
};
|
||||
ds.sendRequest(null,oCallback);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
var dsParseJSONTest = new DataSourceTestCase(dsParseJSONTemplate);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Tests static methods.
|
||||
*
|
||||
*
|
||||
*/
|
||||
var dsStaticMethodsTemplate = {
|
||||
name:"Static Methods Test",
|
||||
data:["a","b","c"],
|
||||
|
||||
testParseNumbers: function() {
|
||||
var number;
|
||||
var ds = this.createInstance();
|
||||
var myNumber = 1;
|
||||
|
||||
number = YAHOO.util.DataSource.parseNumber("1");
|
||||
Assert.areSame(number, myNumber, "Incorrect number from String.");
|
||||
|
||||
number = YAHOO.util.DataSource.parseNumber(1);
|
||||
Assert.areSame(number, myNumber, "Incorrect number from Number.");
|
||||
|
||||
ds = null;
|
||||
},
|
||||
|
||||
testParseDates: function() {
|
||||
var date;
|
||||
var ds = this.createInstance();
|
||||
var myDate = new Date(2001,0,14); // January 14, 2001
|
||||
|
||||
date = YAHOO.util.DataSource.parseDate("1/14/2001");
|
||||
DateAssert.datesAreEqual(date, myDate, "Incorrect date from String.");
|
||||
|
||||
date = YAHOO.util.DataSource.parseDate(myDate);
|
||||
DateAssert.datesAreEqual(date, myDate, "Incorrect date from Date");
|
||||
|
||||
date = YAHOO.util.DataSource.parseDate(979459200000);
|
||||
DateAssert.datesAreEqual(date, myDate, "Incorrect date from Number.");
|
||||
|
||||
ds = null;
|
||||
}
|
||||
};
|
||||
var dsStaticMethodsTest = new DataSourceTestCase(dsStaticMethodsTemplate);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Base test case for YAHOO.util.DataType APIs.
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DataUtilTestCase(template) {
|
||||
DataUtilTestCase.superclass.constructor.call(this, template);
|
||||
};
|
||||
YAHOO.lang.extend(DataUtilTestCase, TestCase);
|
||||
|
||||
DataUtilTestCase.prototype.setUp = function() {
|
||||
};
|
||||
|
||||
DataUtilTestCase.prototype.tearDown = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Tests YAHOO.util.Number APIs.
|
||||
*
|
||||
*
|
||||
*/
|
||||
var dataNumberTemplate = {
|
||||
name:"Util Number Test",
|
||||
|
||||
testFormat: function() {
|
||||
output = YAHOO.util.Number.format("1");
|
||||
Assert.areSame("1", output, "Incorrect output from String.");
|
||||
|
||||
output = YAHOO.util.Number.format(1);
|
||||
Assert.areSame("1", output, "Incorrect output from Number.");
|
||||
|
||||
output = YAHOO.util.Number.format(0);
|
||||
Assert.areSame("0", output, "Incorrect output from zero.");
|
||||
|
||||
output = YAHOO.util.Number.format(-1);
|
||||
Assert.areSame("-1", output, "Incorrect output from negative Number.");
|
||||
|
||||
output = YAHOO.util.Number.format(123, {prefix:"$"});
|
||||
Assert.areSame("$123", output, "Incorrect prefix");
|
||||
|
||||
output = YAHOO.util.Number.format(123, {suffix:" items"});
|
||||
Assert.areSame("123 items", output, "Incorrect suffix");
|
||||
|
||||
output = YAHOO.util.Number.format(123.123, {decimalPlaces:5});
|
||||
Assert.areSame("123.12300", output, "Incorrect decimal rounding: expected 5 places");
|
||||
|
||||
output = YAHOO.util.Number.format(123, {decimalPlaces:5});
|
||||
Assert.areSame("123.00000", output, "Incorrect decimal padding: expected 5 places");
|
||||
|
||||
output = YAHOO.util.Number.format(123.123, {decimalPlaces:4});
|
||||
Assert.areSame("123.1230", output, "Incorrect decimal rounding: expected 4 places");
|
||||
|
||||
output = YAHOO.util.Number.format(123.123, {decimalPlaces:3});
|
||||
Assert.areSame("123.123", output, "Incorrect decimal rounding: expected 3 places");
|
||||
|
||||
output = YAHOO.util.Number.format(123.127, {decimalPlaces:2});
|
||||
Assert.areSame("123.13", output, "Incorrect decimal rounding: expected rounded to 2 places");
|
||||
|
||||
output = YAHOO.util.Number.format(123.123, {decimalPlaces:2});
|
||||
Assert.areSame("123.12", output, "Incorrect decimal rounding: expected 2 places");
|
||||
|
||||
output = YAHOO.util.Number.format(123.123, {decimalPlaces:1});
|
||||
Assert.areSame("123.1", output, "Incorrect decimal rounding: expected 1 place");
|
||||
|
||||
output = YAHOO.util.Number.format(123.123, {decimalPlaces:0});
|
||||
Assert.areSame("123", output, "Incorrect decimal rounding: expected 0 places");
|
||||
|
||||
output = YAHOO.util.Number.format(123.123, {decimalPlaces:-1});
|
||||
Assert.areSame("120", output, "Incorrect decimal rounding: expected -1 places");
|
||||
|
||||
output = YAHOO.util.Number.format("123123123", {thousandsSeparator:","});
|
||||
Assert.areSame("123,123,123", output, "Incorrect thousands separation");
|
||||
|
||||
output = YAHOO.util.Number.format("123123123.176",{
|
||||
prefix: "¥",
|
||||
decimalPlaces:2,
|
||||
thousandsSeparator:".",
|
||||
decimalSeparator:","
|
||||
});
|
||||
Assert.areSame("¥123.123.123,18", output, "Incorrect Yen formatting");
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
var dataNumberTest = new DataUtilTestCase(dataNumberTemplate);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Runs tests.
|
||||
*
|
||||
*
|
||||
*/
|
||||
YAHOO.util.Event.addListener(window, "load", function() {
|
||||
var logger = new TestLogger();
|
||||
logger.hideCategory('info');
|
||||
|
||||
var datasourcesuite = new TestSuite("DataSource Test Suite");
|
||||
datasourcesuite.add(datasourceTest);
|
||||
datasourcesuite.add(dsCacheTest);
|
||||
datasourcesuite.add(dsComplexArrayTest);
|
||||
datasourcesuite.add(dsStaticMethodsTest);
|
||||
datasourcesuite.add(dsXHRTest);
|
||||
datasourcesuite.add(dsParseJSONTest);
|
||||
datasourcesuite.add(dataNumberTest);
|
||||
|
||||
TestRunner.add(datasourcesuite);
|
||||
|
||||
YAHOO.util.Event.addListener("btnRun", "click", function(){TestRunner.run();});
|
||||
YAHOO.util.Dom.get("btnRun").disabled = false;
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1740
www/extras/yui/tests/datatable.html
Normal file
1740
www/extras/yui/tests/datatable.html
Normal file
File diff suppressed because it is too large
Load diff
1385
www/extras/yui/tests/datemath.html
Normal file
1385
www/extras/yui/tests/datemath.html
Normal file
File diff suppressed because it is too large
Load diff
463
www/extras/yui/tests/dom.html
Normal file
463
www/extras/yui/tests/dom.html
Normal file
|
|
@ -0,0 +1,463 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>DOM Test Suite</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css">
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
h1, h2, h3, h4, h5, h6, p, ul, ol, li {
|
||||
Xmargin:0;
|
||||
Xpadding:0;
|
||||
}
|
||||
|
||||
#doc {
|
||||
border:5px solid #000;
|
||||
margin:10px;
|
||||
padding:10px;
|
||||
}
|
||||
|
||||
#hd {
|
||||
background:#ccc;
|
||||
}
|
||||
|
||||
#foo {
|
||||
float:left; /* required for getStyle test */
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var Y = YAHOO.util,
|
||||
tool = YAHOO.tool,
|
||||
suite = new tool.TestSuite("yuisuite");
|
||||
|
||||
Y.Event.onDOMReady(function() {
|
||||
var logger = new YAHOO.tool.TestLogger(null, { height: '80%' });
|
||||
|
||||
suite.add( new tool.TestCase({
|
||||
name: 'YAHOO.util.Dom',
|
||||
|
||||
test_get: function() {
|
||||
YAHOO.util.Assert.areEqual(document.getElementById('doc'),
|
||||
Y.Dom.get('doc'), 'wrong node returned');
|
||||
|
||||
YAHOO.util.Assert.areEqual(document.getElementById('doc'),
|
||||
Y.Dom.get(document.getElementById('doc')), 'wrong node returned');
|
||||
|
||||
YAHOO.util.ArrayAssert.itemsAreEqual(
|
||||
[ document.getElementById('hd'), document.getElementById('bd') ],
|
||||
Y.Dom.get(['hd', document.getElementById('bd')]), 'wrong node returned');
|
||||
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.get('dox'), 'non-existent ID');
|
||||
},
|
||||
|
||||
test_getStyle: function() {
|
||||
YAHOO.util.Assert.areEqual('left',
|
||||
Y.Dom.getStyle('foo', 'float'), 'wrong style returned');
|
||||
|
||||
document.getElementById('doc').style.marginBottom = '10px';
|
||||
|
||||
YAHOO.util.Assert.areEqual('10px',
|
||||
Y.Dom.getStyle('doc', 'marginBottom'), 'wrong style returned');
|
||||
},
|
||||
|
||||
test_setStyle: function() {
|
||||
Y.Dom.setStyle('ft', 'opacity', 0.5);
|
||||
YAHOO.util.Assert.areEqual(Y.Dom.getStyle('ft', 'opacity'),
|
||||
0.5, 'wrong style returned');
|
||||
|
||||
Y.Dom.setStyle('main', 'float', 'none');
|
||||
YAHOO.util.Assert.areEqual(Y.Dom.getStyle('main', 'float'),
|
||||
'none', 'wrong style returned');
|
||||
},
|
||||
test_hasClass: function() {
|
||||
YAHOO.util.Assert.isTrue(Y.Dom.hasClass('lorem-ipsum', 'lorem'),
|
||||
'hasClass failed with existing class');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.hasClass('lorem-ipsum', 'dolor'),
|
||||
'hasClass failed with non-existing class');
|
||||
},
|
||||
|
||||
test_addClass: function() {
|
||||
Y.Dom.addClass('ft', 'foo');
|
||||
|
||||
YAHOO.util.Assert.areEqual(
|
||||
'foo',
|
||||
document.getElementById('ft').className,
|
||||
'addClass failed to add');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.addClass('ft', 'foo'),
|
||||
'addClass should return false if element already hasClass');
|
||||
},
|
||||
|
||||
test_removeClass: function() {
|
||||
Y.Dom.removeClass('lorem-ipsum', 'ipsum');
|
||||
YAHOO.util.Assert.areEqual('lorem', Y.Dom.get('lorem-ipsum').className,
|
||||
'removeClass failed');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.removeClass('main', 'bar'),
|
||||
'removeClass should return false if class not present');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.removeClass('main'),
|
||||
'removeClass should return false if no class argument');
|
||||
},
|
||||
|
||||
test_replaceClass: function() {
|
||||
Y.Dom.replaceClass('lorem-ipsum', 'lorem', 'ipsum');
|
||||
YAHOO.util.Assert.areEqual('ipsum', Y.Dom.get('lorem-ipsum').className,
|
||||
'replaceClass failed');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.replaceClass('lorem-ipsum', 'ipsum'),
|
||||
'replaceClass should return false if new class not specified');
|
||||
|
||||
YAHOO.util.Assert.isTrue(Y.Dom.replaceClass('lorem-ipsum', '', 'lorem'),
|
||||
'replaceClass should addClass if old class not specified');
|
||||
|
||||
YAHOO.util.Assert.areEqual('ipsum lorem', Y.Dom.get('lorem-ipsum').className,
|
||||
'replaceClass failed: should addClass if old class not specified');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.replaceClass('lorem-ipsum', 'ipsum', 'ipsum'),
|
||||
'replaceClass should return false if new class and old are equal');
|
||||
|
||||
},
|
||||
|
||||
test_getElementsByClassName: function() {
|
||||
YAHOO.util.Assert.areEqual(2, Y.Dom.getElementsByClassName('mod').length, 'getByClassName failed for .mod');
|
||||
YAHOO.util.Assert.areEqual(2, Y.Dom.getElementsByClassName('mod', 'div').length, 'getByClassName failed for div.mod');
|
||||
YAHOO.util.Assert.areEqual(2, Y.Dom.getElementsByClassName('mod', 'div', 'bd').length, 'getByClassName failed for #bd div.mod');
|
||||
YAHOO.util.Assert.areEqual(2, Y.Dom.getElementsByClassName('mod', '', 'bd').length,'getByClassName failed for #bd .mod' );
|
||||
YAHOO.util.Assert.areEqual(0, Y.Dom.getElementsByClassName('mod', 'div', 'hd').length, 'getByClassName failed for #hd .mod');
|
||||
YAHOO.util.Assert.areEqual(0, Y.Dom.getElementsByClassName('moo').length, 'getByClassName failed for .moo');
|
||||
YAHOO.util.Assert.areEqual(0, Y.Dom.getElementsByClassName('mod', 'div', 'fake-id').length, 'getByClassName failed for #fake-id div.mod');
|
||||
},
|
||||
|
||||
test_getElementsBy: function() {
|
||||
YAHOO.util.Assert.areEqual(2, Y.Dom.getElementsBy(function(el) { return el.className == 'mod'}).length, 'getBy failed for .mod');
|
||||
YAHOO.util.Assert.areEqual(2, Y.Dom.getElementsBy(function(el) { return el.className == 'mod'}, 'div').length, 'getBy failed for div.mod');
|
||||
YAHOO.util.Assert.areEqual(2, Y.Dom.getElementsBy(function(el) { return el.className == 'mod'}, 'div', 'bd').length, 'getBy failed for #bd div.mod');
|
||||
YAHOO.util.Assert.areEqual(2, Y.Dom.getElementsBy(function(el) { return el.className == 'mod'}, '', 'bd').length, 'getBy failed for #bd .mod');
|
||||
YAHOO.util.Assert.areEqual(0, Y.Dom.getElementsBy(function(el) { return el.className == 'mod'}, 'div', 'hd').length, 'getBy failed for #hd div.mod');
|
||||
YAHOO.util.Assert.areEqual(0, Y.Dom.getElementsBy(function(el) { return el.className == 'moo'}).length, 'getBy failed for .moo');
|
||||
YAHOO.util.Assert.areEqual(0, Y.Dom.getElementsBy(function(el) { return el.className == 'mod'}, 'div', 'fake-id').length, 'getBy failed for #fake-id div.mod');
|
||||
},
|
||||
|
||||
test_generateId: function() {
|
||||
var header = document.getElementsByTagName('h1')[0];
|
||||
Y.Dom.generateId(header);
|
||||
YAHOO.util.Assert.areEqual('yui-gen0', header.id,
|
||||
'generateId failed');
|
||||
},
|
||||
|
||||
test_isAncestor: function() {
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.isAncestor(Y.Dom.get('main'), Y.Dom.get('bd')),
|
||||
'isAncestor failed for false case');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.isAncestor('main', 'bd'),
|
||||
'isAncestor failed for false case');
|
||||
|
||||
YAHOO.util.Assert.isTrue(Y.Dom.isAncestor('bd', 'main'),
|
||||
'isAncestor failed for true case');
|
||||
|
||||
YAHOO.util.Assert.isFalse(
|
||||
Y.Dom.isAncestor(document.body.appendChild(document.createElement('div')), 'bd'),
|
||||
'isAncestor failed for false case');
|
||||
},
|
||||
|
||||
test_getRegion: function() {
|
||||
YAHOO.util.Assert.isObject(Y.Dom.getRegion('bd'),
|
||||
'getRegion failed for element in document');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.getRegion('xbd'),
|
||||
'getRegion failed for id not in document');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.getRegion(document.createElement('div')),
|
||||
'getRegion failed for element not in document');
|
||||
},
|
||||
|
||||
test_point: function() {
|
||||
var point = new Y.Point(100, 200);
|
||||
var testX = point.left === point.right && point.x === point[0] && point[0] === point.left && point.left === 100;
|
||||
var testY = point.top === point.bottom && point.y === point[1] && point[1] == point.top && point.top === 200;
|
||||
YAHOO.util.Assert.isTrue(testX && testY, 'test point with x, y constructor');
|
||||
|
||||
point = new Y.Point([100, 200]);
|
||||
var testX = point.left === point.right && point.x === point[0] && point[0] === point.left && point.left === 100;
|
||||
var testY = point.top === point.bottom && point.y === point[1] && point[1] == point.top && point.top === 200;
|
||||
YAHOO.util.Assert.isTrue(testX && testY, 'test point with [x, y] constructor');
|
||||
},
|
||||
|
||||
test_inDocument: function() {
|
||||
YAHOO.util.Assert.isTrue(Y.Dom.inDocument('main'),
|
||||
'inDocument failed for true ID case');
|
||||
|
||||
YAHOO.util.Assert.isTrue(Y.Dom.inDocument(document.body),
|
||||
'inDocument failed for true element case');
|
||||
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.inDocument(el),
|
||||
'inDocument failed for false element case');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.inDocument('fake-id'),
|
||||
'inDocument failed for false ID case');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.inDocument({}),
|
||||
'inDocument failed for null');
|
||||
},
|
||||
|
||||
test_batch: function() {
|
||||
var nodes = Y.Dom.batch(['hd', 'bd'], function(node) {
|
||||
node.title = 'foobar';
|
||||
});
|
||||
|
||||
YAHOO.util.Assert.areEqual('foobar', Y.Dom.get('hd').title,
|
||||
'batch failed for multiple IDs');
|
||||
|
||||
YAHOO.util.Assert.areEqual('foobar', Y.Dom.get('bd').title,
|
||||
'batch failed for multiple IDs');
|
||||
|
||||
Y.Dom.batch('ft', function(node) { node.title = 'barbaz'; } );
|
||||
|
||||
YAHOO.util.Assert.areEqual('barbaz', Y.Dom.get('ft').title,
|
||||
'batch failed for single ID');
|
||||
|
||||
Y.Dom.batch(Y.Dom.get('ft'),
|
||||
function(node) { node.title = 'foobaz'; } );
|
||||
|
||||
YAHOO.util.Assert.areEqual('foobaz', Y.Dom.get('ft').title,
|
||||
'batch failed for single HTMLElement');
|
||||
|
||||
YAHOO.util.Assert.areEqual(0, Y.Dom.batch([], function() { return true; }).length,
|
||||
'batch failed for empty array');
|
||||
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.batch(null), 'batch failed: node(s) required');
|
||||
YAHOO.util.Assert.isFalse(Y.Dom.batch([]), 'batch failed: method is required');
|
||||
},
|
||||
|
||||
test_getAncestorByClassName: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getAncestorByClassName(el, 'foo'),
|
||||
'wrong node returned');
|
||||
var el = Y.Dom.getAncestorByClassName(document.getElementById('foo'), 'main');
|
||||
YAHOO.util.Assert.areEqual(document.getElementById('main'),
|
||||
el, 'wrong node returned');
|
||||
|
||||
el = Y.Dom.getAncestorByClassName(document.getElementById('foo'), 'fake-class');
|
||||
YAHOO.util.Assert.areEqual(null,
|
||||
el, 'wrong node returned');
|
||||
},
|
||||
|
||||
test_getAncestorByTagName: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getAncestorByTagName(el, 'foo'),
|
||||
'wrong node returned');
|
||||
var el = Y.Dom.getAncestorByTagName('foo', 'div');
|
||||
YAHOO.util.Assert.areEqual(document.getElementById('main'),
|
||||
el, 'wrong node returned');
|
||||
|
||||
el = Y.Dom.getAncestorByTagName(document.getElementById('foo'), 'span');
|
||||
YAHOO.util.Assert.areEqual(null,
|
||||
el, 'wrong node returned');
|
||||
},
|
||||
|
||||
test_getAncestorBy: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getAncestorBy(el),
|
||||
'wrong node returned');
|
||||
var el = Y.Dom.getAncestorBy(document.getElementById('foo'), function(el) {
|
||||
return el.id === 'bd';
|
||||
});
|
||||
YAHOO.util.Assert.areEqual(document.getElementById('bd'),
|
||||
el, 'wrong node returned');
|
||||
|
||||
el = Y.Dom.getAncestorBy(document.getElementById('foo'), function() { return false; });
|
||||
YAHOO.util.Assert.areEqual(null,
|
||||
el, 'wrong node returned');
|
||||
},
|
||||
|
||||
test_getPreviousSiblingBy: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getPreviousSiblingBy(el),
|
||||
'wrong node returned');
|
||||
var el = Y.Dom.getPreviousSiblingBy(document.getElementById('foo'),
|
||||
function(node) { return node.tagName == 'H2'; }
|
||||
);
|
||||
YAHOO.util.Assert.areEqual(document.getElementsByTagName('h2')[0],
|
||||
el, 'wrong node returned');
|
||||
},
|
||||
test_getPreviousSibling: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getPreviousSibling(el),
|
||||
'wrong node returned');
|
||||
YAHOO.util.Assert.areEqual(Y.Dom.getPreviousSibling('bd'),
|
||||
Y.Dom.get('hd'), 'wrong node returned');
|
||||
},
|
||||
|
||||
test_getNextSiblingBy: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getNextSiblingBy(el),
|
||||
'wrong node returned');
|
||||
var el = Y.Dom.getNextSiblingBy(document.getElementById('foo'),
|
||||
function(node) { return node.className == 'mod'; }
|
||||
);
|
||||
YAHOO.util.Assert.areEqual(Y.Dom.getElementsByClassName('mod', 'div', 'main')[1],
|
||||
el, 'wrong node returned');
|
||||
},
|
||||
|
||||
test_getNextSibling: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getNextSibling(el),
|
||||
'wrong node returned');
|
||||
YAHOO.util.Assert.areEqual(Y.Dom.getNextSibling('bd'),
|
||||
Y.Dom.get('ft'), 'wrong node returned');
|
||||
},
|
||||
|
||||
test_getFirstChildBy: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getFirstChildBy(el),
|
||||
'wrong node returned');
|
||||
var el = Y.Dom.getFirstChildBy(document.getElementById('doc'),
|
||||
function(node) { return node.id == 'bd'; }
|
||||
);
|
||||
YAHOO.util.Assert.areEqual(document.getElementById('bd'),
|
||||
el, 'wrong node returned');
|
||||
},
|
||||
|
||||
test_getFirstChild: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getFirstChild(el),
|
||||
'wrong node returned');
|
||||
YAHOO.util.Assert.areEqual(document.getElementById('hd'),
|
||||
Y.Dom.getFirstChild(document.getElementById('doc')), 'wrong node returned');
|
||||
},
|
||||
|
||||
test_getLastChildBy: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getLastChildBy(el),
|
||||
'wrong node returned');
|
||||
var el = Y.Dom.getLastChildBy(document.getElementById('doc'),
|
||||
function(node) { return node.id == 'bd'; }
|
||||
);
|
||||
YAHOO.util.Assert.areEqual(document.getElementById('bd'),
|
||||
el, 'wrong node returned');
|
||||
},
|
||||
|
||||
test_getLastChild: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Assert.areEqual(null, Y.Dom.getLastChild(el),
|
||||
'wrong node returned');
|
||||
YAHOO.util.Assert.areEqual(
|
||||
document.getElementById('ft'),
|
||||
Y.Dom.getLastChild(document.getElementById('doc')),
|
||||
'wrong node returned'
|
||||
);
|
||||
},
|
||||
test_getChildrenBy: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.ArrayAssert.itemsAreEqual([], Y.Dom.getChildrenBy(el),
|
||||
'wrong node returned');
|
||||
var el = Y.Dom.getChildrenBy(document.getElementById('main'),
|
||||
function(node) { return node.className == 'mod'; }
|
||||
);
|
||||
YAHOO.util.ArrayAssert.itemsAreEqual(
|
||||
Y.Dom.getElementsByClassName('mod', 'div', 'main'),
|
||||
el,
|
||||
'wrong node returned'
|
||||
);
|
||||
},
|
||||
|
||||
test_getChildren: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.ArrayAssert.itemsAreEqual([], Y.Dom.getChildrenBy(el),
|
||||
'wrong node returned');
|
||||
YAHOO.util.ArrayAssert.itemsAreEqual(
|
||||
[ Y.Dom.get('hd'), Y.Dom.get('bd'), Y.Dom.get('ft') ],
|
||||
Y.Dom.getChildren('doc'),
|
||||
'wrong node returned'
|
||||
);
|
||||
},
|
||||
test_insertBefore: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Dom.insertBefore(el, 'bd');
|
||||
YAHOO.util.Assert.areEqual(
|
||||
document.getElementById('bd').previousSibling,
|
||||
el,
|
||||
'insertBefore failed'
|
||||
);
|
||||
},
|
||||
test_insertAfter: function() {
|
||||
var el = document.createElement('div');
|
||||
YAHOO.util.Dom.insertAfter(el, 'bd');
|
||||
YAHOO.util.Assert.areEqual(
|
||||
document.getElementById('bd').nextSibling,
|
||||
el,
|
||||
'insertAfter failed'
|
||||
);
|
||||
}
|
||||
|
||||
}));
|
||||
tool.TestRunner.add(suite);
|
||||
|
||||
if (parent && parent != window) {
|
||||
tool.TestManager.load();
|
||||
} else {
|
||||
tool.TestRunner.run();
|
||||
}
|
||||
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="doc">
|
||||
<div id="hd">
|
||||
<h1>Page Header</h1>
|
||||
</div>
|
||||
<div id="bd">
|
||||
<div id="main" class="main">
|
||||
<h2>Section Header</h2>
|
||||
<em class="lorem ipsum ipsum" id="lorem-ipsum">lorem ipsum</em>
|
||||
<div class="mod" id="foo">
|
||||
<div class="hd">
|
||||
<h3>Module Header</h3>
|
||||
</div>
|
||||
<div class="bd">
|
||||
<p>Fusce feugiat diam. Vestibulum elementum dui in augue. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris pulvinar.</p>
|
||||
</div>
|
||||
<div class="ft"><a href="#">more</a></div>
|
||||
</div>
|
||||
<div class="mod">
|
||||
<div class="hd">
|
||||
<h3>Module Header</h3>
|
||||
</div>
|
||||
<div class="bd">
|
||||
<form action="#" method="get" id="search">
|
||||
<fieldset>
|
||||
<legend>Search</legend>
|
||||
<label for="search-p">Query</label>
|
||||
<input type="text" name="p" id="search-p">
|
||||
<input type="submit" value="search">
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="ft"><a href="http://www.developer.yahoo.com">more</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="ft">
|
||||
<p>In hac habitasse platea dictumst. Sed sit amet ligula vitae justo consequat facilisis. Integer tortor. Integer erat. In hac habitasse platea dictumst. Phasellus convallis quam vitae turpis aliquam lobortis. Aliquam scelerisque condimentum lectus. Proin semper adipiscing leo. Nulla facilisi.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
278
www/extras/yui/tests/dragdrop.html
Normal file
278
www/extras/yui/tests/dragdrop.html
Normal file
|
|
@ -0,0 +1,278 @@
|
|||
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>YUI Tests</title>
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
.dd { position:absolute; height: 100px; width: 100px; z-index:99 }
|
||||
#ddcontainer { top:100px; left: 0px; border: 1px solid green; position:absolute; height: 500px; width: 500px; overflow:auto }
|
||||
#dd1div { top: 100px; left: 100px; background: red; }
|
||||
#dd2div { top: 100px; left: 300px; background: blue; }
|
||||
.downlow { position: absolute; top: 1000px; }
|
||||
|
||||
</style>
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/dragdrop/dragdrop-debug.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="ddcontainer">
|
||||
<div id="dd1div" class="dd">dd1</div>
|
||||
<div id="dd2div" class="dd">dd2</div>
|
||||
<div class="downlow">way down</div>
|
||||
</div>
|
||||
<div class="downlow">way down</div>
|
||||
|
||||
<h1>Drag and Drop Test Page</h1>
|
||||
<p><input type="button" value="Run Tests" id="btnRun" /></p>
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
|
||||
var Dom=YAHOO.util.Dom,
|
||||
Event=YAHOO.util.Event,
|
||||
Assert=YAHOO.util.Assert,
|
||||
ObjectAssert=YAHOO.util.ObjectAssert,
|
||||
ArrayAssert=YAHOO.util.ArrayAssert,
|
||||
suite=new YAHOO.tool.TestSuite("yuisuite");
|
||||
|
||||
|
||||
suite.add(new YAHOO.tool.TestCase({
|
||||
|
||||
//name of the test case
|
||||
name : "dragdrop",
|
||||
|
||||
//extra information about tests
|
||||
_should : {
|
||||
|
||||
//tests with these names should fail
|
||||
fail : { test_to_fail: true },
|
||||
|
||||
//tests with these names should throw an error
|
||||
error : { },
|
||||
|
||||
//ignore these tests
|
||||
ignore : { }
|
||||
},
|
||||
|
||||
test_mouseDown: function() {
|
||||
reset();
|
||||
dd1.handleMouseDown({
|
||||
pageX: 110,
|
||||
pageY: 230,
|
||||
target: dd1.getEl()
|
||||
});
|
||||
YAHOO.util.DDM.handleMouseUp({ pageX: 110, pageY: 210 });
|
||||
|
||||
Assert.areEqual(startDrag, 0, "startDrag should not have fired");
|
||||
Assert.areEqual(mouseDown, 1, "mouseDown should have fired once");
|
||||
},
|
||||
|
||||
test_mouseMiss: function() {
|
||||
reset();
|
||||
dd1.handleMouseDown({ // miss
|
||||
pageX: 90,
|
||||
pageY: 90,
|
||||
target: dd1.getEl()
|
||||
});
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 120, pageY: 220 });
|
||||
YAHOO.util.DDM.handleMouseUp({ pageX: 120, pageY: 220 });
|
||||
|
||||
// check this
|
||||
Assert.areEqual(mouseDown, 1, "mouseDown should have fired once");
|
||||
Assert.areEqual(startDrag, 0, "startDrag should not have fired");
|
||||
Assert.areEqual(endDrag, 0, "endDrag should not have fired");
|
||||
Assert.areEqual(mouseUp, 0, "mouseUp should not have fired");
|
||||
},
|
||||
|
||||
test_startDrag: function() {
|
||||
reset();
|
||||
dd1.handleMouseDown({
|
||||
pageX: 120,
|
||||
pageY: 230,
|
||||
target: dd1.getEl()
|
||||
});
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 120, pageY: 220 });
|
||||
YAHOO.util.DDM.handleMouseUp({ pageX: 120, pageY: 220 });
|
||||
|
||||
Assert.areEqual(mouseDown, 1, "mouseDown should have fired once");
|
||||
Assert.areEqual(startDrag, 1, "startDrag should have fired once");
|
||||
Assert.areEqual(endDrag, 1, "endDrag should have fired once");
|
||||
Assert.areEqual(mouseUp, 1, "mouseUp should have fired once");
|
||||
},
|
||||
|
||||
test_dragOver: function() {
|
||||
reset();
|
||||
dd1.handleMouseDown({
|
||||
pageX: 120,
|
||||
pageY: 230,
|
||||
target: dd1.getEl()
|
||||
});
|
||||
|
||||
for (var i=1;i<21;i=i+1) {
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 124+(10*i), pageY: 220 });
|
||||
}
|
||||
for (var i=20;i>0;i=i-1) {
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 124+(10*i), pageY: 220 });
|
||||
}
|
||||
YAHOO.util.DDM.handleMouseUp({ pageX: 120, pageY: 210 });
|
||||
|
||||
Assert.areEqual(startDrag, 1, "startDrag should have fired once");
|
||||
Assert.areEqual(drag, 40, "drag should have fired 40 times");
|
||||
Assert.areEqual(dragOver, 5, "dragOver should have fired 5 times");
|
||||
Assert.areEqual(dragOut, 1, "dragOut should have fired once");
|
||||
Assert.areEqual(invalidDrop, 1, "invalidDrop should have fired once");
|
||||
Assert.areEqual(dragDrop, 0, "dragDrop should have fired once");
|
||||
},
|
||||
|
||||
test_dragOnly: function() {
|
||||
reset();
|
||||
dd1.dragOnly = true;
|
||||
dd1.handleMouseDown({
|
||||
pageX: 120,
|
||||
pageY: 230,
|
||||
target: dd1.getEl()
|
||||
});
|
||||
|
||||
for (var i=1;i<21;i=i+1) {
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 124+(10*i), pageY: 220 });
|
||||
}
|
||||
for (var i=20;i>0;i=i-1) {
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 124+(10*i), pageY: 220 });
|
||||
}
|
||||
YAHOO.util.DDM.handleMouseUp({ pageX: 120, pageY: 210 });
|
||||
|
||||
Assert.areEqual(1, startDrag, "startDrag should have fired once");
|
||||
Assert.areEqual(40, drag, "drag should have fired 40 times");
|
||||
Assert.areEqual(0, dragOver, "dragOver should have fired 0 times");
|
||||
Assert.areEqual(0, dragOut, "dragOut should have fired 0 times");
|
||||
Assert.areEqual(0, invalidDrop, "invalidDrop should have fired 0 times");
|
||||
Assert.areEqual(0, dragDrop, "dragDrop should have fired 0 times");
|
||||
},
|
||||
|
||||
test_bodyScroll: function() {
|
||||
window.scrollTo(0,150);
|
||||
reset();
|
||||
dd1.handleMouseDown({
|
||||
pageX: 140,
|
||||
pageY: 220,
|
||||
target: dd1.getEl()
|
||||
});
|
||||
|
||||
for (var i=1;i<21;i=i+1) {
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 124+(10*i), pageY: 210 });
|
||||
}
|
||||
for (var i=20;i>0;i=i-1) {
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 124+(10*i), pageY: 210 });
|
||||
}
|
||||
YAHOO.util.DDM.handleMouseUp({ pageX: 120, pageY: 210 });
|
||||
|
||||
Assert.areEqual(startDrag, 1, "startDrag should have fired once");
|
||||
Assert.areEqual(drag, 40, "drag should have fired 40 times");
|
||||
Assert.areEqual(dragOver, 5, "dragOver should have fired 5 times");
|
||||
Assert.areEqual(dragOut, 1, "dragOut should have fired once");
|
||||
Assert.areEqual(invalidDrop, 1, "invalidDrop should have fired once");
|
||||
Assert.areEqual(dragDrop, 0, "dragDrop should have fired once");
|
||||
},
|
||||
|
||||
test_containerScroll: function() {
|
||||
reset();
|
||||
Dom.get("ddcontainer").scrollTop=150;
|
||||
dd1.handleMouseDown({
|
||||
pageX: 140,
|
||||
pageY: 100,
|
||||
target: dd1.getEl()
|
||||
});
|
||||
|
||||
for (var i=1;i<21;i=i+1) {
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 124+(10*i), pageY: 110 });
|
||||
}
|
||||
for (var i=20;i>0;i=i-1) {
|
||||
YAHOO.util.DDM.handleMouseMove({ pageX: 124+(10*i), pageY: 110 });
|
||||
}
|
||||
YAHOO.util.DDM.handleMouseUp({ pageX: 120, pageY: 110 });
|
||||
|
||||
Assert.areEqual(startDrag, 1, "startDrag should have fired once");
|
||||
Assert.areEqual(drag, 40, "drag should have fired 40 times");
|
||||
Assert.areEqual(dragOver, 5, "dragOver should have fired 5 times");
|
||||
Assert.areEqual(dragOut, 1, "dragOut should have fired once");
|
||||
Assert.areEqual(invalidDrop, 1, "invalidDrop should have fired once");
|
||||
Assert.areEqual(dragDrop, 0, "dragDrop should have fired once");
|
||||
},
|
||||
|
||||
test_to_fail: function (){
|
||||
Assert.isNull("not null");
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
function runTests(){
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
|
||||
function reset() {
|
||||
window.scrollTo(0,0);
|
||||
Dom.get("ddcontainer").scrollTop=0;
|
||||
startDrag=0, mouseDown=0, endDrag=0, dragEnter=0, dragOver=0, dragOut=0,
|
||||
drag=0, dragDrop=0, invalidDrop=0, mouseUp=0;
|
||||
dd1.dragOnly = false;
|
||||
}
|
||||
|
||||
var dd1, dd2, startDrag, mouseDown, endDrag, dragEnter, dragOver, dragOut,
|
||||
drag, dragDrop, invalidDrop, mouseUp;
|
||||
|
||||
function onMouseDown(e) { mouseDown++; }
|
||||
function startDrag(x, y) { startDrag++; }
|
||||
function onDrag(e) { drag++; }
|
||||
function onDragEnter(e, id) { dragEnter++; }
|
||||
function onDragOver(e, id) { dragOver++; }
|
||||
function onDragOut(e, id) { dragOut++; }
|
||||
function onDragDrop(e, id) { dragDrop++; }
|
||||
function onInvalidDrop(e) { invalidDrop++; }
|
||||
function endDrag(e) { endDrag++; }
|
||||
function onMouseUp(e) { mouseUp++; }
|
||||
|
||||
YAHOO.util.Event.on(window, "load", function (){
|
||||
//create the logger
|
||||
var logger = new YAHOO.tool.TestLogger();
|
||||
|
||||
//add the tests
|
||||
YAHOO.tool.TestRunner.add(suite);
|
||||
|
||||
//add event handler
|
||||
YAHOO.util.Event.addListener("btnRun", "click", runTests);
|
||||
|
||||
dd1 = new YAHOO.util.DD("dd1div");
|
||||
dd1.onMouseDown= onMouseDown;
|
||||
dd1.startDrag = startDrag;
|
||||
dd1.onDrag= onDrag;
|
||||
dd1.onDragEnter = onDragEnter;
|
||||
dd1.onDragOver = onDragOver;
|
||||
dd1.onDragOut = onDragOut;
|
||||
dd1.onDragDrop = onDragDrop;
|
||||
dd1.onInvalidDrop = onInvalidDrop;
|
||||
dd1.endDrag = endDrag;
|
||||
dd1.onMouseUp = onMouseUp;
|
||||
|
||||
dd2 = new YAHOO.util.DD("dd2div");
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
} else {
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
230
www/extras/yui/tests/editor.html
Normal file
230
www/extras/yui/tests/editor.html
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Editor Test Suite</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../build/reset-fonts-grids/reset-fonts-grids.css">
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../build/container/assets/skins/sam/container.css">
|
||||
<link rel="stylesheet" type="text/css" href="../build/menu/assets/skins/sam/menu.css">
|
||||
<link rel="stylesheet" type="text/css" href="../build/button/assets/skins/sam/button.css">
|
||||
<link rel="stylesheet" type="text/css" href="../build/editor/assets/skins/sam/editor.css">
|
||||
|
||||
<script type="text/javascript" src="../build/utilities/utilities.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/container/container_core-min.js"></script>
|
||||
<script type="text/javascript" src="../build/menu/menu-min.js"></script>
|
||||
<script type="text/javascript" src="../build/button/button-min.js"></script>
|
||||
<script type="text/javascript" src="../build/editor/editor-beta.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<style>
|
||||
#testRegEx, #testRegEx2 {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
var editor = null;
|
||||
(function() {
|
||||
var Dom = YAHOO.util.Dom,
|
||||
Event = YAHOO.util.Event,
|
||||
Tool = YAHOO.tool,
|
||||
Suite = new Tool.TestSuite('yuisuite'),
|
||||
Assert = YAHOO.util.Assert;
|
||||
|
||||
|
||||
|
||||
Event.onDOMReady(function() {
|
||||
editor = new YAHOO.widget.Editor('editor', {
|
||||
dompath: true,
|
||||
animate: true
|
||||
});
|
||||
editor.render();
|
||||
|
||||
var logger = new Tool.TestLogger(null, { height: '80%' });
|
||||
editor.on('editorContentLoaded', function() { //We have to wait until the Element renders before we can test it..
|
||||
Suite.add( new Tool.TestCase({
|
||||
name: 'YAHOO.widget.Editor',
|
||||
|
||||
test_render: function() {
|
||||
Assert.areEqual(Dom.get('editor_container'), editor.get('element_cont').get('element'), 'Could not find Editors container');
|
||||
Assert.areEqual(Dom.get('editor_toolbar'), editor.toolbar.get('element'), 'Could not find Editors Toolbar');
|
||||
Assert.isInstanceOf(YAHOO.widget.Toolbar, editor.toolbar, 'Could not find Toolbars Instance');
|
||||
Assert.areEqual(Dom.getStyle('editor', 'display'), editor.getStyle('display'), 'Textarea is visible..');
|
||||
Assert.isInstanceOf(YAHOO.widget.Overlay, editor.get('panel'), 'Could not find Overlay Instance');
|
||||
|
||||
},
|
||||
test_content: function() {
|
||||
var t_data = Dom.get('editor').value;
|
||||
var e_data = editor.getEditorHTML();
|
||||
Assert.areEqual(t_data, e_data, 'Editor data is different than text area');
|
||||
},
|
||||
test_window: function() {
|
||||
Assert.areEqual(document.getElementById('editor_editor').contentWindow, editor._getWindow(), 'Window object is not right');
|
||||
},
|
||||
test_doc: function() {
|
||||
Assert.areEqual(document.getElementById('editor_editor').contentWindow.document, editor._getDoc(), 'Document object is not right');
|
||||
},
|
||||
test_regex: function() {
|
||||
editor.setEditorHTML(Dom.get('testRegEx').innerHTML);
|
||||
var e_data = editor.cleanHTML();
|
||||
var real_data = editor.filter_all_rgb(Dom.get('testRegEx2').innerHTML);
|
||||
|
||||
Assert.areEqual(real_data, e_data, 'Regex save routine failed');
|
||||
},
|
||||
test_blank_image: function() {
|
||||
editor.toolbar.resetAllButtons();
|
||||
var picURL = editor.get('blankimage');
|
||||
editor._focusWindow();
|
||||
editor.toolbar.getButtonByValue('insertimage').fireEvent('mousedown', { ev: 'mousedown' });
|
||||
var pic = editor._getDoc().getElementsByTagName('img')[0];
|
||||
|
||||
Assert.areEqual(picURL, pic.getAttribute('src', 2), 'Image source and string do not match');
|
||||
Assert.isInstanceOf(YAHOO.widget.EditorWindow, editor.currentWindow, 'Editor Window Failed to Open');
|
||||
editor.closeWindow();
|
||||
Assert.areEqual(null, editor.currentWindow, 'Editor Window Failed to Close');
|
||||
editor.toolbar.resetAllButtons();
|
||||
Assert.areEqual(null, pic.parentNode, 'Image is still inside the editor');
|
||||
|
||||
},
|
||||
test_insertimage: function() {
|
||||
var picURL = 'http:/'+'/farm1.static.flickr.com/171/379031784_e4ba36a375_t_d.jpg';
|
||||
editor._focusWindow();
|
||||
editor.execCommand('insertimage', picURL);
|
||||
var pic = editor._getDoc().getElementsByTagName('img')[0];
|
||||
|
||||
Assert.areEqual(picURL, pic.getAttribute('src', 2));
|
||||
},
|
||||
test_image_props: function() {
|
||||
var pic = editor._getDoc().getElementsByTagName('img')[0];
|
||||
YAHOO.util.UserAction.dblclick(pic);
|
||||
Assert.isInstanceOf(YAHOO.widget.EditorWindow, editor.currentWindow, 'Editor Window Failed to Open');
|
||||
},
|
||||
test_close_window: function() {
|
||||
editor.closeWindow();
|
||||
Assert.areEqual(null, editor.currentWindow, 'Editor Window Failed to Close');
|
||||
editor.toolbar.resetAllButtons();
|
||||
},
|
||||
test_selected_element: function() {
|
||||
editor.setEditorHTML('<em id="test">This is a test element</em>');
|
||||
YAHOO.util.UserAction.click(editor._getDoc().getElementById('test'));
|
||||
Assert.areEqual(editor._getDoc().getElementById('test'), editor._getSelectedElement(), 'Selected Element is not em#test');
|
||||
Assert.areEqual(true, editor.toolbar.getButtonByValue('italic').hasClass('yui-button-selected'), 'Italic button is not selected');
|
||||
editor.toolbar.resetAllButtons();
|
||||
},
|
||||
test_dom_path: function() {
|
||||
editor.setEditorHTML('<p>This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.</p><p>This is a test. This is a test. <em style="font-family: Comic Sans MS">This is a test. <strong id="test">This is a test.</strong> This is a test.</em> This is a test. This is a test. This is a test.</p><p>This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.</p>');
|
||||
YAHOO.util.UserAction.click(editor._getDoc().getElementById('test'));
|
||||
Assert.areEqual('<span title="body">body</span> < <span title="p">p</span> < <span title="em">em</span> < <span title="strong#test">strong#tes...</span>', editor.dompath.innerHTML, 'Dom path is not correct..');
|
||||
Assert.areEqual(true, editor.toolbar.getButtonByValue('bold').hasClass('yui-button-selected'), 'Bold button is not selected');
|
||||
Assert.areEqual(true, editor.toolbar.getButtonByValue('italic').hasClass('yui-button-selected'), 'Italic button is not selected');
|
||||
editor.toolbar.resetAllButtons();
|
||||
},
|
||||
test_hidden_elements: function() {
|
||||
editor.toolbar.getButtonByValue('hiddenelements').fireEvent('mousedown', { ev: 'mousedown' });
|
||||
Assert.areEqual(true, Dom.hasClass(editor._getDoc().body, 'yui-hidden'), 'hidden class is not on the body');
|
||||
editor.toolbar.getButtonByValue('hiddenelements').fireEvent('mousedown', { ev: 'mousedown' });
|
||||
Assert.areEqual(false, Dom.hasClass(editor._getDoc().body, 'yui-hidden'), 'hidden class is on the body');
|
||||
},
|
||||
test_event_mouseup: function() {
|
||||
var event = false;
|
||||
editor.on('editorMouseUp', function() {
|
||||
event = true;
|
||||
});
|
||||
YAHOO.util.UserAction.mouseup(editor._getDoc().body);
|
||||
Assert.areEqual(true, event, 'MouseUP Event failed to Fired');
|
||||
},
|
||||
test_event_mousedown: function() {
|
||||
var event = false;
|
||||
editor.on('editorMouseDown', function() {
|
||||
event = true;
|
||||
});
|
||||
YAHOO.util.UserAction.mousedown(editor._getDoc().body);
|
||||
Assert.areEqual(true, event, 'MouseDown Event failed to Fired');
|
||||
},
|
||||
test_event_double_click: function() {
|
||||
var event = false;
|
||||
editor.on('editorDoubleClick', function() {
|
||||
event = true;
|
||||
});
|
||||
YAHOO.util.UserAction.dblclick(editor._getDoc().body);
|
||||
Assert.areEqual(true, event, 'DoubleClick Event failed to Fired');
|
||||
},
|
||||
test_event_keyup: function() {
|
||||
var event = false;
|
||||
editor.on('editorKeyUp', function() {
|
||||
event = true;
|
||||
});
|
||||
YAHOO.util.UserAction.keyup(editor._getDoc().body);
|
||||
Assert.areEqual(true, event, 'KeyUp Event failed to Fired');
|
||||
},
|
||||
test_event_keydown: function() {
|
||||
var event = false;
|
||||
editor.on('editorKeyDown', function() {
|
||||
event = true;
|
||||
});
|
||||
YAHOO.util.UserAction.keydown(editor._getDoc().body);
|
||||
Assert.areEqual(true, event, 'KeyDown Event failed to Fired');
|
||||
},
|
||||
test_event_keypress: function() {
|
||||
var event = false;
|
||||
editor.on('editorKeyPress', function() {
|
||||
event = true;
|
||||
});
|
||||
YAHOO.util.UserAction.keypress(editor._getDoc().body);
|
||||
Assert.areEqual(true, event, 'KeyPress Event failed to Fired');
|
||||
},
|
||||
test_createlink: function() {
|
||||
editor.toolbar.resetAllButtons();
|
||||
editor.setEditorHTML('test');
|
||||
var e_data = editor.getEditorHTML();
|
||||
Assert.areEqual('test', e_data, 'Editor data is different than what was injected');
|
||||
editor.execCommand('selectall', '');
|
||||
editor.toolbar.getButtonByValue('createlink').fireEvent('mousedown', { ev: 'mousedown' });
|
||||
|
||||
Assert.isInstanceOf(YAHOO.widget.EditorWindow, editor.currentWindow, 'Editor Window Failed to Open');
|
||||
Dom.get('createlink_url').value = 'www.yahoo.com';
|
||||
|
||||
editor.closeWindow();
|
||||
Assert.areEqual(null, editor.currentWindow, 'Editor Window Failed to Close');
|
||||
|
||||
var link = editor._getDoc().getElementsByTagName('a')[0];
|
||||
var linkURL = link.getAttribute('href', 2);
|
||||
|
||||
Assert.areEqual('http:/'+'/www.yahoo.com', linkURL, 'Link url does not match what was set');
|
||||
editor.toolbar.resetAllButtons();
|
||||
},
|
||||
test_content_after: function() {
|
||||
var t_data = Dom.get('editor').value;
|
||||
editor.setEditorHTML(t_data);
|
||||
var e_data = editor.getEditorHTML();
|
||||
Assert.areEqual(t_data, e_data, 'Editor data is different than text area');
|
||||
}
|
||||
}));
|
||||
Tool.TestRunner.add(Suite);
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
} else {
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body class="yui-skin-sam">
|
||||
<div id="doc">
|
||||
<textarea id="editor" style="height: 300px; width: 522px">This is a test.</textarea>
|
||||
|
||||
<div id="testRegEx">This is a test. <b>This</b> is a test. This is a <i>test</i>. This is a <u>test</u>. This is a test. This is a test. This is a test. <span style="font-size: 16px; font-family: Comic Sans MS;" tabindex="1" tag="span" class="yui-tag-span yui-tag">This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. </span>This is a test. This is a test. This is a test. This is a test. This is a test.<br><br>This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. <span style="font-size: 18px; font-family: Trebuchet MS; color: rgb(160, 64, 255);" tabindex="1" tag="span" class="yui-tag-span yui-tag">This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.</span> This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. </div>
|
||||
<div id="testRegEx2">This is a test. <strong>This</strong> is a test. This is a <em>test</em>. This is a <span style="text-decoration: underline;">test</span>. This is a test. This is a test. This is a test. <span style="font-size: 16px; font-family: Comic Sans MS;" tabindex="1">This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. </span>This is a test. This is a test. This is a test. This is a test. This is a test.<br><br>This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. <span style="font-size: 18px; font-family: Trebuchet MS; color: #a040ff;" tabindex="1">This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.</span> This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
104
www/extras/yui/tests/element.html
Normal file
104
www/extras/yui/tests/element.html
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Element Test Suite</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css">
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/element/element-beta-min.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
#foo {
|
||||
background:#ccc;
|
||||
height:100px;
|
||||
width:100px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var Y = YAHOO.util,
|
||||
tool = YAHOO.tool,
|
||||
suite = new tool.TestSuite("yuisuite");
|
||||
|
||||
Y.Event.onDOMReady(function() {
|
||||
var logger = new YAHOO.tool.TestLogger(null, { height: '80%' });
|
||||
|
||||
var foo = new Y.Element('foo');
|
||||
var elFoo = document.getElementById('foo');
|
||||
|
||||
suite.add( new tool.TestCase({
|
||||
name: 'YAHOO.util.Element',
|
||||
|
||||
test_getElement: function() {
|
||||
YAHOO.util.Assert.areEqual(elFoo, foo.get('element'), 'incorrect element');
|
||||
},
|
||||
|
||||
test_setHTMLAttr: function() {
|
||||
var innerHTML = 'updated';
|
||||
foo.set('innerHTML', innerHTML);
|
||||
YAHOO.util.Assert.areEqual(innerHTML, foo.get('innerHTML'), 'incorrect innerHTML');
|
||||
},
|
||||
|
||||
test_setHTMLAttr: function() {
|
||||
var innerHTML = 'updated';
|
||||
foo.set('innerHTML', innerHTML);
|
||||
YAHOO.util.Assert.areEqual(innerHTML, foo.get('innerHTML'), 'incorrect innerHTML');
|
||||
},
|
||||
|
||||
test_onChange: function() {
|
||||
var pass = false;
|
||||
var handler = function() {
|
||||
pass = true;
|
||||
};
|
||||
foo.on('titleChange', handler);
|
||||
foo.set('title', 'foo title');
|
||||
YAHOO.util.Assert.isTrue(pass, 'titleChange event failed to fire');
|
||||
},
|
||||
|
||||
test_DomEvent: function() {
|
||||
var pass = false;
|
||||
var handler = function() {
|
||||
pass = true;
|
||||
};
|
||||
foo.on('click', handler);
|
||||
YAHOO.util.UserAction.click('foo');
|
||||
YAHOO.util.Assert.isTrue(pass, 'click handler failed to be called');
|
||||
},
|
||||
|
||||
test_customEvent: function() {
|
||||
var pass = false;
|
||||
var handler = function() {
|
||||
pass = true;
|
||||
};
|
||||
foo.on('foo', handler);
|
||||
foo.fireEvent('foo');
|
||||
YAHOO.util.Assert.isTrue(pass, 'foo handler failed to be called');
|
||||
}
|
||||
}));
|
||||
tool.TestRunner.add(suite);
|
||||
|
||||
if (parent && parent != window) {
|
||||
tool.TestManager.load();
|
||||
} else {
|
||||
tool.TestRunner.run();
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body class="yui-skin-sam">
|
||||
<div id="doc">
|
||||
<div id="foo">foo</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
309
www/extras/yui/tests/imageloader.html
Normal file
309
www/extras/yui/tests/imageloader.html
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
<html>
|
||||
<head>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
|
||||
<style>
|
||||
.everything { position:relative; height:420px; }
|
||||
.everything div { border:1px solid #888; }
|
||||
.topmain { position:absolute; top:10px; left:120px; height:75px; width:100px; }
|
||||
.duo1 { position:absolute; top:130px; left:20px; height:67px; width:100px; }
|
||||
#duo1 { background-image:url('http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/uluru.jpg'); }
|
||||
.duo2 { position:absolute; top:130px; left:220px; height:53px; width:100px; }
|
||||
.src { position:absolute; top:220px; left:120px; height:72px; width:100px; }
|
||||
.trigger { position:absolute; top:330px; left:120px; height:75px; width:100px; }
|
||||
.sizer { position:absolute; top:450px; left:20px; height:150px; width:200px; }
|
||||
.sharedTrigger1 { position:absolute; top:10px; left:420px; height:72px; width:100px; }
|
||||
.sharedTrigger2 { position:absolute; top:10px; left:550px; height:67px; width:100px; }
|
||||
.fold-top { position:absolute; top:130px; left:420px; height:75px; width:100px; }
|
||||
.fold-bottom { position:absolute; top:500px; left:420px; height:75px; width:100px; }
|
||||
.customTrigger { position:absolute; top:330px; left:420px; height:67px; width:100px; }
|
||||
|
||||
.yui-imgload { background:none !important; }
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class='everything' id='everything'>
|
||||
<div class='topmain' id='topmain'></div>
|
||||
<div class='duo1 yui-imgload' id='duo1'></div>
|
||||
<div class='duo2'>
|
||||
<img class='yui-imgload' id='duo2' style='background-image:url("http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/katatjuta.jpg");' width='100' height='53' />
|
||||
</div>
|
||||
<div class='src' id='srcImgCont'>
|
||||
<img id='srcImg' />
|
||||
</div>
|
||||
<div class='trigger' id='addlTrigger'></div>
|
||||
<div class='sizer'>
|
||||
<img id='sizerImg' style='visibility:hidden;' />
|
||||
</div>
|
||||
<div class='sharedTrigger1' id='sharedTrigger1'></div>
|
||||
<div class='sharedTrigger2' id='sharedTrigger2'></div>
|
||||
<div class='fold-top'>
|
||||
<img id='foldImgTop' />
|
||||
</div>
|
||||
<div class='fold-bottom'>
|
||||
<img id='foldImgBottom' />
|
||||
</div>
|
||||
<div class='customTrigger' id='customTrigger'></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
<script type="text/javascript" src="../build/imageloader/imageloader.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
var imgUrlsTestCase = new YAHOO.tool.TestCase({
|
||||
/*
|
||||
* Test case to check the URL setting in the different types of image objects
|
||||
*/
|
||||
|
||||
name: 'Setting Urls',
|
||||
|
||||
setUp: function() {
|
||||
// background-image group
|
||||
this.bgImgUrl = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/museum.jpg';
|
||||
this.mainGroup = new YAHOO.util.ImageLoader.group('topmain', 'mouseover');
|
||||
this.mainGroup.registerBgImage('topmain', this.bgImgUrl);
|
||||
this.mainGroup.name = 'imgUrlsTestBgImg';
|
||||
this.mainGroupImage = document.getElementById('topmain');
|
||||
|
||||
// src-image group
|
||||
this.srcImgUrl = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/morraine.jpg';
|
||||
this.srcGroup = new YAHOO.util.ImageLoader.group('srcImgCont', 'click');
|
||||
this.srcGroup.registerSrcImage('srcImg', this.srcImgUrl);
|
||||
this.srcGroup.name = 'imgUrlsTestSrcImg';
|
||||
this.srcGroupImage = document.getElementById('srcImg');
|
||||
},
|
||||
|
||||
testBgImg: function() {
|
||||
YAHOO.util.UserAction.mouseover('topmain');
|
||||
// style.bgImg is "url('...')", but we can't rely on those quotes across browsers. indexOf is sufficient
|
||||
YAHOO.util.Assert.areNotEqual(this.mainGroupImage.style.backgroundImage.indexOf(this.bgImgUrl), -1);
|
||||
},
|
||||
|
||||
testSrcImg: function() {
|
||||
YAHOO.util.UserAction.click('srcImgCont');
|
||||
YAHOO.util.Assert.areEqual(this.srcGroupImage.src, this.srcImgUrl);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var classNameTestCase = new YAHOO.tool.TestCase({
|
||||
/*
|
||||
* Test case to check fetching by CSS class name
|
||||
*/
|
||||
|
||||
name: 'Class Name Fetching',
|
||||
|
||||
setUp: function() {
|
||||
this.duo1Url = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/uluru.jpg';
|
||||
this.duo2Url = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/katatjuta.jpg';
|
||||
this.duo1Image = document.getElementById('duo1');
|
||||
this.duo2Image = document.getElementById('duo2');
|
||||
// classname group
|
||||
this.classGroup = new YAHOO.util.ImageLoader.group('duo1', 'mouseover');
|
||||
this.classGroup.className = 'yui-imgload';
|
||||
this.classGroup.name = 'classNameTest';
|
||||
},
|
||||
|
||||
testClassNames: function() {
|
||||
// We have to just check for the classname. Nothing else in the element will indicate the difference between before and after url application
|
||||
YAHOO.util.Assert.areEqual(this.duo1Image.className, 'duo1 yui-imgload');
|
||||
YAHOO.util.Assert.areEqual(this.duo2Image.className, 'yui-imgload');
|
||||
YAHOO.util.UserAction.mouseover('duo1');
|
||||
YAHOO.util.Assert.areEqual(this.duo1Image.className, 'duo1');
|
||||
YAHOO.util.Assert.areEqual(this.duo2Image.className, '');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var addTriggerTestCase = new YAHOO.tool.TestCase({
|
||||
/*
|
||||
* Test case for checking the addTrigger method
|
||||
*/
|
||||
|
||||
name: 'addTrigger test',
|
||||
|
||||
setUp: function() {
|
||||
this.imageUrl = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/museum.jpg';
|
||||
this.triggerGroup = new YAHOO.util.ImageLoader.group('topmain', 'dblclick');
|
||||
this.triggerGroup.registerBgImage('addlTrigger', this.imageUrl);
|
||||
this.triggerGroup.addTrigger('addlTrigger', 'click');
|
||||
this.triggerGroup.name = 'addTriggerGroup';
|
||||
this.triggerImage = document.getElementById('addlTrigger');
|
||||
},
|
||||
|
||||
testAddTrigger: function() {
|
||||
YAHOO.util.Assert.areEqual(this.triggerImage.style.backgroundImage, '');
|
||||
YAHOO.util.UserAction.click('addlTrigger');
|
||||
YAHOO.util.Assert.areNotEqual(this.triggerImage.style.backgroundImage.indexOf(this.imageUrl), -1);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var customTriggerTestCase = new YAHOO.tool.TestCase({
|
||||
/*
|
||||
* Test case for checking adding custom event triggers to a group
|
||||
*/
|
||||
|
||||
name: 'custom trigger test',
|
||||
|
||||
setUp: function() {
|
||||
this.imageUrl = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/uluru.jpg';
|
||||
this.customEvent = new YAHOO.util.CustomEvent('imageloader_unit_test_for_custom_trigger');
|
||||
this.triggerGroup = new YAHOO.util.ImageLoader.group();
|
||||
this.triggerGroup.addCustomTrigger(this.customEvent);
|
||||
this.triggerGroup.registerBgImage('customTrigger', this.imageUrl);
|
||||
this.triggerGroup.name = 'customTriggerGroup';
|
||||
this.triggerImage = document.getElementById('customTrigger');
|
||||
},
|
||||
|
||||
testCustomTrigger: function() {
|
||||
YAHOO.util.Assert.areEqual(this.triggerImage.style.backgroundImage, '');
|
||||
this.customEvent.fire();
|
||||
YAHOO.util.Assert.areNotEqual(this.triggerImage.style.backgroundImage.indexOf(this.imageUrl), -1);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var imgSizingTestCase = new YAHOO.tool.TestCase({
|
||||
/*
|
||||
* Test case to check post-fetch resizing of image, as well as 'visibility' setting
|
||||
*/
|
||||
|
||||
name: 'Image Sizing',
|
||||
|
||||
setUp: function() {
|
||||
this.imageUrl = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/japan.jpg';
|
||||
this.sizerGroup = new YAHOO.util.ImageLoader.group('sizerImg', 'mouseover');
|
||||
this.sizerGroup.name = 'imgSizingGroup';
|
||||
var sizerILImg = this.sizerGroup.registerSrcImage('sizerImg', this.imageUrl, 200, 150);
|
||||
sizerILImg.setVisible = true;
|
||||
this.sizerImage = document.getElementById('sizerImg');
|
||||
},
|
||||
|
||||
testImageVisibility: function() {
|
||||
YAHOO.util.UserAction.mouseover('sizerImg');
|
||||
YAHOO.util.Assert.areEqual(this.sizerImage.style.visibility, 'visible');
|
||||
},
|
||||
|
||||
testImageSizing: function() {
|
||||
// not sure if we can trust order, so make sure trigger was fired
|
||||
YAHOO.util.UserAction.mouseover('sizerImg');
|
||||
YAHOO.util.Assert.areEqual(this.sizerImage.height, 150);
|
||||
YAHOO.util.Assert.areEqual(this.sizerImage.width, 200);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var triggerRemovalTestCase = new YAHOO.tool.TestCase({
|
||||
/*
|
||||
* Test case to check removing the trigger from groups that share the same trigger.
|
||||
* During development, there was an initial problem of when one group fired, the other group's trigger was removed.
|
||||
* This was due to the way the fetch() methods were passed to Event's addListener(); fixed by wrapping the fetch calls.
|
||||
* More details available in js code comments, in addTrigger() method
|
||||
*/
|
||||
|
||||
name: "Trigger Removal for Competing Groups' Triggers",
|
||||
|
||||
setUp: function() {
|
||||
this.imageAUrl = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/morraine.jpg';
|
||||
this.imageZUrl = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/uluru.jpg';
|
||||
this.groupA = new YAHOO.util.ImageLoader.group('sharedTrigger1', 'click');
|
||||
this.groupA.registerBgImage('sharedTrigger1', this.imageAUrl);
|
||||
this.groupA.name = 'triggerRemovalGroup(A)';
|
||||
this.groupZ = new YAHOO.util.ImageLoader.group('sharedTrigger1', 'click');
|
||||
this.groupZ.registerBgImage('sharedTrigger2', this.imageZUrl);
|
||||
this.groupZ.addTrigger('sharedTrigger2', 'click');
|
||||
this.groupZ.name = 'triggerRemovalGroup(Z)';
|
||||
this.groupAImage = document.getElementById('sharedTrigger1');
|
||||
this.groupZImage = document.getElementById('sharedTrigger2');
|
||||
},
|
||||
|
||||
testCompetingTriggers: function() {
|
||||
YAHOO.util.UserAction.click('sharedTrigger2');
|
||||
YAHOO.util.Assert.areNotEqual(this.groupZImage.style.backgroundImage.indexOf(this.imageZUrl), -1);
|
||||
YAHOO.util.Assert.areEqual(this.groupAImage.style.backgroundImage, '');
|
||||
YAHOO.util.UserAction.click('sharedTrigger1');
|
||||
YAHOO.util.Assert.areNotEqual(this.groupAImage.style.backgroundImage.indexOf(this.imageAUrl), -1);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var foldConditionalTestCase = new YAHOO.tool.TestCase({
|
||||
/*
|
||||
* Test case to check fold-conditional loading of a group
|
||||
* We're faking the viewport size and fold determination so that everything will be dependable in any situation (including automated runs)
|
||||
*/
|
||||
|
||||
name: "Fold Conditional Loading",
|
||||
|
||||
setUp: function() {
|
||||
this.imageTopUrl = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/japan.jpg';
|
||||
this.imageBotUrl = 'http://developer.yahoo.com/yui/docs/assets/examples/exampleimages/small/japan.jpg';
|
||||
this.foldGroup = new YAHOO.util.ImageLoader.group();
|
||||
this.foldGroup.registerSrcImage('foldImgTop', this.imageTopUrl);
|
||||
this.foldGroup.registerSrcImage('foldImgBottom', this.imageBotUrl);
|
||||
this.foldGroup.foldConditional = true;
|
||||
this.foldGroup.name = 'foldConditionalGroup';
|
||||
this.groupTopImage = document.getElementById('foldImgTop');
|
||||
this.groupBotImage = document.getElementById('foldImgBottom');
|
||||
|
||||
// override the foldCheck function of this group, because we'll need to fake things to make them dependable
|
||||
this.foldGroup._foldCheck = function() {
|
||||
var hLimit = 300;
|
||||
var wLimit = 1000;
|
||||
for (var id in this._imgObjs) {
|
||||
if (YAHOO.lang.hasOwnProperty(this._imgObjs, id)) {
|
||||
var elPos = YAHOO.util.Dom.getXY(this._imgObjs[id].domId);
|
||||
if (elPos[1] < hLimit && elPos[0] < wLimit) {
|
||||
this._imgObjs[id].fetch();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
testFoldCheck: function() {
|
||||
this.foldGroup._foldCheck();
|
||||
YAHOO.util.Assert.areEqual(this.groupTopImage.src, this.imageTopUrl);
|
||||
YAHOO.util.Assert.areEqual(this.groupBotImage.src, '');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var imageLoaderTestSuite = new YAHOO.tool.TestSuite('YUI ImageLoader Utility');
|
||||
imageLoaderTestSuite.add(imgUrlsTestCase);
|
||||
imageLoaderTestSuite.add(classNameTestCase);
|
||||
imageLoaderTestSuite.add(addTriggerTestCase);
|
||||
imageLoaderTestSuite.add(customTriggerTestCase);
|
||||
imageLoaderTestSuite.add(imgSizingTestCase);
|
||||
imageLoaderTestSuite.add(triggerRemovalTestCase);
|
||||
imageLoaderTestSuite.add(foldConditionalTestCase);
|
||||
|
||||
YAHOO.tool.TestRunner.add(imageLoaderTestSuite);
|
||||
|
||||
YAHOO.util.Event.onDOMReady(function() {
|
||||
var logger = new YAHOO.tool.TestLogger();
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
} else {
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
135
www/extras/yui/tests/logger.html
Normal file
135
www/extras/yui/tests/logger.html
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>YUI Logger Tests</title>
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo-min.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom-min.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event-min.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Logger Tests</h1>
|
||||
<p><input type="button" value="Run Tests" id="btnRun" disabled="true" /></p>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
|
||||
var Dom=YAHOO.util.Dom,
|
||||
Assert=YAHOO.util.Assert,
|
||||
ObjectAssert=YAHOO.util.ObjectAssert,
|
||||
ArrayAssert=YAHOO.util.ArrayAssert,
|
||||
DateAssert=YAHOO.util.DateAssert,
|
||||
UserAction=YAHOO.util.UserAction,
|
||||
TestCase = YAHOO.tool.TestCase,
|
||||
TestLogger = YAHOO.tool.TestLogger,
|
||||
TestRunner = YAHOO.tool.TestRunner,
|
||||
TestSuite = YAHOO.tool.TestSuite,
|
||||
|
||||
Logger = YAHOO.widget.Logger,
|
||||
LogReader = YAHOO.widget.LogReader,
|
||||
LogWriter = YAHOO.widget.LogWriter;
|
||||
|
||||
function LoggerTestCase(template) {
|
||||
LoggerTestCase.superclass.constructor.call(this, template);
|
||||
};
|
||||
YAHOO.lang.extend(LoggerTestCase, TestCase);
|
||||
|
||||
var loggerTemplate = {
|
||||
name: "Logger Tests",
|
||||
|
||||
testCreateNewCategory: function() {
|
||||
Logger._createNewCategory("testcategory");
|
||||
Assert.areSame(Logger.categories[Logger.categories.length-1], "testcategory", "Could not find new category");
|
||||
}
|
||||
};
|
||||
var loggerTest = new LoggerTestCase(loggerTemplate);
|
||||
|
||||
function LogReaderTestCase(template) {
|
||||
LogReaderTestCase.superclass.constructor.call(this, template);
|
||||
this.container = null;
|
||||
};
|
||||
YAHOO.lang.extend(LogReaderTestCase, TestCase);
|
||||
|
||||
LogReaderTestCase.prototype.setUp = function() {
|
||||
this.container = document.createElement("div");
|
||||
this.container.id = "testLogReaderContainer";
|
||||
document.body.appendChild(this.container);
|
||||
};
|
||||
|
||||
LogReaderTestCase.prototype.tearDown = function() {
|
||||
if (this.container != null) {
|
||||
YAHOO.util.Event.purgeElement(this.container, true);
|
||||
document.body.removeChild(this.container);
|
||||
}
|
||||
};
|
||||
|
||||
LogReaderTestCase.prototype.createInstance = function(oConfig) {
|
||||
var lr = new LogReader(this.container, oConfig);
|
||||
return lr;
|
||||
};
|
||||
|
||||
var logreaderTemplate = {
|
||||
name: "LogReader Tests",
|
||||
testConstruction: function() {
|
||||
var lr = this.createInstance();
|
||||
Assert.isObject(lr, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(LogReader, lr, "Failed to create basic instance");
|
||||
lr = null;
|
||||
}
|
||||
};
|
||||
var logreaderTest = new LogReaderTestCase(logreaderTemplate);
|
||||
|
||||
function LogWriterTestCase(template) {
|
||||
LogWriterTestCase.superclass.constructor.call(this, template);
|
||||
};
|
||||
YAHOO.lang.extend(LogWriterTestCase, TestCase);
|
||||
|
||||
LogWriterTestCase.prototype.setUp = function() {
|
||||
};
|
||||
|
||||
LogWriterTestCase.prototype.tearDown = function() {
|
||||
};
|
||||
|
||||
LogWriterTestCase.prototype.createInstance = function(oConfig) {
|
||||
var lw = new LogWriter("testlogwriter", oConfig);
|
||||
return lw;
|
||||
};
|
||||
|
||||
var logwriterTemplate = {
|
||||
name: "LogWriter Tests",
|
||||
|
||||
testConstruction: function() {
|
||||
var lw = this.createInstance();
|
||||
Assert.isObject(lw, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(LogWriter, lw, "Failed to create basic instance");
|
||||
lr = null;
|
||||
}
|
||||
};
|
||||
var logwriterTest = new LogWriterTestCase(logwriterTemplate);
|
||||
|
||||
YAHOO.util.Event.addListener(window, "load", function() {
|
||||
var logger = new TestLogger();
|
||||
|
||||
var loggersuite = new TestSuite("Logger Test Suite");
|
||||
loggersuite.add(loggerTest);
|
||||
loggersuite.add(logreaderTest);
|
||||
loggersuite.add(logwriterTest);
|
||||
|
||||
TestRunner.add(loggersuite);
|
||||
|
||||
YAHOO.util.Event.addListener("btnRun", "click", function(){TestRunner.run();});
|
||||
YAHOO.util.Dom.get("btnRun").disabled = false;
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1753
www/extras/yui/tests/menu.html
Normal file
1753
www/extras/yui/tests/menu.html
Normal file
File diff suppressed because it is too large
Load diff
443
www/extras/yui/tests/module.html
Normal file
443
www/extras/yui/tests/module.html
Normal file
|
|
@ -0,0 +1,443 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>YAHOO.widget.Module Tests</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/calendar/assets/skins/sam/calendar.css" />
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo-min.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom-min.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event-min.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../build/container/container-min.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
YAHOO.util.Assert.isDOMElement = function (actual, message) {
|
||||
|
||||
if (!(YAHOO.lang.isObject(actual) && YAHOO.lang.isString(actual.nodeName) && actual.nodeType === 1)) {
|
||||
|
||||
YAHOO.util.Assert.fail(message || "Not a DOM element.");
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
|
||||
var oLogger = new YAHOO.tool.TestLogger();
|
||||
|
||||
var oModule;
|
||||
|
||||
var Assert = YAHOO.util.Assert,
|
||||
Module = YAHOO.widget.Module;
|
||||
|
||||
var oTestCase = new YAHOO.tool.TestCase({
|
||||
|
||||
name: "Sample Test Case",
|
||||
|
||||
testConstructor: function () {
|
||||
|
||||
// Create a Module from existing markup
|
||||
|
||||
oModule = new Module("module1");
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
|
||||
|
||||
oModule = new Module(document.getElementById("module1"));
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
|
||||
|
||||
var oDIV = document.createElement("div");
|
||||
|
||||
oModule = new Module(oDIV);
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
oDIV = null;
|
||||
|
||||
oDIV = document.createElement("div");
|
||||
oDIV.id = "module2";
|
||||
|
||||
oModule = new Module(oDIV);
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
oDIV = null;
|
||||
|
||||
oDIV = document.createElement("div");
|
||||
oDIV.id = "module2";
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
oDIV = null;
|
||||
|
||||
|
||||
// Create a Module without existing markup
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
},
|
||||
|
||||
testProperties: function () {
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
Assert.areEqual(Module, oModule.constructor, "The Module's constructor is not YAHOO.widget.Module.");
|
||||
|
||||
Assert.isString(oModule.id, "The Module does not have an id.");
|
||||
|
||||
Assert.areEqual("module2", oModule.id, "The Module does not have an id.");
|
||||
|
||||
Assert.isString(oModule.platform, "The Module's \"platform\" property is not set.");
|
||||
|
||||
Assert.isString(oModule.browser, "The Module's \"browser\" property is not set.");
|
||||
|
||||
Assert.isBoolean(oModule.isSecure, "The Module's \"isSecure\" property is not set.");
|
||||
|
||||
oModule = null;
|
||||
|
||||
},
|
||||
|
||||
testConfigurationProperties: function () {
|
||||
|
||||
// Visible
|
||||
|
||||
oModule = new Module("module2", { visible: true });
|
||||
|
||||
oModule.setBody("This is the body");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isTrue(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("block", oModule.element.style.display, "The Module is not visible when it should be.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
oModule.setBody("This is the body");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isTrue(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("block", oModule.element.style.display, "The Module is not visible when it should be.");
|
||||
|
||||
oModule.cfg.setProperty("visible", false);
|
||||
|
||||
Assert.isFalse(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("none", oModule.element.style.display, "The Module is not hidden when it should be.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2", { visible: false });
|
||||
oModule.setBody("This is the body");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isFalse(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("none", oModule.element.style.display, "The Module is not hidden when it should be.");
|
||||
|
||||
oModule.cfg.setProperty("visible", true);
|
||||
|
||||
Assert.isTrue(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("block", oModule.element.style.display, "The Module is not visible when it should be.");
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
testMethods: function () {
|
||||
|
||||
// Header methods
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oModule.setHeader("This is the header.");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.header, "The Module's header element not created.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
var oEM = document.createElement("em");
|
||||
oEM.innerHTML = "This is the header.";
|
||||
|
||||
oModule.setHeader(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.header, "The Module's header element not created.");
|
||||
Assert.areEqual(oEM, oModule.header.firstChild, "The Module's header element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the header.";
|
||||
|
||||
oModule.appendToHeader(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.header, "The Module's header element not created.");
|
||||
Assert.areEqual(oEM, oModule.header.firstChild, "The Module's header element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
// Body methods
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oModule.setBody("This is the body.");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.body, "The Module's body element not created.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("em");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.setBody(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.body, "The Module's body element not created.");
|
||||
Assert.areEqual(oEM, oModule.body.firstChild, "The Module's body element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.appendToBody(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.body, "The Module's header element not created.");
|
||||
Assert.areEqual(oEM, oModule.body.firstChild, "The Module's header element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
// Footer methods
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oModule.setFooter("This is the footer.");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.footer, "The Module's footer element not created.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("em");
|
||||
oEM.innerHTML = "This is the footer.";
|
||||
|
||||
oModule.setFooter(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.footer, "The Module's footer element not created.");
|
||||
Assert.areEqual(oEM, oModule.footer.firstChild, "The Module's footer element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the footer.";
|
||||
|
||||
oModule.appendToFooter(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.footer, "The Module's header element not created.");
|
||||
Assert.areEqual(oEM, oModule.footer.firstChild, "The Module's header element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
// Render
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.setBody(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.areEqual(document.body, oModule.element.parentNode, "The Module was not rendered into the body of the document.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.setBody(oEM);
|
||||
|
||||
var oRenderTarget = document.createElement("div");
|
||||
oRenderTarget.id = "rendertarget";
|
||||
|
||||
document.body.appendChild(oRenderTarget);
|
||||
|
||||
oModule.render("rendertarget");
|
||||
|
||||
Assert.areEqual(oRenderTarget, oModule.element.parentNode, "The Module was not rendered into the specified target element.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.setBody(oEM);
|
||||
|
||||
var oModuleContainer = document.createElement("div");
|
||||
oModuleContainer.id = "modulecontainer";
|
||||
|
||||
oModule.render("rendertarget", oModuleContainer);
|
||||
|
||||
Assert.areEqual(oRenderTarget, oModule.element.parentNode, "The Module was not rendered into the specified target element.");
|
||||
Assert.areEqual(oModuleContainer, oModule.body.parentNode, "The Module's container is not the element that was specified.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
// Show
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oModule.setBody("This is the body");
|
||||
|
||||
oModule.render(document.body);
|
||||
|
||||
oModule.show();
|
||||
|
||||
Assert.areEqual("block", oModule.element.style.display, "The Module is not visible after calling the \"show\" method.");
|
||||
|
||||
|
||||
// Hide
|
||||
|
||||
oModule.hide();
|
||||
|
||||
Assert.areEqual("none", oModule.element.style.display, "The Module is not hidden after calling the \"hide\" method.");
|
||||
|
||||
|
||||
// toString
|
||||
|
||||
Assert.areEqual(("Module " + oModule.id), oModule.toString(), "The Module \"toString\" method is not returning the correct value.");
|
||||
|
||||
|
||||
// destroy
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
Assert.areEqual(null, document.getElementById("module2"), "The Module was not successfully destroyed.");
|
||||
|
||||
|
||||
},
|
||||
|
||||
testEvents: function () {
|
||||
|
||||
var CustomEvent = YAHOO.util.CustomEvent;
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
Assert.isInstanceOf(CustomEvent, oModule.beforeInitEvent, "Module event \"beforeInitEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.initEvent, "Module event \"initEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.appendEvent, "Module event \"appendEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.beforeRenderEvent, "Module event \"beforeRenderEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.renderEvent, "Module event \"renderEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.changeHeaderEvent, "Module event \"changeHeaderEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.changeBodyEvent, "Module event \"changeBodyEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.changeFooterEvent, "Module event \"changeFooterEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.changeContentEvent, "Module event \"changeContentEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.destroyEvent, "Module event \"destroyEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.beforeShowEvent, "Module event \"beforeShowEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.showEvent, "Module event \"showEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.beforeHideEvent, "Module event \"beforeHideEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.hideEvent, "Module event \"hideEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, YAHOO.widget.Module.textResizeEvent, "YAHOO.widget.Module.textResizeEvent is not an instance of YAHOO.util.CustomEvent.");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
YAHOO.tool.TestRunner.add(oTestCase);
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
} else {
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="module1">
|
||||
<div class="bd">The body of the module1</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
425
www/extras/yui/tests/profiler.html
Normal file
425
www/extras/yui/tests/profiler.html
Normal file
|
|
@ -0,0 +1,425 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>profiler tests</title>
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/profiler/profiler-beta.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>profile tests</h1>
|
||||
<p><input type="button" value="Run Tests" id="btnRun" /></p>
|
||||
<script type="text/javascript">
|
||||
|
||||
YAHOO.namespace("test");
|
||||
|
||||
//global function
|
||||
function getMessage(){
|
||||
return "hi";
|
||||
}
|
||||
|
||||
//global object
|
||||
var myObject = {
|
||||
getName : function(){
|
||||
return "myObject";
|
||||
}
|
||||
};
|
||||
|
||||
YAHOO.test.profiler_test = (function(){
|
||||
|
||||
var Assert = YAHOO.util.Assert;
|
||||
var Profiler = YAHOO.tool.Profiler;
|
||||
var YUE /*:Object*/ = YAHOO.util.Event;
|
||||
var YUD /*:Object*/ = YAHOO.util.Dom;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Information needed to run tests
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
var testObject = {
|
||||
|
||||
factorial : function (num){
|
||||
if (num > 1) {
|
||||
return num * testObject.factorial(num-1);
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
|
||||
add : function (iterations){
|
||||
var sum = 0;
|
||||
for (var i=0; i < iterations; i++){
|
||||
sum++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var root = {};
|
||||
root.SuperType = function(){
|
||||
this.name = "SuperType";
|
||||
}
|
||||
|
||||
root.SuperType.prototype.getName = function(){
|
||||
return this.name;
|
||||
};
|
||||
|
||||
root.SubType = function(){
|
||||
this.age = 29;
|
||||
root.SubType.superclass.constructor.call(this);
|
||||
}
|
||||
|
||||
YAHOO.extend(root.SubType, root.SuperType, {
|
||||
getAge : function (){
|
||||
return this.age;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Base Test Suite
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
var suite = new YAHOO.tool.TestSuite("Profiler Tests");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Test Case for basic function profiling
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
suite.add(new YAHOO.tool.TestCase({
|
||||
|
||||
name : "Profiler Registration Tests",
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Special assertions for profiler
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
assertFunctionIsRegistered : function (fullFuncName, shortFuncName, owner, originalFunction, newFunction){
|
||||
var containerFunc = Profiler._container[fullFuncName];
|
||||
Assert.areNotEqual(originalFunction, newFunction, fullFuncName + " function was not replaced.");
|
||||
Assert.areEqual(originalFunction, containerFunc, "Original " + fullFuncName + " function was not stored.");
|
||||
Assert.areEqual(originalFunction.prototype, containerFunc.prototype, fullFuncName + " prototype was not copied.");
|
||||
Assert.areEqual(shortFuncName, containerFunc.__yuiFuncName, fullFuncName + " function name was not stored.");
|
||||
Assert.areEqual(owner, containerFunc.__yuiOwner, "Owner for " + fullFuncName + "was not stored.");
|
||||
Assert.isObject(Profiler._report[fullFuncName], "Report for " + fullFuncName + " function was not created.");
|
||||
|
||||
},
|
||||
|
||||
assertFunctionIsNotRegistered : function(fullFuncName, shortFuncName, owner, originalFunction, newFunction){
|
||||
Assert.areEqual(originalFunction, newFunction, "Original " + fullFuncName + " function was not placed back on owner.");
|
||||
Assert.isUndefined(Profiler._report[fullFuncName], "Report for " + fullFuncName + " function was not destroyed.");
|
||||
Assert.isUndefined(Profiler._container[fullFuncName], "Container for original " + fullFuncName + " function was not destroyed.");
|
||||
},
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Tests
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
testRegisterFunction : function (){
|
||||
|
||||
var originalFunction = testObject.factorial;
|
||||
var fullFuncName = "testObject.factorial";
|
||||
|
||||
Profiler.registerFunction(fullFuncName, testObject);
|
||||
|
||||
this.assertFunctionIsRegistered(fullFuncName, "factorial", testObject, originalFunction, testObject.factorial);
|
||||
|
||||
Profiler.unregisterFunction(fullFuncName);
|
||||
|
||||
this.assertFunctionIsNotRegistered(fullFuncName, "factorial", testObject, originalFunction, testObject.factorial);
|
||||
|
||||
},
|
||||
|
||||
testRegisterGlobalFunction : function (){
|
||||
|
||||
var originalFunction = getMessage;
|
||||
var fullFuncName = "getMessage";
|
||||
|
||||
Profiler.registerFunction(fullFuncName, window);
|
||||
|
||||
this.assertFunctionIsRegistered(fullFuncName, "getMessage", window, originalFunction, getMessage);
|
||||
|
||||
Profiler.unregisterFunction(fullFuncName);
|
||||
|
||||
this.assertFunctionIsNotRegistered(fullFuncName, "getMessage", window, originalFunction, getMessage);
|
||||
|
||||
},
|
||||
|
||||
testRegisterGlobalFunctionOnGlobalObject : function (){
|
||||
|
||||
var originalFunction = myObject.getName;
|
||||
var fullFuncName = "myObject.getName";
|
||||
|
||||
Profiler.registerFunction(fullFuncName);
|
||||
|
||||
this.assertFunctionIsRegistered(fullFuncName, "getName", myObject, originalFunction, myObject.getName);
|
||||
|
||||
Profiler.unregisterFunction(fullFuncName);
|
||||
|
||||
this.assertFunctionIsNotRegistered(fullFuncName, "getName", myObject, originalFunction, myObject.getName);
|
||||
|
||||
},
|
||||
|
||||
testRegisterObject : function (){
|
||||
|
||||
var funcNames = [];
|
||||
var originalFuncs = {};
|
||||
|
||||
//get all methods
|
||||
for (var propName in testObject){
|
||||
if (typeof propName == "function"){
|
||||
funcNames.push(propName);
|
||||
originalFuncs[propName] = testObject[propName];
|
||||
}
|
||||
}
|
||||
|
||||
Profiler.registerObject("testObject", testObject);
|
||||
|
||||
Assert.isObject(Profiler._container["testObject"], "Object was not added to container.");
|
||||
|
||||
//check each method
|
||||
for (var i=0; i < funcNames.length; i++){
|
||||
var fullFuncName = "testobject." + funcNames[i];
|
||||
var originalFunction = originalFuncs[funcNames[i]];
|
||||
this.assertFunctionIsRegistered(fullFuncName, funcNames[i], testObject, originalFunction, testObject[funcNames[i]]);
|
||||
}
|
||||
|
||||
Profiler.unregisterObject("testObject");
|
||||
|
||||
//check each method
|
||||
for (var i=0; i < funcNames.length; i++){
|
||||
var fullFuncName = "testobject." + funcNames[i];
|
||||
var originalFunction = originalFuncs[funcNames[i]];
|
||||
this.assertFunctionIsNotRegistered(fullFuncName, funcNames[i], testObject, originalFunction, testObject[funcNames[i]]);
|
||||
}
|
||||
|
||||
Assert.isUndefined(Profiler._container["testObject"], "Object was not removed from container.");
|
||||
|
||||
},
|
||||
|
||||
testRegisterConstructor : function (){
|
||||
|
||||
var originalConstructor = root.SuperType;
|
||||
|
||||
//gather stuff on the prototype
|
||||
var funcNames = [];
|
||||
var originalFuncs = {};
|
||||
|
||||
for (var prop in root.SuperType.prototype){
|
||||
if (YAHOO.lang.isFunction(root.SuperType.prototype)){
|
||||
funcNames.push(prop);
|
||||
originalFuncs[prop] = root.SuperType.prototype[prop];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Profiler.registerConstructor("root.SuperType", root);
|
||||
this.assertFunctionIsRegistered("root.SuperType", "SuperType", root, originalConstructor, root.SuperType);
|
||||
|
||||
//check each method
|
||||
for (var i=0; i < funcNames.length; i++){
|
||||
var fullFuncName = "root.SuperType.prototype." + funcNames[i];
|
||||
var originalFunction = originalFuncs[funcNames[i]];
|
||||
this.assertFunctionIsRegistered(fullFuncName, funcNames[i], root.SuperType.prototype, originalFunction, root.SuperType.prototype[funcNames[i]]);
|
||||
}
|
||||
|
||||
Profiler.unregisterConstructor("root.SuperType");
|
||||
|
||||
//check each method
|
||||
for (var i=0; i < funcNames.length; i++){
|
||||
var fullFuncName = "root.SuperType.prototype." + funcNames[i];
|
||||
var originalFunction = originalFuncs[funcNames[i]];
|
||||
this.assertFunctionIsNotRegistered(fullFuncName, funcNames[i], root.SuperType.prototype, originalFunction, root.SuperType.prototype[funcNames[i]]);
|
||||
}
|
||||
|
||||
this.assertFunctionIsNotRegistered("root.SuperType", "SuperType", root, originalConstructor, root.SuperType);
|
||||
},
|
||||
|
||||
testRegisterConstructorWithInheritance : function (){
|
||||
|
||||
var originalConstructor = root.SubType;
|
||||
|
||||
//gather stuff on the prototype
|
||||
var funcNames = [];
|
||||
var originalFuncs = {};
|
||||
|
||||
for (var prop in root.SubType.prototype){
|
||||
if (YAHOO.lang.isFunction(root.SubType.prototype)){
|
||||
funcNames.push(prop);
|
||||
originalFuncs[prop] = root.SubType.prototype[prop];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Profiler.registerConstructor("root.SubType", root);
|
||||
this.assertFunctionIsRegistered("root.SubType", "SubType", root, originalConstructor, root.SubType);
|
||||
|
||||
//check the superclass property
|
||||
Assert.isObject(root.SubType.superclass, "SubType superclass should be an object.");
|
||||
Assert.areEqual(root.SuperType, root.SubType.superclass.constructor, "SubType superclass constructor should be SuperType.");
|
||||
|
||||
//check each method
|
||||
for (var i=0; i < funcNames.length; i++){
|
||||
var fullFuncName = "root.SubType.prototype." + funcNames[i];
|
||||
var originalFunction = originalFuncs[funcNames[i]];
|
||||
this.assertFunctionIsRegistered(fullFuncName, funcNames[i], root.SubType.prototype, originalFunction, root.SubType.prototype[funcNames[i]]);
|
||||
}
|
||||
|
||||
Profiler.unregisterConstructor("root.SubType");
|
||||
|
||||
//check each method
|
||||
for (var i=0; i < funcNames.length; i++){
|
||||
var fullFuncName = "root.SubType.prototype." + funcNames[i];
|
||||
var originalFunction = originalFuncs[funcNames[i]];
|
||||
this.assertFunctionIsNotRegistered(fullFuncName, funcNames[i], root.SubType.prototype, originalFunction, root.SubType.prototype[funcNames[i]]);
|
||||
}
|
||||
|
||||
this.assertFunctionIsNotRegistered("root.SubType", "SubType", root, originalConstructor, root.SubType);
|
||||
},
|
||||
|
||||
testFunctionAccuracy1 : function (){
|
||||
|
||||
Profiler.registerFunction("testObject.factorial", testObject);
|
||||
|
||||
var result = testObject.factorial(10);
|
||||
|
||||
Profiler.unregisterFunction("testObject.factorial");
|
||||
|
||||
Assert.areEqual(3628800, result, "Factorial result was incorrect.");
|
||||
|
||||
|
||||
},
|
||||
|
||||
testFunctionAccuracy2 : function (){
|
||||
|
||||
Profiler.registerConstructor("root.SubType", root);
|
||||
|
||||
var o = new root.SubType();
|
||||
var age = o.getAge();
|
||||
var name = o.getName();
|
||||
|
||||
Assert.areEqual(29, age, "o.age was incorrect.");
|
||||
Assert.areEqual("SuperType", name, "o.name was incorrect");
|
||||
|
||||
var o2 = new root.SubType();
|
||||
age = o2.getAge();
|
||||
name = o2.getName();
|
||||
|
||||
Assert.areEqual(29, age, "o2.Age was incorrect.");
|
||||
Assert.areEqual("SuperType", name, "o2.Name was incorrect");
|
||||
|
||||
Profiler.unregisterConstructor("root.SubType");
|
||||
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Test Case for report data
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
suite.add(new YAHOO.tool.TestCase({
|
||||
|
||||
name : "Profiler Report Data Tests",
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Special assertions for profiler
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
testGetFunctionReport : function (){
|
||||
|
||||
Profiler.registerFunction("testObject.factorial", testObject);
|
||||
|
||||
testObject.factorial(10);
|
||||
|
||||
var report = Profiler.getFunctionReport("testObject.factorial");
|
||||
Profiler.unregisterFunction("testObject.factorial");
|
||||
|
||||
Assert.isObject(report, "Report should be an object.");
|
||||
Assert.isNumber(report.calls, "Call count should be a number.");
|
||||
Assert.isNumber(report.max, "Max should be a number.");
|
||||
Assert.isNumber(report.min, "Min should be a number.");
|
||||
Assert.isNumber(report.avg, "Average should be a number.");
|
||||
},
|
||||
|
||||
testGetCallCount : function (){
|
||||
|
||||
Profiler.registerFunction("testObject.factorial", testObject);
|
||||
|
||||
testObject.factorial(10);
|
||||
|
||||
var report = Profiler.getFunctionReport("testObject.factorial");
|
||||
var callCount = Profiler.getCallCount("testObject.factorial");
|
||||
Profiler.unregisterFunction("testObject.factorial");
|
||||
|
||||
Assert.isObject(report, "Report should be an object.");
|
||||
Assert.areEqual(10, report.calls, "Report.calls is incorrect.");
|
||||
Assert.areEqual(10, callCount, "Call count is incorrect.");
|
||||
|
||||
},
|
||||
|
||||
testGetReport : function () {
|
||||
|
||||
Profiler.registerConstructor("root.SubType", root);
|
||||
|
||||
var o = new root.SubType();
|
||||
o.getAge();
|
||||
o.getName();
|
||||
|
||||
var o2 = new root.SubType();
|
||||
o2.getAge();
|
||||
o2.getName();
|
||||
o2.getAge();
|
||||
o2.getName();
|
||||
o2.getName();
|
||||
|
||||
var report = Profiler.getFullReport();
|
||||
|
||||
Profiler.unregisterConstructor("root.SubType");
|
||||
|
||||
Assert.isObject(report, "Report should be an object.");
|
||||
Assert.isObject(report["root.SubType"], "There should be an entry for root.SubType.");
|
||||
Assert.areEqual(2, report["root.SubType"].calls, "root.SubType should have a call count of 2.");
|
||||
//Assert.isObject(report["root.SubType.prototype"], "There should be an entry for root.SubType.prototype.");
|
||||
Assert.isObject(report["root.SubType.prototype.getAge"], "There should be an entry for getAge()");
|
||||
Assert.areEqual(3, report["root.SubType.prototype.getAge"].calls, "getAge() should have a call count of 3.");
|
||||
Assert.isObject(report["root.SubType.prototype.getName"], "There should be an entry for getName()");
|
||||
Assert.areEqual(4, report["root.SubType.prototype.getName"].calls, "getName() should have a call count of 4.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}));
|
||||
|
||||
//return it
|
||||
return suite;
|
||||
|
||||
})();
|
||||
|
||||
(function (){
|
||||
//create the logger
|
||||
var logger = new YAHOO.tool.TestLogger();
|
||||
|
||||
//add the tests
|
||||
YAHOO.tool.TestRunner.add(YAHOO.test.profiler_test);
|
||||
|
||||
//add event handler
|
||||
YAHOO.util.Event.addListener("btnRun", "click", YAHOO.tool.TestRunner.run);
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
} else {
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
259
www/extras/yui/tests/selector.html
Normal file
259
www/extras/yui/tests/selector.html
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Selector Test Suite</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../build/logger/assets/logger.css">
|
||||
<link rel="stylesheet" type="text/css" href="../build/yuitest/assets/testlogger.css">
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/selector/selector-beta.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<script>
|
||||
onload = function() {
|
||||
var Y = YAHOO.util;
|
||||
var logger = new YAHOO.tool.TestLogger(null, {height:'2000px'});
|
||||
var suite = new YAHOO.tool.TestSuite("Selector Suite");
|
||||
var Selector = Y.Selector;
|
||||
|
||||
var $ = Selector.query;
|
||||
var demo = Y.Dom.get('demo');
|
||||
children = Y.Dom.getChildren(demo);
|
||||
var demoFirstChild = children[0];
|
||||
var demoLastChild = children[children.length - 1];
|
||||
|
||||
var selectorQueryAll = new YAHOO.tool.TestCase({
|
||||
name: 'Query All',
|
||||
|
||||
testTest: function() {
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('test-lang-en-us'), '[lang|=en]'), '[lang|=en] (lang="en-us")');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('test-lang-en'), '[lang|=en]'), '[lang|=en] (lang="en")');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('test-lang-none'), '[lang|=en]'), '[lang|=en] false pos');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('checkbox-unchecked'), 'for [type=checkbox]'), 'for [type=checkbox] false pos');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('checkbox-unchecked'), 'form [type=checkbox]'), 'form [type=checkbox]');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('checkbox-unchecked'), 'for [type=checkbox]'), 'for [type=checkbox] false pos');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('checkbox-unchecked'), '[type=checkbox], button'), '[type=checkbox], button');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('checkbox-unchecked'), 'button, [type=checkbox]'), 'button, [type=checkbox]');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('checkbox-unchecked'), 'foo, button'), 'foo, button');
|
||||
//Y.Assert.isTrue(Selector.test(Y.Dom.get('checkbox-checked'), '[type=checkbox]:checked'), 'type=checkbox:checked');
|
||||
//Y.Assert.isTrue(Selector.test(Y.Dom.get('radio-checked'), ':checked'), ':checked (radio)');
|
||||
//Y.Assert.isFalse(Selector.test(Y.Dom.get('radio-unchecked'), ':checked'), ':checked (radio) false pos');
|
||||
//Y.Assert.isFalse(Selector.test(Y.Dom.get('checkbox-unchecked'), '[type=checkbox]:checked'), 'type=checkbox:checked false pos');
|
||||
//Y.Assert.isTrue(Selector.test(Y.Dom.get('checkbox-unchecked'), '[type=checkbox]:not(:checked)'), 'type=checkbox:not(:checked)');
|
||||
},
|
||||
|
||||
testRootQuery: function() {
|
||||
var all = Y.Dom.get('nth-test').getElementsByTagName('li');
|
||||
Y.ArrayAssert.itemsAreEqual(all, $('li', 'nth-test'), 'id as root');
|
||||
Y.ArrayAssert.itemsAreEqual([], $('li', 'nth-tes'), 'id as root false pos');
|
||||
Y.ArrayAssert.itemsAreEqual(all, $('li', Y.Dom.get('nth-test')), 'node as root');
|
||||
Y.ArrayAssert.itemsAreEqual(all, $('#nth-test li', Y.Dom.get('root-test')), 'id selector w/root');
|
||||
Y.ArrayAssert.itemsAreEqual([], $('#root-test li', Y.Dom.get('nth-test')), 'id selector w/root false pos');
|
||||
},
|
||||
testNthLastChild: function() {
|
||||
var all = Y.Dom.get('nth-test').getElementsByTagName('li');
|
||||
var odd = Y.Dom.getElementsByClassName('even', 'li', 'nth-test');
|
||||
var even = Y.Dom.getElementsByClassName('odd', 'li', 'nth-test');
|
||||
var four1 = Y.Dom.getElementsByClassName('last-four-1', 'li', 'nth-test');
|
||||
|
||||
Y.ArrayAssert.itemsAreEqual(odd, $('li:nth-last-child(2n+1)'), '2n+1');
|
||||
Y.ArrayAssert.itemsAreEqual(odd, $('li:nth-last-child(odd)'), 'odd');
|
||||
Y.ArrayAssert.itemsAreEqual(even, $('li:nth-last-child(2n+0)'), '2n+0');
|
||||
Y.ArrayAssert.itemsAreEqual(even, $('li:nth-last-child(2n)'), '2n');
|
||||
Y.ArrayAssert.itemsAreEqual(even, $('li:nth-last-child(even)'), 'even');
|
||||
Y.ArrayAssert.itemsAreEqual(four1, $('li:nth-last-child(4n+1)'), '4n+1');
|
||||
},
|
||||
testNthType: function() {
|
||||
var all = Y.Dom.get('nth-test').getElementsByTagName('li');
|
||||
var odd = Y.Dom.getElementsByClassName('odd', 'li', 'nth-test');
|
||||
var even = Y.Dom.getElementsByClassName('even', 'li', 'nth-test');
|
||||
var three1 = Y.Dom.getElementsByClassName('three-1', 'li', 'nth-test');
|
||||
var four1 = Y.Dom.getElementsByClassName('four-1', 'li', 'nth-test');
|
||||
var four2 = Y.Dom.getElementsByClassName('four-2', 'li', 'nth-test');
|
||||
var four3 = Y.Dom.getElementsByClassName('four-3', 'li', 'nth-test');
|
||||
var four4 = Y.Dom.getElementsByClassName('four-4', 'li', 'nth-test');
|
||||
Y.ArrayAssert.itemsAreEqual(odd, $('li:nth-of-type(odd)'), 'odd');
|
||||
},
|
||||
testNthChild: function() {
|
||||
var all = Y.Dom.get('nth-test').getElementsByTagName('li');
|
||||
var odd = Y.Dom.getElementsByClassName('odd', 'li', 'nth-test');
|
||||
var even = Y.Dom.getElementsByClassName('even', 'li', 'nth-test');
|
||||
var three1 = Y.Dom.getElementsByClassName('three-1', 'li', 'nth-test');
|
||||
var four1 = Y.Dom.getElementsByClassName('four-1', 'li', 'nth-test');
|
||||
var four2 = Y.Dom.getElementsByClassName('four-2', 'li', 'nth-test');
|
||||
var four3 = Y.Dom.getElementsByClassName('four-3', 'li', 'nth-test');
|
||||
var four4 = Y.Dom.getElementsByClassName('four-4', 'li', 'nth-test');
|
||||
|
||||
Y.ArrayAssert.itemsAreEqual(even[1], $('li:nth-child(2)'), '2');
|
||||
Y.ArrayAssert.itemsAreEqual(even[1], $('li:nth-child(0n+2)'), '0n+2');
|
||||
Y.ArrayAssert.itemsAreEqual(three1, $('li:nth-child(3n+1)'), '3n+1');
|
||||
Y.ArrayAssert.itemsAreEqual(all, $('li:nth-child(n+1)'), 'n+1');
|
||||
|
||||
// from http://www.w3.org/TR/css3-selectors/#nth-child-pseudo examples
|
||||
Y.ArrayAssert.itemsAreEqual(odd, $('li:nth-child(2n+1)'), '2n+1');
|
||||
Y.ArrayAssert.itemsAreEqual(odd, $('li:nth-child(odd)'), 'odd');
|
||||
Y.ArrayAssert.itemsAreEqual(even, $('li:nth-child(2n+0)'), '2n+0');
|
||||
Y.ArrayAssert.itemsAreEqual(even, $('li:nth-child(2n)'), '2n');
|
||||
Y.ArrayAssert.itemsAreEqual(even, $('li:nth-child(even)'), 'even');
|
||||
Y.ArrayAssert.itemsAreEqual(four1, $('li:nth-child(4n+1)'), '4n+1');
|
||||
Y.ArrayAssert.itemsAreEqual(four2, $('li:nth-child(4n+2)'), '4n+2');
|
||||
Y.ArrayAssert.itemsAreEqual(four3, $('li:nth-child(4n+3)'), '4n+3');
|
||||
Y.ArrayAssert.itemsAreEqual(four4, $('li:nth-child(4n+4)'), '4n+4');
|
||||
Y.ArrayAssert.itemsAreEqual(even[0], $('li:nth-child(0n+1)'), '0n+1');
|
||||
Y.ArrayAssert.itemsAreEqual(even[0], $('li:nth-child(1)'), '1');
|
||||
Y.ArrayAssert.itemsAreEqual(all, $('li:nth-child(1n+0)'), '1n+0');
|
||||
Y.ArrayAssert.itemsAreEqual(all, $('li:nth-child(n+0)'), 'n+0');
|
||||
|
||||
},
|
||||
|
||||
testSelector: function() {
|
||||
Y.ArrayAssert.itemsAreEqual($('.not-button', 'test-inputs'), $('input:not([type=button])', 'test-inputs'), 'input[type=radio], input[type=checkbox] = input:not([type=button])');
|
||||
Y.ArrayAssert.itemsAreEqual($('p, p'), document.getElementsByTagName('p'), 'p, p');
|
||||
Y.ArrayAssert.itemsAreEqual($('p', null, true), document.getElementsByTagName('p')[0], 'p (firstOnly)');
|
||||
Y.ArrayAssert.itemsAreEqual($('.Foo'), []);
|
||||
Y.ArrayAssert.itemsAreEqual($('p ~ p'), [children[1], children[2]], 'p ~ p');
|
||||
Y.ArrayAssert.itemsAreEqual([], $('#demo.bar p'), '#demo.bar p');
|
||||
Y.ArrayAssert.itemsAreEqual(Y.Dom.get('demo').getElementsByTagName('p'), $('#demo.foo p'), '#demo.foo p');
|
||||
Y.ArrayAssert.itemsAreEqual(Y.Dom.get('demo').getElementsByTagName('p'), $('.foo p'), '.foo p');
|
||||
Y.ArrayAssert.itemsAreEqual(Y.Dom.get('demo').getElementsByTagName('p'), $('#demo p'), '#demo p');
|
||||
Y.ArrayAssert.itemsAreEqual($('p > em'), [Y.Dom.getFirstChild('demo-first-child')], 'p > em');
|
||||
Y.ArrayAssert.itemsAreEqual(Y.Dom.getElementsByClassName('para'), $('[class~=para]'), '[class=~para]');
|
||||
Y.ArrayAssert.itemsAreEqual(document.body.getElementsByTagName('p'), $('body div p'), 'body div p');
|
||||
Y.ArrayAssert.itemsAreEqual([], $('#demo .madeup'), '#demo .madeup');
|
||||
Y.ArrayAssert.itemsAreEqual(Y.Dom.getElementsByClassName('para', 'p'), $('div .para'), 'div .para');
|
||||
Y.ArrayAssert.itemsAreEqual(Y.Dom.getElementsByClassName('first', null, 'demo'), $('#demo .first'), '#demo .first');
|
||||
Y.ArrayAssert.itemsAreEqual(document.getElementsByTagName('div'), $('div'), 'div');
|
||||
Y.ArrayAssert.itemsAreEqual(document.body.getElementsByTagName('div'), $('body div'), 'body div');
|
||||
Y.ArrayAssert.itemsAreEqual([demoFirstChild, Y.Dom.getNextSibling(demoFirstChild)], $('#demo p:not(.last)'), '#demo p:not(.last)');
|
||||
Y.ArrayAssert.itemsAreEqual(Y.Dom.get('demo2').getElementsByTagName('div'), $('div:contains(child of demo2)', 'demo2'), 'div:contains:(child of demo2) ');
|
||||
Y.ArrayAssert.itemsAreEqual([Y.Dom.get('class-bar')], $('.Bar'), '.Bar');
|
||||
}
|
||||
});
|
||||
|
||||
var simpleTest = new YAHOO.tool.TestCase({
|
||||
name: 'Simple Node Test',
|
||||
|
||||
testPseudo: function() {
|
||||
//Y.Assert.isTrue(Selector.test(Y.Dom.get('empty'), ':empty'), 'empty');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo2'), ':empty'), 'empty false pos');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.getLastChild('demo'), ':last-child'), 'last-child');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.getFirstChild('demo'), 'p:first-child'), 'first-child tag');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.getFirstChild('demo'), ':first-child'), 'first-child');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.getFirstChild('demo'), ':only-of-type'), 'only-of-type false pos');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.getFirstChild('demo'), ':first-child.last'), 'first-child class false pos');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.getFirstChild('demo'), ':first-child.first'), 'first-child class');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.getFirstChild('demo'), ':only-child'), 'only-child');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.getFirstChild('demo'), ':first-of-type'), 'first-of-type');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.getLastChild('demo'), ':last-of-type'), 'last-of-type');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), ':not(.foo)'), 'not(.foo)');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), ':not(p)'), 'not(p)');
|
||||
Y.Assert.isTrue(Selector.test(demoFirstChild, ':not(.last)'), 'not(.last)');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo2'), ':contains(demo2)'), 'contains(demo2)');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo2'), ':not(:contains(demo2))'), ':not(:contains(demo2))');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo2'), ':not(:contains(demo1))'), ':not(:contains(demo1))');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo2'), ':contains(child of demo2)'), 'contains(child of demo2)');
|
||||
},
|
||||
|
||||
testAttr: function() {
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('href-test'), '[href=foo.html]'), 'href=foo.html');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[title]'), 'title exists');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.getFirstChild('demo'), '[title]'), 'title exists false pos');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[id=demo]'), 'id equality');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[id|=de]'), 'id starts with optional hyphen');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), '[id|=me]'), 'id starts with false pos');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[id~=demo]'), 'id includes');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[title~=demo]'), 'title includes');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), '[id!=demo]'), 'id negation');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[id!=bar]'), 'id negation');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[id^=de]'), 'id starts with');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[id$=mo]'), 'id ends with');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), '[id$=m]'), 'id ends with false pos');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[id*=em]'), 'id substr');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), '[id*=ex]'), 'id substr false pos');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '[id=demo][title~=demo]'), 'multiple attributes');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), 'div[id=demo][title~=demo]'), 'tag & multiple attributes');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), 'div[title=this is a demo]'), 'attribute with spaces');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), '[id=demo][title=demo]'), 'multiple attributes false pos');
|
||||
},
|
||||
|
||||
testClass: function() {
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '.foo'), 'class match');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), 'div.foo'), 'tag match');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), 'span.foo'), 'tag false positive');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '#demo.foo'), 'id match');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), '.baz'), 'class false positive');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.getFirstChild('demo'), '.first.para'), 'multiple class match');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.getFirstChild('demo'), 'p.first.para'), 'tag & multiple class match');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), '.foo.bar'), 'multiple class false pos');
|
||||
},
|
||||
|
||||
testId: function() {
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '#demo'), 'id match');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), 'div#demo'), 'tag match');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), 'div#dmo'), 'id false positive');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), 'span#demo'), 'tag false positive');
|
||||
},
|
||||
|
||||
testTag: function() {
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), 'div'), 'tag match');
|
||||
Y.Assert.isFalse(Selector.test(Y.Dom.get('demo'), 'span'), 'tag false positive');
|
||||
Y.Assert.isTrue(Selector.test(Y.Dom.get('demo'), '*'), 'universal tag');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
suite.add(selectorQueryAll);
|
||||
suite.add(simpleTest);
|
||||
YAHOO.tool.TestRunner.add(suite);
|
||||
YAHOO.tool.TestRunner.run();
|
||||
};
|
||||
</script>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="demo" class="foo" title="this is a demo">
|
||||
<p class="para first" id="demo-first-child"><em>lorem ipsum</em></p>
|
||||
<p class="para">lorem ipsum</p>
|
||||
<p class="para last">lorem ipsum</p>
|
||||
</div>
|
||||
|
||||
<div id="demo2">
|
||||
<div>child of demo2</div>
|
||||
</div>
|
||||
|
||||
<div id="empty"></div>
|
||||
|
||||
<div id="root-test">
|
||||
<ol id="nth-test">
|
||||
<li class="odd three-1 four-1">foo</li>
|
||||
<li class="even four-2 last-four-1">foo</li>
|
||||
<li class="odd four-3">foo</li>
|
||||
<li class="even three-1 four-4">foo</li>
|
||||
<li class="odd four-1">foo</li>
|
||||
<li class="even four-2 last-four-1">foo</li>
|
||||
<li class="odd three-1 four-3">foo</li>
|
||||
<li class="even four-4" id="test-lang-none">foo</li>
|
||||
<li class="odd four-1" lang="en-US" id="test-lang-en-us">foo</li>
|
||||
<li class="even three-1 four-2 last-four-1" lang="en" id="test-lang-en">foo</li>
|
||||
</ol>
|
||||
</div>
|
||||
<a id="href-test" href="foo.html">foo</a>
|
||||
<form id="test-inputs">
|
||||
<input type="checkbox" id="checkbox-unchecked" class="not-button">
|
||||
<input type="checkbox" checked id="checkbox-checked-noval" class="not-button">
|
||||
<input type="checkbox" checked="true" id="checkbox-checked" class="not-button">
|
||||
<input type="radio" id="radio-unchecked" class="not-button">
|
||||
<input type="radio" checked="true" id="radio-checked" class="not-button">
|
||||
<input type="button" value="foo">
|
||||
</form>
|
||||
<div class="Bar" id="class-bar"></div>
|
||||
</body>
|
||||
</html>
|
||||
109
www/extras/yui/tests/tabview.html
Normal file
109
www/extras/yui/tests/tabview.html
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>TabView Test Suite</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../build/tabview/assets/skins/sam/tabview.css">
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/element/element-beta.js"></script>
|
||||
<script type="text/javascript" src="../build/tabview/tabview.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var Y = YAHOO.util,
|
||||
tool = YAHOO.tool,
|
||||
suite = new tool.TestSuite("yuisuite");
|
||||
|
||||
Y.Event.onDOMReady(function() {
|
||||
var logger = new YAHOO.tool.TestLogger(null, { height: '80%' });
|
||||
|
||||
var tabview = new YAHOO.widget.TabView('demo');
|
||||
|
||||
suite.add( new tool.TestCase({
|
||||
name: 'YAHOO.widget.TabView',
|
||||
|
||||
test_getActiveIndex: function() {
|
||||
YAHOO.util.Assert.areEqual(0, tabview.get('activeIndex'), 'incorrect activeIndex');
|
||||
},
|
||||
|
||||
test_setActiveIndex: function() {
|
||||
tabview.set('activeIndex', 1);
|
||||
|
||||
YAHOO.util.Assert.areEqual(1, tabview.get('activeIndex'), 'incorrect activeIndex');
|
||||
YAHOO.util.Assert.areEqual(tabview.get('tabs')[1], tabview.get('activeTab'), 'incorrect activeTab');
|
||||
},
|
||||
|
||||
test_setActiveTab: function() {
|
||||
tabview.set('activeTab', tabview.get('tabs')[2]);
|
||||
|
||||
YAHOO.util.Assert.areEqual(2, tabview.get('activeIndex'), 'incorrect activeTab');
|
||||
YAHOO.util.Assert.areEqual(tabview.get('tabs')[2], tabview.get('activeTab'), 'incorrect activeTab');
|
||||
},
|
||||
|
||||
test_addTab: function() {
|
||||
var tab = new YAHOO.widget.Tab({ label: 'new tab', content: 'new tab content' });
|
||||
tabview.addTab(tab);
|
||||
|
||||
var tabs = tabview.get('tabs');
|
||||
YAHOO.util.Assert.areEqual(tab, tabview.getTab(tabs.length - 1), 'incorrect Tab');
|
||||
YAHOO.util.Assert.areEqual(tabs.length - 1, tabview.getTabIndex(tab), 'incorrect Tab');
|
||||
},
|
||||
|
||||
test_removeTab: function() {
|
||||
var tab = tabview.getTab(0);
|
||||
tabview.removeTab(tab);
|
||||
|
||||
YAHOO.util.Assert.areEqual(null, tabview.getTabIndex(tab), 'incorrect Tab');
|
||||
},
|
||||
|
||||
test_activeTabChange: function() {
|
||||
var pass = false;
|
||||
tabview.on('activeTabChange', function() { pass = true; });
|
||||
tabview.set('activeTab', tabview.getTab(0));
|
||||
YAHOO.util.Assert.isTrue(pass, 'activeTabChange not fired');
|
||||
|
||||
pass = false;
|
||||
tabview.set('activeIndex', 2);
|
||||
YAHOO.util.Assert.isTrue(pass, 'activeTabChange not fired');
|
||||
}
|
||||
|
||||
}));
|
||||
tool.TestRunner.add(suite);
|
||||
|
||||
if (parent && parent != window) {
|
||||
tool.TestManager.load();
|
||||
} else {
|
||||
tool.TestRunner.run();
|
||||
}
|
||||
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body class="yui-skin-sam">
|
||||
<div id="doc">
|
||||
<div id="demo" class="yui-navset">
|
||||
<ul class="yui-nav">
|
||||
<li class="selected"><a href="#foo"><em>foo</em></a></li>
|
||||
<li><a href="#bar"><em>bar</em></a></li>
|
||||
<li><a href="#baz"><em>baz</em></a></li>
|
||||
</ul>
|
||||
<div class="yui-content">
|
||||
<div id="foo">foo content</div>
|
||||
<div id="bar">bar content</div>
|
||||
<div id="baz">baz content</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
413
www/extras/yui/tests/yahoo.html
Normal file
413
www/extras/yui/tests/yahoo.html
Normal file
|
|
@ -0,0 +1,413 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>YUI Tests</title>
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
|
||||
<style type="text/css">
|
||||
#xframe {
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var g_modules=[];
|
||||
|
||||
var YAHOO_config = {
|
||||
listener: function(info) {
|
||||
g_modules.push(info.name);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<iframe name="xframe" id="xframe" src="assets/xframe.html"></iframe>
|
||||
<h1>YAHOO test page</h1>
|
||||
<p>This page contains tests being run by yuitest, the results of which<br />
|
||||
are output in the logger to the right. <br />View the source to see how it's done.</p>
|
||||
<p><input type="button" value="Run Tests" id="btnRun" /></p>
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
|
||||
var Dom=YAHOO.util.Dom,
|
||||
Assert=YAHOO.util.Assert,
|
||||
ObjectAssert=YAHOO.util.ObjectAssert,
|
||||
ArrayAssert=YAHOO.util.ArrayAssert,
|
||||
suite=new YAHOO.tool.TestSuite("yuisuite");
|
||||
|
||||
suite.add(new YAHOO.tool.TestCase({
|
||||
|
||||
//name of the test case
|
||||
name : "yahoo",
|
||||
|
||||
//extra information about tests
|
||||
_should : {
|
||||
|
||||
//tests with these names should fail
|
||||
fail : { test_to_fail: true },
|
||||
|
||||
//tests with these names should throw an error
|
||||
error : { },
|
||||
|
||||
//ignore these tests
|
||||
ignore : { }
|
||||
},
|
||||
|
||||
test_config: function() {
|
||||
ArrayAssert.itemsAreEqual(["yahoo", "dom", "event", "logger", "yuitest"], g_modules);
|
||||
},
|
||||
|
||||
test_create_namespace: function () {
|
||||
|
||||
// set up YAHOO.my.namespace
|
||||
var ns = YAHOO.namespace("my.namespace");
|
||||
|
||||
// use the returned reference, assign a value
|
||||
ns.test = "yahoo_my_namespace_test";
|
||||
|
||||
// check for the assigned value using the full path
|
||||
Assert.areEqual(YAHOO.my.namespace.test, "yahoo_my_namespace_test", "The namespace was not set up correctly");
|
||||
|
||||
// assign a value to my to test that it doesn't get wiped out
|
||||
YAHOO.my.test = "yahoo_my_test";
|
||||
|
||||
// create another namespace on my
|
||||
var ns2 = YAHOO.namespace("my.namespace2");
|
||||
|
||||
// make sure my stays the same
|
||||
Assert.areEqual(YAHOO.my.test, "yahoo_my_test", "The namespace was obliterated");
|
||||
},
|
||||
|
||||
test_is_array: function() {
|
||||
Assert.isTrue(YAHOO.lang.isArray([1, 2]), "Array literals are arrays");
|
||||
Assert.isFalse(YAHOO.lang.isArray({"one": "two"}), "Object literals are not arrays");
|
||||
|
||||
var a = new Array();
|
||||
a["one"] = "two";
|
||||
Assert.isTrue(YAHOO.lang.isArray(a), "Associative array are arrays");
|
||||
|
||||
Assert.isFalse(YAHOO.lang.isArray(document.getElementsByTagName("body")),
|
||||
"Element collections are array-like, but not arrays");
|
||||
|
||||
Assert.isFalse(YAHOO.lang.isArray(null), "null is not an array");
|
||||
Assert.isFalse(YAHOO.lang.isArray(''), "'' is not an array");
|
||||
Assert.isFalse(YAHOO.lang.isArray(undefined), "undefined is not an array");
|
||||
|
||||
Assert.isTrue(YAHOO.lang.isArray(xframe.arr), "Cross frame array failure");
|
||||
Assert.isFalse(YAHOO.lang.isArray(xframe.far), "Cross frame fake array failure");
|
||||
Assert.isFalse(YAHOO.lang.isArray(xframe.obj), "Cross frame object failure");
|
||||
Assert.isFalse(YAHOO.lang.isArray(xframe.fun), "Cross frame function failure");
|
||||
Assert.isFalse(YAHOO.lang.isArray(xframe.boo), "Cross frame boolean failure");
|
||||
Assert.isFalse(YAHOO.lang.isArray(xframe.str), "Cross frame string failure");
|
||||
Assert.isFalse(YAHOO.lang.isArray(xframe.nul), "Cross frame null failure");
|
||||
Assert.isFalse(YAHOO.lang.isArray(xframe.und), "Cross frame undefined failure");
|
||||
|
||||
// alert(xframe.arr.constructor.prototype == Array.prototype);
|
||||
// alert(xframe.arr.constructor.prototype == xframe.Array.prototype);
|
||||
},
|
||||
|
||||
test_is_boolean: function() {
|
||||
Assert.isTrue(YAHOO.lang.isBoolean(false), "false failed boolean check");
|
||||
Assert.isFalse(YAHOO.lang.isBoolean(1), "the number 1 is not a boolean");
|
||||
Assert.isFalse(YAHOO.lang.isBoolean("true"), "the string 'true' is not a boolean");
|
||||
},
|
||||
|
||||
test_is_function: function() {
|
||||
Assert.isTrue(YAHOO.lang.isFunction(function(){}), "a function is a function");
|
||||
Assert.isFalse(YAHOO.lang.isFunction({foo: "bar"}), "an object is not a function");
|
||||
|
||||
Assert.isTrue(YAHOO.lang.isFunction(xframe.fun), "Cross frame function failure");
|
||||
Assert.isFalse(YAHOO.lang.isFunction(xframe.arr), "Cross frame array failure");
|
||||
Assert.isFalse(YAHOO.lang.isFunction(xframe.obj), "Cross frame object failure");
|
||||
Assert.isFalse(YAHOO.lang.isFunction(xframe.boo), "Cross frame boolean failure");
|
||||
Assert.isFalse(YAHOO.lang.isFunction(xframe.str), "Cross frame string failure");
|
||||
Assert.isFalse(YAHOO.lang.isFunction(xframe.nul), "Cross frame null failure");
|
||||
Assert.isFalse(YAHOO.lang.isFunction(xframe.und), "Cross frame undefined failure");
|
||||
|
||||
},
|
||||
|
||||
test_is_null: function() {
|
||||
Assert.isTrue(YAHOO.lang.isNull(null), "null is null");
|
||||
Assert.isFalse(YAHOO.lang.isNull(undefined), "undefined is not null");
|
||||
Assert.isFalse(YAHOO.lang.isNull(""), "empty string is not null");
|
||||
},
|
||||
|
||||
test_is_number: function() {
|
||||
Assert.isTrue(YAHOO.lang.isNumber(0), "0 is a number");
|
||||
Assert.isTrue(YAHOO.lang.isNumber(123.123), "123.123 is a number");
|
||||
Assert.isFalse(YAHOO.lang.isNumber('123.123'), "the string '123.123' is not a number, even though it can be cast into one");
|
||||
Assert.isFalse(YAHOO.lang.isNumber(1/0), "undefined numbers and infinity are not numbers we want to use");
|
||||
},
|
||||
|
||||
test_is_object: function() {
|
||||
Assert.isTrue(YAHOO.lang.isObject({}), "an object is an object");
|
||||
Assert.isTrue(YAHOO.lang.isObject(function(){}), "a function is an object");
|
||||
Assert.isTrue(YAHOO.lang.isObject([]), "an array is an object");
|
||||
Assert.isFalse(YAHOO.lang.isObject(1), "numbers are not objects");
|
||||
Assert.isFalse(YAHOO.lang.isObject(true), "boolean values are not objects");
|
||||
Assert.isFalse(YAHOO.lang.isObject("{}"), "strings are not objects");
|
||||
Assert.isFalse(YAHOO.lang.isObject(null), "null should return false even though it technically is an object");
|
||||
|
||||
Assert.isTrue(YAHOO.lang.isObject(xframe.obj), "Cross frame object failure");
|
||||
Assert.isTrue(YAHOO.lang.isObject(xframe.fun), "Cross frame function failure");
|
||||
Assert.isTrue(YAHOO.lang.isObject(xframe.arr), "Cross frame array failure");
|
||||
Assert.isFalse(YAHOO.lang.isObject(xframe.boo), "Cross frame boolean failure");
|
||||
Assert.isFalse(YAHOO.lang.isObject(xframe.str), "Cross frame string failure");
|
||||
Assert.isFalse(YAHOO.lang.isObject(xframe.nul), "Cross frame null failure");
|
||||
Assert.isFalse(YAHOO.lang.isObject(xframe.und), "Cross frame undefined failure");
|
||||
|
||||
},
|
||||
|
||||
test_is_string: function() {
|
||||
Assert.isTrue(YAHOO.lang.isString("{}"), "a string is a string");
|
||||
Assert.isFalse(YAHOO.lang.isString({foo: "bar"}), "an object is not a string");
|
||||
Assert.isFalse(YAHOO.lang.isString(123), "a number is not a string");
|
||||
Assert.isFalse(YAHOO.lang.isString(true), "boolean values are not strings");
|
||||
},
|
||||
|
||||
test_is_undefined: function() {
|
||||
Assert.isTrue(YAHOO.lang.isUndefined(undefined), "undefined is undefined");
|
||||
Assert.isFalse(YAHOO.lang.isUndefined(false), "boolean false is not undefined");
|
||||
Assert.isFalse(YAHOO.lang.isUndefined(null), "null is not undefined");
|
||||
},
|
||||
|
||||
test_trim: function() {
|
||||
Assert.areEqual(YAHOO.lang.trim(" My String"), "My String");
|
||||
Assert.areEqual(YAHOO.lang.trim("My String "), "My String");
|
||||
Assert.areEqual(YAHOO.lang.trim(" My String "), "My String");
|
||||
Assert.areEqual(YAHOO.lang.trim(null), null);
|
||||
Assert.areEqual(YAHOO.lang.trim(undefined), undefined);
|
||||
Assert.areEqual(YAHOO.lang.trim({}), "[object Object]");
|
||||
},
|
||||
|
||||
test_isValue: function() {
|
||||
Assert.isFalse(YAHOO.lang.isValue(null), "null should be false");
|
||||
Assert.isFalse(YAHOO.lang.isValue(undefined), "undefined should be false");
|
||||
Assert.isFalse(YAHOO.lang.isValue(parseInt("adsf", 10)), "NaN should be false");
|
||||
Assert.isFalse(YAHOO.lang.isValue(1/0), "undefined numbers and infinity should be false");
|
||||
Assert.isTrue(YAHOO.lang.isValue(new Date()), "date should be true");
|
||||
Assert.isTrue(YAHOO.lang.isValue(""), "Empty string should be true");
|
||||
Assert.isTrue(YAHOO.lang.isValue(false), "false should be true");
|
||||
},
|
||||
|
||||
test_merge: function() {
|
||||
var o1 = { one: "one" },
|
||||
o2 = { two: "two" },
|
||||
o3 = { two: "twofromthree", three: "three" },
|
||||
o4 = { one: "one", two: "twofromthree", three: "three" },
|
||||
o123 = YAHOO.lang.merge(o1, o2, o3);
|
||||
|
||||
ObjectAssert.propertiesAreEqual(o123, o4);
|
||||
Assert.areEqual(o123.two, o4.two);
|
||||
},
|
||||
|
||||
test_dump: function() {
|
||||
Assert.areEqual("0", YAHOO.lang.dump(0));
|
||||
Assert.areEqual("null", YAHOO.lang.dump(null));
|
||||
Assert.areEqual("false", YAHOO.lang.dump(false));
|
||||
// Other types tested in substitute
|
||||
},
|
||||
|
||||
test_substitute: function() {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var param = {domain: 'valvion.com',
|
||||
media: 'http://media.{domain}/', /* nested */
|
||||
contextdomain: { context1: 'context{domain}', context2: 'yahoo.com' }, /* the value is an object, we will use a custom function to extract the correct data */
|
||||
contextmedia: 'http://contextmedia.{contextdomain context1}/'};
|
||||
var url, l=YAHOO.lang;
|
||||
|
||||
// standard replace, nested
|
||||
url = l.substitute("{media}logo.gif", param);
|
||||
Assert.areEqual(url, "http://media.valvion.com/logo.gif");
|
||||
|
||||
|
||||
// If the replacement value is an object, use the meta info as a key to extract the
|
||||
// correct data. Otherwise just return the value.
|
||||
function multipleChoice(key, val, meta) {
|
||||
return (l.isObject(val)) ? val[meta] : val;
|
||||
}
|
||||
|
||||
// "random data" is not used since the value for the contextmedia key is a string.
|
||||
// contextdomain uses "context1" as a key to expand the string correctly
|
||||
url = l.substitute("{contextmedia random data}logo.gif", param, multipleChoice);
|
||||
Assert.areEqual(url, "http://contextmedia.contextvalvion.com/logo.gif");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var obj = {
|
||||
level1_1: 1.1,
|
||||
level1_2: 1.2,
|
||||
level1_3: {
|
||||
level2_1: 2.1,
|
||||
level2_2: 2.2,
|
||||
level2_3: {
|
||||
level3_1: 3.1,
|
||||
level3_2: 3.2,
|
||||
level3_3: 3.3,
|
||||
level3_4: 3.4
|
||||
},
|
||||
level2_4: 2.4
|
||||
},
|
||||
level1_4: 1.4
|
||||
};
|
||||
|
||||
|
||||
Assert.areEqual(
|
||||
l.substitute("{testobj 0}", { testobj: obj }),
|
||||
"{level1_1 => 1.1, level1_2 => 1.2, level1_3 => {...}, level1_4 => 1.4}",
|
||||
"failed one level object dump"
|
||||
);
|
||||
|
||||
Assert.areEqual(
|
||||
l.substitute("{testobj 1}", { testobj: obj }),
|
||||
"{level1_1 => 1.1, level1_2 => 1.2, level1_3 => {level2_1 => 2.1, level2_2 => 2.2, level2_3 => {...}, level2_4 => 2.4}, level1_4 => 1.4}",
|
||||
"failed two level object dump"
|
||||
);
|
||||
|
||||
Assert.areEqual(
|
||||
l.substitute(
|
||||
"{testobj 10}", { testobj: obj }),
|
||||
"{level1_1 => 1.1, level1_2 => 1.2, level1_3 => {level2_1 => 2.1, level2_2 => 2.2, level2_3 => {level3_1 => 3.1, level3_2 => 3.2, level3_3 => 3.3, level3_4 => 3.4}, level2_4 => 2.4}, level1_4 => 1.4}",
|
||||
"failed deep object dump"
|
||||
);
|
||||
|
||||
var arr = [
|
||||
1.1,
|
||||
1.2,
|
||||
[
|
||||
2.1,
|
||||
2.2,
|
||||
[
|
||||
3.1,
|
||||
3.2,
|
||||
3.3,
|
||||
3.4
|
||||
],
|
||||
2.4
|
||||
],
|
||||
1.4
|
||||
];
|
||||
|
||||
Assert.areEqual(
|
||||
l.substitute("{testarr 1}", { testarr: arr }),
|
||||
"[1.1, 1.2, [2.1, 2.2, {...}, 2.4], 1.4]",
|
||||
"failed two level array dump"
|
||||
);
|
||||
|
||||
var mix = [
|
||||
1.1,
|
||||
new Date(),
|
||||
{
|
||||
level2_1: 2.1,
|
||||
level2_2: 2.2,
|
||||
level2_3: [
|
||||
3.1,
|
||||
3.2,
|
||||
3.3,
|
||||
3.4
|
||||
],
|
||||
level2_4: 2.4
|
||||
},
|
||||
1.4,
|
||||
function(){}
|
||||
];
|
||||
|
||||
var result = l.substitute("{testmix 1}", { testmix: mix });
|
||||
|
||||
Assert.isTrue(
|
||||
(result.indexOf("GMT" > -1)) ? true : false,
|
||||
"failed two level mixed object with a date (date should have produced an output with GMT in it"
|
||||
);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var tostr = {
|
||||
custom1_1: 1.1,
|
||||
custom1_2: 1.2,
|
||||
custom1_3: {
|
||||
custom2_1: 2.1,
|
||||
custom2_2: 2.2,
|
||||
custom2_3: {
|
||||
custom3_1: 3.1,
|
||||
custom3_2: 3.2,
|
||||
custom3_3: 3.3,
|
||||
custom3_4: 3.4
|
||||
},
|
||||
custom2_4: 2.4
|
||||
},
|
||||
custom1_4: 1.4,
|
||||
toString: function() {
|
||||
return "custom toString executed";
|
||||
}
|
||||
};
|
||||
|
||||
Assert.areEqual(
|
||||
l.substitute("{customtostr 1}", { customtostr: tostr }),
|
||||
"custom toString executed",
|
||||
"failed: custom toString should have been used"
|
||||
);
|
||||
|
||||
Assert.areEqual(
|
||||
l.substitute("{customtostr dump 1}", { customtostr: tostr }),
|
||||
"{custom1_1 => 1.1, custom1_2 => 1.2, custom1_3 => {custom2_1 => 2.1, custom2_2 => 2.2, custom2_3 => {...}, custom2_4 => 2.4}, custom1_4 => 1.4, toString => f(){...}}",
|
||||
"failed: custom toString should NOT have been used because the dump keyword should override it"
|
||||
);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
},
|
||||
|
||||
test_extend: function() {
|
||||
},
|
||||
|
||||
test_augmentObject: function() {
|
||||
},
|
||||
|
||||
test_augmentProto: function() {
|
||||
},
|
||||
|
||||
test_to_fail : function (){
|
||||
Assert.isNull("not null");;
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
function runTests(){
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
|
||||
// YAHOO.util.Event.onDomReady(function (){ // need to wait for the frame to load
|
||||
YAHOO.util.Event.on(window, "load", function (){
|
||||
//create the logger
|
||||
var logger = new YAHOO.tool.TestLogger();
|
||||
|
||||
//add the tests
|
||||
YAHOO.tool.TestRunner.add(suite);
|
||||
|
||||
//add event handler
|
||||
YAHOO.util.Event.addListener("btnRun", "click", runTests);
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
} else {
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
119
www/extras/yui/tests/yuiloader.html
Normal file
119
www/extras/yui/tests/yuiloader.html
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>YUI Tests</title>
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var g_modules=[];
|
||||
|
||||
var YAHOO_config = {
|
||||
listener: function g_mycallback(info) {
|
||||
g_modules.push(info.name);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest-beta.js"></script>
|
||||
<script type="text/javascript" src="../build/yuiloader/yuiloader-beta.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>YUILoader test page</h1>
|
||||
<p><input type="button" value="Run Tests" id="btnRun" /></p>
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
|
||||
var Dom=YAHOO.util.Dom,
|
||||
Assert=YAHOO.util.Assert,
|
||||
ObjectAssert=YAHOO.util.ObjectAssert,
|
||||
ArrayAssert=YAHOO.util.ArrayAssert,
|
||||
suite=new YAHOO.tool.TestSuite("yuisuite");
|
||||
|
||||
suite.add(new YAHOO.tool.TestCase({
|
||||
|
||||
//name of the test case
|
||||
name : "yuiloader",
|
||||
|
||||
//extra information about tests
|
||||
_should : {
|
||||
|
||||
//tests with these names should fail
|
||||
fail : { test_to_fail: true },
|
||||
|
||||
//tests with these names should throw an error
|
||||
error : { },
|
||||
|
||||
//ignore these tests
|
||||
ignore : { }
|
||||
},
|
||||
|
||||
test_calculate: function() {
|
||||
|
||||
loader = new YAHOO.util.YUILoader();
|
||||
loader.require(["dragdrop"]);
|
||||
loader.calculate();
|
||||
//console.log(loader.sorted);
|
||||
// yahoo dom and event are on the page
|
||||
ArrayAssert.itemsAreEqual(["dragdrop"], loader.sorted);
|
||||
|
||||
loader = new YAHOO.util.YUILoader();
|
||||
loader.require(["menu"]);
|
||||
loader.calculate();
|
||||
//console.log(loader.sorted);
|
||||
ArrayAssert.itemsAreEqual(["containercore", "menu", "skin-sam-menu"], loader.sorted);
|
||||
|
||||
loader = new YAHOO.util.YUILoader();
|
||||
loader.require("datatable", "calendar");
|
||||
loader.calculate({force: ["yahoo"]});
|
||||
loader.calculate();
|
||||
//console.log(loader.sorted);
|
||||
ArrayAssert.itemsAreEqual(
|
||||
["yahoo", "element", "datasource", "datatable", "calendar",
|
||||
"skin-sam-datatable", "skin-sam-calendar"], loader.sorted);
|
||||
loader = new YAHOO.util.YUILoader();
|
||||
loader.loaded = {"yahoo": true, "dom": true};
|
||||
loader.loadOptional = true;
|
||||
loader.require(["slider", "connection", "element"]);
|
||||
loader.require("treeview", "skin-sam");
|
||||
loader.calculate();
|
||||
//console.log(loader.sorted);
|
||||
ArrayAssert.itemsAreEqual(
|
||||
["dragdrop", "animation", "slider", "connection", "element", "treeview", "skin-sam"], loader.sorted);
|
||||
},
|
||||
// this is not a good test
|
||||
test_config: function() {
|
||||
loader = new YAHOO.util.YUILoader();
|
||||
loader.require("colorpicker");
|
||||
|
||||
loader.insert(function() {
|
||||
YAHOO.util.Assert.isNotUndefined(YAHOO.widget.ColorPicker);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
(function (){
|
||||
//create the logger
|
||||
var logger = new YAHOO.tool.TestLogger();
|
||||
|
||||
//add the tests
|
||||
YAHOO.tool.TestRunner.add(suite);
|
||||
|
||||
//add event handler
|
||||
YAHOO.util.Event.addListener("btnRun", "click", YAHOO.tool.TestRunner.run);
|
||||
|
||||
runTests();
|
||||
})();
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
82
www/extras/yui/tests/yuiloader_config.html
Normal file
82
www/extras/yui/tests/yuiloader_config.html
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>yuiloader test</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
|
||||
var logger, suite, page_modules=[];
|
||||
|
||||
function log(msg) {
|
||||
|
||||
if (logger) {
|
||||
YAHOO.log(msg);
|
||||
} else if (typeof console !== "undefined" && console.debug) {
|
||||
console.debug(msg);
|
||||
} else {
|
||||
var d=document, b=d.body, n=d.createElement("div");
|
||||
if (b) {
|
||||
n.appendChild(d.createTextNode(msg));
|
||||
b.appendChild(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
YAHOO_config = {
|
||||
listener: function(minfo) {
|
||||
var n = minfo.name;
|
||||
page_modules.push(n);
|
||||
log("page load listener: " + n);
|
||||
},
|
||||
load: {
|
||||
require: ['yuitest'],
|
||||
//filter: 'DEBUG',
|
||||
base: '../build/',
|
||||
allowRollup: false,
|
||||
|
||||
onLoadComplete: function(loader) {
|
||||
|
||||
YAHOO.widget.Logger.enableBrowserConsole();
|
||||
logger = new YAHOO.tool.TestLogger();
|
||||
log("onLoadComplete");
|
||||
|
||||
suite=new YAHOO.tool.TestSuite("yuisuite");
|
||||
|
||||
suite.add(new YAHOO.tool.TestCase({
|
||||
name : "yuiloader",
|
||||
test_page_modules: function() {
|
||||
YAHOO.util.ArrayAssert.itemsAreEqual(
|
||||
// the page-level listener fires after the onLoadComplete
|
||||
// fires, so yuitest will not be in the list yet
|
||||
["yahoo", "event", "dom", "logger"],
|
||||
page_modules);
|
||||
},
|
||||
|
||||
test_logger_css: function() {
|
||||
var el = YAHOO.util.Dom.getElementsByClassName("error")[0];
|
||||
YAHOO.util.Assert.areEqual("rgb(227, 47, 11)",
|
||||
YAHOO.util.Dom.getStyle(el, "background-color"),
|
||||
"An element with the error class is not red");
|
||||
}
|
||||
}));
|
||||
|
||||
YAHOO.tool.TestRunner.add(suite);
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="../build/yuiloader/yuiloader-beta.js"></script>
|
||||
|
||||
</head>
|
||||
<body id="yahoo-com" class="yui-skin-sam">
|
||||
<h1>YUI Loader</h1>
|
||||
<p>yuiloader is loading the test library, so if it fails the test probably won't run at all</p>
|
||||
</body>
|
||||
</html>
|
||||
85
www/extras/yui/tests/yuiloader_rollup.html
Normal file
85
www/extras/yui/tests/yuiloader_rollup.html
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>yuiloader test</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function() {
|
||||
|
||||
var logger, suite, page_modules=[];
|
||||
|
||||
function log(msg) {
|
||||
|
||||
if (logger) {
|
||||
YAHOO.log(msg);
|
||||
} else if (typeof console !== "undefined" && console.debug) {
|
||||
console.debug(msg);
|
||||
} else {
|
||||
var d=document, b=d.body, n=d.createElement("div");
|
||||
if (b) {
|
||||
n.appendChild(d.createTextNode(msg));
|
||||
b.appendChild(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
YAHOO_config = {
|
||||
listener: function(minfo) {
|
||||
var n = minfo.name;
|
||||
page_modules.push(n);
|
||||
log("page load listener: " + n);
|
||||
},
|
||||
load: {
|
||||
require: ['yuitest', 'editor'],
|
||||
//filter: 'DEBUG',
|
||||
//allowRollup: false,
|
||||
base: '../build/',
|
||||
onLoadComplete: function(loader) {
|
||||
|
||||
YAHOO.widget.Logger.enableBrowserConsole();
|
||||
logger = new YAHOO.tool.TestLogger();
|
||||
log("onLoadComplete");
|
||||
|
||||
suite=new YAHOO.tool.TestSuite("yuisuite", "editor");
|
||||
|
||||
suite.add(new YAHOO.tool.TestCase({
|
||||
name : "yuiloader",
|
||||
test_page_modules: function() {
|
||||
YAHOO.util.ArrayAssert.itemsAreEqual(
|
||||
// the page-level listener fires after the onLoadComplete
|
||||
// fires, so editor will not be in the list yet
|
||||
["yahoo", "dom", "event", "yahoo-dom-event", "logger",
|
||||
"yuitest", "container", "menu", "element", "button"],
|
||||
page_modules);
|
||||
},
|
||||
|
||||
// if this fails the css was not applied correctly (in this case
|
||||
// it ususally means the rollup skin.css was not found)
|
||||
test_logger_css: function() {
|
||||
var el = YAHOO.util.Dom.getElementsByClassName("error")[0];
|
||||
YAHOO.util.Assert.areEqual("rgb(227, 47, 11)",
|
||||
YAHOO.util.Dom.getStyle(el, "background-color"),
|
||||
"An element with the error class is not red");
|
||||
}
|
||||
}));
|
||||
|
||||
YAHOO.tool.TestRunner.add(suite);
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="../build/yuiloader/yuiloader-beta.js"></script>
|
||||
|
||||
</head>
|
||||
<body id="yahoo-com" class="yui-skin-sam">
|
||||
<h1>YUI Loader</h1>
|
||||
<p>yuiloader is loading the test library, so if it fails the test probably won't run at all</p>
|
||||
<p>Testing rollups (yahoo-dom-event) which is verified in the test.</p>
|
||||
</body>
|
||||
</html>
|
||||
1361
www/extras/yui/tests/yuitest.html
Normal file
1361
www/extras/yui/tests/yuitest.html
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue