bdd: Test some commands with count.

This commit is contained in:
Florian Bruhin 2015-11-15 20:48:07 +01:00
parent eeab4d41ba
commit fe08cb24f8
5 changed files with 96 additions and 3 deletions

View File

@ -62,6 +62,23 @@ Feature: Going back and forward.
url: http://localhost:*/data/backforward/1.txt url: http://localhost:*/data/backforward/1.txt
- url: http://localhost:*/data/backforward/2.txt - url: http://localhost:*/data/backforward/2.txt
Scenario: Going back with count.
Given I open data/backforward/1.txt
When I open data/backforward/2.txt
And I open data/backforward/3.txt
And I run :tab-only
And I run :back with count 2
And I wait until data/backforward/1.txt is loaded
And I reload
Then the session should look like:
windows:
- tabs:
- history:
- active: true
url: http://localhost:*/data/backforward/1.txt
- url: http://localhost:*/data/backforward/2.txt
- url: http://localhost:*/data/backforward/3.txt
Scenario: Going back in a new window Scenario: Going back in a new window
Given I have a fresh instance Given I have a fresh instance
When I open data/backforward/1.txt When I open data/backforward/1.txt

View File

@ -62,8 +62,13 @@ def fresh_instance(quteproc):
@bdd.when(bdd.parsers.parse("I run {command}")) @bdd.when(bdd.parsers.parse("I run {command}"))
def run_command_when(quteproc, httpbin, command): def run_command_when(quteproc, httpbin, command):
if 'with count' in command:
command, count = command.split(' with count ')
count = int(count)
else:
count = None
command = command.replace('(port)', str(httpbin.port)) command = command.replace('(port)', str(httpbin.port))
quteproc.send_cmd(command) quteproc.send_cmd(command, count=count)
@bdd.when(bdd.parsers.parse("I reload")) @bdd.when(bdd.parsers.parse("I reload"))

View File

@ -15,6 +15,28 @@ Feature: Scrolling
When I run :scroll-px 10 0 When I run :scroll-px 10 0
Then the page should be scrolled horizontally. Then the page should be scrolled horizontally.
Scenario: Scrolling down and up
When I run :scroll-px 10 0
And I run :scroll-px -10 0
Then the page should not be scrolled.
Scenario: Scrolling right and left
When I run :scroll-px 0 10
And I run :scroll-px 0 -10
Then the page should not be scrolled.
Scenario: Scrolling down and up with count
When I run :scroll-px 0 10 with count 2
When I run :scroll-px 0 -10
When I run :scroll-px 0 -10
Then the page should not be scrolled.
Scenario: Scrolling left and right with count
When I run :scroll-px 10 0 with count 2
When I run :scroll-px -10 0
When I run :scroll-px -10 0
Then the page should not be scrolled.
## :scroll ## :scroll
Scenario: Scrolling down Scenario: Scrolling down
@ -63,6 +85,27 @@ Feature: Scrolling
Then the warning ":scroll with dx/dy arguments is deprecated - use :scroll-px instead!" should be shown. Then the warning ":scroll with dx/dy arguments is deprecated - use :scroll-px instead!" should be shown.
Then the page should be scrolled vertically. Then the page should be scrolled vertically.
Scenario: Scrolling down and up with count
When I run :scroll down with count 2
And I run :scroll up
And I run :scroll up
Then the page should not be scrolled.
Scenario: Scrolling right
When I run :scroll right
Then the page should be scrolled horizontally.
Scenario: Scrolling right and left
When I run :scroll right
And I run :scroll left
Then the page should not be scrolled.
Scenario: Scrolling right and left with count
When I run :scroll right with count 2
And I run :scroll left
And I run :scroll left
Then the page should not be scrolled.
## :scroll-perc ## :scroll-perc
Scenario: Scrolling to bottom with :scroll-perc Scenario: Scrolling to bottom with :scroll-perc
@ -109,6 +152,10 @@ Feature: Scrolling
When I run :scroll-perc --horizontal When I run :scroll-perc --horizontal
Then the page should be scrolled horizontally. Then the page should be scrolled horizontally.
Scenario: :scroll-perc with count
When I run :scroll-perc with count 50
Then the page should be scrolled vertically.
## :scroll-page ## :scroll-page
Scenario: Scrolling down with :scroll-page Scenario: Scrolling down with :scroll-page
@ -129,6 +176,12 @@ Feature: Scrolling
And I run :scroll-page -1 0 And I run :scroll-page -1 0
Then the page should not be scrolled. Then the page should not be scrolled.
Scenario: Scrolling right and left with :scroll-page and count
When I run :scroll-page 1 0 with count 2
And I run :scroll-page -1 0
And I run :scroll-page -1 0
Then the page should not be scrolled.
Scenario: :scroll-page with --bottom-navigate Scenario: :scroll-page with --bottom-navigate
When I run :scroll-perc 100 When I run :scroll-perc 100
And I run :scroll-page --bottom-navigate next 0 1 And I run :scroll-page --bottom-navigate next 0 1

View File

@ -2,7 +2,7 @@ Feature: Zooming in and out
Background: Background:
Given I open data/hello.txt Given I open data/hello.txt
And I set ui -> zoom-levels to 50%,90%,110% And I set ui -> zoom-levels to 50%,90%,100%,110%,120%
And I run :tab-only And I run :tab-only
Scenario: Zooming in Scenario: Zooming in
@ -15,11 +15,26 @@ Feature: Zooming in and out
Then the message "Zoom level: 90%" should be shown. Then the message "Zoom level: 90%" should be shown.
And the zoom should be 90% And the zoom should be 90%
Scenario: Zooming in with count
When I run :zoom-in with count 2
Then the message "Zoom level: 120%" should be shown.
And the zoom should be 120%
Scenario: Zooming out with count
When I run :zoom-out with count 2
Then the message "Zoom level: 50%" should be shown.
And the zoom should be 50%
Scenario: Setting zoom Scenario: Setting zoom
When I run :zoom 50 When I run :zoom 50
Then the message "Zoom level: 50%" should be shown. Then the message "Zoom level: 50%" should be shown.
And the zoom should be 50% And the zoom should be 50%
Scenario: Setting zoom with count
When I run :zoom with count 40
Then the message "Zoom level: 40%" should be shown.
And the zoom should be 40%
Scenario: Resetting zoom Scenario: Resetting zoom
When I set ui -> default-zoom to 42% When I set ui -> default-zoom to 42%
And I run :zoom 50 And I run :zoom 50

View File

@ -195,9 +195,12 @@ class QuteProc(testprocess.Process):
str(e) for e in bad_msgs) str(e) for e in bad_msgs)
pytest.fail(text, pytrace=False) pytest.fail(text, pytrace=False)
def send_cmd(self, command): def send_cmd(self, command, count=None):
assert self._ipc_socket is not None assert self._ipc_socket is not None
if count is not None:
command = ':{}:{}'.format(count, command.lstrip(':'))
ipc.send_to_running_instance(self._ipc_socket, [command], ipc.send_to_running_instance(self._ipc_socket, [command],
target_arg='') target_arg='')
self.wait_for(category='commands', module='command', function='run', self.wait_for(category='commands', module='command', function='run',