Update tests for statusbar changes
This commit is contained in:
parent
715cc7b7dd
commit
6f9be72c5b
@ -45,14 +45,22 @@ def test_backforward_widget(backforward_widget, tabbed_browser_stubs,
|
|||||||
tabbed_browser = tabbed_browser_stubs[0]
|
tabbed_browser = tabbed_browser_stubs[0]
|
||||||
tabbed_browser.current_index = 1
|
tabbed_browser.current_index = 1
|
||||||
tabbed_browser.tabs = [tab]
|
tabbed_browser.tabs = [tab]
|
||||||
|
backforward_widget.enabled = True
|
||||||
backforward_widget.on_tab_cur_url_changed(tabbed_browser)
|
backforward_widget.on_tab_cur_url_changed(tabbed_browser)
|
||||||
assert backforward_widget.text() == expected_text
|
assert backforward_widget.text() == expected_text
|
||||||
assert backforward_widget.isVisible() == bool(expected_text)
|
assert backforward_widget.isVisible() == bool(expected_text)
|
||||||
|
|
||||||
|
# Check that the widget stays hidden if not in the statusbar
|
||||||
|
backforward_widget.enabled = False
|
||||||
|
backforward_widget.hide()
|
||||||
|
backforward_widget.on_tab_cur_url_changed(tabbed_browser)
|
||||||
|
assert backforward_widget.isHidden()
|
||||||
|
|
||||||
# Check that the widget gets reset if empty.
|
# Check that the widget gets reset if empty.
|
||||||
if can_go_back and can_go_forward:
|
if can_go_back and can_go_forward:
|
||||||
tab = fake_web_tab(can_go_back=False, can_go_forward=False)
|
tab = fake_web_tab(can_go_back=False, can_go_forward=False)
|
||||||
tabbed_browser.tabs = [tab]
|
tabbed_browser.tabs = [tab]
|
||||||
|
backforward_widget.enabled = True
|
||||||
backforward_widget.on_tab_cur_url_changed(tabbed_browser)
|
backforward_widget.on_tab_cur_url_changed(tabbed_browser)
|
||||||
assert backforward_widget.text() == ''
|
assert backforward_widget.text() == ''
|
||||||
assert not backforward_widget.isVisible()
|
assert not backforward_widget.isVisible()
|
||||||
@ -64,6 +72,7 @@ def test_none_tab(backforward_widget, tabbed_browser_stubs, fake_web_tab):
|
|||||||
tabbed_browser = tabbed_browser_stubs[0]
|
tabbed_browser = tabbed_browser_stubs[0]
|
||||||
tabbed_browser.current_index = 1
|
tabbed_browser.current_index = 1
|
||||||
tabbed_browser.tabs = [tab]
|
tabbed_browser.tabs = [tab]
|
||||||
|
backforward_widget.enabled = True
|
||||||
backforward_widget.on_tab_cur_url_changed(tabbed_browser)
|
backforward_widget.on_tab_cur_url_changed(tabbed_browser)
|
||||||
|
|
||||||
assert backforward_widget.text() == '[<>]'
|
assert backforward_widget.text() == '[<>]'
|
||||||
|
@ -33,15 +33,21 @@ def percentage(qtbot):
|
|||||||
return widget
|
return widget
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('y, expected', [
|
@pytest.mark.parametrize('y, raw, expected', [
|
||||||
(0, '[top]'),
|
(0, False, '[top]'),
|
||||||
(100, '[bot]'),
|
(100, False, '[bot]'),
|
||||||
(75, '[75%]'),
|
(75, False, '[75%]'),
|
||||||
(25, '[25%]'),
|
(25, False, '[25%]'),
|
||||||
(5, '[ 5%]'),
|
(5, False, '[05%]'),
|
||||||
(None, '[???]'),
|
(None, False, '[???]'),
|
||||||
|
(0, True, '[top]'),
|
||||||
|
(100, True, '[bot]'),
|
||||||
|
(75, True, '[75]'),
|
||||||
|
(25, True, '[25]'),
|
||||||
|
(5, True, '[05]'),
|
||||||
|
(None, True, '[???]'),
|
||||||
])
|
])
|
||||||
def test_percentage_text(percentage, y, expected):
|
def test_percentage_text(percentage, y, raw, expected):
|
||||||
"""Test text displayed by the widget based on the y position of a page.
|
"""Test text displayed by the widget based on the y position of a page.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -49,6 +55,7 @@ def test_percentage_text(percentage, y, expected):
|
|||||||
parametrized.
|
parametrized.
|
||||||
expected: expected text given y position. parametrized.
|
expected: expected text given y position. parametrized.
|
||||||
"""
|
"""
|
||||||
|
percentage.raw = raw
|
||||||
percentage.set_perc(x=None, y=y)
|
percentage.set_perc(x=None, y=y)
|
||||||
assert percentage.text() == expected
|
assert percentage.text() == expected
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ from qutebrowser.utils import usertypes
|
|||||||
def progress_widget(qtbot, config_stub):
|
def progress_widget(qtbot, config_stub):
|
||||||
"""Create a Progress widget and checks its initial state."""
|
"""Create a Progress widget and checks its initial state."""
|
||||||
widget = Progress()
|
widget = Progress()
|
||||||
|
widget.enabled = True
|
||||||
qtbot.add_widget(widget)
|
qtbot.add_widget(widget)
|
||||||
assert not widget.isVisible()
|
assert not widget.isVisible()
|
||||||
assert not widget.isTextVisible()
|
assert not widget.isTextVisible()
|
||||||
|
Loading…
Reference in New Issue
Block a user