From: xy.qian Date: Fri, 19 May 2017 03:02:23 +0000 (+0800) Subject: [common][all][Modify testsrunner.js for circile targets] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=412a9769baba0b5f2c23bb278e65c2043be0fa30;p=test%2Ftct%2Fweb%2Fapi.git [common][all][Modify testsrunner.js for circile targets] Change-Id: I6c380ba7aee7703e992fc02881beecba366362ed Signed-off-by: xy.qian --- diff --git a/common/tct-account-tizen-tests/webrunner/testrunner.js b/common/tct-account-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-account-tizen-tests/webrunner/testrunner.js +++ b/common/tct-account-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-appcontrol-tizen-tests/webrunner/testrunner.js b/common/tct-appcontrol-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-appcontrol-tizen-tests/webrunner/testrunner.js +++ b/common/tct-appcontrol-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-bluetooth-tizen-tests/webrunner/testrunner.js b/common/tct-bluetooth-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-bluetooth-tizen-tests/webrunner/testrunner.js +++ b/common/tct-bluetooth-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-bookmark-tizen-tests/webrunner/testrunner.js b/common/tct-bookmark-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-bookmark-tizen-tests/webrunner/testrunner.js +++ b/common/tct-bookmark-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-calendar-tizen-tests/webrunner/testrunner.js b/common/tct-calendar-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-calendar-tizen-tests/webrunner/testrunner.js +++ b/common/tct-calendar-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-callhistory-tizen-tests/webrunner/testrunner.js b/common/tct-callhistory-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-callhistory-tizen-tests/webrunner/testrunner.js +++ b/common/tct-callhistory-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-contact-tizen-tests/webrunner/testrunner.js b/common/tct-contact-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-contact-tizen-tests/webrunner/testrunner.js +++ b/common/tct-contact-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-deprecatedapi-tizen-tests/webrunner/testrunner.js b/common/tct-deprecatedapi-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-deprecatedapi-tizen-tests/webrunner/testrunner.js +++ b/common/tct-deprecatedapi-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-deviceorientation-w3c-tests/webrunner/testrunner.js b/common/tct-deviceorientation-w3c-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-deviceorientation-w3c-tests/webrunner/testrunner.js +++ b/common/tct-deviceorientation-w3c-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-feedback-tizen-tests/webrunner/testrunner.js b/common/tct-feedback-tizen-tests/webrunner/testrunner.js index ea68b0044..114c8f165 100755 --- a/common/tct-feedback-tizen-tests/webrunner/testrunner.js +++ b/common/tct-feedback-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,49 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + +var STUB_PORT = ""; +var RESOURCE_DIR; +$.ajax({ + url:"/opt/usr/home/owner/share/TCT_CONFIG", + data:{}, + async:false, + success:function(data){ + var regEx = /DEVICE_SUITE_TARGET_30=(.+)/i; + var path = regEx.exec(data); + RESOURCE_DIR = path[1]; + } +}); +$.ajax({ + url:RESOURCE_DIR + "/tct/portconfigure.json", + dataType:"json", + data:{}, + async:false, + success:function(data){ + STUB_PORT = data[0]["STUB_PORT"]; + } +}); (function (window){ function TestRunner() { this.start = null; diff --git a/common/tct-filesystem-tizen-tests/webrunner/testrunner.js b/common/tct-filesystem-tizen-tests/webrunner/testrunner.js index c3e14659d..114c8f165 100755 --- a/common/tct-filesystem-tizen-tests/webrunner/testrunner.js +++ b/common/tct-filesystem-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ @@ -50,732 +72,867 @@ $.ajax({ } }); (function (window){ - function TestRunner() { - this.start = null; - this.ui = null; - this.submitResult = null; - this.report = function (result, message) {}; - this.doTest = function () {}; - } + function TestRunner() { + this.start = null; + this.ui = null; + this.submitResult = function () {}; + this.report = function (result, message) {}; + this.doTest = function () {}; + } - TestRunner.prototype = (function () { - var index = -1; - var Tests = []; - var Sets = {}; - function newSummary() { - return {"TOTAL": 0, - "PASS" : 0, - "FAIL" : 0, - "BLOCK" : 0, - "NOTRUN" : 0}; - } - function newTestContext() { - return {start_time: null, - prev_uri: "", - uri: "", - sub_index: 0, - onload_delay: 0 - }; - } - function getParms () { - var parms = {}; - var items = location.search.substring(1).split('&'); - for ( var i = 0, max = items.length; i < max; i++) { - var pos = items[i].indexOf('='); - if (pos > 0) { - var key = items[i].substring(0, pos); - var val = items[i].substring(pos + 1); - if (!parms[key]) { - var rawVal = decodeURI(val); - if (rawVal.indexOf(',') < 0) - parms[key] = rawVal; - else - parms[key] = rawVal.split(','); - } - } else - parms[items[i]] = 1; - } - if (!parms.testsuite) - parms.testsuite = 'tests.xml'; - return parms; - } - var parms = getParms(); - var sum = newSummary(); - var testContext = newTestContext(); - return { - constructor: TestRunner, - options: parms, - getTestContext: function (field) { - return testContext[field]; - }, - - goNext: function () { - if (Tests.length === 0) return false; - if (index >= Tests.length) { - index = -1; - return false; - } - index++; - return true; - }, - - goPrev: function () { - if (Tests.length === 0) return false; - if (index < 0) { - index = Tests.length; - return false; - } - index--; - return true; - }, - - runAll: function () { - testContext = newTestContext(); - this.ui.updateView(VIEWFLAGS.add("batch")); - this.ui.updateView(VIEWFLAGS.del("list")); - this.testIndex(-1); - this.doTest(); - }, - - cleanTests: function () { - Tests = []; - }, - - testIndex: function (ind) { - if (typeof ind === "undefined") - return index; - index = ind; - }, - - getTest: function (ind) { - if (typeof ind === "undefined") - ind = index; - return Tests[ind]; - }, - - addTest: function (test) { - if (test instanceof Array) - Tests = Tests.concat(test); - else - Tests.push(test); - }, - - sumInit: function (num) { - if (typeof num === "undefined") - num = Tests.length; - sum.TOTAL = sum.NOTRUN = num; - sum.PASS = sum.FAIL = sum.BLOCK = 0; - }, - - sumUpdate: function (oldRes, newRes, set) { - if (oldRes !== null) { - sum[oldRes]--; - if (set !== null) Sets[set][oldRes]--; - } - if (newRes !== null) { - sum[newRes]++; - if (set != null) Sets[set][newRes]++; - } - }, - - checkResult: function (oTestDoc) { - var message = ""; - // Handle sub-index test - if (testContext.sub_index > 0) { - var oRes = $(oTestDoc).find("table#results"); - if (oRes.length == 0) - return false; - var ind = testContext.sub_index - 1; - var $n = $(oRes).find('tbody > tr').eq(ind); - if ($n.length == 0) - return false - var result = $n.children("td:eq(0)").text(); - message = $n.children("td:eq(2)").text(); - this.report(result.toUpperCase(), message); - return true; - } - - var oPass = $(oTestDoc).find(".pass"); - var oFail = $(oTestDoc).find(".fail"); - // All tests pass - if (oPass.length > 0 && oFail.length == 0) { - this.report('PASS', message); - return true; - } - // Handle failed tests - if (oFail.length > 0) { - var oRes = $(oTestDoc).find("table#results"); - $(oRes).find('tr.fail').each(function() { - message += " *" + $(this).children("td:eq(1)").text() + ": "; - message += $(this).children("td:eq(2)").text(); - }); - this.report('FAIL', message); - return true; - } - return false; - }, - - testInfo: function (ind) { - var info = ""; - var tc = this.getTest(); - if (!tc) return info; - info += "Test : (" + (index + 1) + "/" + sum.TOTAL + ") "; - info += tc.test_script_entry; - info += "\nPurpose: " + tc.purpose; - if (tc.pre_condition) - info += "\nPrecondition: " + tc.pre_condition; - if (tc.steps) - info += "\n" + tc.steps; - return info; - }, - - getTestCaseUrl: function () { - function getUriField(uri, param) { - var querys = uri.split("?") - if (querys.length <= 1) - return ""; - uri = querys[1]; - var start = uri.indexOf(param); - if (start == -1) - return ""; - start += param.length + 1; - var end = uri.indexOf("&", start); - if (end == -1) - return uri.substring(start); - return uri.substring(start, end); - } - var tc = this.getTest(); - if (!tc) return null; - var delay = tc.onload_delay; - if (delay) - testContext.onload_delay = parseInt(delay) * 1000; - else - testContext.onload_delay = 5000; - - var uri = tc.test_script_entry; - if (typeof this.options.testprefix !== "undefined") { - var pos = uri.indexOf('http://'); - if (pos !== 0) - uri = this.options.testprefix + uri - } - var val = getUriField(uri, "value"); - if (val && tc.execution_type == "auto" && VIEWFLAGS.has("batch")) { // Need sub index in TC - testContext.sub_index = parseInt(val); - testContext.uri = uri.split("?")[0]; - if (testContext.uri == testContext.prev_uri) - return ""; - } else { - testContext.uri = uri; - testContext.sub_index = 0; - } - testContext.prev_uri = testContext.uri; - testContext.start_time = new Date(); - return testContext.uri; - }, - - loadReady: function () { - if (!VIEWFLAGS.has("batch")) - return; - if (!this.ui.testComplete()){ - if (testContext.onload_delay > 0){ - var tval = 500; - var self = this; - setTimeout(function() {self.loadReady();}, tval); - testContext.onload_delay -= tval; - return - } - this.report("BLOCK", "Timeout"); - } - this.doTest(); - }, - - getTestSum: function (include_set) { - var sumdata = "

Total:" + sum.TOTAL - + " Pass:" + sum.PASS - + " Fail:" + sum.FAIL - + " Block:" + sum.BLOCK - + " NotRun:" + sum.NOTRUN - + "

"; - if (VIEWFLAGS.has("batch")) { - var tc = this.getTest(); - if (tc) sumdata += "

(#" + index + ") " + tc.id + "

"; - } - - if (include_set) { - sumdata += "

"; - sumdata += ""; - $.each(Sets, function (key, val){ - sumdata += ""; - sumdata += ""; - sumdata += ""; - sumdata += ""; - sumdata += ""; - }); - sumdata += "
TestSetTotalPassFailBlock
" + key+ "" + val.TOTAL + "" + val.PASS + "" + val.FAIL + "" + val.BLOCK + "
"; - } - return sumdata; - }, - - getBrowseInfo: function () { - var failList = passList = blockList = notrunList = ""; - function createTestList(tc, color, ind) { - var mtag = (tc.execution_type === "manual") ? "(M)" : ""; - return "

  • " + mtag + "" + tc.id + "" + "
  • "; - } - Sets = {}; - $.each(Tests, function (ind ,val) { - if (this.set === null) - this.set = "default"; - if (typeof Sets[this.set] === "undefined") - Sets[this.set] = newSummary(); - Sets[this.set][this.result]++; - Sets[this.set]["TOTAL"]++; - if (this.result == "FAIL") - failList += createTestList(this, "red", ind); - if (this.result == "PASS") - passList += createTestList(this, "green", ind); - if (this.result == "BLOCK") - blockList += createTestList(this, "orange", ind); - if (this.result == "NOTRUN") - notrunList += createTestList(this, "black", ind); - }); - var data = ""; - if (notrunList) - data += "

    Notruns

      " + notrunList + "
    "; - if (failList) - data += "

    Fails

      " + failList + "
    "; - if (blockList) - data += "

    Blocks

      " + blockList + "
    "; - if (passList) - data += "

    Passes

      " + passList + "
    "; - data += ""; - return data; - }, - - TestCase: function () { - return { - id: null, - test_script_entry: null, - execution_type: "manual", - result: "NOTRUN", - purpose: "", - set: null, - pre_condition: "", - onload_delay: 0, - steps: "", - data: null}; - } - }; - }()); - // Standalone test runner - var master_runner = new TestRunner(); - master_runner.start = function (ui) { - function filter(xml, self) { - var set_ind = 0; - var manuals = []; - $(xml).find("set").each(function () { - var setname = $(this).attr("name"); - if (!setname) - setname = "set" + set_ind; - $(this).find("testcase").each(function () { - var v = $(this).attr('execution_type'); - if (self.options.execution_type && v != self.options.execution_type - && $.inArray(v, self.options.execution_type) < 0) { - $(this).remove(); - return; - } - v = $(this).attr('priority'); - if (self.options.priority && v != self.options.priority - && $.inArray(v, self.options.priority) < 0){ - $(this).remove(); - return; - } - var test = self.TestCase(); - test.id = $(this).attr("id"); - test.execution_type = $(this).attr("execution_type"); - test.test_script_entry = $(this).find("test_script_entry").text(); - test.purpose = $(this).attr("purpose"); - test.pre_condition = $(this).find("pre_condition").text(); - test.onload_delay = $(this).attr("onload_delay"); - test.result = "NOTRUN"; - test.set = setname; - test.data = this; - if (test.execution_type === "auto") - self.addTest(test); - else - manuals.push(test); - }); - set_ind++; - }); - self.addTest(manuals); - } - - var self = this; - ui.bind(self); - $.get(self.options.testsuite, null, function (xml) { - self.internal.xmldoc = xml; - filter(xml, self); - self.sumInit(); - setTimeout(function () { - self.ui.browse(); - setTimeout(function () { - if (self.options.autorun) - self.runAll(); - }, 2000); - }, 100); - }, "xml"); - }; - - master_runner.doTest = function () { - var self = this, tc = null; - while (self.goNext()) { - tc = self.getTest(); - if (!tc || tc.execution_type === "manual") - break; - self.ui.updateTestInfo(self.testInfo(), null, null); - self.ui.runTest(self.getTestCaseUrl()); - return; - } - if (self.options.autorun) { - self.submitResult(); - close_window(); - return; - } - this.ui.updateView(VIEWFLAGS.del("batch")); - if (!tc) { - setTimeout(function () {self.ui.browse();}, 500); - return; - } - this.ui.updateTest(); - }; - - master_runner.report = function (result, log) { - var tc = this.getTest(); - if (!tc) return; - var oldresult = tc.result; - this.sumUpdate(oldresult, result, tc.set); - tc.result = result; - $(tc.data).find('result_info').remove(); - $(tc.data).attr('result', result); - var doc = $.parseXML("" + result + - "" + this.getTestContext("start_time") + - "" + new Date() + "" + - escape_html(log) + ""); - $(tc.data).append(doc.documentElement); - if (VIEWFLAGS.has("batch")) result = null; - this.ui.updateTestInfo(null, this.getTestSum(false), result); - }; - - master_runner.submitResult = function () { - var xmldoc = this.internal.xmldoc; - var contents = (new XMLSerializer()).serializeToString(xmldoc); - if (window.opener) window.opener.postMessage(contents, "*"); - }; - - master_runner.internal = {xmldoc: null}; - - // Controlled test runner - var slave_runner = new TestRunner(); - slave_runner.start = function (ui) { - function sync_session_id() { - $.get(SERVER + "/init_session_id?session_id=" - + self.internal.session_id); - } - var self = this; - self.internal.session_id = Math.round(Math.random() * 10000); - sync_session_id(); - var next_step = self.internal.get_json("ask_next_step"); - if (!next_step || next_step.step != "continue") - return false; - ui.bind(self); - var f = function () { - var p = self.internal.get_json("check_execution_progress"); - if (p) self.sumInit(parseInt(p.total)); - self.doTest(); - }; - self.ui.updateView(VIEWFLAGS.add("batch")); - self.ui.updateView(VIEWFLAGS.del("list")); - setTimeout(f, 1000); - return true; - }; - - slave_runner.doTest = function () { - var self = this; - if (self.internal.stage > 0) { - self.ui.updateView(VIEWFLAGS.del("batch")); - self.goNext(); - self.ui.updateTest(); - return; - } - var next_step = self.internal.get_json("ask_next_step"); - if (next_step && next_step.step == "continue") { - var task = self.internal.get_json("auto_test_task"); - if (task === null) { - print_error("ask_test_task", "Fail get task"); - } else if (task.invalid === 0) { - print_error("ask_test_task", "Invalid session"); - } else if (task.stop === 0) { - print_error("ask_test_task", "close window"); - } else if (task.none !== 0) { //handle auto test - var test = self.TestCase(); - test.id = task.case_id; - test.onload_delay = task.onload_delay; - test.test_script_entry = task.entry; - test.execution_type = "auto"; - test.purpose = task.purpose; - test.pre_condition = task.pre_condition; - self.addTest(test); - self.goNext(); - self.ui.updateTestInfo(self.testInfo(), null, null); - self.ui.runTest(self.getTestCaseUrl()); - return; - } else { //handle manual test - self.ui.updateView(VIEWFLAGS.del("batch")); - self.internal.stage = 1; - var mtask = self.internal.get_json("manual_cases"); - if (mtask && mtask.none != 0) { - self.cleanTests(); - for (var i = 0, max = mtask.length; i < max; i++) { - var test = self.TestCase(); - test.id = mtask[i].case_id; - test.test_script_entry = mtask[i].entry; - test.purpose = mtask[i].purpose; - test.pre_condition = mtask[i].pre_condition; - test.result = "NOTRUN"; - test.execution_type = "manual"; - test.index = i; - var steps = ""; - $(mtask[i].steps).each(function () { - steps += "Step-" + this.order + "\t: " + this.step_desc + "\n"; - steps += "Expect\t: " + this.expected + "\n"; - }); - test.steps = steps; - self.addTest(test); - } - self.ui.updateTest(-1); - self.sumInit(); - self.ui.browse(); - } else - close_window(); - return; - } - } - close_window(); - }; - - slave_runner.report = function(result, log) { - var tc = this.getTest(); - var oldresult; - if (this.internal.stage > 0) { - this.internal.post_json("commit_manual_result", - {"case_id": tc.id, "result": result}); - oldresult = tc.result - tc.result = result; - } else { - this.internal.post_json("commit_result", - { "case_id" : tc.id, - "result" : result, - "msg" : "[Message]" + log, - "session_id" : this.internal.session_id}); - oldresult = "NOTRUN"; - } - this.sumUpdate(oldresult, result, null); - if (VIEWFLAGS.has("batch")) result = null; - this.ui.updateTestInfo(null, this.getTestSum(false), result); - }; - - slave_runner.submitResult = function () { - $.get(SERVER + "/generate_xml"); - }; - - slave_runner.internal = { - session_id: null, - stage: 0, - get_json: function (name) { - var jsondata = null; - $.getJSON(SERVER + "/" + name + "?session_id=" - + this.session_id, function(data) { - jsondata = data;}); - return jsondata; }, - post_json: function (name, d) { - $.post(SERVER + "/" + name, d, null, "json"); - } - }; - - var i_ui = (function () { - var testinfo = $("#testinfo").get(0); - var frmTest = $("#frmTest").get(0); - var textTest = $("#textTest").get(0); - var btnPass = $("#btnPass").get(0); - var btnFail = $("#btnFail").get(0); - var btnBlock = $("#btnBlock").get(0); - var btnDone = $("#btnDone").get(0); - var btnNext = $("#btnNext").get(0); - var btnPrev = $("#btnPrev").get(0); - var btnRun = $("#btnRun").get(0); - var divSum = $("#divSum").get(0); - var btnList = $("#btnList").get(0); - var runner = null; - var listmode = null; - var nextTest = function () { - runner.goNext(); - selectTest(); - }; - - var prevTest = function() { - runner.goPrev(); - selectTest(); - }; - - var selectResult = function() { - runner.report(this.value, ""); - }; - - var selectTest = function () { - frmTest.src = ""; - var tc = runner.getTest(); - if (!tc) { - if (runner.testIndex() === -1) - textTest.value = "---Begin---"; - else - textTest.value = "---End---"; - changeColor("NOTRUN"); - return; - } - testinfo.value = runner.testInfo(); - $(divSum).html(runner.getTestSum(false)); - textTest.value = ((tc.execution_type === "manual") ? "(M)" : "") + tc.id; - changeColor(tc.result); - }; - - function changeColor(result) { - if (result === "PASS") - $(textTest).css("backgroundColor", "lightgreen"); - else if (result === "FAIL") - $(textTest).css("backgroundColor", "tomato"); - else if (result === "BLOCK") - $(textTest).css("backgroundColor", "yellow"); - else - $(textTest).css("backgroundColor", "white"); - } - - return { - bind: function (r) { - var self = this; - r.ui = self; - runner = r; - $(btnPass).on("click", selectResult); - $(btnFail).on("click", selectResult); - $(btnBlock).on("click", selectResult); - $(btnNext).on("click", nextTest); - $(btnPrev).on("click", prevTest); - $(btnRun).on("click", function () { - if (VIEWFLAGS.has("list")) { - runner.runAll(); - } else - self.runTest(runner.getTestCaseUrl()); - }); - $(frmTest).on("load", function () {runner.loadReady();}); - $(btnDone).on("click", function () { - runner.submitResult(); - close_window(); - }); - $(btnList).on("click", function () { - frmTest.src = ""; - //self.updateTest(-1); - setTimeout(function () {self.browse();}, 300); - }); - frmTest.height = $(window).height(); - }, - - browse: function () { - var tdoc = frmTest.contentWindow.document; - tdoc.open("text/html", "replace"); - tdoc.writeln(runner.getBrowseInfo()); - var self = this; - $(tdoc).find("section ul li>a").on("click", function (e) { - var ind = parseInt($(this).attr("rel")); - self.updateView(VIEWFLAGS.del("list")); - self.updateTest(ind); - window.scrollTo(0, 0); - e.preventDefault(); - }); - $(divSum).html(runner.getTestSum(true)); - self.updateView(VIEWFLAGS.add("list")); - }, - - updateTest: function (ind) { - if (typeof ind !== "undefined") runner.testIndex(ind); - selectTest(); - }, - - updateView: function (flags) { - if (flags & VIEWFLAGS.flags.list) { - $(".listmode").show(); - $(".singlemode").hide(); - } else { - $(".listmode").hide(); - $(".singlemode").show(); - } - if (flags & VIEWFLAGS.flags.batch) - $(".batchmode").hide(); - else - $(".batchmode").show(); - }, - - testComplete: function () { - return runner.checkResult(frmTest.contentWindow.document); - }, - - runTest: function (uri) { - if (uri === null) return; - if (uri) - frmTest.src = uri; - else - runner.loadReady(); - - }, - - updateTestInfo: function (info, sum, result) { - if (info !== null) - testinfo.value = info; - if (sum !== null) - $(divSum).html(sum); - if (result !== null) - changeColor(result); - }, - }; - } ()); - - function escape_html(s) { - return s.replace(/\&/g, "&").replace(/ 0) { + var key = items[i].substring(0, pos); + var val = items[i].substring(pos + 1); + if (!parms[key]) { + var rawVal = decodeURI(val); + if (rawVal.indexOf(',') < 0) + parms[key] = rawVal; + else + parms[key] = rawVal.split(','); + } + } else + parms[items[i]] = 1; + } + return parms; + } + return { + constructor: TestRunner, + options: getParms(), + addTestsuite: function (testsuite, category) { + if (!category) + category = "default"; + if (typeof Testsuites[category] === "undefined") + Testsuites[category] = []; + Testsuites[category].push(testsuite); + }, + + goNext: function () { + if (Tests.length === 0) return false; + if (index >= Tests.length) { + index = -1; + return false; + } + index++; + return true; + }, + + goPrev: function () { + if (Tests.length === 0) return false; + if (index < 0) { + index = Tests.length; + return false; + } + index--; + return true; + }, + + runAll: function () { + testContext = newTestContext(); + VIEWFLAGS.add("batch"); + this.ui.updateView(VIEWFLAGS.del("suite")); + this.testIndex(-1); + this.doTest(); + }, + + cleanTests: function () { + Tests = []; + }, + + testIndex: function (ind) { + if (typeof ind === "undefined") + return index; + index = ind; + }, + + getTest: function (ind) { + if (typeof ind === "undefined") + ind = index; + return Tests[ind]; + }, + + addTest: function (test) { + if (test instanceof Array) + Tests = Tests.concat(test); + else + Tests.push(test); + }, + + sumInit: function (num) { + if (typeof num === "undefined") + num = Tests.length; + sum.TOTAL = sum.NOTRUN = num; + sum.PASS = sum.FAIL = sum.BLOCK = 0; + }, + + sumUpdate: function (oldRes, newRes, set) { + if (oldRes !== null) { + sum[oldRes]--; + if (set !== null) TestsetSums[set][oldRes]--; + } + if (newRes !== null) { + sum[newRes]++; + if (set != null) TestsetSums[set][newRes]++; + } + }, + + checkResult: function (oTestDoc) { + var message = ""; + if (!oTestDoc) { + this.report('FAIL', 'Test page crash'); + return true; + } + // Handle sub-index test + if (testContext.sub_index > 0) { + var oRes = $(oTestDoc).find("table#results"); + if (oRes.length == 0) + return false; + var ind = testContext.sub_index - 1; + var $n = $(oRes).find('tbody > tr').eq(ind); + if ($n.length == 0) + return false + var result = $n.children("td:eq(0)").text(); + message = $n.children("td:eq(2)").text(); + this.report(result.toUpperCase(), message); + return true; + } + + var oPass = $(oTestDoc).find(".pass"); + var oFail = $(oTestDoc).find(".fail"); + // Qunit sub-cases + var oUnitRes = $(oTestDoc).find("ol.qunit-assert-list"); + $(oUnitRes).find('li').each(function() { + message += "[assert]" + $(this).attr("class"); + message += "[message]*" + $(this).children("span").text() + "\n"; + }); + // All tests pass + if (oPass.length > 0 && oFail.length == 0) { + this.report('PASS', message); + return true; + } + // Handle failed tests + if (oFail.length > 0) { + var oRes = $(oTestDoc).find("table#results"); + $(oRes).find('tr.fail').each(function() { + message += " *" + $(this).children("td:eq(1)").text() + ": "; + message += $(this).children("td:eq(2)").text(); + }); + this.report('FAIL', message); + return true; + } + return false; + }, + + testInfo: function (ind) { + var info = ""; + var tc = this.getTest(); + if (!tc) return info; + info += "Test : (" + (index + 1) + "/" + sum.TOTAL + ") "; + info += tc.test_script_entry; + info += "\nPurpose: " + tc.purpose; + if (tc.pre_condition) + info += "\nPrecondition: " + tc.pre_condition; + if (tc.steps) + info += "\n" + tc.steps; + return info; + }, + + getTestCaseUrl: function () { + function getUriField(uri, param) { + var querys = uri.split("?") + if (querys.length <= 1) + return ""; + uri = querys[1]; + var start = uri.indexOf(param); + if (start == -1) + return ""; + start += param.length + 1; + var end = uri.indexOf("&", start); + if (end == -1) + return uri.substring(start); + return uri.substring(start, end); + } + var tc = this.getTest(); + if (!tc) return null; + var delay = tc.onload_delay; + if (delay) + testContext.onload_delay = parseInt(delay) * 1000; + else + testContext.onload_delay = 5000; + + var uri = tc.test_script_entry; + if (typeof this.options.testprefix !== "undefined") { + var pos = uri.indexOf('http://'); + if (pos !== 0) + uri = this.options.testprefix + uri + } + var val = getUriField(uri, "value"); + if (val && tc.execution_type == "auto" && VIEWFLAGS.has("batch")) { // Need sub index in TC + testContext.sub_index = parseInt(val); + testContext.uri = uri.split("?")[0]; + if (testContext.uri == testContext.prev_uri) + return ""; + } else { + testContext.uri = uri; + testContext.sub_index = 0; + } + testContext.prev_uri = testContext.uri; + testContext.start_time = new Date(); + return testContext.uri; + }, + + loadReady: function () { + if (!VIEWFLAGS.has("batch")) + return; + if (!this.ui.testComplete()){ + if (testContext.onload_delay > 0){ + var tval = 500; + var self = this; + setTimeout(function() {self.loadReady();}, tval); + testContext.onload_delay -= tval; + return + } + this.report("BLOCK", "Timeout"); + } + this.doTest(); + }, + + getListSum: function () { + var sumdata = ""; + sumdata += "

    "; + sumdata += ""; + $.each(TestsuiteSums, function (key, val){ + sumdata += ""; + sumdata += ""; + sumdata += ""; + sumdata += ""; + sumdata += ""; + }); + sumdata += "
    TestsuiteTotalPassFailBlock
    " + key+ "" + val.TOTAL + "" + val.PASS + "" + val.FAIL + "" + val.BLOCK + "
    "; + return sumdata; + }, + + getTestSum: function (include_set) { + var sumdata = "

    Total:" + sum.TOTAL + + " Pass:" + sum.PASS + + " Fail:" + sum.FAIL + + " Block:" + sum.BLOCK + + " Notrun:" + sum.NOTRUN + + ""; + if (this.options.notifyInfo) { + sumdata += " " + this.options.notifyInfo + ""; + this.options.notifyInfo = ""; + } + sumdata += "

    "; + if (VIEWFLAGS.has("batch")) { + var tc = this.getTest(); + if (tc) sumdata += "

    (#" + index + ") " + tc.id + "

    "; + } + if (this.options.testsuite_name) + TestsuiteSums[this.options.testsuite_name] = newSummary(sum) + if (include_set) { + sumdata += "

    "; + sumdata += ""; + $.each(TestsetSums, function (key, val){ + sumdata += ""; + sumdata += ""; + sumdata += ""; + sumdata += ""; + sumdata += ""; + }); + sumdata += "
    TestsetTotalPassFailBlock
    " + key+ "" + val.TOTAL + "" + val.PASS + "" + val.FAIL + "" + val.BLOCK + "
    "; + } + return sumdata; + }, + + getListInfo: function () { + function createList(category) { + var testList = ""; + $.each(Testsuites[category], function (ind, val) { + testList += "

  •  " + val + "" + "
  • "; + }); + return testList; + } + var data = ""; + $.each(Testsuites, function(key, val) { + data += "

     " + key + "

    " + data += createList(key) + "
    "; + }); + data += ""; + return data; + }, + + getBrowseInfo: function () { + var failList = passList = blockList = notrunList = ""; + function createTestList(tc, color, ind) { + var mtag = (tc.execution_type === "manual") ? "(M)" : ""; + return "
  • " + mtag + "" + tc.id + "" + "
  • "; + } + TestsetSums = {}; + $.each(Tests, function (ind, val) { + if (this.set === null) + this.set = "default"; + if (typeof TestsetSums[this.set] === "undefined") + TestsetSums[this.set] = newSummary(); + TestsetSums[this.set][this.result]++; + TestsetSums[this.set]["TOTAL"]++; + if (this.result == "FAIL") + failList += createTestList(this, "red", ind); + if (this.result == "PASS") + passList += createTestList(this, "green", ind); + if (this.result == "BLOCK") + blockList += createTestList(this, "orange", ind); + if (this.result == "NOTRUN") + notrunList += createTestList(this, "black", ind); + }); + var data = ""; + if (notrunList) + data += "

    Notrun

      " + notrunList + "
    "; + if (failList) + data += "

    Fail

      " + failList + "
    "; + if (blockList) + data += "

    Block

      " + blockList + "
    "; + if (passList) + data += "

    Pass

      " + passList + "
    "; + data += ""; + return data; + }, + + TestCase: function () { + return { + id: null, + test_script_entry: null, + execution_type: "manual", + result: "NOTRUN", + purpose: "", + set: null, + pre_condition: "", + onload_delay: 0, + steps: "", + data: null}; + }, + + TestSuite: function () { + return { + id: null, + sum: null, + data: null}; + } + + }; + }()); + // Standalone test runner + var master_runner = new TestRunner(); + master_runner.start = function (ui) { + function filter(xml, self) { + var set_ind = 0; + var manuals = []; + $(xml).find("set").each(function () { + var setname = $(this).attr("name"); + if (!setname) + setname = "set" + set_ind; + $(this).find("testcase").each(function () { + var v = $(this).attr('execution_type'); + if (self.options.execution_type && v != self.options.execution_type + && $.inArray(v, self.options.execution_type) < 0) { + $(this).remove(); + return; + } + v = $(this).attr('priority'); + if (self.options.priority && v != self.options.priority + && $.inArray(v, self.options.priority) < 0){ + $(this).remove(); + return; + } + var test = self.TestCase(); + test.id = $(this).attr("id"); + test.execution_type = $(this).attr("execution_type"); + test.test_script_entry = $(this).find("test_script_entry").text(); + test.purpose = $(this).attr("purpose"); + test.pre_condition = $(this).find("pre_condition").text(); + test.onload_delay = $(this).attr("onload_delay"); + test.result = "NOTRUN"; + test.set = setname; + test.data = this; + if (test.execution_type === "auto") + self.addTest(test); + else + manuals.push(test); + }); + set_ind++; + }); + self.addTest(manuals); + } + + var self = this; + if (ui) ui.bind(self); + if (self.options.testsuite_name) + self.options.testsuite = "opt/" + self.options.testsuite_name + "/tests.xml"; + if (!self.options.testsuite) { + $.getJSON(TESTLIST_FILE, function(data) { + for (var i = 0, imax = data.length; i < imax; i++) { + for (var j = 0, jmax = data[i].tests.length; j < jmax; j++) + self.addTestsuite(data[i].tests[j], data[i].category); + } + self.ui.list(); + self.options.multiplex = true; + }); + } else { + $.get(self.options.testsuite, null, function (xml) { + self.internal.xmldoc = xml; + filter(xml, self); + self.sumInit(); + self.ui.browse(); + setTimeout(function () { + if (self.options.autorun) + self.runAll(); + }, 500); + }, "xml"); + } + }; + + master_runner.doTest = function () { + var self = this, tc = null; + while (self.goNext()) { + tc = self.getTest(); + if (!tc || tc.execution_type === "manual") + break; + self.ui.updateTestInfo(self.testInfo(), null, null); + self.ui.runTest(self.getTestCaseUrl()); + return; + } + this.ui.updateView(VIEWFLAGS.del("batch")); + if (self.options.autorun) { + self.submitResult(); + if (self.options.multiplex) { + self.ui.list(); + return; + } + close_window(); + return; + } + if (!tc) { + setTimeout(function () {self.ui.browse();}, 500); + return; + } + this.ui.updateTest(); + }; + + master_runner.report = function (result, log) { + var tc = this.getTest(); + if (!tc) return; + var oldresult = tc.result; + this.sumUpdate(oldresult, result, tc.set); + tc.result = result; + $(tc.data).find('result_info').remove(); + $(tc.data).attr('result', result); + var doc = $.parseXML("" + result + + "" + + escape_html(log) + ""); + $(tc.data).append(doc.documentElement); + if (VIEWFLAGS.has("batch")) result = null; + this.ui.updateTestInfo(null, this.getTestSum(false), result); + }; + + master_runner.submitResult = function () { + var SERVER = "http://127.0.0.1:8080"; + var contents = (new XMLSerializer()).serializeToString(this.internal.xmldoc); + var resfile = "tests.res.xml"; + if (this.options.testsuite_name) + resfile = this.options.testsuite_name + "." + resfile; + $.post(SERVER + "/save_file", {filename: resfile, data: contents}) + }; + + master_runner.internal = {xmldoc: null}; + + // Controlled test runner + var slave_runner = new TestRunner(); + slave_runner.start = function (ui) { + function sync_session_id() { + $.get(SERVER + "/init_session_id?session_id=" + + self.internal.session_id); + } + var self = this; + self.internal.session_id = Math.round(Math.random() * 10000); + sync_session_id(); + var next_step = self.internal.get_json("ask_next_step"); + if (!next_step || next_step.step != "continue") { + close_window(); + return false; + } + ui.bind(self); + var f = function () { + var p = self.internal.get_json("check_execution_progress"); + if (p) self.sumInit(parseInt(p.total)); + self.doTest(); + }; + self.ui.updateView(VIEWFLAGS.add("batch")); + self.ui.updateView(VIEWFLAGS.del("suite")); + setTimeout(f, 1000); + return true; + }; + + slave_runner.doTest = function () { + var self = this; + if (self.internal.stage > 0) { + self.ui.updateView(VIEWFLAGS.del("batch")); + self.goNext(); + self.ui.updateTest(); + return; + } + var next_step = self.internal.get_json("ask_next_step"); + if (next_step && next_step.step == "continue") { + var task = self.internal.get_json("auto_test_task"); + if (task === null) { + print_error("ask_test_task", "Fail get task"); + } else if (task.invalid === 0) { + print_error("ask_test_task", "Invalid session"); + } else if (task.stop === 0) { + print_error("ask_test_task", "close window"); + } else if (task.none !== 0) { //handle auto test + var test = self.TestCase(); + test.id = task.case_id; + test.onload_delay = task.onload_delay; + test.test_script_entry = task.entry; + test.execution_type = "auto"; + test.purpose = task.purpose; + test.pre_condition = task.pre_condition; + self.addTest(test); + self.goNext(); + self.ui.updateTestInfo(self.testInfo(), null, null); + self.ui.runTest(self.getTestCaseUrl()); + return; + } else { //handle manual test + self.ui.updateView(VIEWFLAGS.del("batch")); + self.internal.stage = 1; + var mtask = self.internal.get_json("manual_cases"); + if (mtask && mtask.none != 0) { + self.cleanTests(); + for (var i = 0, max = mtask.length; i < max; i++) { + var test = self.TestCase(); + test.id = mtask[i].case_id; + test.test_script_entry = mtask[i].entry; + test.purpose = mtask[i].purpose; + test.pre_condition = mtask[i].pre_condition; + test.result = "NOTRUN"; + test.execution_type = "manual"; + test.index = i; + var steps = ""; + $(mtask[i].steps).each(function () { + steps += "Step-" + this.order + "\t: " + this.step_desc + "\n"; + steps += "Expect\t: " + this.expected + "\n"; + }); + test.steps = steps; + self.addTest(test); + } + self.ui.updateTest(-1); + self.sumInit(); + self.ui.browse(); + } else + close_window(); + return; + } + } + close_window(); + }; + + slave_runner.report = function(result, log) { + var tc = this.getTest(); + var oldresult; + if (this.internal.stage > 0) { + this.internal.post_json("commit_manual_result", + {"case_id": tc.id, "result": result}); + oldresult = tc.result + tc.result = result; + } else { + this.internal.post_json("commit_result", + { "case_id" : tc.id, + "result" : result, + "msg" : "[Message]" + log, + "session_id" : this.internal.session_id}); + oldresult = "NOTRUN"; + } + this.sumUpdate(oldresult, result, null); + if (VIEWFLAGS.has("batch")) result = null; + this.ui.updateTestInfo(null, this.getTestSum(false), result); + }; + + slave_runner.submitResult = function () { + $.get(SERVER + "/generate_xml"); + }; + + slave_runner.internal = { + session_id: null, + stage: 0, + get_json: function (name) { + var jsondata = null; + $.getJSON(SERVER + "/" + name + "?session_id=" + + this.session_id, function(data) { + jsondata = data;}); + return jsondata; }, + post_json: function (name, d) { + $.post(SERVER + "/" + name, d, null, "json"); + } + }; + + var i_ui = (function () { + var testinfo = $("#testinfo").get(0); + var frmTest = $("#frmTest").get(0); + var textTest = $("#textTest").get(0); + var btnPass = $("#btnPass").get(0); + var btnFail = $("#btnFail").get(0); + var btnBlock = $("#btnBlock").get(0); + var btnExit = $("#btnExit").get(0); + var btnNext = $("#btnNext").get(0); + var btnPrev = $("#btnPrev").get(0); + var btnRun = $("#btnRun").get(0); + var divSum = $("#divSum").get(0); + var btnBack = $("#btnBack").get(0); + var btnSave = $("#btnSave").get(0); + var runner = null; + var listmode = null; + var nextTest = function () { + runner.goNext(); + selectTest(); + }; + + var prevTest = function() { + runner.goPrev(); + selectTest(); + }; + + var selectResult = function() { + runner.report(this.value, ""); + }; + + var selectTest = function () { + frmTest.src = ""; + var tc = runner.getTest(); + if (!tc) { + if (runner.testIndex() === -1) + textTest.value = "---Begin---"; + else + textTest.value = "---End---"; + changeColor("NOTRUN"); + return; + } + testinfo.value = runner.testInfo(); + $(divSum).html(runner.getTestSum(false)); + textTest.value = ((tc.execution_type === "manual") ? "(M)" : "") + tc.id; + changeColor(tc.result); + }; + + function changeColor(result) { + if (result === "PASS") + $(textTest).css("backgroundColor", "lightgreen"); + else if (result === "FAIL") + $(textTest).css("backgroundColor", "tomato"); + else if (result === "BLOCK") + $(textTest).css("backgroundColor", "yellow"); + else + $(textTest).css("backgroundColor", "white"); + } + + return { + bind: function (r) { + var self = this; + r.ui = self; + runner = r; + $(btnPass).on("click", selectResult); + $(btnFail).on("click", selectResult); + $(btnBlock).on("click", selectResult); + $(btnNext).on("click", nextTest); + $(btnPrev).on("click", prevTest); + $(btnRun).on("click", function () { + if (VIEWFLAGS.has("list")) { + runner.options.auto_testsuites = []; + var tdoc = frmTest.contentWindow.document; + $(tdoc).find("section li>input:checked").each(function () { + var tname = $(this).attr("id"); + runner.options.auto_testsuites.push(tname); + }); + self.list(); + } else if (VIEWFLAGS.has("suite")) { + runner.runAll(); + } else + self.runTest(runner.getTestCaseUrl()); + }); + $(frmTest).on("load", function () {runner.loadReady();}); + $(btnExit).on("click", function () { + runner.submitResult(); + if (runner.options.multiplex && VIEWFLAGS.has("suite")) + self.list(); + else + close_window(); + }); + $(btnBack).on("click", function () { + frmTest.src = ""; + setTimeout(function () {self.browse();}, 300); + }); + $(btnSave).on("click", function () { + runner.submitResult(); + runner.options.notifyInfo = "*Save succeed*"; + $(divSum).html(runner.getTestSum(true)); + }); + frmTest.height = $(window).height(); + }, + + list: function () { + var tdoc = frmTest.contentWindow.document; + $(btnExit).attr("value", "Exit"); + tdoc.open("text/html", "replace"); + tdoc.writeln(runner.getListInfo()); + var self = this; + $(tdoc).find("section li>a").on("click", function (e) { + runner.options.testsuite_name = $(this).text(); + VIEWFLAGS.del("list"); + runner.start(); + window.scrollTo(0, 0); + e.preventDefault(); + }); + $(tdoc).find("section h3>input[type=checkbox]").on("click", function () { + $boxs = $(this).parent().parent().find("li>input[type=checkbox]"); + $boxs.prop('checked', $(this).is(':checked')); + }); + $(divSum).html(runner.getListSum()); + runner.cleanTests(); + self.updateView(VIEWFLAGS.add("list")); + if (runner.options.auto_testsuites) { + if (runner.options.auto_testsuites.length > 0) { + var ts = runner.options.auto_testsuites.shift(); + runner.options.testsuite_name = ts; + runner.options.autorun = true; + VIEWFLAGS.del("list"); + runner.start(); + } else + runner.options.autorun = false; + } + }, + + browse: function () { + var tdoc = frmTest.contentWindow.document; + if (runner.options.multiplex) + $(btnExit).attr("value", "Back"); + tdoc.open("text/html", "replace"); + tdoc.writeln(runner.getBrowseInfo()); + var self = this; + $(tdoc).find("section ul li>a").on("click", function (e) { + var ind = parseInt($(this).attr("rel")); + self.updateView(VIEWFLAGS.del("suite")); + self.updateTest(ind); + window.scrollTo(0, 0); + e.preventDefault(); + }); + $(divSum).html(runner.getTestSum(true)); + self.updateView(VIEWFLAGS.add("suite")); + }, + + updateTest: function (ind) { + if (typeof ind !== "undefined") runner.testIndex(ind); + selectTest(); + }, + + updateView: function (flags) { + if (flags & VIEWFLAGS.flags.batch) + $(".batchhide").hide(); + else { + $(".batchhide").show(); + if (flags & VIEWFLAGS.flags.list) { + $(".tchide").show(); + $(".suitehide").show(); + $(".listhide").hide(); + } else if (flags & VIEWFLAGS.flags.suite) { + $(".listhide").show(); + $(".tchide").show(); + $(".suitehide").hide(); + } else { + $(".listhide").show(); + $(".suitehide").show(); + $(".tchide").hide(); + } + } + }, + + testComplete: function () { + return runner.checkResult(frmTest.contentWindow.document); + }, + + runTest: function (uri) { + if (uri === null) return; + if (uri) + frmTest.src = uri; + else + runner.loadReady(); + }, + + updateTestInfo: function (info, sum, result) { + if (info !== null) + testinfo.value = info; + if (sum !== null) + $(divSum).html(sum); + if (result !== null) + changeColor(result); + }, + }; + } ()); + + function escape_html(s) { + return s.replace(/\&/g, "&").replace(/ */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-inputdevice-tizen-tests/webrunner/testrunner.js b/common/tct-inputdevice-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-inputdevice-tizen-tests/webrunner/testrunner.js +++ b/common/tct-inputdevice-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-iotcon-tizen-tests/webrunner/testrunner.js b/common/tct-iotcon-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-iotcon-tizen-tests/webrunner/testrunner.js +++ b/common/tct-iotcon-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-mediakey-tizen-tests/webrunner/testrunner.js b/common/tct-mediakey-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-mediakey-tizen-tests/webrunner/testrunner.js +++ b/common/tct-mediakey-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-messaging-email-tizen-tests/webrunner/testrunner.js b/common/tct-messaging-email-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-messaging-email-tizen-tests/webrunner/testrunner.js +++ b/common/tct-messaging-email-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-messaging-mms-tizen-tests/webrunner/testrunner.js b/common/tct-messaging-mms-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-messaging-mms-tizen-tests/webrunner/testrunner.js +++ b/common/tct-messaging-mms-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-messaging-sms-tizen-tests/webrunner/testrunner.js b/common/tct-messaging-sms-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-messaging-sms-tizen-tests/webrunner/testrunner.js +++ b/common/tct-messaging-sms-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-mse-w3c-tests/webrunner/testrunner.js b/common/tct-mse-w3c-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-mse-w3c-tests/webrunner/testrunner.js +++ b/common/tct-mse-w3c-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-networkbearerselection-tizen-tests/webrunner/testrunner.js b/common/tct-networkbearerselection-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-networkbearerselection-tizen-tests/webrunner/testrunner.js +++ b/common/tct-networkbearerselection-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-nfc-tizen-tests/webrunner/testrunner.js b/common/tct-nfc-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-nfc-tizen-tests/webrunner/testrunner.js +++ b/common/tct-nfc-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-sound-tizen-tests/webrunner/testrunner.js b/common/tct-sound-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-sound-tizen-tests/webrunner/testrunner.js +++ b/common/tct-sound-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-systeminfo-tizen-tests/webrunner/testrunner.js b/common/tct-systeminfo-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-systeminfo-tizen-tests/webrunner/testrunner.js +++ b/common/tct-systeminfo-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-systemsetting-tizen-tests/webrunner/testrunner.js b/common/tct-systemsetting-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-systemsetting-tizen-tests/webrunner/testrunner.js +++ b/common/tct-systemsetting-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-tv-audiocontrol-tizen-tests/webrunner/testrunner.js b/common/tct-tv-audiocontrol-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-tv-audiocontrol-tizen-tests/webrunner/testrunner.js +++ b/common/tct-tv-audiocontrol-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-tv-channel-tizen-tests/webrunner/testrunner.js b/common/tct-tv-channel-tizen-tests/webrunner/testrunner.js index 1c1fb7990..114c8f165 100755 --- a/common/tct-tv-channel-tizen-tests/webrunner/testrunner.js +++ b/common/tct-tv-channel-tizen-tests/webrunner/testrunner.js @@ -28,7 +28,29 @@ Authors: Wang, Jing */ -var STUB_PORT = ""; +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + +var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ url:"/opt/usr/home/owner/share/TCT_CONFIG", @@ -40,15 +62,15 @@ $.ajax({ RESOURCE_DIR = path[1]; } }); -$.ajax({ - url:RESOURCE_DIR + "/tct/portconfigure.json", - dataType:"json", - data:{}, - async:false, - success:function(data){ - STUB_PORT = data[0]["STUB_PORT"]; - } -}); +$.ajax({ + url:RESOURCE_DIR + "/tct/portconfigure.json", + dataType:"json", + data:{}, + async:false, + success:function(data){ + STUB_PORT = data[0]["STUB_PORT"]; + } +}); (function (window){ function TestRunner() { this.start = null; diff --git a/common/tct-tv-displaycontrol-tizen-tests/webrunner/testrunner.js b/common/tct-tv-displaycontrol-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-tv-displaycontrol-tizen-tests/webrunner/testrunner.js +++ b/common/tct-tv-displaycontrol-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ diff --git a/common/tct-tv-info-tizen-tests/webrunner/testrunner.js b/common/tct-tv-info-tizen-tests/webrunner/testrunner.js index 1c1fb7990..114c8f165 100755 --- a/common/tct-tv-info-tizen-tests/webrunner/testrunner.js +++ b/common/tct-tv-info-tizen-tests/webrunner/testrunner.js @@ -28,7 +28,29 @@ Authors: Wang, Jing */ -var STUB_PORT = ""; +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + +var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ url:"/opt/usr/home/owner/share/TCT_CONFIG", @@ -40,15 +62,15 @@ $.ajax({ RESOURCE_DIR = path[1]; } }); -$.ajax({ - url:RESOURCE_DIR + "/tct/portconfigure.json", - dataType:"json", - data:{}, - async:false, - success:function(data){ - STUB_PORT = data[0]["STUB_PORT"]; - } -}); +$.ajax({ + url:RESOURCE_DIR + "/tct/portconfigure.json", + dataType:"json", + data:{}, + async:false, + success:function(data){ + STUB_PORT = data[0]["STUB_PORT"]; + } +}); (function (window){ function TestRunner() { this.start = null; diff --git a/common/tct-tv-window-tizen-tests/webrunner/testrunner.js b/common/tct-tv-window-tizen-tests/webrunner/testrunner.js index 1c1fb7990..114c8f165 100755 --- a/common/tct-tv-window-tizen-tests/webrunner/testrunner.js +++ b/common/tct-tv-window-tizen-tests/webrunner/testrunner.js @@ -28,7 +28,29 @@ Authors: Wang, Jing */ -var STUB_PORT = ""; +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + +var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({ url:"/opt/usr/home/owner/share/TCT_CONFIG", @@ -40,15 +62,15 @@ $.ajax({ RESOURCE_DIR = path[1]; } }); -$.ajax({ - url:RESOURCE_DIR + "/tct/portconfigure.json", - dataType:"json", - data:{}, - async:false, - success:function(data){ - STUB_PORT = data[0]["STUB_PORT"]; - } -}); +$.ajax({ + url:RESOURCE_DIR + "/tct/portconfigure.json", + dataType:"json", + data:{}, + async:false, + success:function(data){ + STUB_PORT = data[0]["STUB_PORT"]; + } +}); (function (window){ function TestRunner() { this.start = null; diff --git a/common/tct-websetting-tizen-tests/webrunner/testrunner.js b/common/tct-websetting-tizen-tests/webrunner/testrunner.js index b8fbd34cb..114c8f165 100755 --- a/common/tct-websetting-tizen-tests/webrunner/testrunner.js +++ b/common/tct-websetting-tizen-tests/webrunner/testrunner.js @@ -28,6 +28,28 @@ Authors: Wang, Jing */ +$(function(){ + try { + // Checks if a device supports bluetooth API or not + var shape = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.shape"); + console.log("Shape = " + shape); + //alert(" Shape = " + shape); + } catch (error) { + // alert("Error name: " + error.name + ", message: " + error.message); + console.log("Error name: " + error.name + ", message: " + error.message); + } + + if(shape=="circle"){ + $('body').css('max-width', '100%'); + $('body').css('max-height', '100%'); + $('body').css('background-color', 'white'); + $('body').css('margin-top', '20%'); + $('body').css('margin-bottom', '20%'); + $('body').css('margin-left', '20%'); + $('body').css('margin-right', '20%'); + } +}); + var STUB_PORT = ""; var RESOURCE_DIR; $.ajax({