diff options
author | Axel Spoerl <Axel.Spoerl@qt.io> | 2022-01-14 13:07:36 +0100 |
---|---|---|
committer | Axel Spoerl <Axel.Spoerl@qt.io> | 2022-01-27 02:45:14 +0100 |
commit | 878aea36457a1c270586774e68e56acaef14950a (patch) | |
tree | 185e97a292b08a22faba63afe02c6122a4027fa9 /tests | |
parent | 8224fd45d03670226e1e14cb2724a53de59b386f (diff) |
Add QTabBar test in tst_baseline_widgets
Task-number: QTBUG-99772
Pick-to: 6.3
Change-Id: I501c8e5c8e3ee1a1d3ac2a36b12f51dab90c88c3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/baseline/widgets/tst_baseline_widgets.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/baseline/widgets/tst_baseline_widgets.cpp b/tests/baseline/widgets/tst_baseline_widgets.cpp index 4522e42563..d49e9b494f 100644 --- a/tests/baseline/widgets/tst_baseline_widgets.cpp +++ b/tests/baseline/widgets/tst_baseline_widgets.cpp @@ -62,6 +62,9 @@ private slots: void tst_QScrollBar_data(); void tst_QScrollBar(); + + void tst_QTabBar_data(); + void tst_QTabBar(); }; void tst_Widgets::tst_QSlider_data() @@ -451,6 +454,59 @@ void tst_Widgets::tst_QScrollBar() QTest::mouseRelease(bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0); } +void tst_Widgets::tst_QTabBar_data() +{ + QTest::addColumn<QTabBar::Shape>("shape"); + QTest::addColumn<int>("numberTabs"); + QTest::addColumn<int>("fixedWidth"); + + // fixedWidth <0 will be interpreted as variable width + QTest::newRow("RoundedNorth_3_variableWidth") << QTabBar::RoundedNorth << 3 << -1; + QTest::newRow("RoundedEast_3_variableWidth") << QTabBar::RoundedEast << 3 << -1; + QTest::newRow("RoundedWest_3_variableWidth") << QTabBar::RoundedWest << 3 << -1; + QTest::newRow("RoundedSouth_3_variableWidth") << QTabBar::RoundedSouth << 3 << -1; + QTest::newRow("RoundedNorth_20_fixedWidth") << QTabBar::RoundedNorth << 20 << 250; +} + +void tst_Widgets::tst_QTabBar() +{ + QFETCH(QTabBar::Shape, shape); + QFETCH(int, numberTabs); + QFETCH(int, fixedWidth); + + QTabBar bar (testWindow()); + bar.setShape(shape); + if (fixedWidth > 0) + bar.setFixedWidth(fixedWidth); + + for (int i = 0; i < numberTabs; ++i) { + bar.insertTab(i,"Tab_" + QString::number(i)); + } + + QBoxLayout box(QBoxLayout::LeftToRight, testWindow()); + box.addWidget(&bar); + testWindow()->setLayout(&box); + + takeStandardSnapshots(); + + // press/release first tab + bar.setCurrentIndex(0); + QPoint clickTarget = bar.tabRect(0).center(); + QTest::mousePress(&bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0); + QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressFirstTab"); + QTest::mouseRelease(&bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0); + QVERIFY(bar.currentIndex() == 0); + + // press/release second tab if it exists + if (bar.count() > 1) { + clickTarget = bar.tabRect(1).center(); + QTest::mousePress(&bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0); + QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressSecondTab"); + QTest::mouseRelease(&bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0); + QVERIFY(bar.currentIndex() == 1); + } +} + #define main _realmain QTEST_MAIN(tst_Widgets) #undef main |