From 9b1c07e2e2943b20b2f1f0f9d438ad3cd9217ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Thu, 11 Aug 2016 15:20:52 +0200 Subject: [PATCH] add tests for hints auto-follow in word mode --- tests/end2end/features/hints.feature | 44 +++++++++++++++++++++++- tests/end2end/features/test_hints_bdd.py | 25 ++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature index a5ec33a04..52c6c88e4 100644 --- a/tests/end2end/features/hints.feature +++ b/tests/end2end/features/hints.feature @@ -352,4 +352,46 @@ Feature: Using hints And I press the key "" Then data/hello.txt should be loaded - # TODO: tests for word mode - it tries to access /usr/share/dict/words on the system + Scenario: Using hints -> auto-follow == 'always' in word mode + When I open data/hints/html/simple.html + And I set hints -> mode to word + And I set hints -> auto-follow to always + And I run :hint + Then data/hello.txt should be loaded + + Scenario: Using hints -> auto-follow == 'unique-match' in word mode + When I open data/hints/html/simple.html + And I set hints -> mode to word + And I set hints -> auto-follow to unique-match + And I run :hint + # the link gets "hello" as the hint + And I press the key "h" + Then data/hello.txt should be loaded + + Scenario: Using hints -> auto-follow == 'full-match' in word mode + When I open data/hints/html/simple.html + And I set hints -> mode to word + And I set hints -> auto-follow to full-match + And I run :hint + # this actually presses the keys one by one + And I press the key "hello" + Then data/hello.txt should be loaded + + Scenario: Using hints -> auto-follow == 'never' without Enter in word mode + When I open data/hints/html/simple.html + And I set hints -> mode to word + And I set hints -> auto-follow to never + And I run :hint + # this actually presses the keys one by one + And I press the key "hello" + Then "Leaving mode KeyMode.hint (reason: followed)" should not be logged + + Scenario: Using hints -> auto-follow == 'never' in word mode + When I open data/hints/html/simple.html + And I set hints -> mode to word + And I set hints -> auto-follow to never + And I run :hint + # this actually presses the keys one by one + And I press the key "hello" + And I press the key "" + Then data/hello.txt should be loaded diff --git a/tests/end2end/features/test_hints_bdd.py b/tests/end2end/features/test_hints_bdd.py index 775c347be..b5304cb74 100644 --- a/tests/end2end/features/test_hints_bdd.py +++ b/tests/end2end/features/test_hints_bdd.py @@ -17,5 +17,30 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +import textwrap + +import pytest + import pytest_bdd as bdd bdd.scenarios('hints.feature') + + +@pytest.fixture(autouse=True) +def set_up_word_hints(tmpdir, quteproc): + dict_file = tmpdir / 'dict' + dict_file.write(textwrap.dedent(""" + one + two + three + four + five + six + seven + eight + nine + ten + eleven + twelve + thirteen + """)) + quteproc.set_setting('hints', 'dictionary', str(dict_file))