All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wings.js.yui.yuitest.yuitest-min.js Maven / Gradle / Ivy

The newest version!
/*
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.9.0
*/
YAHOO.namespace("tool");(function(){var a=0;YAHOO.tool.TestCase=function(b){this._should={};for(var c in b){this[c]=b[c];}if(!YAHOO.lang.isString(this.name)){this.name="testCase"+(a++);}};YAHOO.tool.TestCase.prototype={resume:function(b){YAHOO.tool.TestRunner.resume(b);},wait:function(d,c){var b=arguments;if(YAHOO.lang.isFunction(b[0])){throw new YAHOO.tool.TestCase.Wait(b[0],b[1]);}else{throw new YAHOO.tool.TestCase.Wait(function(){YAHOO.util.Assert.fail("Timeout: wait() called but resume() never called.");},(YAHOO.lang.isNumber(b[0])?b[0]:10000));}},setUp:function(){},tearDown:function(){}};YAHOO.tool.TestCase.Wait=function(c,b){this.segment=(YAHOO.lang.isFunction(c)?c:null);this.delay=(YAHOO.lang.isNumber(b)?b:0);};})();YAHOO.namespace("tool");YAHOO.tool.TestSuite=function(a){this.name="";this.items=[];if(YAHOO.lang.isString(a)){this.name=a;}else{if(YAHOO.lang.isObject(a)){YAHOO.lang.augmentObject(this,a,true);}}if(this.name===""){this.name=YAHOO.util.Dom.generateId(null,"testSuite");}};YAHOO.tool.TestSuite.prototype={add:function(a){if(a instanceof YAHOO.tool.TestSuite||a instanceof YAHOO.tool.TestCase){this.items.push(a);}},setUp:function(){},tearDown:function(){}};YAHOO.namespace("tool");YAHOO.tool.TestRunner=(function(){function b(c){this.testObject=c;this.firstChild=null;this.lastChild=null;this.parent=null;this.next=null;this.results={passed:0,failed:0,total:0,ignored:0,duration:0};if(c instanceof YAHOO.tool.TestSuite){this.results.type="testsuite";this.results.name=c.name;}else{if(c instanceof YAHOO.tool.TestCase){this.results.type="testcase";this.results.name=c.name;}}}b.prototype={appendChild:function(c){var d=new b(c);if(this.firstChild===null){this.firstChild=this.lastChild=d;}else{this.lastChild.next=d;this.lastChild=d;}d.parent=this;return d;}};function a(){a.superclass.constructor.apply(this,arguments);this.masterSuite=new YAHOO.tool.TestSuite("yuitests"+(new Date()).getTime());this._cur=null;this._root=null;this._running=false;this._lastResults=null;var d=[this.TEST_CASE_BEGIN_EVENT,this.TEST_CASE_COMPLETE_EVENT,this.TEST_SUITE_BEGIN_EVENT,this.TEST_SUITE_COMPLETE_EVENT,this.TEST_PASS_EVENT,this.TEST_FAIL_EVENT,this.TEST_IGNORE_EVENT,this.COMPLETE_EVENT,this.BEGIN_EVENT];for(var c=0;c0){return YAHOO.lang.substitute(b,{message:a});}else{return a;}},fail:function(a){throw new YAHOO.util.AssertionError(this._formatMessage(a,"Test force-failed."));},areEqual:function(b,c,a){if(b!=c){throw new YAHOO.util.ComparisonFailure(this._formatMessage(a,"Values should be equal."),b,c);}},areNotEqual:function(a,c,b){if(a==c){throw new YAHOO.util.UnexpectedValue(this._formatMessage(b,"Values should not be equal."),a);}},areNotSame:function(a,c,b){if(a===c){throw new YAHOO.util.UnexpectedValue(this._formatMessage(b,"Values should not be the same."),a);}},areSame:function(b,c,a){if(b!==c){throw new YAHOO.util.ComparisonFailure(this._formatMessage(a,"Values should be the same."),b,c);}},isFalse:function(b,a){if(false!==b){throw new YAHOO.util.ComparisonFailure(this._formatMessage(a,"Value should be false."),false,b);}},isTrue:function(b,a){if(true!==b){throw new YAHOO.util.ComparisonFailure(this._formatMessage(a,"Value should be true."),true,b);}},isNaN:function(b,a){if(!isNaN(b)){throw new YAHOO.util.ComparisonFailure(this._formatMessage(a,"Value should be NaN."),NaN,b);}},isNotNaN:function(b,a){if(isNaN(b)){throw new YAHOO.util.UnexpectedValue(this._formatMessage(a,"Values should not be NaN."),NaN);}},isNotNull:function(b,a){if(YAHOO.lang.isNull(b)){throw new YAHOO.util.UnexpectedValue(this._formatMessage(a,"Values should not be null."),null);}},isNotUndefined:function(b,a){if(YAHOO.lang.isUndefined(b)){throw new YAHOO.util.UnexpectedValue(this._formatMessage(a,"Value should not be undefined."),undefined);}},isNull:function(b,a){if(!YAHOO.lang.isNull(b)){throw new YAHOO.util.ComparisonFailure(this._formatMessage(a,"Value should be null."),null,b);}},isUndefined:function(b,a){if(!YAHOO.lang.isUndefined(b)){throw new YAHOO.util.ComparisonFailure(this._formatMessage(a,"Value should be undefined."),undefined,b);}},isArray:function(b,a){if(!YAHOO.lang.isArray(b)){throw new YAHOO.util.UnexpectedValue(this._formatMessage(a,"Value should be an array."),b);}},isBoolean:function(b,a){if(!YAHOO.lang.isBoolean(b)){throw new YAHOO.util.UnexpectedValue(this._formatMessage(a,"Value should be a Boolean."),b);}},isFunction:function(b,a){if(!YAHOO.lang.isFunction(b)){throw new YAHOO.util.UnexpectedValue(this._formatMessage(a,"Value should be a function."),b);}},isInstanceOf:function(b,c,a){if(!(c instanceof b)){throw new YAHOO.util.ComparisonFailure(this._formatMessage(a,"Value isn't an instance of expected type."),b,c);}},isNumber:function(b,a){if(!YAHOO.lang.isNumber(b)){throw new YAHOO.util.UnexpectedValue(this._formatMessage(a,"Value should be a number."),b);}},isObject:function(b,a){if(!YAHOO.lang.isObject(b)){throw new YAHOO.util.UnexpectedValue(this._formatMessage(a,"Value should be an object."),b);}},isString:function(b,a){if(!YAHOO.lang.isString(b)){throw new YAHOO.util.UnexpectedValue(this._formatMessage(a,"Value should be a string."),b);}},isTypeOf:function(b,c,a){if(typeof c!=b){throw new YAHOO.util.ComparisonFailure(this._formatMessage(a,"Value should be of type "+b+"."),b,typeof c);}}};YAHOO.util.AssertionError=function(a){this.message=a;this.name="AssertionError";};YAHOO.lang.extend(YAHOO.util.AssertionError,Object,{getMessage:function(){return this.message;},toString:function(){return this.name+": "+this.getMessage();
}});YAHOO.util.ComparisonFailure=function(b,a,c){YAHOO.util.AssertionError.call(this,b);this.expected=a;this.actual=c;this.name="ComparisonFailure";};YAHOO.lang.extend(YAHOO.util.ComparisonFailure,YAHOO.util.AssertionError,{getMessage:function(){return this.message+"\nExpected: "+this.expected+" ("+(typeof this.expected)+")"+"\nActual:"+this.actual+" ("+(typeof this.actual)+")";}});YAHOO.util.UnexpectedValue=function(b,a){YAHOO.util.AssertionError.call(this,b);this.unexpected=a;this.name="UnexpectedValue";};YAHOO.lang.extend(YAHOO.util.UnexpectedValue,YAHOO.util.AssertionError,{getMessage:function(){return this.message+"\nUnexpected: "+this.unexpected+" ("+(typeof this.unexpected)+") ";}});YAHOO.util.ShouldFail=function(a){YAHOO.util.AssertionError.call(this,a||"This test should fail but didn't.");this.name="ShouldFail";};YAHOO.lang.extend(YAHOO.util.ShouldFail,YAHOO.util.AssertionError);YAHOO.util.ShouldError=function(a){YAHOO.util.AssertionError.call(this,a||"This test should have thrown an error but didn't.");this.name="ShouldError";};YAHOO.lang.extend(YAHOO.util.ShouldError,YAHOO.util.AssertionError);YAHOO.util.UnexpectedError=function(a){YAHOO.util.AssertionError.call(this,"Unexpected error: "+a.message);this.cause=a;this.name="UnexpectedError";this.stack=a.stack;};YAHOO.lang.extend(YAHOO.util.UnexpectedError,YAHOO.util.AssertionError);YAHOO.util.ArrayAssert={contains:function(e,d,b){var c=false;var f=YAHOO.util.Assert;for(var a=0;a0){var b=YAHOO.util.Assert;b.fail(b._formatMessage(a,"Array should be empty."));}},isNotEmpty:function(c,a){if(c.length===0){var b=YAHOO.util.Assert;b.fail(b._formatMessage(a,"Array should not be empty."));}},itemsAreSame:function(d,f,c){var a=Math.max(d.length,f.length||0);var e=YAHOO.util.Assert;for(var b=0;b=0;b--){if(d[b]===e){f.areEqual(a,b,f._formatMessage(c,"Value exists at index "+b+" but should be at index "+a+"."));return;}}f.fail(f._formatMessage(c,"Value doesn't exist in array."));}};YAHOO.namespace("util");YAHOO.util.ObjectAssert={propertiesAreEqual:function(d,g,c){var f=YAHOO.util.Assert;var b=[];for(var e in d){b.push(e);}for(var a=0;a

'+a.toUpperCase()+" "+c+"

";},init:function(){if(YAHOO.tool.TestRunner){this.setTestRunner(YAHOO.tool.TestRunner);}this.hideSource("global");this.hideSource("LogReader");this.hideCategory("warn");this.hideCategory("window");this.hideCategory("time");this.clearConsole();},clearTestRunner:function(){if(this._runner){this._runner.unsubscribeAll();this._runner=null;}},setTestRunner:function(a){if(this._runner){this.clearTestRunner();}this._runner=a;a.subscribe(a.TEST_PASS_EVENT,this._handleTestRunnerEvent,this,true);a.subscribe(a.TEST_FAIL_EVENT,this._handleTestRunnerEvent,this,true);a.subscribe(a.TEST_IGNORE_EVENT,this._handleTestRunnerEvent,this,true);a.subscribe(a.BEGIN_EVENT,this._handleTestRunnerEvent,this,true);a.subscribe(a.COMPLETE_EVENT,this._handleTestRunnerEvent,this,true);a.subscribe(a.TEST_SUITE_BEGIN_EVENT,this._handleTestRunnerEvent,this,true);a.subscribe(a.TEST_SUITE_COMPLETE_EVENT,this._handleTestRunnerEvent,this,true);a.subscribe(a.TEST_CASE_BEGIN_EVENT,this._handleTestRunnerEvent,this,true);a.subscribe(a.TEST_CASE_COMPLETE_EVENT,this._handleTestRunnerEvent,this,true);},_handleTestRunnerEvent:function(d){var a=YAHOO.tool.TestRunner;var c="";var b="";switch(d.type){case a.BEGIN_EVENT:c="Testing began at "+(new Date()).toString()+".";b="info";break;case a.COMPLETE_EVENT:c="Testing completed at "+(new Date()).toString()+".\nPassed:"+d.results.passed+" Failed:"+d.results.failed+" Total:"+d.results.total;b="info";break;case a.TEST_FAIL_EVENT:c=d.testName+": "+d.error.getMessage();b="fail";break;case a.TEST_IGNORE_EVENT:c=d.testName+": ignored.";b="ignore";break;case a.TEST_PASS_EVENT:c=d.testName+": passed.";b="pass";break;case a.TEST_SUITE_BEGIN_EVENT:c='Test suite "'+d.testSuite.name+'" started.';b="info";break;case a.TEST_SUITE_COMPLETE_EVENT:c='Test suite "'+d.testSuite.name+'" completed.\nPassed:'+d.results.passed+" Failed:"+d.results.failed+" Total:"+d.results.total;b="info";break;case a.TEST_CASE_BEGIN_EVENT:c='Test case "'+d.testCase.name+'" started.';b="info";break;case a.TEST_CASE_COMPLETE_EVENT:c='Test case "'+d.testCase.name+'" completed.\nPassed:'+d.results.passed+" Failed:"+d.results.failed+" Total:"+d.results.total;b="info";break;default:c="Unexpected event "+d.type;c="info";}YAHOO.log(c,b,"TestRunner");}});YAHOO.namespace("tool.TestFormat");(function(){YAHOO.tool.TestFormat.JSON=function(b){return YAHOO.lang.JSON.stringify(b);};function a(b){return b.replace(/["'<>&]/g,function(d){switch(d){case"<":return"<";case">":return">";case'"':return""";case"'":return"'";case"&":return"&";}});}YAHOO.tool.TestFormat.XML=function(c){function b(f){var d=YAHOO.lang,e="<"+f.type+' name="'+a(f.name)+'"';if(d.isNumber(f.duration)){e+=' duration="'+f.duration+'"';}if(f.type=="test"){e+=' result="'+f.result+'" message="'+a(f.message)+'">';}else{e+=' passed="'+f.passed+'" failed="'+f.failed+'" ignored="'+f.ignored+'" total="'+f.total+'">';for(var g in f){if(d.hasOwnProperty(f,g)&&d.isObject(f[g])&&!d.isArray(f[g])){e+=b(f[g]);}}}e+="";return e;}return''+b(c);};YAHOO.tool.TestFormat.JUnitXML=function(b){function c(f){var d=YAHOO.lang,e="",g;switch(f.type){case"test":if(f.result!="ignore"){e='';if(f.result=="fail"){e+='";}e+="";}break;case"testcase":e='';for(g in f){if(d.hasOwnProperty(f,g)&&d.isObject(f[g])&&!d.isArray(f[g])){e+=c(f[g]);}}e+="";break;case"testsuite":for(g in f){if(d.hasOwnProperty(f,g)&&d.isObject(f[g])&&!d.isArray(f[g])){e+=c(f[g]);}}break;case"report":e="";for(g in f){if(d.hasOwnProperty(f,g)&&d.isObject(f[g])&&!d.isArray(f[g])){e+=c(f[g]);}}e+="";}return e;}return''+c(b); };YAHOO.tool.TestFormat.TAP=function(c){var d=1;function b(f){var e=YAHOO.lang,g="";switch(f.type){case"test":if(f.result!="ignore"){g="ok "+(d++)+" - "+f.name;if(f.result=="fail"){g="not "+g+" - "+f.message;}g+="\n";}else{g="#Ignored test "+f.name+"\n";}break;case"testcase":g="#Begin testcase "+f.name+"("+f.failed+" failed of "+f.total+")\n";for(prop in f){if(e.hasOwnProperty(f,prop)&&e.isObject(f[prop])&&!e.isArray(f[prop])){g+=b(f[prop]);}}g+="#End testcase "+f.name+"\n";break;case"testsuite":g="#Begin testsuite "+f.name+"("+f.failed+" failed of "+f.total+")\n";for(prop in f){if(e.hasOwnProperty(f,prop)&&e.isObject(f[prop])&&!e.isArray(f[prop])){g+=b(f[prop]);}}g+="#End testsuite "+f.name+"\n";break;case"report":for(prop in f){if(e.hasOwnProperty(f,prop)&&e.isObject(f[prop])&&!e.isArray(f[prop])){g+=b(f[prop]);}}}return g;}return"1.."+c.total+"\n"+b(c);};})();YAHOO.namespace("tool.CoverageFormat");YAHOO.tool.CoverageFormat.JSON=function(a){return YAHOO.lang.JSON.stringify(a);};YAHOO.tool.CoverageFormat.XdebugJSON=function(b){var a={},c;for(c in b){if(b.hasOwnProperty(c)){a[c]=b[c].lines;}}return YAHOO.lang.JSON.stringify(a);};YAHOO.namespace("tool");YAHOO.tool.TestReporter=function(a,b){this.url=a;this.format=b||YAHOO.tool.TestFormat.XML;this._fields=new Object();this._form=null;this._iframe=null;};YAHOO.tool.TestReporter.prototype={constructor:YAHOO.tool.TestReporter,_convertToISOString:function(a){function b(c){return c<10?"0"+c:c;}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"Z";},addField:function(a,b){this._fields[a]=b;},clearFields:function(){this._fields=new Object();},destroy:function(){if(this._form){this._form.parentNode.removeChild(this._form);this._form=null;}if(this._iframe){this._iframe.parentNode.removeChild(this._iframe);this._iframe=null;}this._fields=null;},report:function(a){if(!this._form){this._form=document.createElement("form");this._form.method="post";this._form.style.visibility="hidden";this._form.style.position="absolute";this._form.style.top=0;document.body.appendChild(this._form);if(YAHOO.env.ua.ie){this._iframe=document.createElement('