summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp')
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp66
1 files changed, 65 insertions, 1 deletions
diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
index 00cb26c2d3..d7bfdfaad2 100644
--- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -60,6 +60,7 @@ private slots:
void tabPosition();
void tabEnabled();
void tabHidden();
+ void checkHiddenTab();
void tabText();
void tabShape();
void tabTooltip();
@@ -79,6 +80,9 @@ private slots:
void moveCurrentTab();
void autoHide();
+ void setCurrentBeforeShow_data();
+ void setCurrentBeforeShow();
+
private:
int addPage();
void removePage(int index);
@@ -249,6 +253,32 @@ void tst_QTabWidget::tabHidden()
}
}
+void tst_QTabWidget::checkHiddenTab()
+{
+ tw->addTab(new QWidget(), "foo");
+ tw->addTab(new QWidget(), "bar");
+ tw->addTab(new QWidget(), "baz");
+ QCOMPARE(tw->count(), 3);
+ tw->setCurrentIndex(0);
+ tw->setTabVisible(1, false);
+
+ QKeyEvent keyTab(QKeyEvent::KeyPress, Qt::Key_Tab, Qt::ControlModifier);
+ QVERIFY(QApplication::sendEvent(tw, &keyTab));
+ QCOMPARE(tw->currentIndex(), 2);
+ QVERIFY(QApplication::sendEvent(tw, &keyTab));
+ QCOMPARE(tw->currentIndex(), 0);
+ QVERIFY(QApplication::sendEvent(tw, &keyTab));
+ QCOMPARE(tw->currentIndex(), 2);
+
+ QKeyEvent keyBacktab(QKeyEvent::KeyPress, Qt::Key_Backtab, Qt::ControlModifier);
+ QVERIFY(QApplication::sendEvent(tw, &keyBacktab));
+ QCOMPARE(tw->currentIndex(), 0);
+ QVERIFY(QApplication::sendEvent(tw, &keyBacktab));
+ QCOMPARE(tw->currentIndex(), 2);
+ QVERIFY(QApplication::sendEvent(tw, &keyBacktab));
+ QCOMPARE(tw->currentIndex(), 0);
+}
+
void tst_QTabWidget::tabText()
{
// Test bad arguments
@@ -750,5 +780,39 @@ void tst_QTabWidget::autoHide()
QVERIFY(heightForWidth1 > tabWidget.heightForWidth(20));
}
+void tst_QTabWidget::setCurrentBeforeShow_data()
+{
+ QTest::addColumn<QTabWidget::TabPosition>("tabPosition");
+ QTest::newRow("West") << QTabWidget::West;
+ QTest::newRow("North") << QTabWidget::North;
+ QTest::newRow("East") << QTabWidget::East;
+ QTest::newRow("South") << QTabWidget::South;
+}
+
+void tst_QTabWidget::setCurrentBeforeShow()
+{
+ QFETCH(QTabWidget::TabPosition, tabPosition);
+
+ QTabWidget tabWidget;
+ tabWidget.setTabPosition(tabPosition);
+
+ QPixmap pm(50, 50);
+ pm.fill(Qt::red);
+ const QIcon icon(pm);
+ for (int i = 0; i < 4; ++i)
+ tabWidget.addTab(new QWidget, icon, QString("Tab %1").arg(i));
+
+ // the tab widget has space for the entire tab bar
+ tabWidget.resize(tabWidget.tabBar()->sizeHint() + QSize(50, 50));
+ tabWidget.setCurrentIndex(2);
+ tabWidget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&tabWidget));
+
+ QCOMPARE_GE(tabWidget.tabBar()->tabRect(0).x(), 0);
+ QCOMPARE_GE(tabWidget.tabBar()->tabRect(0).y(), 0);
+
+ QTest::qWait(2000);
+}
+
QTEST_MAIN(tst_QTabWidget)
#include "tst_qtabwidget.moc"