From 601687ba61605317e30bededd43214890e7858ec Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Tue, 29 Mar 2016 22:51:49 +0200 Subject: [PATCH 1/5] Add insert mode feature tests Issue-Link: #999 --- tests/integration/data/inputs.html | 15 ++++ tests/integration/features/insertmode.feature | 69 +++++++++++++++++++ tests/integration/features/test_insertmode.py | 25 +++++++ 3 files changed, 109 insertions(+) create mode 100644 tests/integration/data/inputs.html create mode 100644 tests/integration/features/insertmode.feature create mode 100644 tests/integration/features/test_insertmode.py diff --git a/tests/integration/data/inputs.html b/tests/integration/data/inputs.html new file mode 100644 index 000000000..9bd445bf0 --- /dev/null +++ b/tests/integration/data/inputs.html @@ -0,0 +1,15 @@ + + + + + Inputs + + + + + + + + diff --git a/tests/integration/features/insertmode.feature b/tests/integration/features/insertmode.feature new file mode 100644 index 000000000..fc3c782ae --- /dev/null +++ b/tests/integration/features/insertmode.feature @@ -0,0 +1,69 @@ +Feature: Insert mode + + Background: + Given I open data/inputs.html + And I run :hint all + + # textarea tag + + Scenario: Basic insertion of text in textarea + When I run :follow-hint a + And I press the keys "qutebrowser" + And I run :hint all + And I run :follow-hint a + And I run :enter-mode caret + And I run :toggle-selection + And I run :move-to-prev-word + And I run :yank-selected + Then the message "11 chars yanked to clipboard" should be shown + And the clipboard should contain "qutebrowser" + + Scenario: Paste from primary selection into textarea + When I put "superqutebrowser" into the primary selection + And I run :follow-hint a + And I run :paste-primary + And I run :hint all + And I run :follow-hint a + And I run :enter-mode caret + And I run :toggle-selection + And I run :move-to-prev-word + And I run :yank-selected + Then the message "16 chars yanked to clipboard" should be shown + And the clipboard should contain "superqutebrowser" + + # input tag + + Scenario: Basic insertion of text in input field + When I run :follow-hint s + And I press the keys "qutebrowser" + And I run :hint all + And I run :follow-hint s + And I run :enter-mode caret + And I run :toggle-selection + And I run :move-to-prev-word + And I run :yank-selected + Then the message "11 chars yanked to clipboard" should be shown + And the clipboard should contain "qutebrowser" + + Scenario: Paste from primary selection into input field + When I put "superqutebrowser" into the primary selection + And I run :follow-hint s + And I run :paste-primary + And I run :hint all + And I run :follow-hint s + And I run :enter-mode caret + And I run :toggle-selection + And I run :move-to-prev-word + And I run :yank-selected + Then the message "16 chars yanked to clipboard" should be shown + And the clipboard should contain "superqutebrowser" + + # # select/option tag + + # Scenario: Select an option from a dropdown + # When I run :follow-hint d + # And I run :enter-mode insert + # And I press the keys "b" + # And I press the keys "" + # Then the following tabs should be open: + # - about:blank (active) diff --git a/tests/integration/features/test_insertmode.py b/tests/integration/features/test_insertmode.py new file mode 100644 index 000000000..aa1a74a33 --- /dev/null +++ b/tests/integration/features/test_insertmode.py @@ -0,0 +1,25 @@ +# 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 init_fake_clipboard + +bdd.scenarios('insertmode.feature') From ff13921aadf653ec57221c4d774b310c737d9c79 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Wed, 20 Apr 2016 12:50:33 +0200 Subject: [PATCH 2/5] Add tests for auto-[leave-]insert-mode --- tests/integration/data/inputs.html | 4 -- tests/integration/data/inputs_autofocus.html | 11 +++++ tests/integration/features/insertmode.feature | 45 ++++++++++++++++--- 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 tests/integration/data/inputs_autofocus.html diff --git a/tests/integration/data/inputs.html b/tests/integration/data/inputs.html index 9bd445bf0..510e4978f 100644 --- a/tests/integration/data/inputs.html +++ b/tests/integration/data/inputs.html @@ -7,9 +7,5 @@ - - diff --git a/tests/integration/data/inputs_autofocus.html b/tests/integration/data/inputs_autofocus.html new file mode 100644 index 000000000..db5399252 --- /dev/null +++ b/tests/integration/data/inputs_autofocus.html @@ -0,0 +1,11 @@ + + + + + Inputs Autofocus + + + + + + diff --git a/tests/integration/features/insertmode.feature b/tests/integration/features/insertmode.feature index fc3c782ae..9045a1df6 100644 --- a/tests/integration/features/insertmode.feature +++ b/tests/integration/features/insertmode.feature @@ -1,13 +1,13 @@ Feature: Insert mode Background: - Given I open data/inputs.html - And I run :hint all # textarea tag Scenario: Basic insertion of text in textarea - When I run :follow-hint a + When I open data/inputs.html + And I run :hint all + And I run :follow-hint a And I press the keys "qutebrowser" And I run :hint all And I run :follow-hint a @@ -19,7 +19,9 @@ Feature: Insert mode And the clipboard should contain "qutebrowser" Scenario: Paste from primary selection into textarea - When I put "superqutebrowser" into the primary selection + When I open data/inputs.html + And I run :hint all + And I put "superqutebrowser" into the primary selection And I run :follow-hint a And I run :paste-primary And I run :hint all @@ -34,7 +36,9 @@ Feature: Insert mode # input tag Scenario: Basic insertion of text in input field - When I run :follow-hint s + When I open data/inputs.html + And I run :hint all + And I run :follow-hint s And I press the keys "qutebrowser" And I run :hint all And I run :follow-hint s @@ -46,7 +50,9 @@ Feature: Insert mode And the clipboard should contain "qutebrowser" Scenario: Paste from primary selection into input field - When I put "superqutebrowser" into the primary selection + When I open data/inputs.html + And I run :hint all + And I put "superqutebrowser" into the primary selection And I run :follow-hint s And I run :paste-primary And I run :hint all @@ -58,7 +64,32 @@ Feature: Insert mode Then the message "16 chars yanked to clipboard" should be shown And the clipboard should contain "superqutebrowser" - # # select/option tag + # input -> auto-insert-mode + + Scenario: With input -> auto-insert-mode enabled + When I set input -> auto-insert-mode to true + And I open data/inputs_autofocus.html + And I press the keys "qutebrowser" + And I run :hint all + And I run :follow-hint a + And I run :enter-mode caret + And I run :toggle-selection + And I run :move-to-prev-word + And I run :yank-selected + Then the message "11 chars yanked to clipboard" should be shown + And the clipboard should contain "qutebrowser" + + + # input -> auto-leave-insert-mode + + Scenario: With input -> auto-leave-insert-mode enabled + When I set input -> auto-leave-insert-mode to true + And I open data/inputs_autofocus.html + And I press the keys "abcd" + And I run :hint all + And I run :follow-hint s + And I run :paste-primary + Then the error "paste-primary: This command is only allowed in insert mode." should be shown # Scenario: Select an option from a dropdown # When I run :follow-hint d From 376c5c458ec0c959102a662f11b68da15a3e20b6 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Wed, 20 Apr 2016 16:19:47 +0200 Subject: [PATCH 3/5] Convert insert mode tests to non-bdd tests --- .../html/autofocus.html} | 0 .../data/insert_mode_settings/html/input.html | 10 ++ .../html/inputs_flash.html | 13 +++ .../html/inputs_textarea.html} | 1 - .../insert_mode_settings/html/textarea.html | 10 ++ tests/integration/features/insertmode.feature | 100 ------------------ tests/integration/features/test_insertmode.py | 25 ----- tests/integration/test_insert_mode.py | 86 +++++++++++++++ 8 files changed, 119 insertions(+), 126 deletions(-) rename tests/integration/data/{inputs_autofocus.html => insert_mode_settings/html/autofocus.html} (100%) create mode 100644 tests/integration/data/insert_mode_settings/html/input.html create mode 100644 tests/integration/data/insert_mode_settings/html/inputs_flash.html rename tests/integration/data/{inputs.html => insert_mode_settings/html/inputs_textarea.html} (77%) create mode 100644 tests/integration/data/insert_mode_settings/html/textarea.html delete mode 100644 tests/integration/features/insertmode.feature delete mode 100644 tests/integration/features/test_insertmode.py create mode 100644 tests/integration/test_insert_mode.py diff --git a/tests/integration/data/inputs_autofocus.html b/tests/integration/data/insert_mode_settings/html/autofocus.html similarity index 100% rename from tests/integration/data/inputs_autofocus.html rename to tests/integration/data/insert_mode_settings/html/autofocus.html diff --git a/tests/integration/data/insert_mode_settings/html/input.html b/tests/integration/data/insert_mode_settings/html/input.html new file mode 100644 index 000000000..2965693d3 --- /dev/null +++ b/tests/integration/data/insert_mode_settings/html/input.html @@ -0,0 +1,10 @@ + + + + + Input + + + + + diff --git a/tests/integration/data/insert_mode_settings/html/inputs_flash.html b/tests/integration/data/insert_mode_settings/html/inputs_flash.html new file mode 100644 index 000000000..f0b0c9c51 --- /dev/null +++ b/tests/integration/data/insert_mode_settings/html/inputs_flash.html @@ -0,0 +1,13 @@ + + + + + + Inputs Plugins + + + + + diff --git a/tests/integration/data/inputs.html b/tests/integration/data/insert_mode_settings/html/inputs_textarea.html similarity index 77% rename from tests/integration/data/inputs.html rename to tests/integration/data/insert_mode_settings/html/inputs_textarea.html index 510e4978f..444034da2 100644 --- a/tests/integration/data/inputs.html +++ b/tests/integration/data/insert_mode_settings/html/inputs_textarea.html @@ -6,6 +6,5 @@ - diff --git a/tests/integration/data/insert_mode_settings/html/textarea.html b/tests/integration/data/insert_mode_settings/html/textarea.html new file mode 100644 index 000000000..403809a3a --- /dev/null +++ b/tests/integration/data/insert_mode_settings/html/textarea.html @@ -0,0 +1,10 @@ + + + + + Textarea + + + + + diff --git a/tests/integration/features/insertmode.feature b/tests/integration/features/insertmode.feature deleted file mode 100644 index 9045a1df6..000000000 --- a/tests/integration/features/insertmode.feature +++ /dev/null @@ -1,100 +0,0 @@ -Feature: Insert mode - - Background: - - # textarea tag - - Scenario: Basic insertion of text in textarea - When I open data/inputs.html - And I run :hint all - And I run :follow-hint a - And I press the keys "qutebrowser" - And I run :hint all - And I run :follow-hint a - And I run :enter-mode caret - And I run :toggle-selection - And I run :move-to-prev-word - And I run :yank-selected - Then the message "11 chars yanked to clipboard" should be shown - And the clipboard should contain "qutebrowser" - - Scenario: Paste from primary selection into textarea - When I open data/inputs.html - And I run :hint all - And I put "superqutebrowser" into the primary selection - And I run :follow-hint a - And I run :paste-primary - And I run :hint all - And I run :follow-hint a - And I run :enter-mode caret - And I run :toggle-selection - And I run :move-to-prev-word - And I run :yank-selected - Then the message "16 chars yanked to clipboard" should be shown - And the clipboard should contain "superqutebrowser" - - # input tag - - Scenario: Basic insertion of text in input field - When I open data/inputs.html - And I run :hint all - And I run :follow-hint s - And I press the keys "qutebrowser" - And I run :hint all - And I run :follow-hint s - And I run :enter-mode caret - And I run :toggle-selection - And I run :move-to-prev-word - And I run :yank-selected - Then the message "11 chars yanked to clipboard" should be shown - And the clipboard should contain "qutebrowser" - - Scenario: Paste from primary selection into input field - When I open data/inputs.html - And I run :hint all - And I put "superqutebrowser" into the primary selection - And I run :follow-hint s - And I run :paste-primary - And I run :hint all - And I run :follow-hint s - And I run :enter-mode caret - And I run :toggle-selection - And I run :move-to-prev-word - And I run :yank-selected - Then the message "16 chars yanked to clipboard" should be shown - And the clipboard should contain "superqutebrowser" - - # input -> auto-insert-mode - - Scenario: With input -> auto-insert-mode enabled - When I set input -> auto-insert-mode to true - And I open data/inputs_autofocus.html - And I press the keys "qutebrowser" - And I run :hint all - And I run :follow-hint a - And I run :enter-mode caret - And I run :toggle-selection - And I run :move-to-prev-word - And I run :yank-selected - Then the message "11 chars yanked to clipboard" should be shown - And the clipboard should contain "qutebrowser" - - - # input -> auto-leave-insert-mode - - Scenario: With input -> auto-leave-insert-mode enabled - When I set input -> auto-leave-insert-mode to true - And I open data/inputs_autofocus.html - And I press the keys "abcd" - And I run :hint all - And I run :follow-hint s - And I run :paste-primary - Then the error "paste-primary: This command is only allowed in insert mode." should be shown - - # Scenario: Select an option from a dropdown - # When I run :follow-hint d - # And I run :enter-mode insert - # And I press the keys "b" - # And I press the keys "" - # Then the following tabs should be open: - # - about:blank (active) diff --git a/tests/integration/features/test_insertmode.py b/tests/integration/features/test_insertmode.py deleted file mode 100644 index aa1a74a33..000000000 --- a/tests/integration/features/test_insertmode.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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 init_fake_clipboard - -bdd.scenarios('insertmode.feature') diff --git a/tests/integration/test_insert_mode.py b/tests/integration/test_insert_mode.py new file mode 100644 index 000000000..12e750677 --- /dev/null +++ b/tests/integration/test_insert_mode.py @@ -0,0 +1,86 @@ +# 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 . + +"""Test insert mode settings on html files.""" + +import logging +import json + +import pytest + + +@pytest.mark.parametrize('file_name, source, input_text, auto_insert', [ + ('textarea.html', 'clipboard', 'qutebrowser', 'false'), + ('textarea.html', 'keypress', 'superqutebrowser', 'false'), + ('input.html', 'clipboard', 'amazingqutebrowser', 'false'), + ('input.html', 'keypress', 'awesomequtebrowser', 'false'), + ('autofocus.html', 'keypress', 'cutebrowser', 'true'), +]) +def test_insert_mode(file_name, source, input_text, auto_insert, quteproc): + url_path = 'data/insert_mode_settings/html/{}'.format(file_name) + quteproc.open_path(url_path) + quteproc.wait_for_load_finished(url_path) + + quteproc.set_setting('input', 'auto-insert-mode', auto_insert) + quteproc.send_cmd(':hint all') + quteproc.send_cmd(':follow-hint a') + + if source == 'keypress': + quteproc.press_keys(input_text) + elif source == 'clipboard': + quteproc.send_cmd(':debug-set-fake-clipboard') + quteproc.send_cmd(':debug-set-fake-clipboard "{}"'.format(input_text)) + quteproc.send_cmd(':paste-primary') + + quteproc.send_cmd(':hint all') + quteproc.send_cmd(':follow-hint a') + quteproc.send_cmd(':enter-mode caret') + quteproc.send_cmd(':toggle-selection') + quteproc.send_cmd(':move-to-prev-word') + quteproc.send_cmd(':yank-selected') + + expected_message = '{} chars yanked to clipboard'.format(len(input_text)) + quteproc.mark_expected(category='message', + loglevel=logging.INFO, + message=expected_message) + quteproc.wait_for( + message='Setting fake clipboard: {}'.format(json.dumps(input_text))) + + +def test_auto_leave_insert_mode(quteproc): + url_path = 'data/insert_mode_settings/html/autofocus.html' + quteproc.open_path(url_path) + quteproc.wait_for_load_finished(url_path) + + quteproc.set_setting('input', 'auto-leave-insert-mode', 'true') + + quteproc.press_keys('abcd') + + quteproc.send_cmd(':hint all') + + # Select the disabled input box, to leave insert mode + quteproc.send_cmd(':follow-hint s') + quteproc.send_cmd(':enter-mode caret') + quteproc.send_cmd(':paste-primary') + + expected_message = 'paste-primary: This command is only allowed in '\ + 'insert mode.' + quteproc.mark_expected(category='message', + loglevel=logging.ERROR, + message=expected_message) From dfc1e5703ac58e157e1226ac02e7c2841c084454 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Wed, 20 Apr 2016 16:23:18 +0200 Subject: [PATCH 4/5] Cleanup unused files --- .../insert_mode_settings/html/inputs_flash.html | 13 ------------- .../insert_mode_settings/html/inputs_textarea.html | 10 ---------- tests/integration/test_insert_mode.py | 2 +- 3 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 tests/integration/data/insert_mode_settings/html/inputs_flash.html delete mode 100644 tests/integration/data/insert_mode_settings/html/inputs_textarea.html diff --git a/tests/integration/data/insert_mode_settings/html/inputs_flash.html b/tests/integration/data/insert_mode_settings/html/inputs_flash.html deleted file mode 100644 index f0b0c9c51..000000000 --- a/tests/integration/data/insert_mode_settings/html/inputs_flash.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Inputs Plugins - - - - - diff --git a/tests/integration/data/insert_mode_settings/html/inputs_textarea.html b/tests/integration/data/insert_mode_settings/html/inputs_textarea.html deleted file mode 100644 index 444034da2..000000000 --- a/tests/integration/data/insert_mode_settings/html/inputs_textarea.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Inputs - - - - - diff --git a/tests/integration/test_insert_mode.py b/tests/integration/test_insert_mode.py index 12e750677..7bf0a6958 100644 --- a/tests/integration/test_insert_mode.py +++ b/tests/integration/test_insert_mode.py @@ -74,7 +74,7 @@ def test_auto_leave_insert_mode(quteproc): quteproc.send_cmd(':hint all') - # Select the disabled input box, to leave insert mode + # Select the disabled input box to leave insert mode quteproc.send_cmd(':follow-hint s') quteproc.send_cmd(':enter-mode caret') quteproc.send_cmd(':paste-primary') From 8f3dda6709673d6462ce51c0628997fc684f5b3d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 9 May 2016 07:15:19 +0200 Subject: [PATCH 5/5] Regenerate authors --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 329a3fa4f..90ab8bcee 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -156,10 +156,10 @@ Contributors, sorted by the number of commits in descending order: * Corentin Julé * meles5 * Tarcisio Fedrizzi +* Philipp Hansch * Artur Shaik * Nathan Isom * Thorsten Wißmann -* Philipp Hansch * Kevin Velghe * Austin Anderson * Panagiotis Ktistakis