100% coverage for mainwindow.statusbar.textbase.

This commit is contained in:
Florian Bruhin 2015-08-12 07:37:00 +02:00
parent 8609663f40
commit 5a1663c584
2 changed files with 42 additions and 0 deletions

View File

@ -48,6 +48,7 @@ PERFECT_FILES = [
'qutebrowser/mainwindow/statusbar/percentage.py',
'qutebrowser/mainwindow/statusbar/progress.py',
'qutebrowser/mainwindow/statusbar/tabindex.py',
'qutebrowser/mainwindow/statusbar/textbase.py',
'qutebrowser/config/configtypes.py',
'qutebrowser/config/configdata.py',

View File

@ -50,4 +50,45 @@ def test_elided_text(qtbot, elidemode, check):
label.setText(long_string)
label.resize(100, 50)
label.show()
qtbot.waitForWindowShown(label)
assert check(label._elided_text)
def test_settext_empty(mocker, qtbot):
"""Make sure using setText('') works and runs repaint."""
label = TextBase()
qtbot.add_widget(label)
mocker.patch('qutebrowser.mainwindow.statusbar.textbase.TextBase.repaint',
autospec=True)
label.setText('')
label.repaint.assert_called_with()
def test_resize(qtbot):
"""Make sure the elided text is updated when resizing."""
label = TextBase()
qtbot.add_widget(label)
long_string = 'Hello world! ' * 20
label.setText(long_string)
label.show()
qtbot.waitForWindowShown(label)
text_1 = label._elided_text
label.resize(20, 50)
text_2 = label._elided_text
assert text_1 != text_2
def test_text_elide_none(mocker, qtbot):
"""Make sure the text doesn't get elided if it's empty."""
label = TextBase()
qtbot.add_widget(label)
label.setText('')
mocker.patch('qutebrowser.mainwindow.statusbar.textbase.TextBase.'
'fontMetrics')
label._update_elided_text(20)
assert not label.fontMetrics.called