From fe08cb24f83569d1eecd90fb1c7b631118038a73 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 15 Nov 2015 20:48:07 +0100 Subject: [PATCH] bdd: Test some commands with count. --- .../integration/features/backforward.feature | 17 ++++++ tests/integration/features/conftest.py | 7 ++- tests/integration/features/scroll.feature | 53 +++++++++++++++++++ tests/integration/features/zoom.feature | 17 +++++- tests/integration/quteprocess.py | 5 +- 5 files changed, 96 insertions(+), 3 deletions(-) diff --git a/tests/integration/features/backforward.feature b/tests/integration/features/backforward.feature index dba29fec2..b78832bc3 100644 --- a/tests/integration/features/backforward.feature +++ b/tests/integration/features/backforward.feature @@ -62,6 +62,23 @@ Feature: Going back and forward. url: http://localhost:*/data/backforward/1.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 Given I have a fresh instance When I open data/backforward/1.txt diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 5d06c6967..8e3eb8429 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -62,8 +62,13 @@ def fresh_instance(quteproc): @bdd.when(bdd.parsers.parse("I run {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)) - quteproc.send_cmd(command) + quteproc.send_cmd(command, count=count) @bdd.when(bdd.parsers.parse("I reload")) diff --git a/tests/integration/features/scroll.feature b/tests/integration/features/scroll.feature index ec0bff2c6..c1cf7ff51 100644 --- a/tests/integration/features/scroll.feature +++ b/tests/integration/features/scroll.feature @@ -15,6 +15,28 @@ Feature: Scrolling When I run :scroll-px 10 0 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 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 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 Scenario: Scrolling to bottom with :scroll-perc @@ -109,6 +152,10 @@ Feature: Scrolling When I run :scroll-perc --horizontal 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 Scenario: Scrolling down with :scroll-page @@ -129,6 +176,12 @@ Feature: Scrolling And I run :scroll-page -1 0 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 When I run :scroll-perc 100 And I run :scroll-page --bottom-navigate next 0 1 diff --git a/tests/integration/features/zoom.feature b/tests/integration/features/zoom.feature index bf9c80086..43345a1e7 100644 --- a/tests/integration/features/zoom.feature +++ b/tests/integration/features/zoom.feature @@ -2,7 +2,7 @@ Feature: Zooming in and out Background: 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 Scenario: Zooming in @@ -15,11 +15,26 @@ Feature: Zooming in and out Then the message "Zoom level: 90%" should be shown. 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 When I run :zoom 50 Then the message "Zoom level: 50%" should be shown. 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 When I set ui -> default-zoom to 42% And I run :zoom 50 diff --git a/tests/integration/quteprocess.py b/tests/integration/quteprocess.py index 4a07946f8..ab5c96cd1 100644 --- a/tests/integration/quteprocess.py +++ b/tests/integration/quteprocess.py @@ -195,9 +195,12 @@ class QuteProc(testprocess.Process): str(e) for e in bad_msgs) pytest.fail(text, pytrace=False) - def send_cmd(self, command): + def send_cmd(self, command, count=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], target_arg='') self.wait_for(category='commands', module='command', function='run',