support webdriver test with tizen crosswalk
authorchengtao.liu <chengtaox.liu@intel.com>
Tue, 22 Jul 2014 03:53:12 +0000 (11:53 +0800)
committerchengtao.liu <chengtaox.liu@intel.com>
Tue, 22 Jul 2014 03:53:12 +0000 (11:53 +0800)
testkit-lite
testkitlite/capability/chrome_ubuntu.py
testkitlite/capability/xw_android.py
testkitlite/capability/xw_tizen.py [new file with mode: 0644]
testkitlite/engines/default.py
testkitlite/engines/test_executer.py
testkitlite/engines/webdriver.py
testkitlite/util/session.py

index f7663a964ecb95969f2fff00dddd2f86ec74c144..ea8fd275d91381653e820f777e89c9d03c474424 100755 (executable)
@@ -193,7 +193,9 @@ try:
                     help="check if rerun test mode"),
         make_option("--non-active", dest="non_active", action="store_true",
                     help="Disable the ability to set the result of \
-                    core manual cases from the console")
+                    core manual cases from the console"),
+        make_option("-d", "--debugip", dest="debugip", action="store",
+                    help="specify tizen xwalk debug ip ")
 
     ]
 
@@ -271,7 +273,11 @@ to resolve this issue" % (LOG_DIR)
     elif OPTIONS.bmanualonly:
         exec_types.remove("auto")
 
-    #connector options
+    if OPTIONS.targetplatform and OPTIONS.targetplatform.upper().find('TIZEN') >= 0:
+        if not OPTIONS.debugip:
+            raise ValueError("tizen xwalk need a debugip input")
+
+    # connector options
     conn_opt = {}
     conn_opt['commodule'] = OPTIONS.commodule or "tizenmobile"
     conn_opt['deviceid'] = OPTIONS.device_serial
index 03ff52c8694c435ae90a56d1a04395d81d524268..6e94977782df3c98bc9b847e419f8bef342b4b97 100644 (file)
@@ -1,3 +1,3 @@
-def initCapability(test_app_name=None):
+def initCapability(test_app_name=None, appid=None):
     capability = {'chrome.binary': '/usr/bin/chromium-browser'}
     return {'desired_capabilities': capability, 'test_prefix': 'file:///'}
index 568c64eac7cc83b2f6a507700734889b8d4f9c29..4f25ecf325c3cdc9094c413cd9c9b383913e3955 100644 (file)
@@ -1,4 +1,4 @@
-def initCapability(test_app_name=None):
+def initCapability(test_app_name=None, appid=None):
     capability = {'xwalkOptions': {'androidPackage': 'org.xwalk.%s' %
                                    test_app_name, 'androidActivity': '.%sActivity' % test_app_name}}
     return {'desired_capabilities': capability, 'test_prefix': 'file:///android_asset/www/'}
diff --git a/testkitlite/capability/xw_tizen.py b/testkitlite/capability/xw_tizen.py
new file mode 100644 (file)
index 0000000..7db08b3
--- /dev/null
@@ -0,0 +1,3 @@
+def initCapability(test_app_name=None, appid=None):
+    capability = {'xwalkOptions': {'tizenDebuggerAddress': test_app_name, 'tizenAppId': appid}}
+    return {'desired_capabilities': capability, 'test_prefix': ''}
index 43cbcfa483d9afc703a23d5960b0d5faa2905d91..e1af6867c2ef082fc4602926ed7f9919a56079f9 100644 (file)
@@ -396,10 +396,15 @@ class TestWorker(object):
         if params.get('test-launcher') is not None:
             self.opts['test_type'] = "webapi"
             return self.__init_webtest_opt(params)
+        elif params.get('set_type') in ['ref','js']:
+            self.opts['test_type'] = "webapi"
+            params['test-launcher'] = "xwalk"
+            return self.__init_webtest_opt(params)
         else:
             self.opts['test_type'] = "coreapi"
             return str(uuid.uuid1())
 
