2 * Copyright (C) 2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include "GestureTest.h"
26class tst_FloatingFlickable: public GestureTest
30 tst_FloatingFlickable();
32 void tapGoesThrough();
33 void flickChangesContentX();
34 void flickChangesContentY();
37tst_FloatingFlickable::tst_FloatingFlickable()
38 : GestureTest(QStringLiteral("tst_FloatingFlickable.qml"))
42void tst_FloatingFlickable::tapGoesThrough()
44 QQuickItem *floatingFlickable =
45 m_view->rootObject()->findChild<QQuickItem*>("floatingFlickable");
46 QVERIFY(floatingFlickable != nullptr);
48 TestItem *testItem = new TestItem;
49 testItem->setWidth(floatingFlickable->width());
50 testItem->setHeight(floatingFlickable->height());
51 testItem->setParentItem(m_view->rootObject());
54 floatingFlickable->setZ(2.0);
56 QTest::touchEvent(m_view, m_device)
57 .press(0, QPoint(floatingFlickable->width()/2, floatingFlickable->height()/2));
59 QCOMPARE(testItem->touchEventsReceived.count(), 1);
62static void removeTimeConstraints(QQuickItem *floatingFlickable)
64 auto children = floatingFlickable->findChildren<QObject*>();
65 Q_FOREACH(QObject *child, children) {
66 if (child->metaObject()->className() == QByteArray("UCSwipeAreaPrivate")) {
67 QMetaObject::invokeMethod(child, "setMaxTime", Q_ARG(int, 60 * 60 * 1000));
68 QMetaObject::invokeMethod(child, "setCompositionTime", Q_ARG(int, 0));
73void tst_FloatingFlickable::flickChangesContentX()
75 QSKIP("This fails due to bug #1564571");
76 QQuickItem *floatingFlickable =
77 m_view->rootObject()->findChild<QQuickItem*>("floatingFlickable");
78 QVERIFY(floatingFlickable != nullptr);
79 removeTimeConstraints(floatingFlickable);
81 qreal startContentX = floatingFlickable->property("contentX").toReal();
83 QPoint startPos(floatingFlickable->width() - 5, 10);
85 int step = (startPos.x() - 5) / stepCount;
87 QTest::touchEvent(m_view, m_device).press(0, startPos);
88 for (int i = 0; i < stepCount; ++i) {
90 QPoint touchPos = startPos - QPoint(step*i, 0);
91 QTest::touchEvent(m_view, m_device).move(0, touchPos);
95 QTest::touchEvent(m_view, m_device).release(0, QPoint(5, 10));
97 QVERIFY(floatingFlickable->property("contentX").toReal() > (startContentX + floatingFlickable->width()/2));
100void tst_FloatingFlickable::flickChangesContentY()
102 QSKIP("This fails due to bug #1564571");
103 QQuickItem *floatingFlickable =
104 m_view->rootObject()->findChild<QQuickItem*>("floatingFlickable");
105 QVERIFY(floatingFlickable != nullptr);
107 floatingFlickable->setProperty("direction", Direction::Vertical);
108 removeTimeConstraints(floatingFlickable);
110 qreal startContentY = floatingFlickable->property("contentY").toReal();
112 QPoint startPos(10, floatingFlickable->height() - 5);
114 int step = (startPos.y() - 5) / stepCount;
116 QTest::touchEvent(m_view, m_device).press(0, startPos);
117 for (int i = 0; i < stepCount; ++i) {
119 QPoint touchPos = startPos - QPoint(0, step*i);
120 QTest::touchEvent(m_view, m_device).move(0, touchPos);
124 QTest::touchEvent(m_view, m_device).release(0, QPoint(10, 5));
126 QVERIFY(floatingFlickable->property("contentY").toReal() > (startContentY + floatingFlickable->height()/2));
129QTEST_MAIN(tst_FloatingFlickable)
131#include "tst_FloatingFlickable.moc"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list