bdd: Add some tests for :navigate.

This commit is contained in:
Florian Bruhin 2015-11-24 21:32:45 +01:00
parent 8f2b29a1f9
commit 027a10c04b
11 changed files with 135 additions and 1 deletions

View File

@ -516,7 +516,7 @@ class CommandDispatcher:
self._navigate_up(url, tab, bg, window)
elif where in ('decrement', 'increment'):
self._navigate_incdec(url, where, tab, bg, window)
else:
else: # pragma: no cover
raise ValueError("Got called with invalid value {} for "
"`where'.".format(where))

View File

@ -0,0 +1 @@
one

View File

@ -0,0 +1 @@
two

View File

@ -0,0 +1 @@
three

View File

@ -0,0 +1 @@
four

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Navigate</title>
</head>
<body>
<p>Index page</p>
<a href="/data/navigate/prev.html">previous</a>
<a href="/data/navigate/next.html">next</a>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Navigate</title>
</head>
<body>
<p>next</p>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Navigate</title>
</head>
<body>
<p>prev</p>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Navigate</title>
</head>
<body>
<p>Sub page</p>
</body>
</html>

View File

@ -0,0 +1,67 @@
Feature: Using :navigate
Scenario: :navigate with invalid argument
When I run :navigate foo
Then the error "Invalid value foo." should be shown.
# up
Scenario: Navigating up
When I open data/navigate/sub
And I run :navigate up
Then data/navigate should be loaded
Scenario: Navigating up with root directory
When I open /
And I run :navigate up
Then the error "Can't go up!" should be shown.
# prev/next
Scenario: Navigating to previous page
When I open data/navigate
And I run :navigate prev
Then data/navigate/prev.html should be loaded
Scenario: Navigating to next page
When I open data/navigate
And I run :navigate next
Then data/navigate/next.html should be loaded
Scenario: Navigating to previous page without links
When I open data/navigate/1.txt
And I run :navigate prev
Then the error "No prev links found!" should be shown.
Scenario: Navigating to next page without links
When I open data/navigate/1.txt
And I run :navigate next
Then the error "No forward links found!" should be shown.
# increment/decrement
Scenario: Incrementing number in URL
When I open data/navigate/1.txt
And I run :navigate increment
Then data/navigate/2.txt should be loaded
Scenario: Decrementing number in URL
When I open data/navigate/4.txt
And I run :navigate decrement
Then data/navigate/3.txt should be loaded
Scenario: Decrementing with no number in URL
When I open data/navigate
And I run :navigate decrement
Then the error "No number found in URL!" should be shown.
Scenario: Incrementing with no number in URL
When I open data/navigate
And I run :navigate increment
Then the error "No number found in URL!" should be shown.
Scenario: Setting url-incdec-segments
When I set general -> url-incdec-segments to anchor
And I open data/navigate/1.txt
And I run :navigate increment
Then the error "No number found in URL!" should be shown.

View File

@ -0,0 +1,21 @@
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2015 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('navigate.feature')