From 8039e7ab74cc1486a55e1e3c6507046b06b40994 Mon Sep 17 00:00:00 2001 From: Jan Verbeek Date: Sun, 3 Jul 2016 22:32:07 +0200 Subject: [PATCH] Move :repeat-command tests --- tests/end2end/features/conftest.py | 25 ++++++++++++++++++++++ tests/end2end/features/misc.feature | 26 +++++++++++++++++++++++ tests/end2end/features/scroll.feature | 20 ----------------- tests/end2end/features/test_scroll_bdd.py | 25 ---------------------- 4 files changed, 51 insertions(+), 45 deletions(-) diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index 9d1d5c074..c97318ca9 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -492,3 +492,28 @@ def clipboard_contains_multiline(quteproc, httpbin, content): @bdd.then("qutebrowser should quit") def should_quit(qtbot, quteproc): quteproc.wait_for_quit() + + +def _get_scroll_values(quteproc): + data = quteproc.get_session() + pos = data['windows'][0]['tabs'][0]['history'][0]['scroll-pos'] + return (pos['x'], pos['y']) + + +@bdd.then(bdd.parsers.re(r"the page should be scrolled " + r"(?Phorizontally|vertically)")) +def check_scrolled(quteproc, direction): + x, y = _get_scroll_values(quteproc) + if direction == 'horizontally': + assert x != 0 + assert y == 0 + else: + assert x == 0 + assert y != 0 + + +@bdd.then("the page should not be scrolled") +def check_not_scrolled(quteproc): + x, y = _get_scroll_values(quteproc) + assert x == 0 + assert y == 0 diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index bd54960bd..8f458f1a3 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -464,3 +464,29 @@ Feature: Various utility commands. And I wait until cookies is loaded And I open cookies in a new tab Then the cookie qute-test should be set to 42 + + Scenario: :repeat-command + Given I open data/scroll.html + And I run :tab-only + When I run :scroll down + And I run :repeat-command + And I run :scroll up + Then the page should be scrolled vertically + + Scenario: :repeat-command with count + Given I open data/scroll.html + And I run :tab-only + When I run :scroll down with count 3 + And I run :scroll up + And I run :repeat-command with count 2 + Then the page should not be scrolled + + Scenario: :repeat-command with not-normal command inbetween + Given I open data/scroll.html + And I run :tab-only + When I run :scroll down with count 3 + And I run :scroll up + And I run :prompt-accept + And I run :repeat-command with count 2 + Then the page should not be scrolled + And the error "prompt-accept: This command is only allowed in prompt/yesno mode." should be shown diff --git a/tests/end2end/features/scroll.feature b/tests/end2end/features/scroll.feature index 508a2c2e5..676cd0890 100644 --- a/tests/end2end/features/scroll.feature +++ b/tests/end2end/features/scroll.feature @@ -241,23 +241,3 @@ Feature: Scrolling When I open data/hello.txt And I run :scroll-page 1 1 Then no crash should happen - - Scenario: :repeat-command - When I run :scroll down - And I run :repeat-command - And I run :scroll up - Then the page should be scrolled vertically - - Scenario: :repeat-command with count - When I run :scroll down with count 3 - And I run :scroll up - And I run :repeat-command with count 2 - Then the page should not be scrolled - - Scenario: :repeat-command with not-normal command inbetween - When I run :scroll down with count 3 - And I run :scroll up - And I run :prompt-accept - And I run :repeat-command with count 2 - Then the page should not be scrolled - And the error "prompt-accept: This command is only allowed in prompt/yesno mode." should be shown diff --git a/tests/end2end/features/test_scroll_bdd.py b/tests/end2end/features/test_scroll_bdd.py index 7ea63936e..de1ed3e0a 100644 --- a/tests/end2end/features/test_scroll_bdd.py +++ b/tests/end2end/features/test_scroll_bdd.py @@ -19,28 +19,3 @@ import pytest_bdd as bdd bdd.scenarios('scroll.feature') - - -def _get_scroll_values(quteproc): - data = quteproc.get_session() - pos = data['windows'][0]['tabs'][0]['history'][0]['scroll-pos'] - return (pos['x'], pos['y']) - - -@bdd.then(bdd.parsers.re(r"the page should be scrolled " - r"(?Phorizontally|vertically)")) -def check_scrolled(quteproc, direction): - x, y = _get_scroll_values(quteproc) - if direction == 'horizontally': - assert x != 0 - assert y == 0 - else: - assert x == 0 - assert y != 0 - - -@bdd.then("the page should not be scrolled") -def check_not_scrolled(quteproc): - x, y = _get_scroll_values(quteproc) - assert x == 0 - assert y == 0