tests: Add QUTE_BDD_WEBENGINE environment variable

This commit is contained in:
Florian Bruhin 2016-09-05 12:31:29 +02:00
parent cf070d48f2
commit 19ac488997
7 changed files with 23 additions and 19 deletions

View File

@ -138,6 +138,12 @@ def pytest_addoption(parser):
help='Use QtWebEngine for BDD tests') 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) @pytest.fixture(scope='session', autouse=True)
def check_display(request): def check_display(request):
if (not request.config.getoption('--no-xvfb') and if (not request.config.getoption('--no-xvfb') and

View File

@ -131,18 +131,18 @@ if not getattr(sys, 'frozen', False):
def pytest_collection_modifyitems(config, items): def pytest_collection_modifyitems(config, items):
"""Apply @qtwebengine_* markers.""" """Apply @qtwebengine_* markers."""
webengine = config.getoption('--qute-bdd-webengine')
vercheck = qtutils.version_check vercheck = qtutils.version_check
qtbug_54419_fixed = ((vercheck('5.6.2') and not vercheck('5.7.0')) or qtbug_54419_fixed = ((vercheck('5.6.2') and not vercheck('5.7.0')) or
qtutils.version_check('5.7.1') or qtutils.version_check('5.7.1') or
os.environ.get('QUTE_QTBUG54419_PATCHED', '')) os.environ.get('QUTE_QTBUG54419_PATCHED', ''))
markers = { 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, 'qtwebengine_skip': ('Skipped with QtWebEngine', pytest.mark.skipif,
webengine), config.webengine),
'qtwebkit_skip': ('Skipped with QtWebKit', pytest.mark.skipif, 'qtwebkit_skip': ('Skipped with QtWebKit', pytest.mark.skipif,
not webengine), not config.webengine),
'qtwebengine_createWindow': ('Skipped because of QTBUG-54419', 'qtwebengine_createWindow': ('Skipped because of QTBUG-54419',
pytest.mark.skipif, not qtbug_54419_fixed) pytest.mark.skipif, not qtbug_54419_fixed)
} }

View File

@ -408,7 +408,7 @@ def compare_session(request, quteproc, expected):
partial_compare is used, which means only the keys/values listed will be partial_compare is used, which means only the keys/values listed will be
compared. compared.
""" """
if request.config.getoption('--qute-bdd-webengine'): if request.config.webengine:
pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented") pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
quteproc.compare_session(expected) 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. 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") pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
session = quteproc.get_session() session = quteproc.get_session()
active_suffix = ' (active)' active_suffix = ' (active)'
@ -530,7 +530,7 @@ def _get_scroll_values(quteproc):
@bdd.then(bdd.parsers.re(r"the page should be scrolled " @bdd.then(bdd.parsers.re(r"the page should be scrolled "
r"(?P<direction>horizontally|vertically)")) r"(?P<direction>horizontally|vertically)"))
def check_scrolled(request, quteproc, direction): 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") pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
x, y = _get_scroll_values(quteproc) x, y = _get_scroll_values(quteproc)
if direction == 'horizontally': if direction == 'horizontally':
@ -543,7 +543,7 @@ def check_scrolled(request, quteproc, direction):
@bdd.then("the page should not be scrolled") @bdd.then("the page should not be scrolled")
def check_not_scrolled(request, quteproc): 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") pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
x, y = _get_scroll_values(quteproc) x, y = _get_scroll_values(quteproc)
assert x == 0 assert x == 0

View File

