Baseline test: add coverage for treeview with alternate rows

After f4976f86cd, alternate rows are no
longer painted all the way, as the code is never called for styles that
don't include the tree item decoration in the selection, such as the
Windows styles.

Add a baseline test to record the appearance of such trees.

Task-number: QTBUG-106227
Pick-to: 6.4 6.2
Change-Id: If21076393fdf65205cab91299f8e557dbe9c4ea9
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Volker Hilsheimer 2022-10-23 11:31:28 +02:00
parent bea5649cd1
commit 94039c9a6a

View File

@ -945,19 +945,22 @@ void tst_Widgets::tst_QTreeView_data()
{
QTest::addColumn<bool>("showHeader");
QTest::addColumn<bool>("hasIcons");
QTest::addColumn<bool>("alternatingRowColors");
QTest::addColumn<QSize>("fixedSize");
QTest::addColumn<int>("treeHeight");
QTest::addColumn<int>("itemsPerNode");
// QSize() => variable size
QTest::newRow("HeaderIcons_4_3") << true << true << QSize() << 3 << 2;
QTest::newRow("NoHeaderNoIcons_4_4") << false << false << QSize(100, 350) << 3 << 2;
QTest::newRow("HeaderIcons_4_3") << true << true << false << QSize() << 3 << 2;
QTest::newRow("NoHeaderNoIcons_4_4") << false << false << false << QSize(100, 350) << 3 << 2;
QTest::newRow("AlternatingRows") << true << true << true << QSize() << 3 << 2;
}
void tst_Widgets::tst_QTreeView()
{
QFETCH(bool, showHeader);
QFETCH(bool, hasIcons);
QFETCH(bool, alternatingRowColors);
QFETCH(QSize, fixedSize);
QFETCH(int, treeHeight);
QFETCH(int, itemsPerNode);
@ -971,6 +974,8 @@ void tst_Widgets::tst_QTreeView()
showHeader ? model.setHorizontalHeaderItem(0, new QStandardItem("TreeHeader"))
: treeView.setHeaderHidden(true);
treeView.setAlternatingRowColors(alternatingRowColors);
// Populate tree model
for (int i = 0; i < itemsPerNode; ++i) {
QStandardItem* root = tst_QTreeView_populateItem(treeHeight, i, hasIcons);