Make tmpfile always there as a import option, plus some small cleanup
authorjwang <jing.j.wang@intel.com>
Sun, 9 Jun 2013 04:26:20 +0000 (12:26 +0800)
committerjwang <jing.j.wang@intel.com>
Sun, 9 Jun 2013 04:46:32 +0000 (12:46 +0800)
Change-Id: I7236788009c97d6988861b9ad16ee9ac898b3874

js/main.js

index e0759d1..87b96ed 100755 (executable)
@@ -33,7 +33,11 @@ Authors:
 var _appURL;
 var _resultXML;
 var Tests;
-var mandatorylist = new Array("usbHost","screenNormal","inputKeyboard","multiTouchCount");
+var mandatorylist = new Array(
+            "usbHost",
+            "screenSizeNormal",
+            "inputKeyboard",
+            "multiTouchCount");
 var accMarks = {};
 var noSupport = {};
 var resultFile = "tct-behavior-tests.result.xml";
@@ -56,7 +60,7 @@ function updateToolTitle() {
         }
     });
 
-    $("#tool_title").empty().append("<h1 style=\"width:75%; margin-left:auto; margin-right:auto;\">TCT Behavior Test Tool</h1><a class=\"ui-btn-right\">"+version+"</a>");
+    $("#tool_title").empty().append("<h1 style=\"width:75%; margin-left:auto; margin-right:auto;\">TCT Behavior Test Tool</h1><a class=\"ui-btn-right\">" + version + "</a>");
 }
 
 function launchApp() {
@@ -73,7 +77,7 @@ function runApp(url) {
     _appURL = url;
     jQuery("#overlayBackground").show();
     $.mobile.showPageLoadingMsg();
-    _timer = setTimeout(launchApp, 1000);
+    _timer = setTimeout(launchApp, 500);
 }
 
 function updateAppDecoration() {
@@ -167,26 +171,26 @@ function writeFile(filename, content, need_exit) {
         if (filename == resultFile)
             alert("Export result to " + resultFile + " successfully.");
 
-        if(need_exit)
+        if (need_exit)
             exitTest();
     };
 
     onsuccess = function(dir) {
-        if (need_exit)
-            dir.deleteFile(dir.fullPath + "/" + tmpResultFile);
+//        if (need_exit)
+//            dir.deleteFile(dir.fullPath + "/" + tmpResultFile);
         dir.deleteFile(dir.fullPath + "/" + filename);
         file = dir.createFile(filename);
         file.openStream("rw", successCallback, onerror, "UTF-8");
     };
 
     onerror = function(error) {
-        alert("Export result fail: "+error);
+        alert("Export result fail: " + error);
     };
 
     try {
         tizen.filesystem.resolve('documents', onsuccess, onerror, "rw");
     } catch (err) {
-        console.log("Write file fail: " + err.message);
+        alert("Write file fail: " + err.message);
     }
 }
 
@@ -217,13 +221,13 @@ function loadTmpResult(){
     successCallback = function(files) {
         for(var i = 0; i < files.length; i++)
             if (files[i].name == tmpResultFile) {
-                if (confirm("found tmp result. do you want to load it?")) {
+                if (confirm("Continue last test?")) {
                     files[i].readAsText(
                         function(xml){
                             _mergeResult($(xml).find("testcase"));
                             updateAppDecoration();
-                        }, function(e){
-                            console.log("read tmp result error: " + e.message);
+                        }, function(err){
+                            console.log("read tmp result error: " + err.message);
                         }, "UTF-8"
                     );
                     return;
@@ -240,11 +244,14 @@ function loadTmpResult(){
 
     onerror = function(error) {
         console.log(error);
+        updateAppDecoration();
     };
+
     try {
         tizen.filesystem.resolve('documents', onsuccess, onerror, "rw");
     } catch (err) {
         console.log("Load tmp result fail: " + err.message);
+        updateAppDecoration();
     }
 }
 
@@ -252,6 +259,16 @@ 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")) {
@@ -296,7 +313,7 @@ function isCapPresent(name) {
         }
         return true;
     } catch (err) {
-        alert("Exception: " + err.message);
+        console.log("Exception: " + err.message);
         return false;
     }
 }
@@ -309,7 +326,7 @@ function isCapMandatory(name) {
         };
         return false;
     } catch (err) {
-        alert("Exception: " + err.message);
+        console.log("Exception: " + err.message);
         return false;
     }
 }