Add integration tests for set-mark and jump-mark.
This commit is contained in:
parent
c7b830d69d
commit
dc246772e7
116
tests/integration/data/marks.html
Normal file
116
tests/integration/data/marks.html
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Marks I</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 id="top">Top</h1>
|
||||||
|
<a href="#top">Top</a>
|
||||||
|
<a href="#bottom">Bottom</a>
|
||||||
|
<pre>
|
||||||
|
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.
|
||||||
|
</pre>
|
||||||
|
<h1 id="bottom">Bottom</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
65
tests/integration/features/marks.feature
Normal file
65
tests/integration/features/marks.feature
Normal file
@ -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
|
33
tests/integration/features/test_marks.py
Normal file
33
tests/integration/features/test_marks.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||||
|
|
||||||
|
# Copyright 2014-2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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<y>\d+)"))
|
||||||
|
def check_y(quteproc, y):
|
||||||
|
assert int(y) == _get_scroll_y(quteproc)
|
Loading…
Reference in New Issue
Block a user