2012-03-03 20:53:23 -05:00
|
|
|
/**
|
|
|
|
* Facade for the entire application
|
|
|
|
*/
|
|
|
|
rectest.RecTest = Class( 'RecTest',
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* jQuery instance
|
|
|
|
* @var {jQuery}
|
|
|
|
*/
|
|
|
|
'private _jQuery': null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Supported test cases
|
|
|
|
* @var {Object}
|
|
|
|
*/
|
|
|
|
'private _cases': {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Runs test configurations
|
|
|
|
* @var {TestRunner}
|
|
|
|
*/
|
|
|
|
'private _runner': null,
|
|
|
|
|
|
|
|
|
|
|
|
__construct: function( jquery, cases )
|
|
|
|
{
|
2012-03-04 07:31:04 -05:00
|
|
|
this._jQuery = jquery;
|
|
|
|
this._cases = cases;
|
|
|
|
this._runner = rectest.TestRunner(
|
|
|
|
jquery, rectest.set.SetFactory()
|
|
|
|
);
|
2012-03-03 20:53:23 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
'public init': function()
|
|
|
|
{
|
|
|
|
// display js-dependent content
|
|
|
|
this._jQuery( '.hasjs' ).removeClass( 'hasjs' );
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
'public listCases': function( $select )
|
|
|
|
{
|
|
|
|
for ( var preset in this._cases )
|
|
|
|
{
|
|
|
|
var data = this._cases[ preset ];
|
|
|
|
|
|
|
|
$select.append( this._jQuery( '<option>' )
|
|
|
|
.attr( 'value', preset )
|
|
|
|
.text( data.title )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2012-03-03 23:33:16 -05:00
|
|
|
'public goConfig': function()
|
2012-03-03 20:53:23 -05:00
|
|
|
{
|
2012-03-03 23:33:16 -05:00
|
|
|
this._jQuery( 'body' )
|
|
|
|
.removeClass( 'pending' )
|
|
|
|
.removeClass( 'testing' )
|
|
|
|
;
|
2012-03-03 20:53:23 -05:00
|
|
|
|
2012-03-03 23:33:16 -05:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
'public goVerify': function()
|
|
|
|
{
|
|
|
|
this._jQuery( 'body' ).addClass( 'pending' );
|
|
|
|
return this;
|
|
|
|
},
|
2012-03-03 20:53:23 -05:00
|
|
|
|
|
|
|
|
2012-03-03 23:33:16 -05:00
|
|
|
'public run': function()
|
|
|
|
{
|
|
|
|
var _self = this,
|
|
|
|
$body = this._jQuery( 'body' ),
|
|
|
|
options = this._getOptions(),
|
|
|
|
testcase = this._cases[ options['case'] ].testCase();
|
|
|
|
|
|
|
|
$body.addClass( 'testing' ).removeClass( 'pending' );
|
2012-03-03 20:53:23 -05:00
|
|
|
|
2012-03-03 23:33:16 -05:00
|
|
|
this._runner.run( testcase, options, function( history )
|
|
|
|
{
|
|
|
|
_self.goConfig();
|
2012-03-03 20:53:23 -05:00
|
|
|
|
2012-03-03 23:33:16 -05:00
|
|
|
console.log( history );
|
|
|
|
console.log( 'done' );
|
2012-03-03 20:53:23 -05:00
|
|
|
} );
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
'private _getOptions': function()
|
|
|
|
{
|
|
|
|
var options = {},
|
|
|
|
values = [
|
2012-03-04 07:31:04 -05:00
|
|
|
'case', 'set', 'ralgo', 'interval', 'blank', 'samples', 'delay'
|
2012-03-03 20:53:23 -05:00
|
|
|
],
|
|
|
|
i = values.length;
|
|
|
|
|
|
|
|
while ( i-- )
|
|
|
|
{
|
|
|
|
var id = values[ i ];
|
|
|
|
options[ id ] = this._jQuery( '#' + id ).val();
|
|
|
|
}
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
} );
|