From a678cae002ce24ece24e044dd8e1ae44529e75df Mon Sep 17 00:00:00 2001 From: jwang Date: Sun, 9 Jun 2013 15:55:10 +0800 Subject: [PATCH] Fix capability missing when merge happen Change-Id: I80181cef224fe803e4a6d375d785d4749799793b --- js/main.js | 80 ++++++++++++++++++++++++++++++++++---------------------------- tests.xml | 2 +- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/js/main.js b/js/main.js index df9c7c1..cf0be5e 100755 --- a/js/main.js +++ b/js/main.js @@ -33,6 +33,7 @@ Authors: var _appURL; var _resultXML; var Tests; +var caps; var mandatorylist = new Array( "usbHost", "screenSizeNormal", @@ -135,16 +136,22 @@ function resetResult() { function _resetResult() { Tests.each( function() { - $(this).attr("result", "non-executed"); - var testAppcap = $(this).attr("id"); - var is_cap_support = true; + var testAppname = $(this).attr("id"); + var isCappresent = true; + var isCapmandatory = false; $(this).find("capability").each(function(){ - is_cap_support = isCapSupport($(this).attr("name")); + isCappresent = isCapPresent($(this).attr("name")); + isCapmandatory = isCapMandatory($(this).attr("name")); }); - if(is_cap_support === false){ - noSupport[testAppcap] = true; - $(this).attr("result", "FAIL"); + if(isCappresent === false){ + noSupport[testAppname] = true; + if (isCapmandatory === true) + $(this).attr("result", "FAIL"); + else + $(this).attr("result", "PASS"); } + else + $(this).attr("result", "non-executed"); } ); } @@ -212,6 +219,7 @@ function loadTests() { success : function(xml){ _resultXML = xml; Tests = $(xml).find("testcase"); + getCapPresent(); loadTmpResult(); } }); @@ -258,17 +266,6 @@ function loadTmpResult(){ function _mergeResult(tmpResult) { Tests.each( function(index, item) { - $(item).attr("result", "non-executed"); - var testAppcap = $(item).attr("id"); - var is_cap_support = true; - $(item).find("capability").each(function(){ - is_cap_support = isCapSupport($(item).attr("name")); - }); - if(is_cap_support === false){ - noSupport[testAppcap] = true; - $(item).attr("result", "FAIL"); - } - tmpResult.each( function(order, tmpItem) { if ($(item).attr("id") === $(tmpItem).attr("id")) { @@ -277,6 +274,16 @@ function _mergeResult(tmpResult) { } } ); + var testAppname = $(this).attr("id"); + var isCappresent = true; + var isCapmandatory = false; + $(this).find("capability").each(function(){ + isCappresent = isCapPresent($(this).attr("name")); + isCapmandatory = isCapMandatory($(this).attr("name")); + }); + if(isCappresent === false){ + noSupport[testAppname] = true; + } } ); } @@ -304,30 +311,31 @@ function initTests() { }, false); } -function isCapPresent(name) { +function getCapPresent() { try { - var caps = tizen.systeminfo.getCapabilities(); - if (typeof(caps[name]) == "boolean"){ + caps = tizen.systeminfo.getCapabilities(); + } catch (e){ + alert("Exception: " + e.message); + } +} + +function isCapPresent(name) { + if ((caps != undefined)&&(caps[name] != undefined)) { + if (typeof(caps[name]) == "boolean") return caps[name]; - } - return true; - } catch (err) { - console.log("Exception: " + err.message); - return false; + else + return true; } + else + return false; } function isCapMandatory(name) { - try { - for (var i = 0;i < mandatorylist.length; i++) { - if (mandatorylist[i] === name) - return true; - }; - return false; - } catch (err) { - console.log("Exception: " + err.message); - return false; - } + for (var i = 0;i < mandatorylist.length; i++) { + if (mandatorylist[i] === name) + return true; + }; + return false; } function isCapSupport(name) { diff --git a/tests.xml b/tests.xml index 20752a6..3f39b47 100644 --- a/tests.xml +++ b/tests.xml @@ -70,7 +70,7 @@ - + -- 2.7.4