tests: Add a view fixture in test_tab
This commit is contained in:
parent
68f5ed4fa4
commit
558ef290e4
@ -20,9 +20,11 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from PyQt5.QtCore import PYQT_VERSION, pyqtSignal, QPoint
|
from PyQt5.QtCore import PYQT_VERSION, pyqtSignal, QPoint
|
||||||
|
from PyQt5.QtGui import QColor
|
||||||
|
|
||||||
from qutebrowser.browser import browsertab
|
from qutebrowser.browser import browsertab
|
||||||
from qutebrowser.keyinput import modeman
|
from qutebrowser.keyinput import modeman
|
||||||
|
from qutebrowser.utils import objreg
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PyQt5.QtWebKitWidgets import QWebView
|
from PyQt5.QtWebKitWidgets import QWebView
|
||||||
@ -41,10 +43,8 @@ except ImportError:
|
|||||||
WebEngineView = None
|
WebEngineView = None
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(PYQT_VERSION < 0x050600,
|
@pytest.fixture(params=[WebView, WebEngineView])
|
||||||
reason='Causes segfaults, see #1638')
|
def view(qtbot, config_stub, request):
|
||||||
@pytest.mark.parametrize('view', [WebView, WebEngineView])
|
|
||||||
def test_tab(qtbot, view, config_stub, tab_registry):
|
|
||||||
config_stub.data = {
|
config_stub.data = {
|
||||||
'input': {
|
'input': {
|
||||||
'forward-unbound-keys': 'auto'
|
'forward-unbound-keys': 'auto'
|
||||||
@ -55,12 +55,16 @@ def test_tab(qtbot, view, config_stub, tab_registry):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if view is None:
|
if request.param is None:
|
||||||
pytest.skip("View not available")
|
pytest.skip("View not available")
|
||||||
|
|
||||||
w = view()
|
v = request.param()
|
||||||
qtbot.add_widget(w)
|
qtbot.add_widget(v)
|
||||||
|
return v
|
||||||
|
|
||||||
|
@pytest.mark.skipif(PYQT_VERSION < 0x050600,
|
||||||
|
reason='Causes segfaults, see #1638')
|
||||||
|
def test_tab(qtbot, view, config_stub, tab_registry):
|
||||||
tab_w = browsertab.AbstractTab(win_id=0)
|
tab_w = browsertab.AbstractTab(win_id=0)
|
||||||
qtbot.add_widget(tab_w)
|
qtbot.add_widget(tab_w)
|
||||||
tab_w.show()
|
tab_w.show()
|
||||||
@ -79,11 +83,11 @@ def test_tab(qtbot, view, config_stub, tab_registry):
|
|||||||
tab_w.search = browsertab.AbstractSearch(parent=tab_w)
|
tab_w.search = browsertab.AbstractSearch(parent=tab_w)
|
||||||
tab_w.printing = browsertab.AbstractPrinting()
|
tab_w.printing = browsertab.AbstractPrinting()
|
||||||
|
|
||||||
tab_w._set_widget(w)
|
tab_w._set_widget(view)
|
||||||
assert tab_w._widget is w
|
assert tab_w._widget is view
|
||||||
assert tab_w.history._tab is tab_w
|
assert tab_w.history._tab is tab_w
|
||||||
assert tab_w.history._history is w.history()
|
assert tab_w.history._history is view.history()
|
||||||
assert w.parent() is tab_w
|
assert view.parent() is tab_w
|
||||||
|
|
||||||
|
|
||||||
class TestTabData:
|
class TestTabData:
|
||||||
|
Loading…
Reference in New Issue
Block a user