diff options
author | Florian Bruhin <me@the-compiler.org> | 2020-04-27 17:45:31 +0200 |
---|---|---|
committer | svetelna <zu.miklankova@gmail.com> | 2020-05-02 21:27:28 +0200 |
commit | 7db846e6443ef3f8955a554dc92e94cd5f88657c (patch) | |
tree | 8d97e8db8c8a9e4f9e8647204612554c2a07d584 /tests/unit/browser/test_caret.py | |
parent | 90028d21d6ecf6d7c2271167f17bd264cec68eb7 (diff) | |
download | qutebrowser-7db846e6443ef3f8955a554dc92e94cd5f88657c.tar.gz qutebrowser-7db846e6443ef3f8955a554dc92e94cd5f88657c.zip |
Harden caret tests and always show window
With newer Qt versions, it looks like the caret window always needs to be shown
for the selection to work correctly. However, the test silently passed when no
selection was available.
Diffstat (limited to 'tests/unit/browser/test_caret.py')
-rw-r--r-- | tests/unit/browser/test_caret.py | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/tests/unit/browser/test_caret.py b/tests/unit/browser/test_caret.py index 9b817c4ac..fb940f7c0 100644 --- a/tests/unit/browser/test_caret.py +++ b/tests/unit/browser/test_caret.py @@ -29,6 +29,8 @@ from qutebrowser.utils import utils, qtutils, usertypes @pytest.fixture def caret(web_tab, qtbot, mode_manager): + web_tab.container.expose() + with qtbot.wait_signal(web_tab.load_finished): web_tab.load_url(QUrl('qute://testdata/data/caret.html')) @@ -61,9 +63,13 @@ class Selection: selection = selection.strip() assert selection == expected return + elif not selection and not expected: + return self._qtbot.wait(50) + assert False, 'Failed to get selection!' + def check_multiline(self, expected, *, strip=False): self.check(textwrap.dedent(expected).strip(), strip=strip) @@ -287,17 +293,6 @@ def test_drop_selection(caret, selection): class TestSearch: - @pytest.fixture(autouse=True) - def expose(self, web_tab): - """Expose the web view if needed. - - With QtWebEngine 5.13 on macOS/Windows, searching fails (callback - called with False) when the view isn't exposed. - """ - if qtutils.version_check('5.13') and not utils.is_linux: - web_tab.container.expose() - web_tab.show() - # https://bugreports.qt.io/browse/QTBUG-60673 @pytest.mark.qtbug60673 @@ -340,15 +335,6 @@ class TestFollowSelected: def toggle_js(self, request, config_stub): config_stub.val.content.javascript.enabled = request.param - @pytest.fixture(autouse=True) - def expose(self, web_tab): - """Expose the web view if needed. - - On QtWebKit, or Qt < 5.11 and > 5.12 on QtWebEngine, we need to - show the tab for selections to work properly. - """ - web_tab.container.expose() - def test_follow_selected_without_a_selection(self, qtbot, caret, selection, web_tab, mode_manager): caret.move_to_next_word() # Move cursor away from the link |