Merge different FakeTabbedBrowser objects
This commit is contained in:
parent
096b0a7a37
commit
994e8c692f
@ -566,6 +566,9 @@ class TabbedBrowserStub(QObject):
|
||||
self.tabs = []
|
||||
self.shutting_down = False
|
||||
self._qtabbar = QTabBar()
|
||||
self.index_of = None
|
||||
self.current_index = None
|
||||
self.opened_url = None
|
||||
|
||||
def count(self):
|
||||
return len(self.tabs)
|
||||
@ -582,6 +585,26 @@ class TabbedBrowserStub(QObject):
|
||||
def tabBar(self):
|
||||
return self._qtabbar
|
||||
|
||||
def indexOf(self, _tab):
|
||||
if self.index_of is None:
|
||||
raise ValueError("indexOf got called with index_of None!")
|
||||
elif self.index_of is RuntimeError:
|
||||
raise RuntimeError
|
||||
else:
|
||||
return self.index_of
|
||||
|
||||
def currentIndex(self):
|
||||
if self.current_index is None:
|
||||
raise ValueError("currentIndex got called with current_index "
|
||||
"None!")
|
||||
return self.current_index
|
||||
|
||||
def currentWidget(self):
|
||||
return self.tabs[self.currentIndex() - 1]
|
||||
|
||||
def tabopen(self, url):
|
||||
self.opened_url = url
|
||||
|
||||
|
||||
class ApplicationStub(QObject):
|
||||
|
||||
|
@ -29,27 +29,6 @@ from qutebrowser.browser import signalfilter
|
||||
from qutebrowser.utils import objreg
|
||||
|
||||
|
||||
class FakeTabbedBrowser:
|
||||
|
||||
def __init__(self):
|
||||
self.index_of = None
|
||||
self.current_index = None
|
||||
|
||||
def indexOf(self, _tab):
|
||||
if self.index_of is None:
|
||||
raise ValueError("indexOf got called with index_of None!")
|
||||
elif self.index_of is RuntimeError:
|
||||
raise RuntimeError
|
||||
else:
|
||||
return self.index_of
|
||||
|
||||
def currentIndex(self):
|
||||
if self.current_index is None:
|
||||
raise ValueError("currentIndex got called with current_index "
|
||||
"None!")
|
||||
return self.current_index
|
||||
|
||||
|
||||
class Signaller(QObject):
|
||||
|
||||
signal = pyqtSignal(str)
|
||||
@ -84,8 +63,8 @@ def objects():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tabbed_browser(win_registry):
|
||||
tb = FakeTabbedBrowser()
|
||||
def tabbed_browser(stubs, win_registry):
|
||||
tb = stubs.TabbedBrowserStub()
|
||||
objreg.register('tabbed-browser', tb, scope='window', window=0)
|
||||
yield tb
|
||||
objreg.delete('tabbed-browser', scope='window', window=0)
|
||||
|
@ -31,15 +31,6 @@ from qutebrowser.utils import usertypes, objreg
|
||||
Enum = usertypes.enum('Enum', ['foo', 'foo_bar'])
|
||||
|
||||
|
||||
class FakeTabbedBrowser:
|
||||
|
||||
def __init__(self):
|
||||
self.opened_url = None
|
||||
|
||||
def tabopen(self, url):
|
||||
self.opened_url = url
|
||||
|
||||
|
||||
class TestArgumentParser:
|
||||
|
||||
@pytest.fixture
|
||||
@ -47,8 +38,8 @@ class TestArgumentParser:
|
||||
return argparser.ArgumentParser('foo')
|
||||
|
||||
@pytest.fixture
|
||||
def tabbed_browser(self, win_registry):
|
||||
tb = FakeTabbedBrowser()
|
||||
def tabbed_browser(self, stubs, win_registry):
|
||||
tb = stubs.TabbedBrowserStub()
|
||||
objreg.register('tabbed-browser', tb, scope='window', window=0)
|
||||
yield tb
|
||||
objreg.delete('tabbed-browser', scope='window', window=0)
|
||||
|
@ -137,20 +137,6 @@ class FakeMainWindow(QObject):
|
||||
return self._geometry
|
||||
|
||||
|
||||
class FakeTabbedBrowser:
|
||||
|
||||
"""A fake tabbed-browser which contains some widgets."""
|
||||
|
||||
def __init__(self, widgets):
|
||||
self._widgets = widgets
|
||||
|
||||
def widgets(self):
|
||||
return self._widgets
|
||||
|
||||
def currentIndex(self):
|
||||
return 1
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fake_window(win_registry, stubs, monkeypatch, qtbot):
|
||||
"""Fixture which provides a fake main windows with a tabbedbrowser."""
|
||||
@ -159,7 +145,7 @@ def fake_window(win_registry, stubs, monkeypatch, qtbot):
|
||||
|
||||
webview = QWebView()
|
||||
qtbot.add_widget(webview)
|
||||
browser = FakeTabbedBrowser([webview])
|
||||
browser = stubs.TabbedBrowserStub([webview])
|
||||
objreg.register('tabbed-browser', browser, scope='window', window=0)
|
||||
|
||||
yield
|
||||
@ -211,7 +197,7 @@ class TestSave:
|
||||
"""Fixture which provides a window with a fake history."""
|
||||
win = FakeMainWindow(b'fake-geometry-0', win_id=0)
|
||||
objreg.register('main-window', win, scope='window', window=0)
|
||||
browser = FakeTabbedBrowser([webview])
|
||||
browser = stubs.TabbedBrowserStub([webview])
|
||||
|
||||
objreg.register('tabbed-browser', browser, scope='window', window=0)
|
||||
qapp = stubs.FakeQApplication(active_window=win)
|
||||
|
Loading…
Reference in New Issue
Block a user