Update tcresult.xml set by set
authorhjnim.kim <hjnim.kim@samsung.com>
Tue, 10 Sep 2013 05:16:32 +0000 (14:16 +0900)
committerhjnim.kim <hjnim.kim@samsung.com>
Wed, 11 Sep 2013 02:57:27 +0000 (11:57 +0900)
Web UI FW TC update tcresult.xml set by set

Change-Id: I9b668f0addf39adea765fde0f66f62d992bb3d1d

tct-webuifw-tests/tests/unit-tests/runner.js

index cfa358b933e5a3f0639fcb0dc044555432b52f5f..4ddd7e38412db92a3814662a786a6a5ec3c89d3b 100644 (file)
@@ -129,6 +129,13 @@ $(document).ready(function() {
                        },
 
                        onFrameDone: function( failed, passed, total, runtime ){
+                               // make result object
+                               var details = { };
+                               details.failed = failed;
+                               details.passed = passed;
+                               details.total = total;
+                               details.time = runtime;
+
                                // make sure we don't time out the tests
                                clearTimeout( self.testTimer );
 
@@ -140,14 +147,18 @@ $(document).ready(function() {
                                // hide the extra assertions made to propogate the count
                                // to the suite level test
                                self.hideAssertionResults();
-                               // continue on to the next suite
-                               QUnit.start();
+
+                               generateReport( details, UnitTCRunner.getTestResult(), false );
                        },
 
                        getTestResult: function() {
                                return currentRun;
                        },
 
+                       getCurrentTest: function() {
+                               return currentTest;
+                       },
+
                        recordAssertions: function( count, parentTest ) {
                                for( var i = 0; i < count; i++ ) {
                                        ok( true, self.assertionResultPrefix + parentTest );
@@ -220,7 +231,7 @@ $(document).ready(function() {
                                        device_model: "SDK, Target",
                                        device_name: "Tizen",
                                        host: navigator.userAgent,
-                                       os_version:"2.1", 
+                                       os_version:"2.2",
                                        resolution: "", 
                                        screen_size: $(window).height() + " x " + $(window).width()
                                } );
@@ -232,7 +243,7 @@ $(document).ready(function() {
                };
        };
        //Generate XML
-       var generateReport = function(results, run) {
+       var generateReport = function(results, run, end) {
                var pad = function(n) {
                        return n < 10 ? '0' + n : n;
                };
@@ -344,10 +355,13 @@ $(document).ready(function() {
 
                // Generate JUnit XML report!
                var m, mLen, module, t, tLen, test, a, aLen, assertion, isEmptyElement,
-                       rn, trn,
+                       rn, trn, currentTest,
                        xmlWriter = new XmlWriter({
                                linebreak_at: ['testsuites', 'testsuite', 'testcase', 'failure', 'system-out', 'system-err']
                        });
+               if(!end) {
+                       currentTest = QUnit.config.current.testName;
+               }
                xmlWriter.pi ( 'xml-stylesheet type="text/xsl"  href="testresult.xsl"' );
                xmlWriter.start('test_definition', {
                        name: "http://tempuri.org",
@@ -355,12 +369,13 @@ $(document).ready(function() {
                        'xmlns:xsi': "http://www.w3.org/2001/XMLSchema-instance",
                        'xsi:noNamespaceSchemaLocation' : "test_definition.xsd"
                });
+
                xmlWriter.start('environment', {
                                        device_id: "",
                                        device_model: "SDK & Target",
                                        device_name: "Tizen",
                                        host: navigator.userAgent,
-                                       os_version:"2.1", 
+                                       os_version:"2.2",
                                        resolution: "", 
                                        screen_size: $(window).height() + " x " + $(window).width()
                                } );
@@ -393,7 +408,11 @@ $(document).ready(function() {
 
                for (m = 0, mLen = run.modules.length; m < mLen; m++) {
                        module = run.modules[m];
-
+                       if( !end ) {
+                               if( currentTest.toLowerCase() != module.name.toLowerCase() ) {
+                                       continue;
+                               }
+                       }
                        xmlWriter.start( 'set', {
                                name: module.name
                        });
@@ -454,16 +473,17 @@ $(document).ready(function() {
                // Invoke the user-defined callback
                QUnit.jUnitReport({
                        results: results,
-                       xml: xmlWriter.getString()
+                       xml: xmlWriter.getString(),
+                       end: end
                });
        };
 
-        function exitAPP(){
-                if(tizen) {
-                        var app = tizen.application.getCurrentApplication();
-                        app.exit();
-                }
-        }
+               function exitAPP(){
+                               if(tizen) {
+                                               var app = tizen.application.getCurrentApplication();
+                                               app.exit();
+                               }
+               }
 
        QUnit.jUnitReport = function(data) {
                var console = window.console;
@@ -484,11 +504,16 @@ $(document).ready(function() {
                                                                function(fs){
                                                                        fs.write(data.xml);
                                                                        fs.close();
-                                                                       setTimeout(exitAPP(), 5000);
+                                                                       if( data.end ) {
+                                                                               setTimeout(exitAPP(), 5000);
+                                                                       } else {
+                                                                               // continue on to the next suite
+                                                                               QUnit.start();
+                                                                       }
                                                        }, function(e){console.log("Error");setTimeout(exitAPP(), 5000);}, "UTF-8");
                                                }else{
-                                                        setTimeout(exitAPP(), 5000);
-                                                }
+                                                               setTimeout(exitAPP(), 5000);
+                                               }
                                        },
                                        function(e){
                                                console.log(e);
@@ -505,7 +530,7 @@ $(document).ready(function() {
        QUnit.done = function( details ) {
                // All Test is done
                console.log( "QUnit.done" );
-               generateReport( details, UnitTCRunner.getTestResult());
+               generateReport( details, UnitTCRunner.getTestResult(), true);
        }
        // get the test directories
        var UnitTCRunner = new Runner();