Test tab completion with multiple tabbed browsers.
This commit is contained in:
parent
b6652ad6bc
commit
9d49f5a57d
@ -235,12 +235,15 @@ def session_manager_stub(stubs):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.yield_fixture
|
||||||
def tabbed_browser_stub(stubs):
|
def tabbed_browser_stubs(stubs, win_registry):
|
||||||
"""Fixture which provides a fake tabbed-browser object."""
|
"""Fixture providing a fake tabbed-browser object on win_id 0 and 1."""
|
||||||
stub = stubs.TabbedBrowserStub()
|
win_registry.add_window(1)
|
||||||
objreg.register('tabbed-browser', stub, scope='window', window=0)
|
stubs = [stubs.TabbedBrowserStub(), stubs.TabbedBrowserStub()]
|
||||||
yield stub
|
objreg.register('tabbed-browser', stubs[0], scope='window', window=0)
|
||||||
|
objreg.register('tabbed-browser', stubs[1], scope='window', window=1)
|
||||||
|
yield stubs
|
||||||
objreg.delete('tabbed-browser', scope='window', window=0)
|
objreg.delete('tabbed-browser', scope='window', window=0)
|
||||||
|
objreg.delete('tabbed-browser', scope='window', window=1)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.yield_fixture
|
||||||
|
@ -231,30 +231,39 @@ def test_session_completion(session_manager_stub):
|
|||||||
|
|
||||||
|
|
||||||
def test_tab_completion(stubs, qtbot, app_stub, win_registry,
|
def test_tab_completion(stubs, qtbot, app_stub, win_registry,
|
||||||
tabbed_browser_stub):
|
tabbed_browser_stubs):
|
||||||
tabbed_browser_stub.tabs = [
|
tabbed_browser_stubs[0].tabs = [
|
||||||
stubs.FakeWebView(QUrl('https://github.com'), 'GitHub', 0),
|
stubs.FakeWebView(QUrl('https://github.com'), 'GitHub', 0),
|
||||||
stubs.FakeWebView(QUrl('https://wikipedia.org'), 'Wikipedia', 1),
|
stubs.FakeWebView(QUrl('https://wikipedia.org'), 'Wikipedia', 1),
|
||||||
stubs.FakeWebView(QUrl('https://duckduckgo.com'), 'DuckDuckGo', 2)
|
stubs.FakeWebView(QUrl('https://duckduckgo.com'), 'DuckDuckGo', 2)
|
||||||
]
|
]
|
||||||
|
tabbed_browser_stubs[1].tabs = [
|
||||||
|
stubs.FakeWebView(QUrl('https://wiki.archlinux.org'), 'ArchWiki', 0),
|
||||||
|
]
|
||||||
actual = _get_completions(miscmodels.TabCompletionModel())
|
actual = _get_completions(miscmodels.TabCompletionModel())
|
||||||
assert actual == [
|
assert actual == [
|
||||||
('0', [
|
('0', [
|
||||||
('0/1', 'https://github.com', 'GitHub'),
|
('0/1', 'https://github.com', 'GitHub'),
|
||||||
('0/2', 'https://wikipedia.org', 'Wikipedia'),
|
('0/2', 'https://wikipedia.org', 'Wikipedia'),
|
||||||
('0/3', 'https://duckduckgo.com', 'DuckDuckGo')
|
('0/3', 'https://duckduckgo.com', 'DuckDuckGo')
|
||||||
|
]),
|
||||||
|
('1', [
|
||||||
|
('1/1', 'https://wiki.archlinux.org', 'ArchWiki'),
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_tab_completion_delete(stubs, qtbot, app_stub, win_registry,
|
def test_tab_completion_delete(stubs, qtbot, app_stub, win_registry,
|
||||||
tabbed_browser_stub):
|
tabbed_browser_stubs):
|
||||||
"""Verify closing a tab by deleting it from the completion widget."""
|
"""Verify closing a tab by deleting it from the completion widget."""
|
||||||
tabbed_browser_stub.tabs = [
|
tabbed_browser_stubs[0].tabs = [
|
||||||
stubs.FakeWebView(QUrl('https://github.com'), 'GitHub', 0),
|
stubs.FakeWebView(QUrl('https://github.com'), 'GitHub', 0),
|
||||||
stubs.FakeWebView(QUrl('https://wikipedia.org'), 'Wikipedia', 1),
|
stubs.FakeWebView(QUrl('https://wikipedia.org'), 'Wikipedia', 1),
|
||||||
stubs.FakeWebView(QUrl('https://duckduckgo.com'), 'DuckDuckGo', 2)
|
stubs.FakeWebView(QUrl('https://duckduckgo.com'), 'DuckDuckGo', 2)
|
||||||
]
|
]
|
||||||
|
tabbed_browser_stubs[1].tabs = [
|
||||||
|
stubs.FakeWebView(QUrl('https://wiki.archlinux.org'), 'ArchWiki', 0),
|
||||||
|
]
|
||||||
model = miscmodels.TabCompletionModel()
|
model = miscmodels.TabCompletionModel()
|
||||||
index = Mock()
|
index = Mock()
|
||||||
cat = Mock()
|
cat = Mock()
|
||||||
@ -265,7 +274,7 @@ def test_tab_completion_delete(stubs, qtbot, app_stub, win_registry,
|
|||||||
cat.child = Mock(return_value=index)
|
cat.child = Mock(return_value=index)
|
||||||
completion_widget.currentIndex = Mock(return_value=index)
|
completion_widget.currentIndex = Mock(return_value=index)
|
||||||
model.delete_cur_item(completion_widget)
|
model.delete_cur_item(completion_widget)
|
||||||
actual = [tab.url() for tab in tabbed_browser_stub.tabs]
|
actual = [tab.url() for tab in tabbed_browser_stubs[0].tabs]
|
||||||
assert actual == [QUrl('https://github.com'),
|
assert actual == [QUrl('https://github.com'),
|
||||||
QUrl('https://duckduckgo.com')]
|
QUrl('https://duckduckgo.com')]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user