diff options
author | Stanislav Yelenskiy <qt@devstas.com> | 2020-09-25 00:17:28 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-10-21 07:19:36 +0000 |
commit | b39b018f4a54252ee7a9ffada6d0f05f5896baaf (patch) | |
tree | 7092aa63b37b36e2611e58421a793f3071634bc9 /tests/auto/widgets | |
parent | 9f9275f82f6117c18eadee289c7df525aab187ee (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>
Diffstat (limited to 'tests/auto/widgets')
-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 db94e03ff4..d61b48a41c 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"); |