diff options
author | Shawn Rutledge <shawn.rutledge@theqtcompany.com> | 2016-05-03 18:27:12 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-06-10 13:07:17 +0000 |
commit | 982b70d37db337b2c57a3cfce0f24c3d00a598d6 (patch) | |
tree | f86dd50fa2cef003b32b77bbe8eab7cbfac2251e /tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp | |
parent | e73e2264ded27ceb9f3af5b548036d33effa0797 (diff) |
autotests: use QTest::createTouchDevice()
Task-number: QTBUG-44030
Change-Id: I514c1294a0ff6587b825982a8bb354104c214120
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp')
-rw-r--r-- | tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 74fd64bf59..e6fd67e3a8 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -213,11 +213,10 @@ private: QTouchDevice *touchPadDevice; }; -tst_QTouchEvent::tst_QTouchEvent() : touchScreenDevice(new QTouchDevice), touchPadDevice(new QTouchDevice) +tst_QTouchEvent::tst_QTouchEvent() + : touchScreenDevice(QTest::createTouchDevice()) + , touchPadDevice(QTest::createTouchDevice(QTouchDevice::TouchPad)) { - touchPadDevice->setType(QTouchDevice::TouchPad); - QWindowSystemInterface::registerTouchDevice(touchScreenDevice); - QWindowSystemInterface::registerTouchDevice(touchPadDevice); } void tst_QTouchEvent::cleanup() @@ -1490,10 +1489,6 @@ bool WindowTouchEventFilter::eventFilter(QObject *, QEvent *event) void tst_QTouchEvent::testQGuiAppDelivery() { - QTouchDevice *device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - QWindow w; w.setGeometry(100, 100, 100, 100); w.show(); @@ -1521,38 +1516,33 @@ void tst_QTouchEvent::testQGuiAppDelivery() QCOMPARE(filter.d.isEmpty(), true); // Now the real thing. - QWindowSystemInterface::handleTouchEvent(&w, device, points); // TouchBegin + QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchBegin QCoreApplication::processEvents(); QCOMPARE(filter.d.count(), 1); - QCOMPARE(filter.d.contains(device), true); - QCOMPARE(filter.d.value(device).points.count(), 1); - QCOMPARE(filter.d.value(device).lastSeenType, QEvent::TouchBegin); + QCOMPARE(filter.d.contains(touchScreenDevice), true); + QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1); + QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin); points[0].state = Qt::TouchPointMoved; - QWindowSystemInterface::handleTouchEvent(&w, device, points); // TouchUpdate + QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchUpdate QCoreApplication::processEvents(); QCOMPARE(filter.d.count(), 1); - QCOMPARE(filter.d.contains(device), true); - QCOMPARE(filter.d.value(device).points.count(), 2); - QCOMPARE(filter.d.value(device).lastSeenType, QEvent::TouchUpdate); + QCOMPARE(filter.d.contains(touchScreenDevice), true); + QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 2); + QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchUpdate); points[0].state = Qt::TouchPointReleased; - QWindowSystemInterface::handleTouchEvent(&w, device, points); // TouchEnd + QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchEnd QCoreApplication::processEvents(); QCOMPARE(filter.d.count(), 1); - QCOMPARE(filter.d.contains(device), true); - QCOMPARE(filter.d.value(device).points.count(), 3); - QCOMPARE(filter.d.value(device).lastSeenType, QEvent::TouchEnd); + QCOMPARE(filter.d.contains(touchScreenDevice), true); + QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 3); + QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchEnd); } void tst_QTouchEvent::testMultiDevice() { - QTouchDevice *deviceOne = new QTouchDevice; - deviceOne->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(deviceOne); - QTouchDevice *deviceTwo = new QTouchDevice; - deviceTwo->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(deviceTwo); + QTouchDevice *deviceTwo = QTest::createTouchDevice(); QWindow w; w.setGeometry(100, 100, 100, 100); @@ -1564,7 +1554,7 @@ void tst_QTouchEvent::testMultiDevice() QList<QWindowSystemInterface::TouchPoint> pointsOne, pointsTwo; - // deviceOne reports a single point, deviceTwo reports the beginning of a multi-point sequence. + // touchScreenDevice reports a single point, deviceTwo reports the beginning of a multi-point sequence. // Even though there is a point with id 0 for both devices, they should be delivered cleanly, independently. QWindowSystemInterface::TouchPoint tp; tp.id = 0; @@ -1580,20 +1570,20 @@ void tst_QTouchEvent::testMultiDevice() tp.area = QHighDpi::toNative(area1, QHighDpiScaling::factor(&w), screenOrigin); pointsTwo.append(tp); - QWindowSystemInterface::handleTouchEvent(&w, deviceOne, pointsOne); + QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, pointsOne); QWindowSystemInterface::handleTouchEvent(&w, deviceTwo, pointsTwo); QCoreApplication::processEvents(); - QCOMPARE(filter.d.contains(deviceOne), true); + QCOMPARE(filter.d.contains(touchScreenDevice), true); QCOMPARE(filter.d.contains(deviceTwo), true); - QCOMPARE(filter.d.value(deviceOne).lastSeenType, QEvent::TouchBegin); + QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin); QCOMPARE(filter.d.value(deviceTwo).lastSeenType, QEvent::TouchBegin); - QCOMPARE(filter.d.value(deviceOne).points.count(), 1); + QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1); QCOMPARE(filter.d.value(deviceTwo).points.count(), 2); - QCOMPARE(filter.d.value(deviceOne).points.at(0).screenRect(), QRectF(area0)); - QCOMPARE(filter.d.value(deviceOne).points.at(0).state(), pointsOne[0].state); + QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).screenRect(), QRectF(area0)); + QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).state(), pointsOne[0].state); QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenRect(), QRectF(area0)); QCOMPARE(filter.d.value(deviceTwo).points.at(0).state(), pointsTwo[0].state); |