summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/util
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
committerTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
commit6630937e63ae5797487b86743a7733c8ae5cc42c (patch)
tree3d53dacf6430f9099e1fb20835881205de674961 /tests/auto/widgets/util
parent37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff)
parentc7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff)
Merge commit 'dev' into 'wip/cmake-merge'
Diffstat (limited to 'tests/auto/widgets/util')
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp27
-rw-r--r--tests/auto/widgets/util/qscroller/tst_qscroller.cpp47
2 files changed, 44 insertions, 30 deletions
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 <class Function>
-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 <class Function>
-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()
diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
index 43063881b2..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();
@@ -347,9 +348,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,10 +374,7 @@ void tst_QScroller::scrollTo()
void tst_QScroller::scroll()
{
-#ifdef Q_OS_MAC
- QSKIP("Flakey test - QTBUG-30133");
-#endif
-#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);
@@ -419,10 +414,7 @@ void tst_QScroller::scroll()
void tst_QScroller::overshoot()
{
-#ifdef Q_OS_MAC
- QSKIP("Flakey test - QTBUG-29950");
-#endif
-#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);
@@ -513,6 +505,39 @@ void tst_QScroller::overshoot()
#endif
}
+void tst_QScroller::multipleWindows()
+{
+#if QT_CONFIG(gestures) && QT_CONFIG(scroller)
+ QScopedPointer<tst_QScrollerWidget> 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<tst_QScrollerWidget> 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"