Implemented test for TextBase widget

This commit is contained in:
Bruno Oliveira 2015-04-01 20:50:20 -03:00
parent a98060e020
commit 3096f3856a
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,46 @@
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2014-2015 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 TextBase widget."""
from qutebrowser.mainwindow.statusbar.textbase import TextBase
def test_elided_text(qtbot):
"""
Ensure that a widget that can't hold the entire label text will display
and elided version of the string instead.
Args:
qtbot: pytestqt.plugin.QtBot fixture
Note:
It is difficult to check what is actually being drawn in a
portable way, so at least we ensure our customized methods are being
called and the elided string contains the horizontal ellipsis character.
"""
label = TextBase()
qtbot.add_widget(label)
long_string = 'Hello world! ' * 20
label.setText(long_string)
label.resize(100, 50)
label.show()
assert '' in label._elided_text

View File

@ -19,6 +19,7 @@ setenv = QT_QPA_PLATFORM_PLUGIN_PATH={envsitepackagesdir}/PyQt5/plugins/platform
deps = deps =
py==1.4.26 py==1.4.26
pytest==2.7.0 pytest==2.7.0
pytest-qt==1.3.0
# We don't use {[testenv:mkvenv]commands} here because that seems to be broken # We don't use {[testenv:mkvenv]commands} here because that seems to be broken
# on Ubuntu Trusty. # on Ubuntu Trusty.
commands = commands =
@ -30,6 +31,7 @@ deps =
{[testenv:unittests]deps} {[testenv:unittests]deps}
coverage==3.7.1 coverage==3.7.1
pytest-cov==1.8.1 pytest-cov==1.8.1
pytest-qt==1.3.0
cov-core==1.15.0 cov-core==1.15.0
commands = commands =
{[testenv:mkvenv]commands} {[testenv:mkvenv]commands}