From 572d7011f123324e70dde4c75260f32cd696f709 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 12 Feb 2016 13:40:20 +0100 Subject: Test and fix AbstractButton::pressAndHold() Using the same auto test that already exists for TextField and TextArea nicely exposed some difference in the behavior: - the signal wasn't canceled on second press - the signal was canceled right away on any tiny move. now it allows the same little threshold than TextField and TextArea Change-Id: I6b9bd19c614b36dd0ec7b232f821af3aa929d02a Reviewed-by: Mitch Curtis --- tests/auto/pressandhold/tst_pressandhold.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/auto/pressandhold') diff --git a/tests/auto/pressandhold/tst_pressandhold.cpp b/tests/auto/pressandhold/tst_pressandhold.cpp index 33d93cc0..8c4cf673 100644 --- a/tests/auto/pressandhold/tst_pressandhold.cpp +++ b/tests/auto/pressandhold/tst_pressandhold.cpp @@ -54,14 +54,17 @@ private slots: void tst_PressAndHold::pressAndHold_data() { QTest::addColumn("data"); + QTest::addColumn("signal"); - QTest::newRow("TextField") << QByteArray("import Qt.labs.controls 1.0; TextField { text: 'TextField' }"); - QTest::newRow("TextArea") << QByteArray("import Qt.labs.controls 1.0; TextArea { text: 'TextArea' }"); + QTest::newRow("Button") << QByteArray("import Qt.labs.controls 1.0; Button { text: 'Button' }") << QByteArray(SIGNAL(pressAndHold())); + QTest::newRow("TextField") << QByteArray("import Qt.labs.controls 1.0; TextField { text: 'TextField' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*))); + QTest::newRow("TextArea") << QByteArray("import Qt.labs.controls 1.0; TextArea { text: 'TextArea' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*))); } void tst_PressAndHold::pressAndHold() { QFETCH(QByteArray, data); + QFETCH(QByteArray, signal); QQmlEngine engine; QQmlComponent component(&engine); @@ -71,8 +74,8 @@ void tst_PressAndHold::pressAndHold() QScopedPointer waitControl(component.create()); QVERIFY(!control.isNull() && !waitControl.isNull()); - QSignalSpy spy(control.data(), SIGNAL(pressAndHold(QQuickMouseEvent*))); - QSignalSpy waitSpy(waitControl.data(), SIGNAL(pressAndHold(QQuickMouseEvent*))); + QSignalSpy spy(control.data(), signal); + QSignalSpy waitSpy(waitControl.data(), signal); QVERIFY(spy.isValid() && waitSpy.isValid()); int startDragDistance = QGuiApplication::styleHints()->startDragDistance(); -- cgit v1.2.3