diff options
author | Liang Qi <liang.qi@qt.io> | 2020-01-04 15:32:34 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2020-01-04 15:32:34 +0100 |
commit | a503bf54705d89204007e8f887b668fe5ef519fc (patch) | |
tree | b2d1a452da39450eac78a1aeb1df116a73f64b23 /tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp | |
parent | e65c43fd0ffa57248e7d750570b7deae171a82f5 (diff) | |
parent | 1f87fb359fdff14e42662384a9c8a0bcb3837671 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
src/corelib/tools/qvector.h
Make QVector(DataPointer dd) public to be able to properly merge
5b4b437b30b320e2cd7c9a566999a39772e5d431 from 5.15 into dev.
src/widgets/kernel/qapplication.cpp
tests/auto/tools/moc/allmocs_baseline_in.json
Done-With: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Change-Id: I929ba7c036d570382d0454c2c75f6f0d96ddbc01
Diffstat (limited to 'tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp')
-rw-r--r-- | tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp index 11effcfa93..bc1496d0f6 100644 --- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp @@ -60,6 +60,10 @@ private slots: void removeTab_data(); void removeTab(); + void hideTab_data(); + void hideTab(); + void hideAllTabs(); + void setElideMode_data(); void setElideMode(); void sizeHints(); @@ -244,6 +248,73 @@ void tst_QTabBar::removeTab() QTEST(tabbar.currentIndex(), "finalIndex"); } +void tst_QTabBar::hideTab_data() +{ + QTest::addColumn<int>("currentIndex"); + QTest::addColumn<int>("hideIndex"); + QTest::addColumn<int>("spyCount"); + QTest::addColumn<int>("finalIndex"); + + QTest::newRow("hideEnd") << 0 << 2 << 0 << 0; + QTest::newRow("hideEndWithIndexOnEnd") << 2 << 2 << 1 << 1; + QTest::newRow("hideMiddle") << 2 << 1 << 0 << 2; + QTest::newRow("hideMiddleOnMiddle") << 1 << 1 << 1 << 2; + QTest::newRow("hideFirst") << 2 << 0 << 0 << 2; + QTest::newRow("hideFirstOnFirst") << 0 << 0 << 1 << 1; +} + +void tst_QTabBar::hideTab() +{ + QTabBar tabbar; + + QFETCH(int, currentIndex); + QFETCH(int, hideIndex); + tabbar.addTab("foo"); + tabbar.addTab("bar"); + tabbar.addTab("baz"); + tabbar.setCurrentIndex(currentIndex); + QSignalSpy spy(&tabbar, &QTabBar::currentChanged); + tabbar.setTabVisible(hideIndex, false); + QTEST(spy.count(), "spyCount"); + QTEST(tabbar.currentIndex(), "finalIndex"); +} + +void tst_QTabBar::hideAllTabs() +{ + QTabBar tabbar; + + tabbar.addTab("foo"); + tabbar.addTab("bar"); + tabbar.addTab("baz"); + tabbar.setCurrentIndex(0); + + // Check we don't crash trying to hide an unexistant tab + QSize prevSizeHint = tabbar.sizeHint(); + tabbar.setTabVisible(3, false); + QCOMPARE(tabbar.currentIndex(), 0); + QSize sizeHint = tabbar.sizeHint(); + QVERIFY(sizeHint.width() == prevSizeHint.width()); + prevSizeHint = sizeHint; + + tabbar.setTabVisible(1, false); + QCOMPARE(tabbar.currentIndex(), 0); + sizeHint = tabbar.sizeHint(); + QVERIFY(sizeHint.width() < prevSizeHint.width()); + prevSizeHint = sizeHint; + + tabbar.setTabVisible(2, false); + QCOMPARE(tabbar.currentIndex(), 0); + sizeHint = tabbar.sizeHint(); + QVERIFY(sizeHint.width() < prevSizeHint.width()); + prevSizeHint = sizeHint; + + tabbar.setTabVisible(0, false); + // We cannot set currentIndex < 0 + QCOMPARE(tabbar.currentIndex(), 0); + sizeHint = tabbar.sizeHint(); + QVERIFY(sizeHint.width() < prevSizeHint.width()); +} + void tst_QTabBar::setElideMode_data() { QTest::addColumn<int>("tabElideMode"); |