From 920d5a7b283a7485b2ee2178f9723c2bd032bdbb Mon Sep 17 00:00:00 2001 From: "hjnim.kim" Date: Wed, 28 Nov 2012 15:10:32 +0900 Subject: [PATCH] UnitTest:JQM Unit TC helper has been added,TCs have been modified JQM Tc helper and log module has been added. If you want to use this module, navigate /web-ui-fw/tests/jqm-helper/ in emulator, target device. Change-Id: I459970d152d445954bb6e0b701d14abe8aea95ab --- .../tests/unit/button-markup/index.html | 2 +- .../tests/unit/button/index.html | 1 + .../tests/unit/checkboxradio/index.html | 1 + .../tests/unit/collapsible/index.html | 1 + .../tests/unit/controlgroup/index.html | 1 + .../jquery-mobile-1.2.0/tests/unit/core/index.html | 1 + .../tests/unit/degrade-inputs/index.html | 1 + .../tests/unit/dialog/index.html | 1 + .../tests/unit/field-contain/index.html | 1 + .../tests/unit/fixed-toolbar/index.html | 1 + .../jquery-mobile-1.2.0/tests/unit/init/index.html | 1 + .../tests/unit/kitchensink/index.html | 2 + .../tests/unit/listview/index.html | 1 + .../tests/unit/loader/index.html | 1 + .../tests/unit/media/index.html | 1 + .../tests/unit/navbar/index.html | 1 + .../tests/unit/navigation/index.html | 3 +- .../tests/unit/page-sections/index.html | 1 + .../jquery-mobile-1.2.0/tests/unit/page/index.html | 1 + .../tests/unit/popup/index.html | 1 + .../tests/unit/select/index.html | 1 + .../tests/unit/slider/index.html | 1 + .../tests/unit/support/index.html | 1 + .../tests/unit/textinput/index.html | 1 + .../tests/unit/widget/index.html | 1 + .../jquery-mobile-1.2.0/tests/unit/zoom/index.html | 1 + tests/jqm-tchelper/index.html | 76 +++++++++++ tests/jqm-tchelper/jquery.browser.js | 117 ++++++++++++++++ tests/jqm-tchelper/log.php | 84 ++++++++++++ tests/jqm-tchelper/result.php | 86 ++++++++++++ tests/jqm-tchelper/tizen.testHelper.js | 151 +++++++++++++++++++++ tests/unit-tests/runner.js | 4 + 32 files changed, 546 insertions(+), 2 deletions(-) create mode 100644 tests/jqm-tchelper/index.html create mode 100644 tests/jqm-tchelper/jquery.browser.js create mode 100644 tests/jqm-tchelper/log.php create mode 100644 tests/jqm-tchelper/result.php create mode 100644 tests/jqm-tchelper/tizen.testHelper.js diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/button-markup/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/button-markup/index.html index ec27844..a86bb5f 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/button-markup/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/button-markup/index.html @@ -26,7 +26,7 @@ - + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/button/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/button/index.html index b0ebe4e..ddacb5b 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/button/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/button/index.html @@ -14,6 +14,7 @@ + + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/collapsible/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/collapsible/index.html index 1492ded..999b99a 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/collapsible/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/collapsible/index.html @@ -27,6 +27,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/controlgroup/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/controlgroup/index.html index 1b4b9c1..5d1c059 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/controlgroup/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/controlgroup/index.html @@ -27,6 +27,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/core/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/core/index.html index 4cad369..2a37311 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/core/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/core/index.html @@ -26,6 +26,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/degrade-inputs/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/degrade-inputs/index.html index a847f9a..4db1759 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/degrade-inputs/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/degrade-inputs/index.html @@ -21,6 +21,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/dialog/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/dialog/index.html index d9ddd74..32a69f0 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/dialog/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/dialog/index.html @@ -34,6 +34,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/field-contain/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/field-contain/index.html index 1be5157..645821c 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/field-contain/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/field-contain/index.html @@ -26,6 +26,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/fixed-toolbar/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/fixed-toolbar/index.html index 0701d88..dcadb6f 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/fixed-toolbar/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/fixed-toolbar/index.html @@ -22,6 +22,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/init/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/init/index.html index 6a6c07c..b36fff4 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/init/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/init/index.html @@ -17,6 +17,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/kitchensink/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/kitchensink/index.html index 4307d42..11adf29 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/kitchensink/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/kitchensink/index.html @@ -23,6 +23,8 @@ + + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/listview/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/listview/index.html index 8d210fb..4e9d7c5 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/listview/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/listview/index.html @@ -34,6 +34,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/loader/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/loader/index.html index 85a8d6f..fb96744 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/loader/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/loader/index.html @@ -14,6 +14,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/media/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/media/index.html index 52c39a5..e722070 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/media/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/media/index.html @@ -25,6 +25,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/navbar/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/navbar/index.html index 27fd46e..d7d4f55 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/navbar/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/navbar/index.html @@ -25,6 +25,7 @@ +

