[IMP] web,tests,test_main_flows: Chrome headless touch option

Before this commit Chrome's "touch mode" was enabled in both desktop and
mobile-like tests suite (when run headless).

To better match real usecases, this commit adds an option to
enable "touch mode" only in mobile tests suites; keeping it disabled in
desktop ones.

Part-of: odoo/odoo#95924
This commit is contained in:
Pierre Paridans
2022-07-19 11:50:51 +02:00
parent 22591206d4
commit 69f047c26d
3 changed files with 10 additions and 5 deletions
+1
View File
@@ -40,6 +40,7 @@ class WebSuite(odoo.tests.HttpCase):
@odoo.tests.tagged('post_install', '-at_install')
class MobileWebSuite(odoo.tests.HttpCase):
browser_size = '375x667'
touch_enabled = True
def test_mobile_js(self):
# webclient mobile test suite
@@ -78,6 +78,7 @@ class TestUi(BaseTestUi):
class TestUiMobile(BaseTestUi):
browser_size = '375x667'
touch_enabled = True
def test_01_main_flow_tour_mobile(self):
+8 -5
View File
@@ -880,7 +880,7 @@ class ChromeBrowser:
""" Helper object to control a Chrome headless process. """
remote_debugging_port = 0 # 9222, change it in a non-git-tracked file
def __init__(self, logger, window_size, test_class):
def __init__(self, logger, window_size, touch_enabled, test_class):
self._logger = logger
self.test_class = test_class
if websocket is None:
@@ -904,6 +904,7 @@ class ChromeBrowser:
os.makedirs(self.screenshots_dir, exist_ok=True)
self.window_size = window_size
self.touch_enabled = touch_enabled
self.sigxcpu_handler = None
self._chrome_start()
self._find_websocket()
@@ -1043,10 +1044,11 @@ class ChromeBrowser:
'--remote-debugging-port': str(self.remote_debugging_port),
'--no-sandbox': '',
'--disable-gpu': '',
# required for tests that depends on the jquery.touchSwipe library, which detects
# touch capabilities using "'ontouchstart' in window"
'--touch-events':'',
}
if self.touch_enabled:
# enable Chrome's Touch mode, useful to detect touch capabilities using
# "'ontouchstart' in window"
switches['--touch-events'] = ''
cmd = [self.executable]
cmd += ['%s=%s' % (k, v) if v else k for k, v in switches.items()]
@@ -1557,6 +1559,7 @@ class HttpCase(TransactionCase):
registry_test_mode = True
browser = None
browser_size = '1366x768'
touch_enabled = False
_logger: logging.Logger = None
@@ -1587,7 +1590,7 @@ class HttpCase(TransactionCase):
def start_browser(cls):
# start browser on demand
if cls.browser is None:
cls.browser = ChromeBrowser(cls._logger, cls.browser_size, cls.__name__)
cls.browser = ChromeBrowser(cls._logger, cls.browser_size, cls.touch_enabled, cls.__name__)
cls.addClassCleanup(cls.terminate_browser)
@classmethod