<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);
<!doctype html>
<!--
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+
-->
<head>
<meta name="viewport" content="width=device-width">
<script src="jquery-1.10.2.min.js"></script>
<style type="text/css">
-div#navbar,#footbar{
+html {
+ font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+table#browse {
+ border-collapse:collapse;
+ table-layout:fixed;width:80%;
+}
+
+table#browse th:first-child,table#browse td:first-child {width:40%;}
+
+table#browse th:last-child,table#browse td:last-child {width:30%;}
+
+table#browse th {
+ padding:0;
+ padding-bottom:0.5em;
+ text-align:left;
+ border-bottom:medium solid black;
+}
+table#browse td {
+ padding:1em;
+ padding-bottom:0.5em;
+ border-bottom:thin solid black;
+}
+div#navbar{
box-sizing: border-box;
width: 99%;
border: 0px;
text-align: left;
- background: teal;
+ background: slateblue;
color: white;
}
-
+div#footbar{
+ width: 99%;
+ border: 0px;
+ text-align: left;
+}
textarea#testinfo{
width: 99%;
- font-size: 14px;
+ font-size: 0.8em;
+}
+input{
+ font-size: 1.2em;
+ padding-top: 0.1em;
+ padding-bottom: 0.1em;
}
-input,label,select{
- font-size: 14px;
+#btnPrev,#btnNext{
+ width: 8%;
+}
+#btnDone,#btnRun,#btnList,#btnPass,#btnFail,#btnBlock{
+ width: 12%;
+ font-weight: bold;
}
-span.short{
- padding-left: 10px;
+#btnPass { color: green;}
+#btnFail { color: red;}
+#btnBlock { color: orange;}
+#labBatch{
+ font-size: 0.5em;
+}
+#textTest {
+ width: 60%;
}
-span.long{
- padding-left: 60px;
+#frmTest {
+ border: none;
+}
+.singlemode { display: none;}
+.short{
+ padding-left: 1em;
}
</style>
</head>
<body>
-<div id="navbar">
- <span class="short"><input type="button" style="width:8%" id="btnPrev" value="< Prev"/></span>
- <select id="selTestlist" style="width:60%"> </select>
- <input type="button" style="width:8%" id="btnNext" value="Next >"/>
- <input type="checkbox" name="manualonly" id="chkManualonly"/><label for="chkManualonly">Manual-Only</label>
+<div id="navbar" class="batchmode">
+ <span class="short singlemode"><input type="button" id="btnList" value="List"/></span>
+ <span class="singlemode short">
+ <input type="button" id="btnPrev" value="<"/>
+ <input type="text" id="textTest" readonly />
+ <input type="button" id="btnNext" value=">"/>
+ </span>
+ <span class="short listmode"> <input type="button" id="btnDone" value="Done"/></span>
</div>
-<div width="99%">
- <textarea id="testinfo" rows=8 disabled>
+<div id="divSum"> </div>
+<div width="99%" class="singlemode">
+ <textarea class="batchmode" id="testinfo" rows=4 disabled>
</textarea>
</div>
-<div id="footbar">
- <span class="short"><input type="button" style="width:8%" id="btnDone" value="Done"/></span>
- <span class="short"><input type="radio" name="result" id="radPass" value="PASS"/><label for="radPass">Pass</label></span>
- <span class="short"><input type="radio" name="result" id="radFail" value="FAIL"/><label for="radFail">Fail</label></span>
- <span class="long"><input type="button" style="width:8%" id="btnRun" value="Run"/></span>
- <input type="checkbox" name="batch" id="chkBatch"/><label for="chkBatch">Batch</label>
+<div id="footbar" class="batchmode">
+ <span class="short"><input type="button" id="btnRun" value="Run"/></span>
+ <span class="short singlemode"><input type="button" id="btnPass" value="PASS"/></span>
+ <span class="short singlemode"><input type="button" id="btnFail" value="FAIL"/></span>
+ <span class="short singlemode"><input type="button" id="btnBlock" value="BLOCK"/></span>
</div>
-<iframe frameborder="1" width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
+<iframe width="100%" id="frmTest" allowFullScreen="true" mozAllowFullScreen="true" webkitAllowFullscreen="true" src="">
</iframe>
<script src="testrunner.js"> </script>
</body>
/*
-# Copyright (C) 2013 Intel Corporation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-*/
+Copyright (c) 2013 Intel Corporation.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of works must retain the original copyright notice, this list
+ of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the original copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of Intel Corporation nor the names of its contributors
+ may be used to endorse or promote products derived from this work without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Authors:
+ Wang, Jing <jing.j.wang@intel.com>
+*/
(function (window){
function TestRunner() {
this.start = null;
- this.submitResult = null;
this.ui = null;
+ this.submitResult = null;
this.report = function (result, message) {};
this.doTest = function () {};
- this.internal = {};
}
TestRunner.prototype = (function () {
var index = -1;
- var autoflag = false;
var Tests = [];
- var sum = {"TOTAL": 0,
- "PASS" : 0,
- "FAIL" : 0,
- "BLOCK" : 0,
- "NOTRUN" : 0
- };
- var testContext = {
- start_time: null,
- prev_uri: "",
- uri: "",
- sub_index: 0,
- onload_delay: 0
- };
+ 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];
},
- cleanTests: function () {
- Tests = [];
- },
-
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;
},
- getTestIndex: function () {
- return index;
+ runAll: function () {
+ testContext = newTestContext();
+ this.ui.updateView(VIEWFLAGS.add("batch"));
+ this.ui.updateView(VIEWFLAGS.del("list"));
+ this.testIndex(-1);
+ this.doTest();
+ },
+
+ cleanTests: function () {
+ Tests = [];
},
- setTestIndex: function (ind) {
+ testIndex: function (ind) {
+ if (typeof ind === "undefined")
+ return index;
index = ind;
},
},
addTest: function (test) {
- Tests.push(test);
- },
-
- getTestLength: function () {
- if (Tests === null)
- return 0;
- return Tests.length;
+ 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;
+ sum.TOTAL = sum.NOTRUN = num;
+ sum.PASS = sum.FAIL = sum.BLOCK = 0;
},
- sumUpdate: function (oldRes, newRes) {
- if (oldRes !== null)
+ sumUpdate: function (oldRes, newRes, set) {
+ if (oldRes !== null) {
sum[oldRes]--;
- if (newRes !== null)
+ if (set !== null) Sets[set][oldRes]--;
+ }
+ if (newRes !== null) {
sum[newRes]++;
+ if (set != null) Sets[set][newRes]++;
+ }
},
- checkResult: function () {
+ checkResult: function (oTestDoc) {
var message = "";
- var oTestDoc = this.ui.getTestfrmDoc();
// Handle sub-index test
if (testContext.sub_index > 0) {
var oRes = $(oTestDoc).find("table#results");
return false;
var ind = testContext.sub_index - 1;
var $n = $(oRes).find('tbody > tr').eq(ind);
- if ($n.length > 0) {
- var result = $n.children("td:eq(0)").text();
- message = $n.children("td:eq(2)").text();
- if (result)
- this.report(result.toUpperCase(), message);
- } else
- this.report('FAIL', 'Not found test');
+ 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;
}
return false;
},
- testinfo: function () {
+ testInfo: function (ind) {
var info = "";
- for (var n in sum)
- info += n + ":" + sum[n] + " ";
var tc = this.getTest();
- info += "\n\nTest\t: " + tc.test_script_entry;
- info += "\nPurpose\t: " + tc.purpose;
+ 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)
return info;
},
- getTestCase: function (name, ind) {
- if (ind === null)
- ind = this.getTestIndex();
- var tc = this.getTest(ind);
- return tc[name];
- },
-
- getTestCase: function () {
+ 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 "";
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;
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") { // Need sub index in TC
+ 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) {
- this.load_ready();
+ if (testContext.uri == testContext.prev_uri)
return "";
- }
} else {
testContext.uri = uri;
testContext.sub_index = 0;
return testContext.uri;
},
- load_ready: function () {
- if (!autoflag)
+ loadReady: function () {
+ if (!VIEWFLAGS.has("batch"))
return;
- if (!this.checkResult()){
+ if (!this.ui.testComplete()){
if (testContext.onload_delay > 0){
var tval = 500;
var self = this;
- setTimeout(function() {self.load_ready();}, tval);
+ setTimeout(function() {self.loadReady();}, tval);
testContext.onload_delay -= tval;
return
}
this.doTest();
},
- setAutomode: function (flag) {
- if (this.ui)
- this.ui.setAutotestView(flag);
- autoflag = flag;
+ getTestSum: function (include_set) {
+ var sumdata = "<section><h3>Total:" + sum.TOTAL
+ + " Pass:<span style='color:green;'>" + sum.PASS
+ + "</span> Fail:<span style='color:red;'>" + sum.FAIL
+ + "</span> Block:<span style='color:orange;'>" + sum.BLOCK
+ + "</span> NotRun:<span style='color:black;'>" + sum.NOTRUN
+ + "</span></h3></section>";
+ if (VIEWFLAGS.has("batch")) {
+ var tc = this.getTest();
+ if (tc) sumdata += "<h4><span style='background-color: wheat'>(#" + index + ") " + tc.id + "</span></h4>";
+ }
+
+ if (include_set) {
+ sumdata += "<p><table id='browse'><tr><th>TestSet</th>";
+ sumdata += "<th>Total</th><th>Pass</th><th>Fail</th><th>Block</th></tr>";
+ $.each(Sets, function (key, val){
+ sumdata += "<tr><td>" + key+ "</td>";
+ sumdata += "<td style='color:black;'>" + val.TOTAL + "</td>";
+ sumdata += "<td style='color:green;'>" + val.PASS + "</td>";
+ sumdata += "<td style='color:red;'>" + val.FAIL + "</td>";
+ sumdata += "<td style='color:orange;'>" + val.BLOCK + "</td></tr>";
+ });
+ sumdata += "</table>";
+ }
+ return sumdata;
},
- autoTest: function () {
- index = -1;
- this.setAutomode(true);
- this.doTest();
+ getBrowseInfo: function () {
+ var failList = passList = blockList = notrunList = "";
+ function createTestList(tc, color, ind) {
+ var mtag = (tc.execution_type === "manual") ? "(M)" : "";
+ return "<li>" + mtag + "<a rel='" + ind + "' href='' style ='color:" + color + ";'>" + tc.id + "</a>" + "</li>";
+ }
+ 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 = "<html><head><style>ul li {padding-bottom:0.8em;font-size: 1.3em;}";
+ data += "html{font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;}</style></head><body>";
+ if (notrunList)
+ data += "<section><h3>Notruns</h3><ul>" + notrunList + "</ul></section>";
+ if (failList)
+ data += "<section><h3 style='color: red;'>Fails</h3><ul>" + failList + "</ul></section>";
+ if (blockList)
+ data += "<section><h3 style='color: orange;'>Blocks</h3><ul>" + blockList + "</ul></section>";
+ if (passList)
+ data += "<section><h3 style='color: green'>Passes</h3><ul>" + passList + "</ul></section>";
+ data += "</body></html>";
+ return data;
},
- TestCase: function() {
+ TestCase: function () {
return {
id: null,
test_script_entry: null,
execution_type: "manual",
result: "NOTRUN",
purpose: "",
+ set: null,
pre_condition: "",
onload_delay: 0,
steps: "",
var master_runner = new TestRunner();
master_runner.start = function (ui) {
function filter(xml, self) {
- $(xml).find("testcase").each(function() {
- var v = $(this).attr('execution_type');
- if (parms.execution_type && v != parms.execution_type
- && $.inArray(v, parms.execution_type) < 0) {
- $(this).remove();
- return;
- }
- v = $(this).attr('priority');
- if (parms.priority && v != parms.priority
- && $.inArray(v, parms.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.data = this;
- self.addTest(test);
- });
- }
-
- 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(',');
+ 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;
}
- } else
- parms[items[i]] = 1;
- }
- if (!parms.testsuite)
- parms.testsuite = 'tests.xml';
- return parms;
+ 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);
- var parms = getParms();
- $.get(parms.testsuite, null, function (xml) {
- self.internal.xmldoc = xml;
- filter(xml, self);
- self.sumInit();
- self.ui.updateList();
- if (parms.hasOwnProperty("autorun"))
- self.autoTest();
- }, "xml");
+ $.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;
- self.goNext();
- while ((tc = self.getTest())) {
- if (tc.execution_type != 'auto') {
- self.goNext();
- continue;
- }
- self.ui.updateTestInfo(self.testinfo());
- self.ui.runTest(self.getTestCase());
+ 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;
}
- self.ui.updateList();
- this.setAutomode(false);
- setTimeout(function () {self.submitResult();}, 2000);
+ 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);
+ this.sumUpdate(oldresult, result, tc.set);
tc.result = result;
$(tc.data).find('result_info').remove();
$(tc.data).attr('result', result);
"</start><end>" + new Date() + "</end><stdout>" +
escape_html(log) + "</stdout></result_info>");
$(tc.data).append(doc.documentElement);
- this.ui.updateResult(result);
- this.ui.updateTestInfo(this.testinfo());
+ if (VIEWFLAGS.has("batch")) result = null;
+ this.ui.updateTestInfo(null, this.getTestSum(false), result);
};
master_runner.submitResult = function () {
var xmldoc = this.internal.xmldoc;
- var data = "<title>Test Result</title><head>";
- data += "<link rel='stylesheet' type='text/css' href='report.css'>";
- data += "</head><body><section id='summary'><h2>Summary</h2>";
- var failList = $(xmldoc).find("testcase[result='FAIL']");
- var blockList = $(xmldoc).find("testcase[result='BLOCK']");
- var ipassList = $(xmldoc).find("testcase[result='PASS']");
- var ifail, iblock;
- data += "<h3>Total:" + this.getTestLength()
- + " Pass:<span style='color:green;'>" + ipassList.length
- + "</span> Fail:<span style='color:red;'>" + failList.length
- + "</span> Block:<span style='color:orange;'>" + blockList.length
- + "</span></h3></section>";
-
- data += "<p><table id='results'><tr><th>TestSet</th>";
- data += "<th>Pass</th><th>Fail</th><th>Block</th></tr>";
- $(xmldoc).find("set").each(function (){
- ipass = $(this).find("testcase[result='PASS']").length;
- ifail = $(this).find("testcase[result='FAIL']").length;
- iblock = $(this).find("testcase[result='BLOCK']").length;
- data += "<tr><td>" + $(this).attr('name') + "</td>";
- data += "<td style='color:green;'>" + ipass + "</td>";
- data += "<td style='color:red;'>" + ifail + "</td>";
- data += "<td style='color:orange;'>" + iblock + "</td></tr>";
- });
- data += "</table>";
-
- function appendList(list, title, color) {
- data += "<section><h2>" + title + "</h2>";
- $(list).each(function() {
- var url = $(this).find("test_script_entry").text();
- data += "<ul><li><a href='" + url + "' style ='color:" + color + ";'>" + url + "</a></li></ul>";
- });
- data += "</section>";
- }
-
- if (failList.length > 0)
- appendList(failList, "Fails", "red");
-
- if (blockList.length > 0)
- appendList(blockList, "Blocks", "orange");
-
- var tdoc = this.ui.getTestfrmDoc();
- tdoc.open("text/html", "replace");
- tdoc.writeln(data);
+ var contents = (new XMLSerializer()).serializeToString(xmldoc);
+ if (window.opener) window.opener.postMessage(contents, "*");
};
master_runner.internal = {xmldoc: null};
if (!next_step || next_step.step != "continue")
return false;
ui.bind(self);
- self.ui.updateTestInfo("Connecting server...");
var f = function () {
var p = self.internal.get_json("check_execution_progress");
- if (p)
- self.sumInit(parseInt(p.total));
+ if (p) self.sumInit(parseInt(p.total));
self.doTest();
};
- self.setAutomode(true);
- setTimeout(f, 2000);
+ 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.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
+ self.goNext();
+ self.ui.updateTest();
return;
}
var next_step = self.internal.get_json("ask_next_step");
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) {
+ } else if (task.invalid === 0) {
print_error("ask_test_task", "Invalid session");
- } else if (task.stop == 0) {
+ } else if (task.stop === 0) {
print_error("ask_test_task", "close window");
- } else if (task.none != 0) { //handle auto test
+ } 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.cleanTests();
self.addTest(test);
- self.setTestIndex(0);
- self.ui.runTest(self.getTestCase());
+ self.goNext();
+ self.ui.updateTestInfo(self.testInfo(), null, null);
+ self.ui.runTest(self.getTestCaseUrl());
return;
} else { //handle manual test
- self.setAutomode(false);
+ self.ui.updateView(VIEWFLAGS.del("batch"));
self.internal.stage = 1;
var mtask = self.internal.get_json("manual_cases");
- if (mtask && mtask.none !=0) {
+ if (mtask && mtask.none != 0) {
self.cleanTests();
for (var i = 0, max = mtask.length; i < max; i++) {
var test = self.TestCase();
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";
test.steps = steps;
self.addTest(test);
}
- self.ui.updateList();
+ self.ui.updateTest(-1);
self.sumInit();
+ self.ui.browse();
} else
close_window();
return;
{"case_id": tc.id, "result": result});
oldresult = tc.result
tc.result = result;
- this.ui.updateResult(result);
} else {
this.internal.post_json("commit_result",
{ "case_id" : tc.id,
"session_id" : this.internal.session_id});
oldresult = "NOTRUN";
}
- this.sumUpdate(oldresult, result);
- this.ui.updateTestInfo(this.testinfo());
+ 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");
- close_window();
};
slave_runner.internal = {
var i_ui = (function () {
var testinfo = $("#testinfo").get(0);
var frmTest = $("#frmTest").get(0);
- var selTestlist = $("#selTestlist").get(0);
- var radPass = $("#radPass").get(0);
- var radFail = $("#radFail").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 divNav = $("#navbar").get(0);
- var divFoot = $("#footbar").get(0);
- var chkBatch = $("#chkBatch").get(0);
- var chkManualonly = $("#chkManualonly").get(0);
+ var divSum = $("#divSum").get(0);
+ var btnList = $("#btnList").get(0);
var runner = null;
+ var listmode = null;
var nextTest = function () {
- if (selTestlist.selectedIndex >= (selTestlist.options.length - 1))
- selTestlist.selectedIndex = 0;
- else
- selTestlist.selectedIndex++;
- selectTest.call(selTestlist);
+ runner.goNext();
+ selectTest();
};
var prevTest = function() {
- if (selTestlist.selectedIndex <= 0)
- selTestlist.selectedIndex = selTestlist.options.length - 1;
- else
- selTestlist.selectedIndex--;
- selectTest.call(selTestlist);
+ runner.goPrev();
+ selectTest();
};
var selectResult = function() {
};
var selectTest = function () {
- var opt = this.options[this.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- var result = runner.getTest().result;
- if (result == "PASS"){
- radPass.checked = true;
- } else if (result == "FAIL"){
- radFail.checked = true;
- } else {
- radPass.checked = false;
- radFail.checked = false;
- }
frmTest.src = "";
- testinfo.value = runner.testinfo();
+ 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);
};
- var changeOptColor = function (result, opt) {
- if (result == "PASS")
- $(opt).css("backgroundColor", "greenyellow");
- else if ($.inArray(result, ["FAIL", "BLOCK"]) > -1)
- $(opt).css("backgroundColor", "orangered");
- };
+ 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;
- $(radPass).on("click", selectResult);
- $(radFail).on("click", selectResult);
+ $(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 (chkBatch.checked && !chkManualonly.checked)
- runner.autoTest();
- else {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- runner.setTestIndex(parseInt(opt.value));
- self.runTest(runner.getTestCase());
- }
+ if (VIEWFLAGS.has("list")) {
+ runner.runAll();
+ } else
+ self.runTest(runner.getTestCaseUrl());
});
- $(frmTest).on("load", function () {runner.load_ready();});
+ $(frmTest).on("load", function () {runner.loadReady();});
$(btnDone).on("click", function () {
- setTimeout(function () {runner.submitResult();}, 300);
- frmTest.src = "";});
- $(chkManualonly).on("click", function () {
- chkBatch.disabled = this.checked;
- chkBatch.checked = false;
- self.updateList();
+ 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();
+ },
- setAutotestView: function (autoflag) {
- if (autoflag){
- $(divNav).hide();
- $(divFoot).hide();
+ updateView: function (flags) {
+ if (flags & VIEWFLAGS.flags.list) {
+ $(".listmode").show();
+ $(".singlemode").hide();
} else {
- $(divNav).show();
- $(divFoot).show();
- frmTest.src = "";
+ $(".listmode").hide();
+ $(".singlemode").show();
}
+ if (flags & VIEWFLAGS.flags.batch)
+ $(".batchmode").hide();
+ else
+ $(".batchmode").show();
},
- getTestfrmDoc: function () {
- return frmTest.contentWindow.document;
+ testComplete: function () {
+ return runner.checkResult(frmTest.contentWindow.document);
},
-
+
runTest: function (uri) {
+ if (uri === null) return;
if (uri)
frmTest.src = uri;
+ else
+ runner.loadReady();
+
},
- updateList: function (){
- var item;
- selTestlist.options.length = 0;
- for(var i = 0, max = runner.getTestLength(); i < max; i++){
- var tc = runner.getTest(i);
- if (chkManualonly.checked && tc.execution_type=="auto")
- continue;
- if (tc.id.length > 32) {
- var prefix = tc.id.substring(0, 9);
- var postfix = tc.id.substring(15);
- item = new Option(prefix + " ... " + postfix, i);
- } else
- item = new Option(tc.id, i);
- selTestlist.options.add(item);
- changeOptColor(tc.result, item);
- }
- $(selTestlist).on("change", selectTest);
- selectTest.call(selTestlist);
- },
-
- updateResult: function (result) {
- var opt = selTestlist.options[selTestlist.selectedIndex];
- changeOptColor(result, opt);
+ updateTestInfo: function (info, sum, result) {
+ if (info !== null)
+ testinfo.value = info;
+ if (sum !== null)
+ $(divSum).html(sum);
+ if (result !== null)
+ changeColor(result);
},
-
- updateTestInfo: function (info) {
- testinfo.value = info;
- }
};
} ());
master_runner.start(i_ui);
}
var SERVER = "http://127.0.0.1:8000";
+ var VIEWFLAGS = { val: 0,
+ flags: {list: 1, batch: 2},
+ add: function (f) { this.val |= this.flags[f]; return this.val},
+ del: function (f) { this.val &= ~this.flags[f]; return this.val},
+ has: function (f) { return this.val & this.flags[f];},
+ };
$.ajaxSetup({ async: false});
$(window).on("ready", pre_init);
})(window);