diff --git a/tests/integration/data/scroll.html b/tests/integration/data/scroll.html new file mode 100644 index 000000000..954267f04 --- /dev/null +++ b/tests/integration/data/scroll.html @@ -0,0 +1,211 @@ + + + + + Scrolling + + +
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+This is a very long line so this page can be scrolled horizontally. Did you think this line would end here already? Nah, it does not. But now it will. Or will it? I think it's not long enough yet.
+    
+
diff --git a/tests/integration/features/scroll.feature b/tests/integration/features/scroll.feature
new file mode 100644
index 000000000..77e711c50
--- /dev/null
+++ b/tests/integration/features/scroll.feature
@@ -0,0 +1,60 @@
+Feature: Scrolling
+    Tests the various scroll commands.
+
+    Background:
+        Given I open data/scroll.html
+        And I run :tab-only
+
+    Scenario: Scrolling pixel-wise vertically
+        When I run :scroll-px 0 10
+        Then the page should be scrolled vertically.
+
+    Scenario: Scrolling pixel-wise horizontally
+        When I run :scroll-px 10 0
+        Then the page should be scrolled horizontally.
+
+    Scenario: Scrolling down
+        When I run :scroll down
+        Then the page should be scrolled vertically.
+
+    Scenario: Scrolling down and up
+        When I run :scroll down
+        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 with page down
+        When I run :scroll page-down
+        Then the page should be scrolled vertically.
+
+    Scenario: Scrolling with page down and page up
+        When I run :scroll page-down
+        And I run :scroll page-up
+        Then the page should not be scrolled.
+
+    Scenario: Scrolling to bottom
+        When I run :scroll bottom
+        Then the page should be scrolled vertically.
+
+    Scenario: Scrolling to bottom and to top
+        When I run :scroll bottom
+        And I run :scroll top
+        Then the page should not be scrolled.
+
+    Scenario: :scroll with invalid argument
+        When I run :scroll foobar
+        Then the error "Invalid value 'foobar' for direction - expected one of: bottom, down, left, page-down, page-up, right, top, up" should be shown.
+        And the page should not be scrolled.
+
+    Scenario: :scroll with deprecated pixel argument
+        When I run :scroll 0 10
+        Then the warning ":scroll with dx/dy arguments is deprecated - use :scroll-px instead!" should be shown.
+        Then the page should be scrolled vertically.
diff --git a/tests/integration/features/test_scroll.py b/tests/integration/features/test_scroll.py
new file mode 100644
index 000000000..b0cf223c8
--- /dev/null
+++ b/tests/integration/features/test_scroll.py
@@ -0,0 +1,46 @@
+# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
+
+# Copyright 2015 Florian Bruhin (The Compiler) 
+#
+# This file is part of qutebrowser.
+#
+# qutebrowser is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# qutebrowser is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with qutebrowser.  If not, see .
+
+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