Move :repeat-command tests

This commit is contained in:
Jan Verbeek 2016-07-03 22:32:07 +02:00
parent 4172e39045
commit 8039e7ab74
4 changed files with 51 additions and 45 deletions

View File

@ -492,3 +492,28 @@ def clipboard_contains_multiline(quteproc, httpbin, content):
@bdd.then("qutebrowser should quit") @bdd.then("qutebrowser should quit")
def should_quit(qtbot, quteproc): def should_quit(qtbot, quteproc):
quteproc.wait_for_quit() 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"(?P<direction>horizontally|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

View File

@ -464,3 +464,29 @@ Feature: Various utility commands.
And I wait until cookies is loaded And I wait until cookies is loaded
And I open cookies in a new tab And I open cookies in a new tab
Then the cookie qute-test should be set to 42 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

View File

@ -241,23 +241,3 @@ Feature: Scrolling
When I open data/hello.txt When I open data/hello.txt
And I run :scroll-page 1 1 And I run :scroll-page 1 1
Then no crash should happen 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

View File

@ -19,28 +19,3 @@
import pytest_bdd as bdd import pytest_bdd as bdd
bdd.scenarios('scroll.feature') 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"(?P<direction>horizontally|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