jQuery Mobile Navigation Test Suite

diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/navigation/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/navigation/index.html index 0c06073..f7131dc 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/navigation/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/navigation/index.html @@ -15,9 +15,10 @@ - + +
diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/page-sections/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/page-sections/index.html index d3850cf..34563cb 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/page-sections/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/page-sections/index.html @@ -28,6 +28,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/page/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/page/index.html index ab85991..8565864 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/page/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/page/index.html @@ -25,6 +25,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/popup/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/popup/index.html index ca573e7..4fc8147 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/popup/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/popup/index.html @@ -28,6 +28,7 @@ +
diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/select/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/select/index.html index a288e2e..1365abf 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/select/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/select/index.html @@ -30,6 +30,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/slider/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/slider/index.html index 9efff02..024289b 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/slider/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/slider/index.html @@ -27,6 +27,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/support/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/support/index.html index dac7fb2..837cb3e 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/support/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/support/index.html @@ -26,6 +26,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/textinput/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/textinput/index.html index 8d33a3c..f075974 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/textinput/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/textinput/index.html @@ -22,6 +22,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/widget/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/widget/index.html index 70361f3..61ae215 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/widget/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/widget/index.html @@ -29,6 +29,7 @@ + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/zoom/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/zoom/index.html index 84eb44a..d283ffb 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/zoom/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/zoom/index.html @@ -26,6 +26,7 @@ + diff --git a/tests/jqm-tchelper/index.html b/tests/jqm-tchelper/index.html new file mode 100644 index 0000000..339717c --- /dev/null +++ b/tests/jqm-tchelper/index.html @@ -0,0 +1,76 @@ + + + + + + + + + +
+
OS :
+
Browser :
+
Version :
+ +
+ + + + + + \ No newline at end of file diff --git a/tests/jqm-tchelper/jquery.browser.js b/tests/jqm-tchelper/jquery.browser.js new file mode 100644 index 0000000..7da0faa --- /dev/null +++ b/tests/jqm-tchelper/jquery.browser.js @@ -0,0 +1,117 @@ +var BrowserDetect = { + init: function () { + this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; + this.version = this.searchVersion(navigator.userAgent) + || this.searchVersion(navigator.appVersion) + || "an unknown version"; + this.OS = this.searchString(this.dataOS) || "an unknown OS"; + }, + searchString: function (data) { + for (var i=0;ifileName = $fileName; + $this->filePath = $this->basePath . DIRECTORY_SEPARATOR . $this->filesDir . DIRECTORY_SEPARATOR; + } + public function createFile($writeMode) { + if($this->fileHandle = fopen($this->filePath . $this->fileName, $writeMode)) { + return true; + } + return false; + } + + public function closeFile(){ + fclose($this->fileHandle); + } + + public function writeToFile($dataToInsert) { + self::createFile('w'); + if(fwrite($this->fileHandle , $dataToInsert)) { + return true; + } + self::closeFile(); + return false; + } + public function appendToFile($dataToInsert){ + self::createFile('a'); + if(fwrite($this->fileHandle , $dataToInsert)) { + return true; + } + self::closeFile(); + return false; + } + + public function readFromFile($bytesToRead = 0){ + self::createFile('r'); + if($bytesToRead > 0) { + if($result = fread($this->fileHandle , $bytesToRead)) { + return $result; + } + } else { + if($result = fread($this->fileHandle , filesize($this->filePath . $this->fileName))) { + return $result; + } + } + self::closeFile(); + return false; + } +} + +?> + +appendToFile( $_POST["currentTest"]."|". $obj["result"] ."|". $obj["actual"] ."|". $obj["expected"] ."|". $obj["message"] ."|". $obj["source"] ."\n" ); + $file->closeFile(); + echo $_POST["currentTest"]."|". $obj["result"] ."|". $obj["actual"] ."|". $obj["expected"] ."|". $obj["message"] ."|". $obj["source"]; + }else{ + echo "nofile"; + } + + if( $_REQUEST["reset"] ) + { + $file = new SevFile("log.txt"); + $file->writeToFile(""); + $file->closeFile(); + echo "reset"; + } +?> \ No newline at end of file diff --git a/tests/jqm-tchelper/result.php b/tests/jqm-tchelper/result.php new file mode 100644 index 0000000..8da23ef --- /dev/null +++ b/tests/jqm-tchelper/result.php @@ -0,0 +1,86 @@ + + + + + + + +

Test Report

