From cf2d3f46530cd79d6d7c4fb34ad0043b3e94ef8b Mon Sep 17 00:00:00 2001 From: "hjnim.kim" Date: Thu, 10 Jan 2013 14:57:20 +0900 Subject: [PATCH] UnitTC: Pass,error count save method has been changed Unit Test total, pass, error, time count save method has been changed from get parameter to browser cookie. Cause there were some errors while listview, event testing( url navigation problem ) QUnit.log method has been removed cause QUnit object bug and Some JQM TC has been excepted( is not suitable mobile browser ) Change-Id: Ifd4e58e3a82d14f7aaafd621de982f4a9304fcc9 --- .../jquery-mobile-1.2.0/tests/unit/core/index.html | 8 ++- .../tests/unit/event/event_core.js | 11 ++- .../tests/unit/event/index.html | 1 + .../tests/unit/listview/index.html | 2 +- .../tests/unit/support/support_core.js | 6 ++ tests/jqm-tchelper/cookie.js | 21 ++++++ tests/jqm-tchelper/index.html | 45 ++++--------- tests/jqm-tchelper/result.php | 36 +++------- tests/jqm-tchelper/tizen.testHelper.js | 78 +++++++++++++--------- tests/unit-tests/index.html | 2 +- tests/unit-tests/runner.js | 9 ++- 11 files changed, 119 insertions(+), 100 deletions(-) create mode 100644 tests/jqm-tchelper/cookie.js 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 2a37311..e3450e0 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 @@ -17,8 +17,12 @@ ], [ "jquery.mobile.init" ], [ - "core.js", - "core_scroll.js" + "core.js" + // Scroll function to operate asynchronously, this testcases check the async function synchronously. + // e.g. + // $(window).scrollTop(1000); <- scrollTop operate asynchronously + // ok($(window).scrollTop() > 0, $(window).scrollTop()); <- can be problematic + /*"core_scroll.js"*/ ] ]); diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/event/event_core.js b/libs/js/jquery-mobile-1.2.0/tests/unit/event/event_core.js index 4d538ac..f26b044 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/event/event_core.js +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/event/event_core.js @@ -153,18 +153,17 @@ }); $( "#qunit-fixture" ).trigger("vmousedown"); - + // tapholdThreshold has been changed from 100 to 2000 setTimeout(function(){ ok( !taphold, "taphold not fired" ); - deepEqual( target, undefined, "taphold target should be #qunit-fixture" ); - }, $.event.special.tap.tapholdThreshold - 10); - + deepEqual( target, undefined, "taphold target should be #qunit-fixture!" ); + }, $.event.special.tap.tapholdThreshold - 2000); setTimeout(function(){ ok( taphold, "taphold fired" ); - equal( target, $( "#qunit-fixture" ).get( 0 ), "taphold target should be #qunit-fixture" ); + equal( target, $( "#qunit-fixture" ).get( 0 ), "taphold target should be #qunit-fixture!" ); start(); - }, $.event.special.tap.tapholdThreshold + 10); + }, $.event.special.tap.tapholdThreshold + 2000); }); //NOTE used to simulate movement when checked diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/event/index.html b/libs/js/jquery-mobile-1.2.0/tests/unit/event/index.html index 12d7542..ec38923 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/event/index.html +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/event/index.html @@ -27,6 +27,7 @@ + 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 4e9d7c5..20d3404 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,7 +34,7 @@ - + diff --git a/libs/js/jquery-mobile-1.2.0/tests/unit/support/support_core.js b/libs/js/jquery-mobile-1.2.0/tests/unit/support/support_core.js index 27b3e7c..f7cc55b 100644 --- a/libs/js/jquery-mobile-1.2.0/tests/unit/support/support_core.js +++ b/libs/js/jquery-mobile-1.2.0/tests/unit/support/support_core.js @@ -55,6 +55,11 @@ $.testHelper.excludeFileProtocol(function(){ start(); }); }); + /* + To delete the windows property is prohibited. (Security issue) + + delete window["orientation"] is now working + !$.support.orientation <- return false asyncTest( "detects functionality from basic negative properties and attributes (where possible)", function(){ delete window["orientation"]; @@ -64,6 +69,7 @@ $.testHelper.excludeFileProtocol(function(){ start(); }); }); + */ // NOTE mocks prependTo to simulate base href updates or lack thereof var mockBaseCheck = function( url ){ diff --git a/tests/jqm-tchelper/cookie.js b/tests/jqm-tchelper/cookie.js new file mode 100644 index 0000000..b7db434 --- /dev/null +++ b/tests/jqm-tchelper/cookie.js @@ -0,0 +1,21 @@ +function setCookie( cookieName, cookieValue, expireDate) { + var today = new Date(); + today.setDate( today.getDate() + parseInt( expireDate ) ); + document.cookie = cookieName + "=" + escape( cookieValue ) + "; path=/; expires=" + today.toGMTString() + ";"; +} +function getCookie(name) { + var cname = name + "="; + var dc = document.cookie; + if (dc.length > 0) { + begin = dc.indexOf(cname); + if (begin != -1) { + begin += cname.length; + end = dc.indexOf(";", begin); + if (end == -1) { + end = dc.length; + } + return unescape(dc.substring(begin, end)); + } + } + return null; +} \ No newline at end of file diff --git a/tests/jqm-tchelper/index.html b/tests/jqm-tchelper/index.html index 339717c..30cc6f9 100644 --- a/tests/jqm-tchelper/index.html +++ b/tests/jqm-tchelper/index.html @@ -1,36 +1,10 @@ - + + +
@@ -70,7 +55,5 @@
- - \ No newline at end of file diff --git a/tests/jqm-tchelper/result.php b/tests/jqm-tchelper/result.php index 8da23ef..a6a8823 100644 --- a/tests/jqm-tchelper/result.php +++ b/tests/jqm-tchelper/result.php @@ -1,32 +1,18 @@ - + @@ -66,19 +52,19 @@ --> Tests total - + Tests Passed - + Tests Failed - + Time(m seconds) - + diff --git a/tests/jqm-tchelper/tizen.testHelper.js b/tests/jqm-tchelper/tizen.testHelper.js index 3fa5667..c914a24 100644 --- a/tests/jqm-tchelper/tizen.testHelper.js +++ b/tests/jqm-tchelper/tizen.testHelper.js @@ -5,10 +5,34 @@ * - 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 + * Issues + * - Some testcases may change URL during test * It is a not complete versionc. Optimization, refactoring is needed + * */ + +function setCookie( cookieName, cookieValue, expireDate) { + var today = new Date(); + today.setDate( today.getDate() + parseInt( expireDate ) ); + document.cookie = cookieName + "=" + escape( cookieValue ) + "; path=/; expires=" + today.toGMTString() + ";"; +} +function getCookie(name) { + var cname = name + "="; + var dc = document.cookie; + if (dc.length > 0) { + begin = dc.indexOf(cname); + if (begin != -1) { + begin += cname.length; + end = dc.indexOf(";", begin); + if (end == -1) { + end = dc.length; + } + return unescape(dc.substring(begin, end)); + } + } + return null; +} + ( function ( ) { var QueryString = function () { @@ -20,15 +44,11 @@ vars = query.split("&"); - for (var i = 0 ; i < vars.length ; i++) - { + for (var i = 0 ; i < vars.length ; i++) { pair = vars[i].split("="); - if (typeof query_string[pair[0]] === "undefined") - { + if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = pair[1]; - } - else if (typeof query_string[pair[0]] === "string") - { + } else if (typeof query_string[pair[0]] === "string") { arr = [ query_string[pair[0]], pair[1] ]; query_string[pair[0]] = arr; } else { @@ -41,6 +61,8 @@ except : listview, event */ var tests = [ + "listview", + "event", "button", "button-markup", "navigation", @@ -85,24 +107,16 @@ // 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 ); + passCount = ( getCookie( "TizenP") === "undefined" ) ? 0 : parseInt( getCookie( "TizenP") ); + failCount = ( getCookie( "TizenF") === "undefined" ) ? 0 : parseInt( getCookie( "TizenF") ); + totalCount = ( getCookie( "TizenT") === "undefined" ) ? 0 : parseInt( getCookie( "TizenT") ); + runTime = ( getCookie( "TizenR") === "undefined" ) ? 0 : parseInt( getCookie( "TizenR") ); 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; @@ -112,24 +126,26 @@ updir = "../"; for( i = 0 ; i < tests.length ; i++ ) { - if( tests[i] == currentTest ) - { + if( tests[i] == currentTest ) { break; } } - if( tests.length -1 == i || - currentTest === "listview" || - currentTest === "event" ) + if( tests.length -1 == i ) { //Goto result Page - nextUrl ="../../../../../../tests/jqm-tchelper/result.php" + "?" + "p=" + passCount + "&f=" + failCount + "&t=" + totalCount + "&r=" + runTime; + nextUrl ="../../../../../../tests/jqm-tchelper/result.php"; }else{ - if( currentTest === "navigation" ) - { + if( currentTest === "navigation" ) { updir += "../../"; + } else if ( currentTest === "listview" ) { + updir += "../"; } - nextUrl = updir + tests[i + 1] +"/?" + "p=" + passCount + "&f=" + failCount + "&t=" + totalCount + "&r=" + runTime; + setCookie( "TizenP", passCount ); + setCookie( "TizenF", failCount ); + setCookie( "TizenR", runTime ); + setCookie( "TizenT", totalCount ); + nextUrl = updir + tests[i + 1]; } return nextUrl; diff --git a/tests/unit-tests/index.html b/tests/unit-tests/index.html index f38938c..b2079af 100644 --- a/tests/unit-tests/index.html +++ b/tests/unit-tests/index.html @@ -6,7 +6,7 @@ - +