tests: Add QUTE_BDD_WEBENGINE environment variable
This commit is contained in:
parent
cf070d48f2
commit
19ac488997
@ -138,6 +138,12 @@ def pytest_addoption(parser):
|
||||
help='Use QtWebEngine for BDD tests')
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
webengine_arg = config.getoption('--qute-bdd-webengine')
|
||||
webengine_env = os.environ.get('QUTE_BDD_WEBENGINE', '')
|
||||
config.webengine = bool(webengine_arg or webengine_env)
|
||||
|
||||
|
||||
@pytest.fixture(scope='session', autouse=True)
|
||||
def check_display(request):
|
||||
if (not request.config.getoption('--no-xvfb') and
|
||||
|
@ -131,18 +131,18 @@ if not getattr(sys, 'frozen', False):
|
||||
|
||||
def pytest_collection_modifyitems(config, items):
|
||||
"""Apply @qtwebengine_* markers."""
|
||||
webengine = config.getoption('--qute-bdd-webengine')
|
||||
vercheck = qtutils.version_check
|
||||
qtbug_54419_fixed = ((vercheck('5.6.2') and not vercheck('5.7.0')) or
|
||||
qtutils.version_check('5.7.1') or
|
||||
os.environ.get('QUTE_QTBUG54419_PATCHED', ''))
|
||||
|
||||
markers = {
|
||||
'qtwebengine_todo': ('QtWebEngine TODO', pytest.mark.xfail, webengine),
|
||||
'qtwebengine_todo': ('QtWebEngine TODO', pytest.mark.xfail,
|
||||
config.webengine),
|
||||
'qtwebengine_skip': ('Skipped with QtWebEngine', pytest.mark.skipif,
|
||||
webengine),
|
||||
config.webengine),
|
||||
'qtwebkit_skip': ('Skipped with QtWebKit', pytest.mark.skipif,
|
||||
not webengine),
|
||||
not config.webengine),
|
||||
'qtwebengine_createWindow': ('Skipped because of QTBUG-54419',
|
||||
pytest.mark.skipif, not qtbug_54419_fixed)
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ def compare_session(request, quteproc, expected):
|
||||
partial_compare is used, which means only the keys/values listed will be
|
||||
compared.
|
||||
"""
|
||||
if request.config.getoption('--qute-bdd-webengine'):
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
quteproc.compare_session(expected)
|
||||
|
||||
@ -473,7 +473,7 @@ def check_open_tabs(quteproc, request, tabs):
|
||||
|
||||
It expects a list of URLs, with an optional "(active)" suffix.
|
||||
"""
|
||||
if request.config.getoption('--qute-bdd-webengine'):
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
session = quteproc.get_session()
|
||||
active_suffix = ' (active)'
|
||||
@ -530,7 +530,7 @@ def _get_scroll_values(quteproc):
|
||||
@bdd.then(bdd.parsers.re(r"the page should be scrolled "
|
||||
r"(?P<direction>horizontally|vertically)"))
|
||||
def check_scrolled(request, quteproc, direction):
|
||||
if request.config.getoption('--qute-bdd-webengine'):
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
x, y = _get_scroll_values(quteproc)
|
||||
if direction == 'horizontally':
|
||||
@ -543,7 +543,7 @@ def check_scrolled(request, quteproc, direction):
|
||||
|
||||
@bdd.then("the page should not be scrolled")
|
||||
def check_not_scrolled(request, quteproc):
|
||||
if request.config.getoption('--qute-bdd-webengine'):
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
x, y = _get_scroll_values(quteproc)
|
||||
assert x == 0
|
||||
|
@ -24,7 +24,7 @@ bdd.scenarios('marks.feature')
|
||||
|
||||
@bdd.then(bdd.parsers.parse("the page should be scrolled to {x} {y}"))
|
||||
def check_y(request, quteproc, x, y):
|
||||
if request.config.getoption('--qute-bdd-webengine'):
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
|
||||
data = quteproc.get_session()
|
||||
pos = data['windows'][0]['tabs'][0]['history'][-1]['scroll-pos']
|
||||
|
@ -157,7 +157,6 @@ class QuteProc(testprocess.Process):
|
||||
|
||||
def __init__(self, request, *, parent=None):
|
||||
super().__init__(parent)
|
||||
self._webengine = request.config.getoption('--qute-bdd-webengine')
|
||||
self._ipc_socket = None
|
||||
self.basedir = None
|
||||
self._focus_ready = False
|
||||
@ -261,7 +260,7 @@ class QuteProc(testprocess.Process):
|
||||
return executable, args
|
||||
|
||||
def _default_args(self):
|
||||
backend = 'webengine' if self._webengine else 'webkit'
|
||||
backend = 'webengine' if self.request.config.webengine else 'webkit'
|
||||
return ['--debug', '--no-err-windows', '--temp-basedir',
|
||||
'--json-logging', '--backend', backend, 'about:blank']
|
||||
|
||||
@ -338,7 +337,7 @@ class QuteProc(testprocess.Process):
|
||||
('general', 'auto-save-interval', '0'),
|
||||
('general', 'new-instance-open-target.window', 'last-opened')
|
||||
]
|
||||
if not self._webengine:
|
||||
if not self.request.config.webengine:
|
||||
settings.append(('network', 'ssl-strict', 'false'))
|
||||
|
||||
for sect, opt, value in settings:
|
||||
|
@ -85,21 +85,20 @@ def _parse_file(test_name):
|
||||
@pytest.mark.parametrize('find_implementation', ['javascript', 'python'])
|
||||
def test_hints(test_name, zoom_text_only, zoom_level, find_implementation,
|
||||
quteproc, request):
|
||||
webengine = bool(request.config.getoption('--qute-bdd-webengine'))
|
||||
if zoom_text_only and webengine:
|
||||
if zoom_text_only and request.config.webengine:
|
||||
pytest.skip("QtWebEngine doesn't have zoom-text-only")
|
||||
if find_implementation == 'python' and webengine:
|
||||
if find_implementation == 'python' and request.config.webengine:
|
||||
pytest.skip("QtWebEngine doesn't have a python find implementation")
|
||||
|
||||
parsed = _parse_file(test_name)
|
||||
if parsed.qtwebengine_todo is not None and webengine:
|
||||
if parsed.qtwebengine_todo is not None and request.config.webengine:
|
||||
pytest.xfail("QtWebEngine TODO: {}".format(parsed.qtwebengine_todo))
|
||||
|
||||
url_path = 'data/hints/html/{}'.format(test_name)
|
||||
quteproc.open_path(url_path)
|
||||
|
||||
# setup
|
||||
if not webengine:
|
||||
if not request.config.webengine:
|
||||
quteproc.set_setting('ui', 'zoom-text-only', str(zoom_text_only))
|
||||
quteproc.set_setting('hints', 'find-implementation',
|
||||
find_implementation)
|
||||
@ -111,7 +110,7 @@ def test_hints(test_name, zoom_text_only, zoom_level, find_implementation,
|
||||
quteproc.wait_for_load_finished('data/' + parsed.target)
|
||||
# reset
|
||||
quteproc.send_cmd(':zoom 100')
|
||||
if not webengine:
|
||||
if not request.config.webengine:
|
||||
quteproc.set_setting('ui', 'zoom-text-only', 'false')
|
||||
quteproc.set_setting('hints', 'find-implementation', 'javascript')
|
||||
|
||||
|
@ -48,7 +48,7 @@ def test_insert_mode(file_name, elem_id, source, input_text, auto_insert,
|
||||
if source == 'keypress':
|
||||
quteproc.press_keys(input_text)
|
||||
elif source == 'clipboard':
|
||||
if request.config.getoption('--qute-bdd-webengine'):
|
||||
if request.config.webengine:
|
||||
pytest.xfail(reason="QtWebEngine TODO: :insert-text is not "
|
||||
"implemented")
|
||||
quteproc.send_cmd(':debug-set-fake-clipboard "{}"'.format(input_text))
|
||||
|
Loading…
Reference in New Issue
Block a user