From a5e32f93759db5aff30994546cd1cc172e6a57dc Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 27 Nov 2018 14:34:26 +0100 Subject: Re-enable the QScroller tests on macOS Maybe they aren't flaky anymore... let's find out. Task-number: QTBUG-29950 Task-number: QTBUG-30133 Change-Id: I1a2a3ef7facac5b6e59588d7c6b1b28b40a788ea Reviewed-by: Friedemann Kleint --- tests/auto/widgets/util/qscroller/tst_qscroller.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'tests/auto/widgets/util') diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp index 43063881b2..fac13c7074 100644 --- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp +++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp @@ -347,9 +347,6 @@ void tst_QScroller::scrollerProperties() void tst_QScroller::scrollTo() { -#ifdef Q_OS_MAC - QSKIP("Flakey test - QTBUG-29950"); -#endif { tst_QScrollerWidget *sw = new tst_QScrollerWidget(); sw->scrollArea = QRectF( 0, 0, 1000, 1000 ); @@ -376,9 +373,6 @@ void tst_QScroller::scrollTo() void tst_QScroller::scroll() { -#ifdef Q_OS_MAC - QSKIP("Flakey test - QTBUG-30133"); -#endif #ifndef QT_NO_GESTURES // -- good case. normal scroll tst_QScrollerWidget *sw = new tst_QScrollerWidget(); @@ -419,9 +413,6 @@ void tst_QScroller::scroll() void tst_QScroller::overshoot() { -#ifdef Q_OS_MAC - QSKIP("Flakey test - QTBUG-29950"); -#endif #ifndef QT_NO_GESTURES tst_QScrollerWidget *sw = new tst_QScrollerWidget(); sw->scrollArea = QRectF(0, 0, 1000, 1000); -- cgit v1.2.3 From c4ee12589122923e680e8dd359c30f6dde370f54 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 27 Nov 2018 10:47:52 +0100 Subject: Set QScroller's parent to its widget, for memory management If the widget to which the scroller was assigned is deleted, the QScroller ought to be deleted too, to avoid filtering events and then following a dangling pointer while trying to react. Fixes: QTBUG-71232 Change-Id: I62680df8d84fb630df1bd8c482df099989457542 Reviewed-by: Friedemann Kleint Reviewed-by: Robert Griebl --- .../auto/widgets/util/qscroller/tst_qscroller.cpp | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'tests/auto/widgets/util') diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp index fac13c7074..8bdd4b4783 100644 --- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp +++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp @@ -125,6 +125,7 @@ private slots: void scrollTo(); void scroll(); void overshoot(); + void multipleWindows(); private: QTouchDevice *m_touchScreen = QTest::createTouchDevice(); @@ -373,7 +374,7 @@ void tst_QScroller::scrollTo() void tst_QScroller::scroll() { -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) && QT_CONFIG(scroller) // -- good case. normal scroll tst_QScrollerWidget *sw = new tst_QScrollerWidget(); sw->scrollArea = QRectF(0, 0, 1000, 1000); @@ -413,7 +414,7 @@ void tst_QScroller::scroll() void tst_QScroller::overshoot() { -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) && QT_CONFIG(scroller) tst_QScrollerWidget *sw = new tst_QScrollerWidget(); sw->scrollArea = QRectF(0, 0, 1000, 1000); QScroller::grabGesture(sw, QScroller::TouchGesture); @@ -504,6 +505,39 @@ void tst_QScroller::overshoot() #endif } +void tst_QScroller::multipleWindows() +{ +#if QT_CONFIG(gestures) && QT_CONFIG(scroller) + QScopedPointer sw1(new tst_QScrollerWidget()); + sw1->scrollArea = QRectF(0, 0, 1000, 1000); + QScroller::grabGesture(sw1.data(), QScroller::TouchGesture); + sw1->setGeometry(100, 100, 400, 300); + QScroller *s1 = QScroller::scroller(sw1.data()); + kineticScroll(sw1.data(), QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); + // now we should be scrolling + QTRY_COMPARE( s1->state(), QScroller::Scrolling ); + + // That was fun! Do it again! + QScopedPointer sw2(new tst_QScrollerWidget()); + sw2->scrollArea = QRectF(0, 0, 1000, 1000); + QScroller::grabGesture(sw2.data(), QScroller::TouchGesture); + sw2->setGeometry(100, 100, 400, 300); + QScroller *s2 = QScroller::scroller(sw2.data()); + kineticScroll(sw2.data(), QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); + // now we should be scrolling + QTRY_COMPARE( s2->state(), QScroller::Scrolling ); + + // wait for both to stop + QTRY_VERIFY(s1->state() != QScroller::Scrolling); + QTRY_VERIFY(s2->state() != QScroller::Scrolling); + + sw1.reset(); // destroy one window + sw2->reset(); // reset the other scroller's internal state + // make sure we can still scroll the remaining one without crashing (QTBUG-71232) + kineticScroll(sw2.data(), QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); +#endif +} + QTEST_MAIN(tst_QScroller) #include "tst_qscroller.moc" -- cgit v1.2.3 From 1b5a17632efbaf6c1d0eacdda72fad3bc9d5fe13 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 6 Feb 2019 22:09:33 +0100 Subject: Fix deprecation warnings in widget autotests Fix all deprecation warnings within tests/auto/widgets Change-Id: I854f54c0a1dc0a0086f626b93cd39f63cb1b6033 Reviewed-by: Edward Welbourne Reviewed-by: Friedemann Kleint --- .../widgets/util/qcompleter/tst_qcompleter.cpp | 27 +++++++--------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'tests/auto/widgets/util') diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index ad64f1aef7..8bb16cc9d1 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -1595,27 +1595,16 @@ void tst_QCompleter::task247560_keyboardNavigation() } // Helpers for QTBUG_14292_filesystem: Recursion helper for below recurseTreeModel -template -bool recurseTreeModelIndex(const QModelIndex &idx, Function f, int depth = 0) -{ - if (f(idx, depth)) - return true; - const int rowCount = idx.model()->rowCount(idx); - for (int row = 0; row < rowCount; ++row) - if (recurseTreeModelIndex(idx.child(row, 0), f, depth + 1)) - return true; - return false; -} - // Function to recurse over a tree model applying a function // taking index and depth, returning true to terminate recursion. - template -bool recurseTreeModel(const QAbstractItemModel &m, Function f) +bool recurseTreeModel(const QAbstractItemModel &m, const QModelIndex &idx, Function f, int depth = 0) { - const int rowCount = m.rowCount(QModelIndex()); + if (idx.isValid() && f(idx, depth)) + return true; + const int rowCount = m.rowCount(idx); for (int row = 0; row < rowCount; ++row) - if (recurseTreeModelIndex(m.index(row, 0, QModelIndex()), f)) + if (recurseTreeModel(m, m.index(row, 0, idx), f, depth + 1)) return true; return false; } @@ -1658,7 +1647,7 @@ QDebug operator<<(QDebug d, const QAbstractItemModel &m) { QDebug dns = d.nospace(); dns << '\n'; - recurseTreeModel(m, DebugFunction(dns)); + recurseTreeModel(m, QModelIndex(), DebugFunction(dns)); return d; } @@ -1671,8 +1660,8 @@ static const char testDir2[] = "holla"; static inline bool testFileSystemReady(const QAbstractItemModel &model) { - return recurseTreeModel(model, SearchFunction(QLatin1String(testDir1), QFileSystemModel::FileNameRole)) - && recurseTreeModel(model, SearchFunction(QLatin1String(testDir2), QFileSystemModel::FileNameRole)); + return recurseTreeModel(model, QModelIndex(), SearchFunction(QLatin1String(testDir1), QFileSystemModel::FileNameRole)) + && recurseTreeModel(model, QModelIndex(), SearchFunction(QLatin1String(testDir2), QFileSystemModel::FileNameRole)); } void tst_QCompleter::QTBUG_14292_filesystem() -- cgit v1.2.3