Merge branch 'test_completion' of https://github.com/rcorre/qutebrowser into rcorre-test_completion
This commit is contained in:
commit
6b31576950
7
tests/end2end/features/completion.feature
Normal file
7
tests/end2end/features/completion.feature
Normal file
@ -0,0 +1,7 @@
|
||||
Feature: Command bar completion
|
||||
|
||||
Scenario: No warnings when completing with one entry (#1600)
|
||||
Given I open about:blank
|
||||
When I run :set-cmd-text -s :open
|
||||
And I run :completion-item-focus next
|
||||
Then no crash should happen
|
21
tests/end2end/features/test_completion_bdd.py
Normal file
21
tests/end2end/features/test_completion_bdd.py
Normal file
@ -0,0 +1,21 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2016 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net>
|
||||
#
|
||||
# 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('completion.feature')
|
@ -145,7 +145,8 @@ def test_maybe_resize_completion(completionview, config_stub, qtbot):
|
||||
('next-category', [[]], 1, None),
|
||||
('prev-category', [[]], 1, None),
|
||||
])
|
||||
def test_completion_item_focus(which, tree, count, expected, completionview):
|
||||
def test_completion_item_focus(which, tree, count, expected, completionview,
|
||||
qtbot):
|
||||
"""Test that on_next_prev_item moves the selection properly.
|
||||
|
||||
Args:
|
||||
@ -163,12 +164,34 @@ def test_completion_item_focus(which, tree, count, expected, completionview):
|
||||
filtermodel = sortfilter.CompletionFilterModel(model,
|
||||
parent=completionview)
|
||||
completionview.set_model(filtermodel)
|
||||
for _ in range(count):
|
||||
completionview.completion_item_focus(which)
|
||||
if expected is None:
|
||||
for _ in range(count):
|
||||
completionview.completion_item_focus(which)
|
||||
else:
|
||||
with qtbot.waitSignal(completionview.selection_changed):
|
||||
for _ in range(count):
|
||||
completionview.completion_item_focus(which)
|
||||
idx = completionview.selectionModel().currentIndex()
|
||||
assert filtermodel.data(idx) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize('which', ['next', 'prev', 'next-category',
|
||||
'prev-category'])
|
||||
def test_completion_item_focus_no_model(which, completionview, qtbot):
|
||||
"""Test that selectionChanged is not fired when the model is None.
|
||||
|
||||
Validates #1812: help completion repeatedly completes
|
||||
"""
|
||||
with qtbot.assertNotEmitted(completionview.selection_changed):
|
||||
completionview.completion_item_focus(which)
|
||||
model = base.BaseCompletionModel()
|
||||
filtermodel = sortfilter.CompletionFilterModel(model,
|
||||
parent=completionview)
|
||||
completionview.set_model(filtermodel)
|
||||
completionview.set_model(None)
|
||||
with qtbot.assertNotEmitted(completionview.selection_changed):
|
||||
completionview.completion_item_focus(which)
|
||||
|
||||
@pytest.mark.parametrize('show', ['always', 'auto', 'never'])
|
||||
@pytest.mark.parametrize('rows', [[], ['Aa'], ['Aa', 'Bb']])
|
||||
@pytest.mark.parametrize('quick_complete', [True, False])
|
||||
|
Loading…
Reference in New Issue
Block a user