@ -24,7 +24,7 @@ bdd.scenarios('marks.feature')
@bdd.then(bdd.parsers.parse("the page should be scrolled to {x} {y}")) @bdd.then(bdd.parsers.parse("the page should be scrolled to {x} {y}"))
def check_y(request, quteproc, 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") pytest.xfail(reason="QtWebEngine TODO: Sessions are not implemented")
data = quteproc.get_session() data = quteproc.get_session()
pos = data['windows'][0]['tabs'][0]['history'][-1]['scroll-pos'] pos = data['windows'][0]['tabs'][0]['history'][-1]['scroll-pos']

View File

@ -157,7 +157,6 @@ class QuteProc(testprocess.Process):
def __init__(self, request, *, parent=None): def __init__(self, request, *, parent=None):
super().__init__(parent) super().__init__(parent)
self._webengine = request.config.getoption('--qute-bdd-webengine')
self._ipc_socket = None self._ipc_socket = None
self.basedir = None self.basedir = None
self._focus_ready = False self._focus_ready = False
@ -261,7 +260,7 @@ class QuteProc(testprocess.Process):
return executable, args return executable, args
def _default_args(self): 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', return ['--debug', '--no-err-windows', '--temp-basedir',
'--json-logging', '--backend', backend, 'about:blank'] '--json-logging', '--backend', backend, 'about:blank']
@ -338,7 +337,7 @@ class QuteProc(testprocess.Process):
('general', 'auto-save-interval', '0'), ('general', 'auto-save-interval', '0'),
('general', 'new-instance-open-target.window', 'last-opened') ('general', 'new-instance-open-target.window', 'last-opened')
] ]
if not self._webengine: if not self.request.config.webengine:
settings.append(('network', 'ssl-strict', 'false')) settings.append(('network', 'ssl-strict', 'false'))
for sect, opt, value in settings: for sect, opt, value in settings:

View File

@ -85,21 +85,20 @@ def _parse_file(test_name):
@pytest.mark.parametrize('find_implementation', ['javascript', 'python']) @pytest.mark.parametrize('find_implementation', ['javascript', 'python'])
def test_hints(test_name, zoom_text_only, zoom_level, find_implementation, def test_hints(test_name, zoom_text_only, zoom_level, find_implementation,
quteproc, request): quteproc, request):
webengine = bool(request.config.getoption('--qute-bdd-webengine')) if zoom_text_only and request.config.webengine:
if zoom_text_only and webengine:
pytest.skip("QtWebEngine doesn't have zoom-text-only") 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") pytest.skip("QtWebEngine doesn't have a python find implementation")
parsed = _parse_file(test_name) 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)) pytest.xfail("QtWebEngine TODO: {}".format(parsed.qtwebengine_todo))
url_path = 'data/hints/html/{}'.format(test_name) url_path = 'data/hints/html/{}'.format(test_name)
quteproc.open_path(url_path) quteproc.open_path(url_path)
# setup # setup
if not webengine: if not request.config.webengine:
quteproc.set_setting('ui', 'zoom-text-only', str(zoom_text_only)) quteproc.set_setting('ui', 'zoom-text-only', str(zoom_text_only))
quteproc.set_setting('hints', 'find-implementation', quteproc.set_setting('hints', 'find-implementation',
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) quteproc.wait_for_load_finished('data/' + parsed.target)
# reset # reset
quteproc.send_cmd(':zoom 100') quteproc.send_cmd(':zoom 100')
if not webengine: if not request.config.webengine:
quteproc.set_setting('ui', 'zoom-text-only', 'false') quteproc.set_setting('ui', 'zoom-text-only', 'false')
quteproc.set_setting('hints', 'find-implementation', 'javascript') quteproc.set_setting('hints', 'find-implementation', 'javascript')

View File

@ -48,7 +48,7 @@ def test_insert_mode(file_name, elem_id, source, input_text, auto_insert,
if source == 'keypress': if source == 'keypress':
quteproc.press_keys(input_text) quteproc.press_keys(input_text)
elif source == 'clipboard': elif source == 'clipboard':
if request.config.getoption('--qute-bdd-webengine'): if request.config.webengine:
pytest.xfail(reason="QtWebEngine TODO: :insert-text is not " pytest.xfail(reason="QtWebEngine TODO: :insert-text is not "
"implemented") "implemented")
quteproc.send_cmd(':debug-set-fake-clipboard "{}"'.format(input_text)) quteproc.send_cmd(':debug-set-fake-clipboard "{}"'.format(input_text))