Use new angleDela() API and update the documentation.
Change-Id: Ie01c979d8c411e81165caedc7e020e39f9d64371
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
qtest_fail("window not shown", 2)
}
- function mouseWheel(item, x, y, delta, buttons, modifiers, delay, orientation) {
+ function mouseWheel(item, x, y, xDelta, yDelta, buttons, modifiers, delay) {
if (delay == undefined)
delay = -1
if (buttons == undefined)
buttons = Qt.NoButton
if (modifiers === undefined)
modifiers = Qt.NoModifier
- if (delta == undefined)
- delta = 0
- if (orientation == undefined)
- orientation = Qt.Vertical
- if (!qtest_events.mouseWheel(item, x, y, buttons, modifiers, delta, delay, orientation))
+ if (xDelta == undefined)
+ xDelta = 0
+ if (yDelta == undefined)
+ yDelta = 0
+ if (!qtest_events.mouseWheel(item, x, y, buttons, modifiers, xDelta, yDelta, delay))
qtest_fail("window not shown", 2)
}
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mouseRelease(), mouseClick(), mouseDoubleClick(), mouseMove()
+ \sa mouseRelease(), mouseClick(), mouseDoubleClick(), mouseMove(), mouseDrag(), mouseWheel()
*/
/*!
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseMove()
+ \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseMove(), mouseDrag(), mouseWheel()
*/
/*!
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mousePress(), mouseRelease(), mouseDoubleClick(), mouseMove()
+ \sa mousePress(), mouseRelease(), mouseDoubleClick(), mouseMove(), mouseDrag(), mouseWheel()
*/
/*!
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mousePress(), mouseRelease(), mouseClick(), mouseMove()
+ \sa mousePress(), mouseRelease(), mouseClick(), mouseMove(), mouseDrag(), mouseWheel()
*/
/*!
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mousePress(), mouseRelease(), mouseClick(), mouseDoubleClick()
+ \sa mousePress(), mouseRelease(), mouseClick(), mouseDoubleClick(), mouseDrag(), mouseWheel()
+*/
+
+/*!
+ \qmlmethod TestCase::mouseDrag(item, x, y, dx, dy, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
+
+ Simulates dragging the mouse on an \a item with \a button pressed and an optional \a modifier.
+ The initial drag position is defined by \a x and \a y,
+ and drag distance is defined by \a dx and \a dy. If \a delay is specified,
+ the test will wait for the specified amount of milliseconds before releasing the button.
+
+ The position given by \a x and \a y is transformed from the co-ordinate
+ system of \a item into window co-ordinates and then delivered.
+ If \a item is obscured by another item, or a child of \a item occupies
+ that position, then the event will be delivered to the other item instead.
+
+ Note: this method does not imply a drop action, to make a drop, an additional
+ mouseRelease(item, x + dx, y + dy) is needed.
+
+ \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseMove(), mouseRelease(), mouseWheel()
+*/
+
+/*!
+ \qmlmethod TestCase::mouseWheel(item, x, y, xDelta, yDelta, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
+
+ Simulates rotating the mouse wheel on an \a item with \a button pressed and an optional \a modifier.
+ The position of the wheel event is defined by \a x and \a y.
+ If \a delay is specified, the test will wait for the specified amount of milliseconds before releasing the button.
+
+ The position given by \a x and \a y is transformed from the co-ordinate
+ system of \a item into window co-ordinates and then delivered.
+ If \a item is obscured by another item, or a child of \a item occupies
+ that position, then the event will be delivered to the other item instead.
+
+ The \a xDelta and \a yDelta contain the wheel rotation distance in eighths of a degree. see \l QWheelEvent::angleDelta() for more details.
+
+ \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseMove(), mouseRelease(), mouseDrag(), QWheelEvent::angleDelta()
*/
/*!
static void mouseWheel(QWindow* window, QObject* item, Qt::MouseButtons buttons,
Qt::KeyboardModifiers stateKey,
- QPointF _pos, int delta, int delay = -1, Qt::Orientation orientation = Qt::Vertical)
+ QPointF _pos, int xDelta, int yDelta, int delay = -1)
{
QTEST_ASSERT(window);
QTEST_ASSERT(item);
QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
- QWheelEvent we(pos, window->mapToGlobal(pos), delta, buttons, stateKey, orientation);
+ QWheelEvent we(pos, window->mapToGlobal(pos), QPoint(0, 0), QPoint(xDelta, yDelta), 0, Qt::Vertical, buttons, stateKey);
QSpontaneKeyEvent::setSpontaneous(&we); // hmmmm
if (!qApp->notify(window, &we))
bool QuickTestEvent::mouseWheel(
QObject *item, qreal x, qreal y, int buttons,
- int modifiers, int delta, int delay, int orientation)
+ int modifiers, int xDelta, int yDelta, int delay)
{
QWindow *view = eventWindow();
if (!view)
return false;
QtQuickTest::mouseWheel(view, item, Qt::MouseButtons(buttons),
Qt::KeyboardModifiers(modifiers),
- QPointF(x, y), delta, delay, Qt::Orientation(orientation));
+ QPointF(x, y), xDelta, yDelta, delay);
return true;
}
bool mouseMove(QObject *item, qreal x, qreal y, int delay, int buttons);
bool mouseWheel(QObject *item, qreal x, qreal y, int buttons,
- int modifiers, int delta, int delay, int orientation);
+ int modifiers, int xDelta, int yDelta, int delay);
private:
QWindow *eventWindow();
when: windowShown // Must have this line for events to work.
function test_wheel() {
- //mouseWheel(item, x, y, delta, buttons = Qt.NoButton, modifiers = Qt.NoModifier, delay = -1, orientation = Qt.Vertical)
- mouseWheel(flick, 200, 200, -120, Qt.NoButton, Qt.NoModifier, -1, Qt.Vertical);
+ //mouseWheel(item, x, y, xDelta, yDelta, buttons = Qt.NoButton, modifiers = Qt.NoModifier, delay = -1)
+ mouseWheel(flick, 200, 200, 0, -120, Qt.NoButton, Qt.NoModifier, -1);
wait(1000);
verify(flick.contentY > 0);
verify(flick.contentX == 0);
flick.contentY = 0;
verify(flick.contentY == 0);
- mouseWheel(flick, 200, 200, -120, Qt.NoButton, Qt.NoModifier, -1, Qt.Horizontal);
+ mouseWheel(flick, 200, 200, -120, 0, Qt.NoButton, Qt.NoModifier, -1);
wait(1000);
verify(flick.contentX > 0);
verify(flick.contentY == 0);