aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-31 10:13:23 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-09-06 10:58:53 +0000
commit43b5b2bda66dea6c47eb55525341d703b4e22652 (patch)
treee153a3e97a6793fc9512a373334c14c8e0e7928a /tests
parentedb79c31ab18a051d496d517ec65aed460f3c1f5 (diff)
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 <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp13
1 files changed, 11 insertions, 2 deletions
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<QQuickView> view(createView()); \
view->setSource(testFileUrl(fileName)); \
view->show(); \
- QVERIFY(QTest::qWaitForWindowActive(view.data())); \
+ QVERIFY(QTest::qWaitForWindowActive(view)); \
auto tableView = view->rootObject()->property(kTableViewPropName).value<QQuickTableView *>(); \
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>("TestModel", 0, 1, "TestModel");
+ view = createView();
+}
+
+void tst_QQuickTableView::cleanupTestCase()
+{
+ delete view;
}
QQuickTableViewAttached *tst_QQuickTableView::getAttachedObject(const QObject *object) const