[REF] tests: add parameter to choose chrome size

When using the HttpCase browser_js method, the window size is fixed to
1366x768.

With this commit, the default window size is still '1366x768' but a test
class that inherits from HttpCase may change it to test mobile layout
by changing the browser_size class attribute.

The browser is instanciated once per test class, for that reason the
window size cannot be changed in the class methods.

To use different sizes in tests, the tests have to be splitted in
classes.

closes odoo/odoo#28760
This commit is contained in:
Christophe Monniez
2018-11-16 14:35:18 +00:00
parent 1c1ae3bef9
commit 76d29d15bf
+5 -3
View File
@@ -447,7 +447,7 @@ class SavepointCase(SingleTransactionCase):
class ChromeBrowser():
""" Helper object to control a Chrome headless process. """
def __init__(self, logger):
def __init__(self, logger, window_size):
self._logger = logger
if websocket is None:
self._logger.warning("websocket-client module is not installed")
@@ -459,6 +459,7 @@ class ChromeBrowser():
self.user_data_dir = tempfile.mkdtemp(suffix='_chrome_odoo')
self.chrome_process = None
self.screencast_frames = []
self.window_size = window_size
self._chrome_start()
self._find_websocket()
self._logger.info('Websocket url found: %s', self.ws_url)
@@ -529,7 +530,7 @@ class ChromeBrowser():
'--disable-extensions': '',
'--user-data-dir': self.user_data_dir,
'--disable-translate': '',
'--window-size': '1366x768',
'--window-size': self.window_size,
'--remote-debugging-port': str(self.devtools_port),
'--no-sandbox': '',
}
@@ -789,6 +790,7 @@ class HttpCase(TransactionCase):
"""
registry_test_mode = True
browser = None
browser_size = '1366x768'
def __init__(self, methodName='runTest'):
super(HttpCase, self).__init__(methodName)
@@ -804,7 +806,7 @@ class HttpCase(TransactionCase):
def start_browser(cls, logger):
# start browser on demand
if cls.browser is None:
cls.browser = ChromeBrowser(logger)
cls.browser = ChromeBrowser(logger, cls.browser_size)
@classmethod
def tearDownClass(cls):