Convert insert mode tests to non-bdd tests
This commit is contained in:
parent
ff13921aad
commit
376c5c458e
10
tests/integration/data/insert_mode_settings/html/input.html
Normal file
10
tests/integration/data/insert_mode_settings/html/input.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Input</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<input id="qute-input" type="text" value=""/>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--
|
||||||
|
vim: ft=html fileencoding=utf-8 sts=4 sw=4 et:
|
||||||
|
-->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Inputs Plugins</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<embed id="qute-flash" width="400" height="50" src="bookmark.swf" />
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -6,6 +6,5 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<textarea id="qute-textarea"></textarea>
|
<textarea id="qute-textarea"></textarea>
|
||||||
<input id="qute-input" type="text" value=""/>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Textarea</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<textarea id="qute-textarea"></textarea>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -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 "<Enter>"
|
|
||||||
# Then the following tabs should be open:
|
|
||||||
# - about:blank (active)
|
|
@ -1,25 +0,0 @@
|
|||||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
|
||||||
|
|
||||||
# Copyright 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
|
|
||||||
|
|
||||||
# pylint: disable=unused-import
|
|
||||||
from test_yankpaste import init_fake_clipboard
|
|
||||||
|
|
||||||
bdd.scenarios('insertmode.feature')
|
|
86
tests/integration/test_insert_mode.py
Normal file
86
tests/integration/test_insert_mode.py
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||||
|
|
||||||
|
# Copyright 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/>.
|
||||||
|
|
||||||
|
"""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)
|
Loading…
Reference in New Issue
Block a user