TestManager.js revision b33d3bf66f037e3c87d1b857d3706eee0072e0cd
Y.namespace("Test");
/**
* Runs pages containing test suite definitions.
* @namespace Test
* @class Manager
* @static
*/
/**
* Constant for the testpagebegin custom event
* @property TEST_PAGE_BEGIN_EVENT
* @static
* @type string
* @final
*/
/**
* Constant for the testpagecomplete custom event
* @property TEST_PAGE_COMPLETE_EVENT
* @static
* @type string
* @final
*/
/**
* Constant for the testmanagerbegin custom event
* @property TEST_MANAGER_BEGIN_EVENT
* @static
* @type string
* @final
*/
/**
* Constant for the testmanagercomplete custom event
* @property TEST_MANAGER_COMPLETE_EVENT
* @static
* @type string
* @final
*/
//-------------------------------------------------------------------------
// Private Properties
//-------------------------------------------------------------------------
/**
* The URL of the page currently being executed.
* @type String
* @private
* @property _curPage
* @static
*/
_curPage /*:String*/ : null,
/**
* The frame used to load and run tests.
* @type Window
* @private
* @property _frame
* @static
*/
_frame /*:Window*/ : null,
/**
* The logger used to output results from the various tests.
* @type YAHOO.tool.TestLogger
* @private
* @property _logger
* @static
*/
_logger : null,
/**
* The timeout ID for the next iteration through the tests.
* @type int
* @private
* @property _timeoutId
* @static
*/
/**
* Array of pages to load.
* @type String[]
* @private
* @property _pages
* @static
*/
_pages /*:String[]*/ : [],
/**
* Aggregated results
* @type Object
* @private
* @property _results
* @static
*/
_results: null,
//-------------------------------------------------------------------------
// Private Methods
//-------------------------------------------------------------------------
/**
* Handles TestRunner.COMPLETE_EVENT, storing the results and beginning
* the loop again.
* @param {Object} data Data about the event.
* @return {Void}
* @private
* @static
*/
this.fireEvent(this.TEST_PAGE_COMPLETE_EVENT, {
});
//save results
//this._results[this.curPage] = data.results;
//process 'em
this._logger.clearTestRunner();
//if there's more to do, set a timeout to begin again
this._timeoutId = setTimeout(function(){
}, 1000);
} else {
}
},
/**
* Processes the results of a test page run, outputting log messages
* for failed tests.
* @return {Void}
* @private
* @static
*/
var r = this._results;
} else {
}
},
/**
* Loads the next test page into the iframe.
* @return {Void}
* @static
* @private
*/
_run : function () /*:Void*/ {
//set the current page
//load the frame - destroy history in case there are other iframes that
//need testing
},
//-------------------------------------------------------------------------
// Public Methods
//-------------------------------------------------------------------------
/**
* Signals that a test page has been loaded. This should be called from
* within the test page itself to notify the TestManager that it is ready.
* @return {Void}
* @static
*/
load : function () /*:Void*/ {
} else {
if (this._frame) {
//assign event handling
//run it
TestRunner.run();
}
}
},
/**
* Sets the pages to be loaded.
* @param {String[]} pages An array of URLs to load.
* @return {Void}
* @static
*/
},
/**
* Begins the process of running the tests.
* @return {Void}
* @static
*/
start : function () /*:Void*/ {
if (!this._initialized) {
/**
* Fires when loading a test page
* @event testpagebegin
* @param curPage {string} the page being loaded
* @static
*/
this.createEvent(this.TEST_PAGE_BEGIN_EVENT);
/**
* Fires when a test page is complete
* @event testpagecomplete
* @param obj {page: string, results: object} the name of the
* page that was loaded, and the test suite results
* @static
*/
this.createEvent(this.TEST_PAGE_COMPLETE_EVENT);
/**
* Fires when the test manager starts running all test pages
* @event testmanagerbegin
* @static
*/
this.createEvent(this.TEST_MANAGER_BEGIN_EVENT);
/**
* Fires when the test manager finishes running all test pages. External
* test runners should subscribe to this event in order to get the
* aggregated test results.
* @event testmanagercomplete
* @param obj { pages_passed: int, pages_failed: int, tests_passed: int
* tests_failed: int, passed: string[], failed: string[],
* page_results: {} }
* @static
*/
this.createEvent(this.TEST_MANAGER_COMPLETE_EVENT);
//create iframe if not already available
if (!this._frame){
}
//create test logger if not already available
//if (!this._logger){
// this._logger = new YAHOO.tool.TestLogger();
//}
this._initialized = true;
}
// reset the results cache
this._results = {
passed: 0,
failed: 0,
ignored: 0,
total: 0,
type: "report",
name: "YUI Test Results",
failedPages:[],
passedPages:[]
/*
// number of pages that pass
pages_passed: 0,
// number of pages that fail
pages_failed: 0,
// total number of tests passed
tests_passed: 0,
// total number of tests failed
tests_failed: 0,
// array of pages that passed
passed: [],
// array of pages that failed
failed: [],
// map of full results for each page
page_results: {}*/
};
this.fireEvent(this.TEST_MANAGER_BEGIN_EVENT, null);
this._run();
},
/**
* Stops the execution of tests.
* @return {Void}
* @static
*/
stop : function () /*:Void*/ {
clearTimeout(this._timeoutId);
}
};