From 43b5b2bda66dea6c47eb55525341d703b4e22652 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 31 Aug 2018 10:13:23 +0200 Subject: tst_qquicktableview: reuse the same QQuickView for all test cases Instead of creating a new view for every test (which will open a new window), it's better to reuse the same view. Especially since there is a bug in AppKit (which has been reported by Tor-Arne, but I could not find the rdar id) that can sometimes be hit when closing a window, causing it to crash. So creating and closing almost 100 windows in this test will sometimes trigger that bug. Change-Id: If4d962e4b9aeea154d4cd764a5bc414bcd2995b7 Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp') diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index e25a7b72bb..29eb61b7ad 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -56,10 +56,9 @@ static const char *kModelDataBindingProp = "modelDataBinding"; Q_DECLARE_METATYPE(QMarginsF); #define LOAD_TABLEVIEW(fileName) \ - QScopedPointer view(createView()); \ view->setSource(testFileUrl(fileName)); \ view->show(); \ - QVERIFY(QTest::qWaitForWindowActive(view.data())); \ + QVERIFY(QTest::qWaitForWindowActive(view)); \ auto tableView = view->rootObject()->property(kTableViewPropName).value(); \ QVERIFY(tableView); \ auto tableViewPrivate = QQuickTableViewPrivate::get(tableView); \ @@ -78,8 +77,12 @@ public: QQuickTableViewAttached *getAttachedObject(const QObject *object) const; QPoint getContextRowAndColumn(const QQuickItem *item) const; +private: + QQuickView *view = nullptr; + private slots: void initTestCase() override; + void cleanupTestCase(); void setAndGetModel_data(); void setAndGetModel(); @@ -141,6 +144,12 @@ void tst_QQuickTableView::initTestCase() { QQmlDataTest::initTestCase(); qmlRegisterType("TestModel", 0, 1, "TestModel"); + view = createView(); +} + +void tst_QQuickTableView::cleanupTestCase() +{ + delete view; } QQuickTableViewAttached *tst_QQuickTableView::getAttachedObject(const QObject *object) const -- cgit v1.2.3