+
     def __run_core_test(self, sessionid, test_set_name, exetype, cases):
         """
             process the execution for core api test
@@ -483,6 +488,8 @@ class TestWorker(object):
         self.result_obj = TestSetResut(
             self.opts['testsuite_name'], self.opts['testset_name'])
         if self.opts['test_type'] == "webapi":
+            if ctype == 'ref':
+                exetype = 'manual'
             return self.__run_web_test(sessionid, self.opts['testset_name'], exetype, ctype, cases)
         elif self.opts['test_type'] == "coreapi":
             return self.__run_core_test(sessionid, self.opts['testset_name'], exetype, cases)
index 5c1b5a83f2c11ab86101758c79f875f9d9424647..19e425b23356df035065e7e79dd19fa911c8fd9b 100644 (file)
@@ -66,6 +66,9 @@ class TestExecuter:
         self.TE_LOG.addHandler(stream_handler)
         signal.signal(signal.SIGINT, self.__exitHandler)
         signal.signal(signal.SIGTERM, self.__exitHandler)
+        #for tizne xw 
+        self.debugip = test_env.get("debugip", '')
+        self.appid = test_env.get("appid", '')
 
     def __exitHandler(self, a, b):
         if self.web_driver:
@@ -95,16 +98,18 @@ class TestExecuter:
                 self.wd_url = DEFAULT_WD_URL
 
             test_app_name = ''
+            appis = ''
             if self.target_platform.upper().find('ANDROID') >= 0:
                 test_app_name = self.suite_name.replace('-', '_')
                 self.TE_LOG.debug(
                     'Got ANDROID platform, update the app name to %s' % test_app_name)
+            elif self.target_platform.upper().find('TIZEN') >= 0:
+                test_app_name = self.debugip
             else:
-
                 test_app_name = self.suite_name
 
             exec 'from testkitlite.capability.%s import initCapability' % self.target_platform
-            driver_env = initCapability(test_app_name)
+            driver_env = initCapability(test_app_name, self.appid)
             self.test_prefix = driver_env['test_prefix']
             self.web_driver = WebDriver(
                 self.wd_url, driver_env['desired_capabilities'])
index 9e86695ccd991e3b52d2a0a4e5d1820a0a2111ce..e4c7c9ad46f3350ee0e2a1beecbfdefe4712577c 100644 (file)
@@ -19,7 +19,6 @@
 import os
 import time
 import sys
-import logging
 import json
 import socket
 import shutil
@@ -36,7 +35,6 @@ from testkitlite.util import tr_utils
 from testkitlite.util.log import LOGGER
 from testkitlite.util.result import TestSetResut
 
-LOG = logging.getLogger("TestWorker")
 EXECUTER_POLLING_INTERVAL = 2
 CNT_RETRY = 10
 
@@ -79,7 +77,7 @@ def _run_webdrvier_test(self, cases, result_obj):
     for section_json in test_set_queues:
         if result_obj.get_status() == 1:
             break
-        LOG.info("Loading a new section for testing ...")
+        LOGGER.info("Loading a new section for testing ...")
         time.sleep(EXECUTER_POLLING_INTERVAL)
         get_result = False
         while True:
@@ -92,7 +90,7 @@ def _run_webdrvier_test(self, cases, result_obj):
                     exe_command, exe_data = self.talkWithEXE(
                         'TESTS', {'data': section_json}, 0)
                     if exe_command != 'TESTS' or exe_data != 'OK':
-                        LOG.debug('Send tests failed')
+                        LOGGER.debug('Send tests failed')
                         result_obj.set_status(1)
                         break
                     continue
@@ -106,7 +104,7 @@ def _run_webdrvier_test(self, cases, result_obj):
                     get_result = True
                     break
                 elif exe_data == 'ERROR':
-                    LOG.error('Executer got error')
+                    LOGGER.error('Executer got error')
                     get_result = True
                     result_obj.set_status(1)
                     break
@@ -115,7 +113,7 @@ def _run_webdrvier_test(self, cases, result_obj):
                 result_obj.set_status(1)
                 break
         if abort_from_set:
-            LOG.error('Exit from current set execution')
+            LOGGER.error('Exit from current set execution')
             break
     result_obj.set_status(1)
     exe_command, exe_data = self.talkWithEXE(
@@ -157,15 +155,20 @@ class TestWorker(object):
         self.opts['session_dir'] = params.get("session_dir", '')
         self.opts['log_debug'] = params.get("log_debug", '')
         self.opts['exe_socket_file'] = self.exe_socket_file
+        #get tizen xw IP and appid
+        if self.opts['target_platform'].upper().find('TIZEN') >= 0:
+            _opts = self.conn.get_launcher_opt('xwalk', None, None, self.opts['suite_name'], self.opts['testset_name'])
+            self.opts['appid'] = _opts.get("test_app_id", '')
+            self.opts['debugip'] = params.get("debugip", '')
 
         if not self.__exitExecuter():
-            LOG.debug('__exitExecuter failed')
+            LOGGER.debug('__exitExecuter failed')
             return None
 
         if self.__initExecuterSocket():
             time.sleep(EXECUTER_POLLING_INTERVAL)
             if (not self.exe_proc) or (not tr_utils.pidExists(self.exe_proc)):
-                LOG.debug('Executer not existing')
+                LOGGER.debug('Executer not existing')
                 return None
             else:
                 timecnt = 0
@@ -194,7 +197,7 @@ class TestWorker(object):
                 sys.exit(0)
             else:
                 self.exe_proc = new_proc
-                LOG.debug('Runner Proc: %s, Executer Proc: %s' %
+                LOGGER.debug('Runner Proc: %s, Executer Proc: %s' %
                           (self.runner_proc, self.exe_proc))
                 return True
         except OSError, e:
@@ -228,10 +231,10 @@ class TestWorker(object):
                 self.exe_socket.bind(self.exe_socket_file)
                 self.exe_socket.listen(1)
             except Exception, e:
-                LOG.error('Setup socket failed')
+                LOGGER.error('Setup socket failed')
                 return False
             if not self.__initExecuter():
-                LOG.error('Init Executer failed')
+                LOGGER.error('Init Executer failed')
                 if self.exe_proc and tr_utils.pidExists(self.exe_proc):
                     killProcGroup(self.exe_proc)
                 self.exe_proc = None
@@ -242,7 +245,7 @@ class TestWorker(object):
         return True
 
     def talkWithEXE(self, command=None, data=None, recv_timeout=None):
-        LOG.debug('Start send: %s, %s' % (command, data))
+        # LOGGER.debug('Start send: %s, %s' % (command, data))
         try:
             self.exe_socket.settimeout(recv_timeout)
             self.exe_socket_connect.send(
@@ -254,9 +257,9 @@ class TestWorker(object):
                 command = exe_json['COMMAND']
             if exe_json['DATA']:
                 data = exe_json['DATA']
-            LOG.debug('Got: %s, %s' % (command, data))
+            LOGGER.debug('Got: %s, %s' % (command, data))
         except Exception, e:
-            LOG.error('Talk with executer failed: %s, kill executer' % e)
+            LOGGER.error('Talk with executer failed: %s, kill executer' % e)
             self.__exitExecuter()
             return (None, None)
 
index bb6566e9a4798724d934a8f12e2be06ae5ea4614..41e7740394947dcff068a515bceeab6f25a61777 100644 (file)
@@ -99,8 +99,9 @@ class TestSession:
         self.rerun = False
         self.test_prefix = ""
         self.filter_ok = False
-        self.targetplatform = None
         self.wdurl = ""
+        self.debugip =  ""
+        self.targetplatform =  ""
 
     def set_global_parameters(self, options):
         "get all options "
@@ -128,6 +129,8 @@ class TestSession:
             self.targetplatform = options.targetplatform
         if options.wdurl:
             self.wdurl = options.wdurl
+        if options.debugip:
+            self.debugip = options.debugip
 
     def add_filter_rules(self, **kargs):
         """
@@ -933,6 +936,7 @@ class TestSession:
                 starup_parameters[OPT_CAPABILITY] = self.capabilities
             # for webdriver
             starup_parameters['target_platform'] = self.targetplatform
+            starup_parameters['debugip'] = self.debugip
             starup_parameters['wd_url'] = self.wdurl
             starup_parameters['set_type'] = self.set_parameters['type']
             starup_parameters['set_exetype'] = self.set_parameters['exetype']