Fix deprecation warnings in tests

Adjust to changes to QIcon::pixmap, QMetaType::type, and
QAbstractItemView::itemDelegate.

Change-Id: I9eb0331ef899131afc86c33f27feeee76331ffc8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Volker Hilsheimer 2020-09-16 17:49:05 +02:00
parent b850322147
commit fe3bebbd68
3 changed files with 16 additions and 16 deletions

View File

@ -458,7 +458,7 @@ void tst_QIcon::pixmap()
QVERIFY(icon.pixmap(16, 16).size().width() >= 16);
QVERIFY(icon.pixmap(QSize(16, 16)).size().width() >= 16);
QVERIFY(icon.pixmap(QSize(16, 16), 1).size().width() == 16);
QVERIFY(icon.pixmap(nullptr, QSize(16, 16)).size().width() >= 16);
QVERIFY(icon.pixmap(QSize(16, 16), -1).size().width() >= 16);
}
static bool sizeLess(const QSize &a, const QSize &b)

View File

@ -3425,12 +3425,12 @@ void tst_Moc::autoSignalSpyMetaTypeRegistration()
QVERIFY(i > 0);
QCOMPARE(QMetaType::type("CustomObject12"), (int)QMetaType::UnknownType);
QCOMPARE(QMetaType::fromName("CustomObject12").id(), (int)QMetaType::UnknownType);
QSignalSpy spy(&aro, SIGNAL(someSignal(CustomObject12)));
QVERIFY(QMetaType::type("CustomObject12") != QMetaType::UnknownType);
QCOMPARE(QMetaType::type("CustomObject12"), qMetaTypeId<CustomObject12>());
QVERIFY(QMetaType::fromName("CustomObject12").id() != QMetaType::UnknownType);
QCOMPARE(QMetaType::fromName("CustomObject12").id(), qMetaTypeId<CustomObject12>());
}
void tst_Moc::parseDefines()

View File

@ -1069,7 +1069,7 @@ void tst_QTreeView::itemDelegateForColumnOrRow()
QVERIFY(!view.itemDelegateForRow(0));
QVERIFY(!view.itemDelegateForColumn(0));
QCOMPARE(view.itemDelegate(QModelIndex()), defaultDelegate);
QCOMPARE(view.itemDelegateForIndex(QModelIndex()), defaultDelegate);
QStandardItemModel model;
for (int i = 0; i < 100; ++i) {
@ -1085,26 +1085,26 @@ void tst_QTreeView::itemDelegateForColumnOrRow()
QVERIFY(!view.itemDelegateForRow(0));
QVERIFY(!view.itemDelegateForColumn(0));
QCOMPARE(view.itemDelegate(QModelIndex()), defaultDelegate);
QCOMPARE(view.itemDelegate(view.model()->index(0, 0)), defaultDelegate);
QCOMPARE(view.itemDelegateForIndex(QModelIndex()), defaultDelegate);
QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 0)), defaultDelegate);
QPointer<QAbstractItemDelegate> rowDelegate = new QStyledItemDelegate;
view.setItemDelegateForRow(0, rowDelegate);
QVERIFY(!rowDelegate->parent());
QCOMPARE(view.itemDelegateForRow(0), rowDelegate);
QCOMPARE(view.itemDelegate(view.model()->index(0, 0)), rowDelegate);
QCOMPARE(view.itemDelegate(view.model()->index(0, 1)), rowDelegate);
QCOMPARE(view.itemDelegate(view.model()->index(1, 0)), defaultDelegate);
QCOMPARE(view.itemDelegate(view.model()->index(1, 1)), defaultDelegate);
QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 0)), rowDelegate);
QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 1)), rowDelegate);
QCOMPARE(view.itemDelegateForIndex(view.model()->index(1, 0)), defaultDelegate);
QCOMPARE(view.itemDelegateForIndex(view.model()->index(1, 1)), defaultDelegate);
QPointer<QAbstractItemDelegate> columnDelegate = new QStyledItemDelegate;
view.setItemDelegateForColumn(1, columnDelegate);
QVERIFY(!columnDelegate->parent());
QCOMPARE(view.itemDelegateForColumn(1), columnDelegate);
QCOMPARE(view.itemDelegate(view.model()->index(0, 0)), rowDelegate);
QCOMPARE(view.itemDelegate(view.model()->index(0, 1)), rowDelegate); // row wins
QCOMPARE(view.itemDelegate(view.model()->index(1, 0)), defaultDelegate);
QCOMPARE(view.itemDelegate(view.model()->index(1, 1)), columnDelegate);
QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 0)), rowDelegate);
QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 1)), rowDelegate); // row wins
QCOMPARE(view.itemDelegateForIndex(view.model()->index(1, 0)), defaultDelegate);
QCOMPARE(view.itemDelegateForIndex(view.model()->index(1, 1)), columnDelegate);
view.setItemDelegateForRow(0, nullptr);
QVERIFY(!view.itemDelegateForRow(0));
@ -2496,7 +2496,7 @@ void tst_QTreeView::spanningItems()
for (int i = 0; i < model.rowCount(QModelIndex()); ++i) {
if (!view.isFirstColumnSpanned(i, QModelIndex())) {
QModelIndex index = model.index(i, 0, QModelIndex());
w = qMax(w, view.itemDelegate(index)->sizeHint(option, index).width() + view.indentation());
w = qMax(w, view.itemDelegateForIndex(index)->sizeHint(option, index).width() + view.indentation());
}
}
QCOMPARE(view.sizeHintForColumn(0), w);