summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp42
1 files changed, 34 insertions, 8 deletions
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 3c43b3fcd5..236cd6212f 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.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 <QListWidget>
@@ -68,8 +68,14 @@ public:
{
return QListView::visualRegionForSelection(selectionModel()->selection());
}
+ void moveEvent(QMoveEvent *e) override
+ {
+ QListView::moveEvent(e);
+ m_gotValidResizeEvent = !e->pos().isNull();
+ }
friend class tst_QListView;
+ bool m_gotValidResizeEvent = false;
};
class tst_QListView : public QObject
@@ -156,6 +162,7 @@ private slots:
void spacingWithWordWrap();
void scrollOnRemove_data();
void scrollOnRemove();
+ void wordWrapNullIcon();
};
// Testing get/set functions
@@ -612,7 +619,7 @@ void tst_QListView::moveCursor4()
void tst_QListView::moveCursor5()
{
- PublicListView listView;;
+ PublicListView listView;
QStandardItemModel model;
QIcon icon(QPixmap(300,300));
model.appendRow(new QStandardItem(icon,"11"));
@@ -1700,7 +1707,6 @@ void tst_QListView::keyboardSearch()
QListView view;
view.setModel(&model);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::keyClick(&view, Qt::Key_K);
@@ -1802,7 +1808,6 @@ void tst_QListView::shiftSelectionWithItemAlignment()
view.resize(300, view.sizeHintForRow(0) * items.size() / 2 + view.horizontalScrollBar()->height());
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
@@ -1861,7 +1866,6 @@ void tst_QListView::task262152_setModelColumnNavigate()
view.setModelColumn(1);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(&view, QApplication::activeWindow());
QTest::keyClick(&view, Qt::Key_Down);
@@ -2563,8 +2567,9 @@ void tst_QListView::taskQTBUG_58749_adjustToContent()
// use the long text and make sure the width is adjusted.
model.setData(model.index(0, 0), longText);
QApplication::processEvents();
- QVERIFY(w.width() > longTextWidth);
- QVERIFY(view->width() >= longTextWidth);
+ const QRect itemRect = view->visualRect(model.index(0, 0));
+ QVERIFY(w.width() > itemRect.width());
+ QCOMPARE_GE(view->width(), itemRect.width());
}
void tst_QListView::taskQTBUG_51086_skippingIndexesInSelectedIndexes()
@@ -2806,7 +2811,6 @@ void tst_QListView::moveLastRow()
view.setViewMode(QListView::IconMode);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QModelIndex sourceParent = model.index(0, 0);
@@ -2993,6 +2997,7 @@ void tst_QListView::internalDragDropMove()
// The test relies on the global position of mouse events; make sure
// the window is properly mapped on X11.
QVERIFY(QTest::qWaitForWindowActive(&list));
+ QVERIFY(QTest::qWaitFor([&]() { return list.m_gotValidResizeEvent; }));
// execute as soon as the eventloop is running again
// which is the case inside list.startDrag()
QTimer::singleShot(0, [&]()
@@ -3057,6 +3062,11 @@ void tst_QListView::spacingWithWordWrap()
}
};
+ QStyle *oldStyle = QApplication::style();
+ oldStyle->setParent(nullptr);
+ const auto resetStyle = qScopeGuard([oldStyle]{
+ QApplication::setStyle(oldStyle);
+ });
QApplication::setStyle(new MyStyle(scrollBarOverlap));
const int listViewResizeCount = 200;
@@ -3174,6 +3184,22 @@ void tst_QListView::scrollOnRemove()
QTRY_COMPARE(view.verticalScrollBar()->value(), item25Position);
}
+void tst_QListView::wordWrapNullIcon()
+{
+ QListView listView;
+ listView.setViewMode(QListView::IconMode);
+ listView.setWrapping(true);
+ listView.setWordWrap(true);
+ listView.setFixedSize(QSize(100, 500));
+
+ QStandardItemModel model;
+ QStandardItem *item = new QStandardItem(QIcon(), "This is a long text for word wrapping Item_");
+ model.appendRow(item);
+ listView.setModel(&model);
+
+ listView.indexAt(QPoint(0, 0));
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"