summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-05-24 15:47:19 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2016-05-24 17:54:13 +0000
commit65ae3de2e12ab0d9b28699b419e3d3aa8af3a267 (patch)
treeb1122dd992ab6830871770cf60fc9e7d25cab172 /tests/auto/widgets
parent48d14c661df502c78757d6e90ba565c6d970816b (diff)
Fix tst_QListView::setCurrentIndexAfterAppendRowCrash().
The test was half-ported from Qt 4 and #ifdefed out depending on WINVER. When it became active, it failed since it queries the window handle too early in the process. Move the code sending the message into showEvent() to ensure a window handle exists and parent the listview properly to prevent a leaking toplevel. Change-Id: I74aa9ddfd0e88dd31e9258400fc3e473b6e0d92e Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 651172e79f..98cc9b29ed 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -44,6 +44,7 @@
#include <QtWidgets/QDialog>
#include <QtWidgets/QStyledItemDelegate>
#include <QtWidgets/QStyleFactory>
+#include <QtWidgets/QVBoxLayout>
#if defined(Q_OS_WIN) || defined(Q_OS_WINCE)
# include <windows.h>
@@ -111,7 +112,7 @@ private slots:
void scrollBarAsNeeded();
void moveItems();
void wordWrap();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && WINVER >= 0x0500
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void setCurrentIndexAfterAppendRowCrash();
#endif
void emptyItemSize();
@@ -1456,8 +1457,10 @@ class SetCurrentIndexAfterAppendRowCrashDialog : public QDialog
public:
SetCurrentIndexAfterAppendRowCrashDialog()
{
-#if WINVER >= 0x0500
- listView = new QListView();
+ setWindowTitle(QTest::currentTestFunction());
+ listView = new QListView(this);
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(listView);
listView->setViewMode(QListView::IconMode);
model = new QStandardItemModel(this);
@@ -1466,12 +1469,16 @@ public:
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(buttonClicked()));
timer->start(1000);
+ }
+protected:
+ void showEvent(QShowEvent *event) override
+ {
+ QDialog::showEvent(event);
DWORD lParam = 0xFFFFFFFC/*OBJID_CLIENT*/;
DWORD wParam = 0;
if (const HWND hwnd =getHWNDForWidget(this))
SendMessage(hwnd, WM_GETOBJECT, wParam, lParam);
-#endif
}
private slots:
@@ -1488,16 +1495,13 @@ private:
QStandardItemModel *model;
QTimer *timer;
};
-#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) && WINVER >= 0x0500
-// This test only makes sense on windows 2000 and higher.
void tst_QListView::setCurrentIndexAfterAppendRowCrash()
{
SetCurrentIndexAfterAppendRowCrashDialog w;
w.exec();
}
-#endif
+#endif // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT
void tst_QListView::emptyItemSize()
{