Move tabbedbrowser test to tabwidget
This commit is contained in:
parent
e746325d9e
commit
3081d017ce
@ -40,14 +40,6 @@ class TestTabWidget:
|
|||||||
usertypes.Backend.QtWebKit)
|
usertypes.Backend.QtWebKit)
|
||||||
return w
|
return w
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def browser(self, qtbot, monkeypatch, config_stub):
|
|
||||||
w = tabbedbrowser.TabbedBrowser(win_id=0, private=False)
|
|
||||||
qtbot.addWidget(w)
|
|
||||||
monkeypatch.setattr(tabwidget.objects, 'backend',
|
|
||||||
usertypes.Backend.QtWebKit)
|
|
||||||
return w
|
|
||||||
|
|
||||||
def test_small_icon_doesnt_crash(self, widget, qtbot, fake_web_tab):
|
def test_small_icon_doesnt_crash(self, widget, qtbot, fake_web_tab):
|
||||||
"""Test that setting a small icon doesn't produce a crash.
|
"""Test that setting a small icon doesn't produce a crash.
|
||||||
|
|
||||||
@ -108,7 +100,7 @@ class TestTabWidget:
|
|||||||
|
|
||||||
for i in range(num_tabs):
|
for i in range(num_tabs):
|
||||||
if i in pinned_num and shrink_pinned and not vertical:
|
if i in pinned_num and shrink_pinned and not vertical:
|
||||||
assert (first_size.width() <
|
assert (first_size.width() >
|
||||||
widget.tabBar().tabSizeHint(i).width())
|
widget.tabBar().tabSizeHint(i).width())
|
||||||
assert (first_size_min.width() <
|
assert (first_size_min.width() <
|
||||||
widget.tabBar().minimumTabSizeHint(i).width())
|
widget.tabBar().minimumTabSizeHint(i).width())
|
||||||
@ -129,17 +121,22 @@ class TestTabWidget:
|
|||||||
benchmark(widget.update_tab_titles)
|
benchmark(widget.update_tab_titles)
|
||||||
|
|
||||||
@pytest.mark.parametrize("num_tabs", [4, 10])
|
@pytest.mark.parametrize("num_tabs", [4, 10])
|
||||||
def test_add_remove_tab_benchmark(self, benchmark, browser,
|
@pytest.mark.parametrize("rev", [True, False])
|
||||||
qtbot, fake_web_tab, num_tabs):
|
def test_add_remove_tab_benchmark(self, benchmark, widget,
|
||||||
|
qtbot, fake_web_tab, num_tabs, rev):
|
||||||
"""Benchmark for addTab and removeTab."""
|
"""Benchmark for addTab and removeTab."""
|
||||||
def _run_bench():
|
def _run_bench():
|
||||||
|
with qtbot.wait_exposed(widget):
|
||||||
|
widget.show()
|
||||||
for i in range(num_tabs):
|
for i in range(num_tabs):
|
||||||
browser.widget.addTab(fake_web_tab(), 'foobar' + str(i))
|
idx = i if rev else 0
|
||||||
|
widget.insertTab(idx, fake_web_tab(), 'foobar' + str(i))
|
||||||
|
|
||||||
with qtbot.waitExposed(browser):
|
to_del = range(num_tabs)
|
||||||
browser.show()
|
if rev:
|
||||||
|
to_del = reversed(to_del)
|
||||||
browser.shutdown()
|
for i in to_del:
|
||||||
|
widget.removeTab(i)
|
||||||
|
|
||||||
benchmark(_run_bench)
|
benchmark(_run_bench)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user