Clean up tab min/max width tests

This commit is contained in:
Jay Kamat 2018-09-27 18:57:26 -07:00
parent e01682f51d
commit d64771b8e3
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5

View File

@ -38,7 +38,8 @@ class TestTabWidget:
qtbot.addWidget(w)
monkeypatch.setattr(tabwidget.objects, 'backend',
usertypes.Backend.QtWebKit)
monkeypatch.setattr(w.tabBar(), 'width', w.width)
w.show()
# monkeypatch.setattr(w.tabBar(), 'width', w.width)
return w
@pytest.fixture
@ -130,20 +131,16 @@ class TestTabWidget:
benchmark(widget.update_tab_titles)
def test_tab_min_width(self, widget, fake_web_tab, config_stub):
"""Ensure by default, all tab sizes are the same."""
widget.addTab(fake_web_tab(), 'foobar')
normal_size = widget.tabBar().minimumTabSizeHint(0).width()
normal_size += 100
normal_size = widget.tabBar().tabRect(0).width() + 100
config_stub.val.tabs.min_width = normal_size
assert widget.tabBar().minimumTabSizeHint(0).width() == normal_size
assert widget.tabBar().tabRect(0).width() == normal_size
def test_tab_max_width(self, widget, fake_web_tab, config_stub):
"""Ensure by default, all tab sizes are the same."""
widget.addTab(fake_web_tab(), 'foobar')
normal_size = widget.tabBar().tabSizeHint(0).width()
normal_size -= 10
normal_size = widget.tabBar().tabRect(0).width() - 10
config_stub.val.tabs.max_width = normal_size
assert widget.tabBar().tabSizeHint(0).width() == normal_size
assert widget.tabBar().tabRect(0).width() == normal_size
@pytest.mark.parametrize("num_tabs", [4, 10])
def test_add_remove_tab_benchmark(self, benchmark, browser,