Skip to content

Commit

Permalink
Merge pull request #131 from Shao-Feng/native
Browse files Browse the repository at this point in the history
add a new set attribute 'extension' for supporting to load extension …
  • Loading branch information
Shao-Feng committed Mar 23, 2016
2 parents 32b08d9 + 12c11d3 commit a403314
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion testkitlite/commodule/windowshttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
WIN_MAIN = "xwalk.exe"
#C:\Program Files\webapi-promises-nonw3c-tests\xwalk.exe C:\Program Files\webapi-promises-nonw3c-tests\webapi-promises-nonw3c-tests/manifest.json
LAUNCH_XWALK = "\"c:\\Program Files\\%s\\xwalk.exe\" \"c:\\Program Files\\%s\\%s\\manifest.json\""
LAUNCH_XWALK_EXTENSIONS = "\"c:\\Program Files\\%s\\xwalk.exe\" \"c:\\Program Files\\%s\\%s\\manifest.json\" \"--use-rs-video-capture\" --external-extensions-path=\"c:\\Program Files\\%s\\%s\""
QUERY_XWALK = "tasklist | findstr xwalk.exe"
KILL_XWALK = "taskkill /im xwalk.exe /f"

Expand Down Expand Up @@ -156,9 +157,11 @@ def start_debug(self, dlogfile):
global debug_flag, metux
debug_flag = True

def launch_app(self, wgt_name):
def launch_app(self, wgt_name, extension=None):
blauched = False
cmdline = LAUNCH_XWALK % (wgt_name, wgt_name, wgt_name)
if extension is not None:
cmdline = LAUNCH_XWALK_EXTENSIONS % (wgt_name, wgt_name, wgt_name, wgt_name, extension)
cmd_json = {}
cmd_json['cmd'] = cmdline
server_url = "http://%s:8000" % self.deviceip
Expand Down
16 changes: 10 additions & 6 deletions testkitlite/engines/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _core_test_exec(conn, test_session, test_set_name, exetype, cases_queue, res
result_obj.set_status(1)


def _web_test_exec(conn, server_url, test_web_app, exetype, cases_queue, result_obj):
def _web_test_exec(conn, server_url, test_web_app, exetype, cases_queue, result_obj, extension=None):
"""function for running web tests"""
exetype = exetype.lower()
test_set_finished = False
Expand All @@ -221,7 +221,7 @@ def _web_test_exec(conn, server_url, test_web_app, exetype, cases_queue, result_
result_obj.set_status(1)
break

if not conn.launch_app(test_web_app):
if not conn.launch_app(test_web_app, extension):
LOGGER.error("[ ERROR: launch test app %s failed! ]" % test_web_app)
result_obj.set_status(1)
break
Expand All @@ -240,7 +240,7 @@ def _web_test_exec(conn, server_url, test_web_app, exetype, cases_queue, result_
result_cases = ret.get("cases")
error_code = ret.get("error_code")
if error_code is not None:
if not conn.launch_app(test_web_app):
if not conn.launch_app(test_web_app, extension):
test_set_finished = True
result_obj.set_status(1)
break
Expand Down Expand Up @@ -479,7 +479,7 @@ def __run_jqt_test(self, sessionid, test_set_name, cases):
self.opts['async_th'].start()
return True

def __run_web_test(self, sessionid, test_set_name, exetype, ctype, cases):
def __run_web_test(self, sessionid, test_set_name, exetype, ctype, cases, extension = None):
"""
process the execution for web api test
may be splitted to serveral blocks,
Expand Down Expand Up @@ -512,7 +512,7 @@ def __run_web_test(self, sessionid, test_set_name, exetype, ctype, cases):
self.opts['async_th'] = threading.Thread(
target=_web_test_exec,
args=(
self.conn, self.server_url, self.opts['test_app_id'], exetype, test_set_queues, self.result_obj)
self.conn, self.server_url, self.opts['test_app_id'], exetype, test_set_queues, self.result_obj, extension)
)
self.opts['async_th'].start()
return True
Expand All @@ -521,6 +521,8 @@ def run_test(self, sessionid, test_set):
"""
process the execution for a test set
"""
extension = test_set["extension"]

if sessionid is None:
return False

Expand All @@ -529,6 +531,8 @@ def run_test(self, sessionid, test_set):
disabledlog = os.environ.get('disabledlog','')
cases, exetype, ctype = test_set[
"cases"], test_set["exetype"], test_set["type"]


if len(cases) == 0:
return False
# start debug trace thread
Expand All @@ -542,7 +546,7 @@ def run_test(self, sessionid, test_set):
if self.opts['test_type'] == "webapi":
if ctype == 'ref':
exetype = 'manual'
return self.__run_web_test(sessionid, self.opts['testset_name'], exetype, ctype, cases)
return self.__run_web_test(sessionid, self.opts['testset_name'], exetype, ctype, cases, extension)
elif self.opts['test_type'] == "coreapi":
return self.__run_core_test(sessionid, self.opts['testset_name'], exetype, cases)
#elif self.opts['test_type'] == "jqunit":
Expand Down
4 changes: 4 additions & 0 deletions testkitlite/util/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ def __prepare_external_test_json(self, resultfile):
tsuite = root_em.getiterator('suite')[0]
case_tmp = []
parameters.setdefault("suite_name", tsuite.get('name'))
parameters.setdefault("extension", None)
for tset in root_em.getiterator('set'):
case_order = 1
parameters.setdefault("casecount", str(len(tset.getiterator('testcase'))))
Expand All @@ -853,6 +854,9 @@ def __prepare_external_test_json(self, resultfile):
parameters.setdefault("type", tset.get('type'))
parameters.setdefault("exetype", '')
parameters.setdefault("ui_auto_type", '')

parameters["extension"] = tset.get('extension')

if tset.get("ui-auto") is not None:
parameters["ui_auto_type"] = tset.get("ui-auto")
#add test set location, [email protected]
Expand Down

0 comments on commit a403314

Please sign in to comment.