From f9645e447a9af860f5312a0af6147db2653cac1d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 7 Jan 2016 07:49:45 +0100 Subject: [PATCH] bdd: Add first tests for searching. --- tests/integration/data/search.html | 16 +++ tests/integration/features/search.feature | 117 ++++++++++++++++++++++ tests/integration/features/test_search.py | 26 +++++ 3 files changed, 159 insertions(+) create mode 100644 tests/integration/data/search.html create mode 100644 tests/integration/features/search.feature create mode 100644 tests/integration/features/test_search.py diff --git a/tests/integration/data/search.html b/tests/integration/data/search.html new file mode 100644 index 000000000..05f811748 --- /dev/null +++ b/tests/integration/data/search.html @@ -0,0 +1,16 @@ + + + + + Searching text on the page + + +

+ foo
+ Foo
+ Bar
+ bar
+ blüb +

+ + diff --git a/tests/integration/features/search.feature b/tests/integration/features/search.feature new file mode 100644 index 000000000..150a80d63 --- /dev/null +++ b/tests/integration/features/search.feature @@ -0,0 +1,117 @@ +Feature: Searching on a page + Searching text on the page (like /foo) with different options. + + Background: + Given I open data/search.html + + ## searching + + Scenario: Searching text + When I run :search foo + And I run :yank-selected + Then the clipboard should contain "foo" + + Scenario: Searching with --reverse + When I set general -> ignore-case to true + And I run :search -r foo + And I run :yank-selected + Then the clipboard should contain "Foo" + + Scenario: Searching without matches + When I run :search doesnotmatch + Then the warning "Text 'doesnotmatch' not found on page!" should be shown + + # xfail takes a long time to timeout, and this doesn't work because this is + # QtWebKit behaviour. + @skip + Scenario: Searching text with umlauts + When I run :search blub + Then the warning "Text 'blub' not found on page!" should be shown + + ## ignore-case + + Scenario: Searching text with ignore-case = true + When I set general -> ignore-case to true + And I run :search bar + And I run :yank-selected + Then the clipboard should contain "Bar" + + Scenario: Searching text with ignore-case = false + When I set general -> ignore-case to false + And I run :search bar + And I run :yank-selected + Then the clipboard should contain "bar" + + Scenario: Searching text with ignore-case = smart (lower-case) + When I set general -> ignore-case to smart + And I run :search bar + And I run :yank-selected + Then the clipboard should contain "Bar" + + Scenario: Searching text with ignore-case = smart (upper-case) + When I set general -> ignore-case to smart + And I run :search Foo + And I run :yank-selected + Then the clipboard should contain "Foo" # even though foo was first + + ## :search-prev/next + + Scenario: Jumping to next match + When I set general -> ignore-case to true + And I run :search foo + And I run :search-next + And I run :yank-selected + Then the clipboard should contain "Foo" + + Scenario: Jumping to next match without search + When I run :search-next + Then no crash should happen + + Scenario: Jumping to previous match + When I set general -> ignore-case to true + And I run :search foo + And I run :search-next + And I run :search-prev + And I run :yank-selected + Then the clipboard should contain "foo" + + Scenario: Jumping to previous match without search + When I run :search-prev + Then no crash should happen + + # TODO: with count + + ## wrapping + + Scenario: Wrapping around page + When I set general -> wrap-search to true + And I run :search foo + And I run :search-next + And I run :search-next + And I run :yank-selected + Then the clipboard should contain "foo" + + Scenario: Wrapping around page with wrap-search = false + When I set general -> wrap-search to false + And I run :search foo + And I run :search-next + And I run :search-next + Then the warning "Search hit BOTTOM without match for: foo" should be shown + + Scenario: Wrapping around page with --reverse + When I set general -> wrap-search to true + And I run :search --reverse foo + And I run :search-next + And I run :search-next + And I run :yank-selected + Then the clipboard should contain "Foo" + + Scenario: Wrapping around page with wrap-search = false and --reverse + When I set general -> wrap-search to false + And I run :search --reverse foo + And I run :search-next + And I run :search-next + Then the warning "Search hit TOP without match for: foo" should be shown + + # TODO: wrapping message with scrolling + # TODO: wrapping message without scrolling diff --git a/tests/integration/features/test_search.py b/tests/integration/features/test_search.py new file mode 100644 index 000000000..b53f3120c --- /dev/null +++ b/tests/integration/features/test_search.py @@ -0,0 +1,26 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 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 + +# pylint: disable=unused-import +from test_yankpaste import skip_with_broken_clipboard + + +bdd.scenarios('search.feature')