diff options
author | Stanislav Yelenskiy <qt@devstas.com> | 2020-09-25 00:17:28 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2021-02-02 10:56:37 +0200 |
commit | 404b0cc60a65dedbcdc3417f567d9b21c55c359b (patch) | |
tree | 2cdd6f5eea1cd457da4ef455b841ed9393a32e39 /tests | |
parent | 4699abaedca56c735cdc59f0ef217629e26b9192 (diff) |
QTabBar: update index of last visible tab in insertTab
Index of the last visible tab was not updated, if a new tab was inserted
after the current tab and before the last tab.
When the new tab is inserted before the last visible tab, the index of
the last tab increments by one.
When the new tab is inserted after the last visible tab, then the newly
inserted tab becomes the last visible.
Fixes: QTBUG-86898
Change-Id: I2f4b7f705261ec35a5aa7b883ecdddba25f007b7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit b39b018f4a54252ee7a9ffada6d0f05f5896baaf)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp index 5698e756dc..79a963f532 100644 --- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp @@ -59,6 +59,7 @@ private slots: void testCurrentChanged(); void insertAtCurrentIndex(); + void insertAfterCurrentIndex(); void removeTab_data(); void removeTab(); @@ -236,6 +237,31 @@ void tst_QTabBar::insertAtCurrentIndex() QCOMPARE(tabBar.currentIndex(), 3); } +void tst_QTabBar::insertAfterCurrentIndex() +{ + TabBar tabBar; + + tabBar.addTab("Tab10"); + checkPositions(tabBar, { QStyleOptionTab::OnlyOneTab }); + + tabBar.addTab("Tab20"); + checkPositions(tabBar, { QStyleOptionTab::Beginning, QStyleOptionTab::End }); + + tabBar.insertTab(1, "Tab15"); + checkPositions(tabBar, + { QStyleOptionTab::Beginning, QStyleOptionTab::Middle, QStyleOptionTab::End }); + + tabBar.insertTab(3, "Tab30"); + checkPositions(tabBar, + { QStyleOptionTab::Beginning, QStyleOptionTab::Middle, QStyleOptionTab::Middle, + QStyleOptionTab::End }); + + tabBar.insertTab(3, "Tab25"); + checkPositions(tabBar, + { QStyleOptionTab::Beginning, QStyleOptionTab::Middle, QStyleOptionTab::Middle, + QStyleOptionTab::Middle, QStyleOptionTab::End }); +} + void tst_QTabBar::removeTab_data() { QTest::addColumn<int>("currentIndex"); |