diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index 09307711f..3434760ec 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -60,6 +60,9 @@ class WinRegistryHelper: registry = attr.ib() + def windowTitle(self): + return 'window title - qutebrowser' + def __init__(self): self._ids = [] diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index 15d2ce8a0..0a6df9b35 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -520,6 +520,9 @@ class TabbedBrowserStub(QObject): def count(self): return len(self.tabs) + def widgets(self): + return self.tabs + def widget(self, i): return self.tabs[i] diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index 30241b1b3..80b3234a9 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -528,6 +528,30 @@ def test_tab_completion_delete(qtmodeltester, fake_web_tab, app_stub, QUrl('https://duckduckgo.com')] +def test_window_completion(qtmodeltester, fake_web_tab, tabbed_browser_stubs): + tabbed_browser_stubs[0].tabs = [ + fake_web_tab(QUrl('https://github.com'), 'GitHub', 0), + fake_web_tab(QUrl('https://wikipedia.org'), 'Wikipedia', 1), + fake_web_tab(QUrl('https://duckduckgo.com'), 'DuckDuckGo', 2) + ] + tabbed_browser_stubs[1].tabs = [ + fake_web_tab(QUrl('https://wiki.archlinux.org'), 'ArchWiki', 0) + ] + + model = miscmodels.window() + model.set_pattern('') + qtmodeltester.data_display_may_return_none = True + qtmodeltester.check(model) + + _check_completions(model, { + 'Windows': [ + ('0', 'window title - qutebrowser', + 'GitHub, Wikipedia, DuckDuckGo'), + ('1', 'window title - qutebrowser', 'ArchWiki') + ] + }) + + def test_setting_option_completion(qtmodeltester, config_stub, configdata_stub, info): model = configmodel.option(info=info)