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// Ubuntu.Gestures plugin
21#include <DirectionalDragArea.h>
22#include <FloatingFlickable.h>
24#include "GestureTest.h"
27using namespace UbuntuGestures;
29class tst_FloatingFlickable: public GestureTest
33 tst_FloatingFlickable();
35 void tapGoesThrough();
36 void flickChangesContentX();
37 void flickChangesContentY();
40tst_FloatingFlickable::tst_FloatingFlickable()
41 : GestureTest(QStringLiteral("tst_FloatingFlickable.qml"))
45void tst_FloatingFlickable::tapGoesThrough()
47 FloatingFlickable *floatingFlickable =
48 m_view->rootObject()->findChild<FloatingFlickable*>("floatingFlickable");
49 QVERIFY(floatingFlickable != nullptr);
51 TestItem *testItem = new TestItem;
52 testItem->setWidth(floatingFlickable->width());
53 testItem->setHeight(floatingFlickable->height());
54 testItem->setParentItem(m_view->rootObject());
57 floatingFlickable->setZ(2.0);
59 QTest::touchEvent(m_view, m_device)
60 .press(0, QPoint(floatingFlickable->width()/2, floatingFlickable->height()/2));
62 QCOMPARE(testItem->touchEventsReceived.count(), 1);
65void tst_FloatingFlickable::flickChangesContentX()
67 FloatingFlickable *floatingFlickable =
68 m_view->rootObject()->findChild<FloatingFlickable*>("floatingFlickable");
69 QVERIFY(floatingFlickable != nullptr);
71 floatingFlickable->m_dragArea->removeTimeConstraints();
73 qreal startContentX = floatingFlickable->contentX();
75 QPoint startPos(floatingFlickable->width() - 5, 10);
77 int step = (startPos.x() - 5) / stepCount;
79 QTest::touchEvent(m_view, m_device).press(0, startPos);
80 for (int i = 0; i < stepCount; ++i) {
82 QPoint touchPos = startPos - QPoint(step*i, 0);
83 QTest::touchEvent(m_view, m_device).move(0, touchPos);
87 QTest::touchEvent(m_view, m_device).release(0, QPoint(5, 10));
89 QVERIFY(floatingFlickable->contentX() > (startContentX + floatingFlickable->width()/2));
92void tst_FloatingFlickable::flickChangesContentY()
94 FloatingFlickable *floatingFlickable =
95 m_view->rootObject()->findChild<FloatingFlickable*>("floatingFlickable");
96 QVERIFY(floatingFlickable != nullptr);
98 floatingFlickable->setDirection(Direction::Vertical);
99 floatingFlickable->m_dragArea->removeTimeConstraints();
101 qreal startContentY = floatingFlickable->contentY();
103 QPoint startPos(10, floatingFlickable->height() - 5);
105 int step = (startPos.y() - 5) / stepCount;
107 QTest::touchEvent(m_view, m_device).press(0, startPos);
108 for (int i = 0; i < stepCount; ++i) {
110 QPoint touchPos = startPos - QPoint(0, step*i);
111 QTest::touchEvent(m_view, m_device).move(0, touchPos);
115 QTest::touchEvent(m_view, m_device).release(0, QPoint(10, 5));
117 QVERIFY(floatingFlickable->contentY() > (startContentY + floatingFlickable->height()/2));
120QTEST_MAIN(tst_FloatingFlickable)
122#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