End2end tests for spell checking

This commit is contained in:
Michal Siedlaczek 2017-08-20 14:36:35 -07:00
parent cf229cb9c8
commit 329cfa5756
3 changed files with 97 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import sip
from PyQt5.QtCore import QUrl
# so it's available for :debug-pyeval
from PyQt5.QtWidgets import QApplication # pylint: disable=unused-import
from PyQt5.QtWebEngineWidgets import QWebEngineProfile # pylint: disable=unused-import
from qutebrowser.browser import qutescheme
from qutebrowser.utils import log, objreg, usertypes, message, debug, utils

View File

@ -0,0 +1,38 @@
# vim: ft=cucumber fileencoding=utf-8 sts=4 sw=4 et:
Feature: Setting spell checking for QtWebEngine
Background:
Given spell check languages are []
@qtwebkit_skip @qt>=5.8
Scenario: Turn spell check on
Given spell check is off
When I run :set ui spell true
Then ui -> spell should be true
Then spell check is on
@qtwebkit_skip @qt>=5.8
Scenario: Turn spell check off
Given spell check is on
When I run :set ui spell false
Then ui -> spell should be false
Then spell check is off
@qtwebkit_skip @qt>=5.8
Scenario: Set an invalid language
When I run :set ui spell-languages invalid-language (invalid command)
Then the error "set: Invalid value 'invalid-language' *" should be shown
Then actual spell check languages are []
@qtwebkit_skip @qt>=5.8
Scenario: Set valid but not installed language
When I run :set ui spell-languages af-ZA
Then the warning "Language af-ZA is not installed." should be shown
Then actual spell check languages are []
@qtwebkit_skip @qt>=5.8
Scenario: Set valid and installed language
When I run :set ui spell-languages en-US
Then ui -> spell-languages should be en-US
Then actual spell check languages are ['en-US-7-1']

View File

@ -0,0 +1,58 @@
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2017 Michał Siedlaczek <michal.siedlaczek@gmail.com>
#
# 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('spell.feature')
@bdd.given(bdd.parsers.parse("spell check is {val}"))
def spellcheck_enabled_given(quteproc, val):
enabled = val == 'on'
quteproc.send_cmd(':debug-pyeval QWebEngineProfile.defaultProfile()' +
'.setSpellCheckEnabled({})'.format(enabled))
quteproc.wait_for_load_finished('qute://pyeval')
@bdd.given(bdd.parsers.parse("spell check languages are {langs}"))
def spellcheck_langs_given(quteproc, langs):
quteproc.send_cmd(':debug-pyeval QWebEngineProfile.defaultProfile()' +
'.setSpellCheckLanguages({})'.format(langs))
quteproc.wait_for_load_finished('qute://pyeval')
@bdd.then(bdd.parsers.parse("spell check is {val}"))
def spellcheck_enabled_then(quteproc, val):
quteproc.send_cmd(':debug-pyeval QWebEngineProfile.defaultProfile()' +
'.isSpellCheckEnabled()')
quteproc.wait_for_load_finished('qute://pyeval')
content = quteproc.get_content().strip()
if val == 'on':
assert content == 'True'
else:
assert content == 'False'
@bdd.then(bdd.parsers.parse("actual spell check languages are {langs}"))
def spellcheck_langs_then(quteproc, langs):
quteproc.send_cmd(':debug-pyeval QWebEngineProfile.defaultProfile()' +
'.spellCheckLanguages()')
quteproc.wait_for_load_finished('qute://pyeval')
actual_langs = quteproc.get_content().strip()
assert actual_langs == langs