127 lines
2.5 KiB
JavaScript
127 lines
2.5 KiB
JavaScript
|
|
||
|
/**
|
||
|
* 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 )
|
||
|
{
|
||
|
this._jQuery = jquery;
|
||
|
this._cases = cases;
|
||
|
this._runner = rectest.TestRunner( jquery, rectest.TestRun );
|
||
|
},
|
||
|
|
||
|
|
||
|
'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;
|
||
|
},
|
||
|
|
||
|
|
||
|
'public displayNotice': function( str )
|
||
|
{
|
||
|
this._jQuery( '.notice' )
|
||
|
.text( str )
|
||
|
.slideDown( 250, function()
|
||
|
{
|
||
|
$( this ).addClass( 'active' );
|
||
|
} );
|
||
|
|
||
|
return this;
|
||
|
},
|
||
|
|
||
|
|
||
|
'public hideNotice': function()
|
||
|
{
|
||
|
$( '.notice' ).slideUp( 250, function()
|
||
|
{
|
||
|
$( this ).removeClass( 'active' );
|
||
|
} );
|
||
|
|
||
|
return this;
|
||
|
},
|
||
|
|
||
|
|
||
|
'bindContinue': function( $element, callback )
|
||
|
{
|
||
|
var _self = this,
|
||
|
$body = this._jQuery( 'body' );
|
||
|
|
||
|
$element.click( function()
|
||
|
{
|
||
|
var options = _self._getOptions(),
|
||
|
testcase = _self._cases[ options['case'] ].testCase();
|
||
|
|
||
|
$body.addClass( 'testing' );
|
||
|
|
||
|
_self._runner.run( testcase, options, function( history )
|
||
|
{
|
||
|
$body.removeClass( 'testing' );
|
||
|
|
||
|
console.log( history );
|
||
|
console.log( 'done' );
|
||
|
} );
|
||
|
|
||
|
callback.call( _self.__inst );
|
||
|
} );
|
||
|
|
||
|
return this;
|
||
|
},
|
||
|
|
||
|
|
||
|
'private _getOptions': function()
|
||
|
{
|
||
|
var options = {},
|
||
|
values = [
|
||
|
'case', 'set', 'interval', 'blank', 'samples', 'delay'
|
||
|
],
|
||
|
i = values.length;
|
||
|
|
||
|
while ( i-- )
|
||
|
{
|
||
|
var id = values[ i ];
|
||
|
options[ id ] = this._jQuery( '#' + id ).val();
|
||
|
}
|
||
|
|
||
|
return options;
|
||
|
}
|
||
|
} );
|