From 353c10aee7bcb11fee2c2847493139aab85a1485 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 3 Jul 2017 00:03:12 +0200 Subject: [PATCH] Add a separate qutescheme BDD file --- tests/end2end/features/misc.feature | 201 ----------------- tests/end2end/features/qutescheme.feature | 205 ++++++++++++++++++ tests/end2end/features/test_misc_bdd.py | 35 --- tests/end2end/features/test_qutescheme_bdd.py | 56 +++++ 4 files changed, 261 insertions(+), 236 deletions(-) create mode 100644 tests/end2end/features/qutescheme.feature create mode 100644 tests/end2end/features/test_qutescheme_bdd.py diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index 583f58cff..0be55a0b3 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -255,104 +255,6 @@ Feature: Various utility commands. And I run :view-source Then the error "Already viewing source!" should be shown - # :help - - Scenario: :help without topic - When I run :tab-only - And I run :help - And I wait until qute://help/index.html is loaded - Then the following tabs should be open: - - qute://help/index.html (active) - - Scenario: :help with invalid topic - When I run :help foo - Then the error "Invalid help topic foo!" should be shown - - Scenario: :help with command - When the documentation is up to date - And I run :tab-only - And I run :help :back - And I wait until qute://help/commands.html#back is loaded - Then the following tabs should be open: - - qute://help/commands.html#back (active) - - Scenario: :help with invalid command - When I run :help :foo - Then the error "Invalid command foo!" should be shown - - Scenario: :help with setting - When the documentation is up to date - And I run :tab-only - And I run :help editor.command - And I wait until qute://help/settings.html#editor.command is loaded - Then the following tabs should be open: - - qute://help/settings.html#editor.command (active) - - Scenario: :help with -t - When I open about:blank - And I run :tab-only - And I run :help -t - And I wait until qute://help/index.html is loaded - Then the following tabs should be open: - - about:blank - - qute://help/index.html (active) - - # https://github.com/qutebrowser/qutebrowser/issues/2513 - Scenario: Opening link with qute:help - When the documentation is up to date - And I run :tab-only - And I open qute:help without waiting - And I wait for "Changing title for idx 0 to 'qutebrowser help'" in the log - And I hint with args "links normal" and follow a - Then qute://help/quickstart.html should be loaded - - # :history - - Scenario: :history without arguments - When I run :tab-only - And I run :history - And I wait until qute://history/ is loaded - Then the following tabs should be open: - - qute://history/ (active) - - Scenario: :history with -t - When I open about:blank - And I run :tab-only - And I run :history -t - And I wait until qute://history/ is loaded - Then the following tabs should be open: - - about:blank - - qute://history/ (active) - - # qute://settings - - Scenario: Focusing input fields in qute://settings and entering valid value - When I set ignore_case to never - And I open qute://settings - # scroll to the right - the table does not fit in the default screen - And I run :scroll-perc -x 100 - And I run :click-element id input-ignore_case - And I wait for "Entering mode KeyMode.insert *" in the log - And I press the key "" - And I press the keys "always" - And I press the key "" - # an explicit Tab to unfocus the input field seems to stabilize the tests - And I press the key "" - Then the option ignore_case should be set to always - - Scenario: Focusing input fields in qute://settings and entering invalid value - When I open qute://settings - # scroll to the right - the table does not fit in the default screen - And I run :scroll-perc -x 100 - And I run :click-element id input-ignore_case - And I wait for "Entering mode KeyMode.insert *" in the log - And I press the key "" - And I press the keys "foo" - And I press the key "" - # an explicit Tab to unfocus the input field seems to stabilize the tests - And I press the key "" - Then "Invalid value 'foo' *" should be logged - # :home Scenario: :home with single page @@ -365,39 +267,6 @@ Feature: Various utility commands. And I run :home Then data/numbers/1.txt should be loaded - # pdfjs support - - @qtwebengine_skip: pdfjs is not implemented yet - Scenario: pdfjs is used for pdf files - Given pdfjs is available - When I set content.pdfjs to true - And I open data/misc/test.pdf - Then the javascript message "PDF * [*] (PDF.js: *)" should be logged - - @qtwebengine_todo: pdfjs is not implemented yet - Scenario: pdfjs is not used when disabled - When I set content.pdfjs to false - And I set downloads.location.prompt to false - And I open data/misc/test.pdf - Then "Download test.pdf finished" should be logged - - @qtwebengine_skip: pdfjs is not implemented yet - Scenario: Downloading a pdf via pdf.js button (issue 1214) - Given pdfjs is available - # WORKAROUND to prevent the "Painter ended with 2 saved states" warning - # Might be related to https://bugreports.qt.io/browse/QTBUG-13524 and - # a weird interaction with the previous test. - And I have a fresh instance - When I set content.pdfjs to true - And I set downloads.location.suggestion to filename - And I set downloads.location.prompt to true - And I open data/misc/test.pdf - And I wait for "[qute://pdfjs/*] PDF * (PDF.js: *)" in the log - And I run :jseval document.getElementById("download").click() - And I wait for "Asking question text=* title='Save file to:'>, *" in the log - And I run :leave-mode - Then no crash should happen - # :print # Disabled because it causes weird segfaults and QPainter warnings in Qt... @@ -429,21 +298,6 @@ Feature: Various utility commands. And I wait for "Print to file: *" in the log or skip the test Then the PDF hello.pdf should exist in the tmpdir - # :pyeval - Scenario: Running :pyeval - When I run :debug-pyeval 1+1 - And I wait until qute://pyeval is loaded - Then the page should contain the plaintext "2" - - Scenario: Causing exception in :pyeval - When I run :debug-pyeval 1/0 - And I wait until qute://pyeval is loaded - Then the page should contain the plaintext "ZeroDivisionError" - - Scenario: Running :pyeval with --quiet - When I run :debug-pyeval --quiet 1+1 - Then "pyeval output: 2" should be logged - ## https://github.com/qutebrowser/qutebrowser/issues/504 Scenario: Focusing download widget via Tab @@ -500,61 +354,6 @@ Feature: Various utility commands. Then the header User-Agent should be set to Mozilla/5.0 * And the javascript message "Mozilla/5.0 *" should be logged - ## :messages - - Scenario: :messages without level - When I run :message-error the-error-message - And I run :message-warning the-warning-message - And I run :message-info the-info-message - And I run :messages - Then qute://log?level=info should be loaded - And the error "the-error-message" should be shown - And the warning "the-warning-message" should be shown - And the page should contain the plaintext "the-error-message" - And the page should contain the plaintext "the-warning-message" - And the page should contain the plaintext "the-info-message" - - Scenario: Showing messages of type 'warning' or greater - When I run :message-error the-error-message - And I run :message-warning the-warning-message - And I run :message-info the-info-message - And I run :messages warning - Then qute://log?level=warning should be loaded - And the error "the-error-message" should be shown - And the warning "the-warning-message" should be shown - And the page should contain the plaintext "the-error-message" - And the page should contain the plaintext "the-warning-message" - And the page should not contain the plaintext "the-info-message" - - Scenario: Showing messages of type 'info' or greater - When I run :message-error the-error-message - And I run :message-warning the-warning-message - And I run :message-info the-info-message - And I run :messages info - Then qute://log?level=info should be loaded - And the error "the-error-message" should be shown - And the warning "the-warning-message" should be shown - And the page should contain the plaintext "the-error-message" - And the page should contain the plaintext "the-warning-message" - And the page should contain the plaintext "the-info-message" - - @qtwebengine_flaky - Scenario: Showing messages of an invalid level - When I run :messages cataclysmic - Then the error "Invalid log level cataclysmic!" should be shown - - Scenario: Using qute://log directly - When I open qute://log without waiting - # With Qt 5.9, we don't get a loaded message? - And I wait for "Changing title for idx * to 'log'" in the log - Then no crash should happen - - Scenario: Using qute://plainlog directly - When I open qute://plainlog without waiting - # With Qt 5.9, we don't get a loaded message? - And I wait for "Changing title for idx * to 'log'" in the log - Then no crash should happen - ## https://github.com/qutebrowser/qutebrowser/issues/1523 Scenario: Completing a single option argument diff --git a/tests/end2end/features/qutescheme.feature b/tests/end2end/features/qutescheme.feature new file mode 100644 index 000000000..4131f1841 --- /dev/null +++ b/tests/end2end/features/qutescheme.feature @@ -0,0 +1,205 @@ +# vim: ft=cucumber fileencoding=utf-8 sts=4 sw=4 et: + +Feature: Special qute:// pages + + # :help + + Scenario: :help without topic + When I run :tab-only + And I run :help + And I wait until qute://help/index.html is loaded + Then the following tabs should be open: + - qute://help/index.html (active) + + Scenario: :help with invalid topic + When I run :help foo + Then the error "Invalid help topic foo!" should be shown + + Scenario: :help with command + When the documentation is up to date + And I run :tab-only + And I run :help :back + And I wait until qute://help/commands.html#back is loaded + Then the following tabs should be open: + - qute://help/commands.html#back (active) + + Scenario: :help with invalid command + When I run :help :foo + Then the error "Invalid command foo!" should be shown + + Scenario: :help with setting + When the documentation is up to date + And I run :tab-only + And I run :help editor.command + And I wait until qute://help/settings.html#editor.command is loaded + Then the following tabs should be open: + - qute://help/settings.html#editor.command (active) + + Scenario: :help with -t + When I open about:blank + And I run :tab-only + And I run :help -t + And I wait until qute://help/index.html is loaded + Then the following tabs should be open: + - about:blank + - qute://help/index.html (active) + + # https://github.com/qutebrowser/qutebrowser/issues/2513 + Scenario: Opening link with qute:help + When the documentation is up to date + And I run :tab-only + And I open qute:help without waiting + And I wait for "Changing title for idx 0 to 'qutebrowser help'" in the log + And I hint with args "links normal" and follow a + Then qute://help/quickstart.html should be loaded + + # :history + + Scenario: :history without arguments + When I run :tab-only + And I run :history + And I wait until qute://history/ is loaded + Then the following tabs should be open: + - qute://history/ (active) + + Scenario: :history with -t + When I open about:blank + And I run :tab-only + And I run :history -t + And I wait until qute://history/ is loaded + Then the following tabs should be open: + - about:blank + - qute://history/ (active) + + # qute://settings + + Scenario: Focusing input fields in qute://settings and entering valid value + When I set ignore_case to never + And I open qute://settings + # scroll to the right - the table does not fit in the default screen + And I run :scroll-perc -x 100 + And I run :click-element id input-ignore_case + And I wait for "Entering mode KeyMode.insert *" in the log + And I press the key "" + And I press the keys "always" + And I press the key "" + # an explicit Tab to unfocus the input field seems to stabilize the tests + And I press the key "" + Then the option ignore_case should be set to always + + Scenario: Focusing input fields in qute://settings and entering invalid value + When I open qute://settings + # scroll to the right - the table does not fit in the default screen + And I run :scroll-perc -x 100 + And I run :click-element id input-ignore_case + And I wait for "Entering mode KeyMode.insert *" in the log + And I press the key "" + And I press the keys "foo" + And I press the key "" + # an explicit Tab to unfocus the input field seems to stabilize the tests + And I press the key "" + Then "Invalid value 'foo' *" should be logged + + # pdfjs support + + @qtwebengine_skip: pdfjs is not implemented yet + Scenario: pdfjs is used for pdf files + Given pdfjs is available + When I set content.pdfjs to true + And I open data/misc/test.pdf + Then the javascript message "PDF * [*] (PDF.js: *)" should be logged + + @qtwebengine_todo: pdfjs is not implemented yet + Scenario: pdfjs is not used when disabled + When I set content.pdfjs to false + And I set downloads.location.prompt to false + And I open data/misc/test.pdf + Then "Download test.pdf finished" should be logged + + @qtwebengine_skip: pdfjs is not implemented yet + Scenario: Downloading a pdf via pdf.js button (issue 1214) + Given pdfjs is available + # WORKAROUND to prevent the "Painter ended with 2 saved states" warning + # Might be related to https://bugreports.qt.io/browse/QTBUG-13524 and + # a weird interaction with the previous test. + And I have a fresh instance + When I set content.pdfjs to true + And I set downloads.location.suggestion to filename + And I set downloads.location.prompt to true + And I open data/misc/test.pdf + And I wait for "[qute://pdfjs/*] PDF * (PDF.js: *)" in the log + And I run :jseval document.getElementById("download").click() + And I wait for "Asking question text=* title='Save file to:'>, *" in the log + And I run :leave-mode + Then no crash should happen + + # :pyeval + + Scenario: Running :pyeval + When I run :debug-pyeval 1+1 + And I wait until qute://pyeval is loaded + Then the page should contain the plaintext "2" + + Scenario: Causing exception in :pyeval + When I run :debug-pyeval 1/0 + And I wait until qute://pyeval is loaded + Then the page should contain the plaintext "ZeroDivisionError" + + Scenario: Running :pyeval with --quiet + When I run :debug-pyeval --quiet 1+1 + Then "pyeval output: 2" should be logged + + ## :messages + + Scenario: :messages without level + When I run :message-error the-error-message + And I run :message-warning the-warning-message + And I run :message-info the-info-message + And I run :messages + Then qute://log?level=info should be loaded + And the error "the-error-message" should be shown + And the warning "the-warning-message" should be shown + And the page should contain the plaintext "the-error-message" + And the page should contain the plaintext "the-warning-message" + And the page should contain the plaintext "the-info-message" + + Scenario: Showing messages of type 'warning' or greater + When I run :message-error the-error-message + And I run :message-warning the-warning-message + And I run :message-info the-info-message + And I run :messages warning + Then qute://log?level=warning should be loaded + And the error "the-error-message" should be shown + And the warning "the-warning-message" should be shown + And the page should contain the plaintext "the-error-message" + And the page should contain the plaintext "the-warning-message" + And the page should not contain the plaintext "the-info-message" + + Scenario: Showing messages of type 'info' or greater + When I run :message-error the-error-message + And I run :message-warning the-warning-message + And I run :message-info the-info-message + And I run :messages info + Then qute://log?level=info should be loaded + And the error "the-error-message" should be shown + And the warning "the-warning-message" should be shown + And the page should contain the plaintext "the-error-message" + And the page should contain the plaintext "the-warning-message" + And the page should contain the plaintext "the-info-message" + + @qtwebengine_flaky + Scenario: Showing messages of an invalid level + When I run :messages cataclysmic + Then the error "Invalid log level cataclysmic!" should be shown + + Scenario: Using qute://log directly + When I open qute://log without waiting + # With Qt 5.9, we don't get a loaded message? + And I wait for "Changing title for idx * to 'log'" in the log + Then no crash should happen + + Scenario: Using qute://plainlog directly + When I open qute://plainlog without waiting + # With Qt 5.9, we don't get a loaded message? + And I wait for "Changing title for idx * to 'log'" in the log + Then no crash should happen diff --git a/tests/end2end/features/test_misc_bdd.py b/tests/end2end/features/test_misc_bdd.py index a47b89af4..d8e2fd07e 100644 --- a/tests/end2end/features/test_misc_bdd.py +++ b/tests/end2end/features/test_misc_bdd.py @@ -17,45 +17,10 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -import sys -import os.path -import subprocess - -import pytest import pytest_bdd as bdd - -import qutebrowser -from qutebrowser.utils import docutils - bdd.scenarios('misc.feature') -@bdd.when("the documentation is up to date") -def update_documentation(): - """Update the docs before testing :help.""" - base_path = os.path.dirname(os.path.abspath(qutebrowser.__file__)) - doc_path = os.path.join(base_path, 'html', 'doc') - script_path = os.path.join(base_path, '..', 'scripts') - - try: - os.mkdir(doc_path) - except FileExistsError: - pass - - files = os.listdir(doc_path) - if files and all(docutils.docs_up_to_date(p) for p in files): - return - - try: - subprocess.call(['asciidoc'], stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) - except OSError: - pytest.skip("Docs outdated and asciidoc unavailable!") - - update_script = os.path.join(script_path, 'asciidoc2html.py') - subprocess.call([sys.executable, update_script]) - - @bdd.then(bdd.parsers.parse('the PDF {filename} should exist in the tmpdir')) def pdf_exists(quteproc, tmpdir, filename): path = tmpdir / filename diff --git a/tests/end2end/features/test_qutescheme_bdd.py b/tests/end2end/features/test_qutescheme_bdd.py new file mode 100644 index 000000000..14bdc5cb3 --- /dev/null +++ b/tests/end2end/features/test_qutescheme_bdd.py @@ -0,0 +1,56 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2015-2017 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 sys +import os.path +import subprocess + +import pytest +import pytest_bdd as bdd + +import qutebrowser +from qutebrowser.utils import docutils + +bdd.scenarios('qutescheme.feature') + + +@bdd.when("the documentation is up to date") +def update_documentation(): + """Update the docs before testing :help.""" + base_path = os.path.dirname(os.path.abspath(qutebrowser.__file__)) + doc_path = os.path.join(base_path, 'html', 'doc') + script_path = os.path.join(base_path, '..', 'scripts') + + try: + os.mkdir(doc_path) + except FileExistsError: + pass + + files = os.listdir(doc_path) + if files and all(docutils.docs_up_to_date(p) for p in files): + return + + try: + subprocess.call(['asciidoc'], stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) + except OSError: + pytest.skip("Docs outdated and asciidoc unavailable!") + + update_script = os.path.join(script_path, 'asciidoc2html.py') + subprocess.call([sys.executable, update_script])