1 $(document).ready(function() {
2 var Runner = function( ) {
6 frame: window.frames[ "testFrame" ],
8 testTimeout: 3 * 60 * 1000,
10 $frameElem: $( "#testFrame" ),
12 assertionResultPrefix: "assertion result for test:",
14 onTimeout: QUnit.start,
16 onFrameLoad: function() {
17 // establish a timeout for a given suite in case of async tests hanging
18 self.testTimer = setTimeout( self.onTimeout, self.testTimeout );
20 // it might be a redirect with query params for push state
21 // tests skip this call and expect another
22 if( !self.frame.QUnit ) {
23 self.$frameElem.one( "load", self.onFrameLoad );
27 // when the QUnit object reports done in the iframe
28 // run the onFrameDone method
29 self.frame.QUnit.done = self.onFrameDone;
30 self.frame.QUnit.testDone = self.onTestDone;
33 onTestDone: function( result ) {
34 QUnit.ok( !(result.failed > 0), result.name );
35 //self.recordAssertions( result.total - result.failed, result.name );
38 onFrameDone: function( failed, passed, total, runtime ){
39 // make sure we don't time out the tests
40 clearTimeout( self.testTimer );
42 // TODO decipher actual cause of multiple test results firing twice
43 // clear the done call to prevent early completion of other test cases
44 self.frame.QUnit.done = $.noop;
45 self.frame.QUnit.testDone = $.noop;
47 // hide the extra assertions made to propogate the count
48 // to the suite level test
49 self.hideAssertionResults();
51 // continue on to the next suite
55 recordAssertions: function( count, parentTest ) {
56 for( var i = 0; i < count; i++ ) {
57 ok( true, self.assertionResultPrefix + parentTest );
61 hideAssertionResults: function() {
62 $( "li:not([id]):contains('" + self.assertionResultPrefix + "')" ).hide();
65 exec: function( data ) {
66 var template = self.$frameElem.attr( "data-src" );
68 $.each( data.testPages, function(i, dir) {
69 QUnit.asyncTest( dir, function() {
70 console.log('Test start: ' + dir);
72 self.$frameElem.one( "load", self.onFrameLoad );
73 self.$frameElem.attr( "src", template.replace("{{testfile}}", dir + '/index.html') );
77 // having defined all suite level tests let QUnit run
83 // prevent qunit from starting the test suite until all tests are defined
84 QUnit.begin = function( ) {
85 this.config.autostart = false;
86 this.config.reorder = false;
89 QUnit.done = function( details ) {
91 setCookie( "TizenP", details.passed );
92 setCookie( "TizenF", details.failed );
93 setCookie( "TizenR", details.runtime );
94 setCookie( "TizenT", details.total );
95 location.href = "../jqm-tchelper/result.php";
98 // get the test directories
99 new Runner().exec(TESTS);