diff options
Diffstat (limited to 'tests/baseline/stylesheet/tst_baseline_stylesheet.cpp')
-rw-r--r-- | tests/baseline/stylesheet/tst_baseline_stylesheet.cpp | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp b/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp index 19bfed5e33..67a618988b 100644 --- a/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp +++ b/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2021 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 <qbaselinetest.h> #include <qwidgetbaselinetest.h> @@ -27,6 +27,9 @@ private slots: void tst_QTreeView_data(); void tst_QTreeView(); + void tst_QHeaderView_data(); + void tst_QHeaderView(); + private: QDir styleSheetDir; }; @@ -63,7 +66,7 @@ void tst_Stylesheet::loadTestFiles() for (const auto &qssFile : qssFiles) { QFileInfo fileInfo(qssFile); QFile file(qssFile); - file.open(QFile::ReadOnly); + QVERIFY(file.open(QFile::ReadOnly)); QString styleSheet = QString::fromUtf8(file.readAll()); QBaselineTest::newRow(fileInfo.baseName().toUtf8()) << styleSheet; } @@ -160,19 +163,29 @@ void tst_Stylesheet::tst_QTreeView() tw->header()->hide(); layout->addWidget(tw); - for (int i = 0; i < 6; ++i) { + enum { + Unchecked = 0, + Checked = 1, + Children = 2, + Disabled = 3, + CheckedDisabled = 4, + ChildrenDisabled = 5, + NConfigs + }; + + for (int i = 0; i < NConfigs; ++i) { QTreeWidgetItem *topLevelItem = new QTreeWidgetItem(tw, QStringList{QString("top %1").arg(i)}); switch (i) { - case 0: - case 3: + case Unchecked: + case Disabled: topLevelItem->setCheckState(0, Qt::Unchecked); break; - case 1: - case 4: + case Checked: + case CheckedDisabled: topLevelItem->setCheckState(0, Qt::Checked); break; - case 2: - case 5: + case Children: + case ChildrenDisabled: topLevelItem->setCheckState(0, Qt::PartiallyChecked); topLevelItem->setExpanded(true); for (int j = 0; j < 2; ++j) { @@ -181,7 +194,7 @@ void tst_Stylesheet::tst_QTreeView() } break; } - topLevelItem->setDisabled(i > 2); + topLevelItem->setDisabled(i >= Disabled); } testWindow()->setLayout(layout); tw->setRootIsDecorated(true); @@ -190,6 +203,25 @@ void tst_Stylesheet::tst_QTreeView() QBASELINE_CHECK_DEFERRED(takeSnapshot(), "rootDecorated"); tw->setRootIsDecorated(false); QBASELINE_CHECK_DEFERRED(takeSnapshot(), "rootNotDecorated"); + + tw->topLevelItem(Children)->child(0)->setSelected(true); + QBASELINE_CHECK_DEFERRED(takeSnapshot(), "itemSelected"); +} + +void tst_Stylesheet::tst_QHeaderView_data() +{ + loadTestFiles(); +} + +void tst_Stylesheet::tst_QHeaderView() +{ + QHBoxLayout *layout = new QHBoxLayout; + QTableWidget *tw = new QTableWidget(10, 10); + tw->setCurrentCell(1, 1); + layout->addWidget(tw); + testWindow()->setLayout(layout); + makeVisible(); + QBASELINE_TEST(takeSnapshot()); } #define main _realmain @@ -198,7 +230,8 @@ QTEST_MAIN(tst_Stylesheet) int main(int argc, char *argv[]) { - qSetGlobalQHashSeed(0); // Avoid rendering variations caused by QHash randomization + // Avoid rendering variations caused by QHash randomization + QHashSeed::setDeterministicGlobalSeed(); QBaselineTest::handleCmdLineArgs(&argc, &argv); return _realmain(argc, argv); |