+
+ + + + + + + + + + + + + + + +
Device Information +
Operation System
Browser Information
Versions
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
Test summary +
Tests total
Tests Passed
Tests Failed
Time(m seconds)
+
+ + \ No newline at end of file diff --git a/tests/jqm-tchelper/tizen.testHelper.js b/tests/jqm-tchelper/tizen.testHelper.js new file mode 100644 index 0000000..3fa5667 --- /dev/null +++ b/tests/jqm-tchelper/tizen.testHelper.js @@ -0,0 +1,151 @@ +/* + * Goal + * - Run button/index.html -> buttonMarkup/index.html automatically in one browser + * - Summarize result of each test suite + * - pass current summary data by GET variables + * - Get current summary data by parsing URL to get those GET variables + * + * Issues + * - Some testcases may change URL during test + * It is a not complete versionc. Optimization, refactoring is needed + */ +( function ( ) { + + var QueryString = function () { + var query_string = {}, + vars, + pair, + arr, + query = window.location.search.substring(1); + + vars = query.split("&"); + + for (var i = 0 ; i < vars.length ; i++) + { + pair = vars[i].split("="); + if (typeof query_string[pair[0]] === "undefined") + { + query_string[pair[0]] = pair[1]; + } + else if (typeof query_string[pair[0]] === "string") + { + arr = [ query_string[pair[0]], pair[1] ]; + query_string[pair[0]] = arr; + } else { + query_string[pair[0]].push(pair[1]); + } + } + return query_string; + } (); +/* + except : listview, event +*/ + var tests = [ + "button", + "button-markup", + "navigation", + "zoom", + "checkboxradio", + "collapsible", + "controlgroup", + "core", + "degrade-inputs", + "dialog", + "field-contain", + "fixed-toolbar", + "init", + "loader", + "textinput", + "support", + "media", + "kitchensink", + "navbar", + "page", + "page-sections", + "select", + "slider", + "widget" + ], + + passCount, failCount, totalCount, runtime, + currenTest, + url; + + function getCurrentURL ( ) { + return window.location.href; + } + function getURLParameter(name) { + return decodeURI( + (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] + ); +} + url = getCurrentURL( ); + + ( function parseURL ( url ) { + // TODO + var loc, + dir; + passCount = ( typeof QueryString.p === "undefined" ) ? 0 : parseInt( QueryString.p ); + failCount = ( typeof QueryString.f === "undefined" ) ? 0 : parseInt( QueryString.f ); + totalCount = ( typeof QueryString.t === "undefined" ) ? 0 : parseInt( QueryString.t ); + runTime = ( typeof QueryString.r === "undefined" ) ? 0 : parseInt( QueryString.r ); + + loc = window.location.pathname; + dirs = loc.substring(0, loc.lastIndexOf('/')).split('/'); + currentTest = dirs[dirs.length-1]; + } ( url ) ); + QUnit.log = function( obj ) { + var tempUrl = url; + if( obj.result ) { + if ( tempUrl.indexOf("?")>-1 ) { + tempUrl = tempUrl.substr(0,tempUrl.indexOf("?")); + } + $.post( tempUrl + "../../../../../../tests/jqm-tchelper/log.php", { currentTest : currentTest, obj : obj } , function(){}); + } + }; + QUnit.done = function ( details ) { + var nextTestURL; + + function getNextTestURL( currentTest, passCount, failCount, totalCount , runTime ) { + var i = 0, + nextUrl = "", + updir = "../"; + for( i = 0 ; i < tests.length ; i++ ) + { + if( tests[i] == currentTest ) + { + break; + } + } + + if( tests.length -1 == i || + currentTest === "listview" || + currentTest === "event" ) + { + //Goto result Page + nextUrl ="../../../../../../tests/jqm-tchelper/result.php" + "?" + "p=" + passCount + "&f=" + failCount + "&t=" + totalCount + "&r=" + runTime; + }else{ + if( currentTest === "navigation" ) + { + updir += "../../"; + } + nextUrl = updir + tests[i + 1] +"/?" + "p=" + passCount + "&f=" + failCount + "&t=" + totalCount + "&r=" + runTime; + } + + return nextUrl; + } + function gotoURL( url ) { + window.location.href = url; + return; + } + + passCount += details.passed; + failCount += details.failed; + totalCount += details.total; + runTime += details.runtime; + + nextTestURL = getNextTestURL( currentTest, passCount, failCount, totalCount ,runTime ); + gotoURL( nextTestURL ); + + }; +} () ); diff --git a/tests/unit-tests/runner.js b/tests/unit-tests/runner.js index 7ea8d94..6381612 100644 --- a/tests/unit-tests/runner.js +++ b/tests/unit-tests/runner.js @@ -85,6 +85,10 @@ $(document).ready(function() { this.config.autostart = false; }; + QUnit.done = function( details ) { + location.href = "../jqm-tchelper/result.php?t=" + details.total + "&p=" + details.passed + "&f=" + details.failed + "&r=" + details.runtime; + }; + // get the test directories new Runner().exec(TESTS); }); -- 2.7.4