diff --git a/tests/integration/data/marks.html b/tests/integration/data/marks.html new file mode 100644 index 000000000..60cb40636 --- /dev/null +++ b/tests/integration/data/marks.html @@ -0,0 +1,116 @@ + + + + + Marks I + + +

Top

+ Top + Bottom +
+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
+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.
+        
+

Bottom

+ + diff --git a/tests/integration/features/marks.feature b/tests/integration/features/marks.feature new file mode 100644 index 000000000..74694fd20 --- /dev/null +++ b/tests/integration/features/marks.feature @@ -0,0 +1,65 @@ +Feature: Setting positional marks + + Background: + Given I open data/marks.html + And I run :tab-only + + ## :set-mark, :jump-mark + + Scenario: Setting and jumping to a local mark + When I run :scroll-px 0 10 + And I run :set-mark 'a' + And I run :scroll-px 0 20 + And I run :jump-mark 'a' + Then the page should be scrolled to 10 + + Scenario: Jumping back jumping to a particular percentage + When I run :scroll-px 0 20 + And I run :scroll-perc 100 + And I run :jump-mark "'" + Then the page should be scrolled to 20 + + Scenario: Setting the same local mark on another page + When I run :scroll-px 0 10 + And I run :set-mark 'a' + And I open data/marks.html + And I run :scroll-px 0 20 + And I run :set-mark 'a' + And I run :jump-mark 'a' + Then the page should be scrolled to 20 + + Scenario: Jumping to a local mark after returning to a page + When I run :scroll-px 0 10 + And I run :set-mark 'a' + And I open data/numbers/1.txt + And I run :set-mark 'a' + And I open data/marks.html + And I run :jump-mark 'a' + Then the page should be scrolled to 10 + + Scenario: Setting and jumping to a global mark + When I run :scroll-px 0 20 + And I run :set-mark 'A' + And I open data/numbers/1.txt + And I run :jump-mark 'A' + Then data/marks.html should be loaded + And the page should be scrolled to 20 + + Scenario: Jumping to an unset mark + When I run :jump-mark 'b' + Then the error "Mark b is not set" should be shown + + Scenario: Jumping to a local mark that was set on another page + When I run :set-mark 'b' + And I open data/numbers/1.txt + And I run :jump-mark 'b' + Then the error "Mark b is not set" should be shown + + Scenario: Jumping to a local mark after changing fragments + When I open data/marks.html#top + And I run :scroll 'top' + And I run :scroll-px 0 10 + And I run :set-mark 'a' + When I open data/marks.html#bottom + And I run :jump-mark 'a' + Then the page should be scrolled to 10 diff --git a/tests/integration/features/test_marks.py b/tests/integration/features/test_marks.py new file mode 100644 index 000000000..3553ca6f3 --- /dev/null +++ b/tests/integration/features/test_marks.py @@ -0,0 +1,33 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2014-2016 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('marks.feature') + + +def _get_scroll_y(quteproc): + data = quteproc.get_session() + pos = data['windows'][0]['tabs'][0]['history'][-1]['scroll-pos'] + return pos['y'] + + +@bdd.then(bdd.parsers.re(r"the page should be scrolled to " + r"(?P\d+)")) +def check_y(quteproc, y): + assert int(y) == _get_scroll_y(quteproc)