1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the $MODULE$ of the Qt Toolkit. |
7 ** This file is part of the $MODULE$ of the Qt Toolkit. |
8 ** |
8 ** |
191 void basicRawEventTranslation(); |
191 void basicRawEventTranslation(); |
192 void multiPointRawEventTranslationOnTouchScreen(); |
192 void multiPointRawEventTranslationOnTouchScreen(); |
193 void multiPointRawEventTranslationOnTouchPad(); |
193 void multiPointRawEventTranslationOnTouchPad(); |
194 void deleteInEventHandler(); |
194 void deleteInEventHandler(); |
195 void deleteInRawEventTranslation(); |
195 void deleteInRawEventTranslation(); |
|
196 void crashInQGraphicsSceneAfterNotHandlingTouchBegin(); |
196 }; |
197 }; |
197 |
198 |
198 void tst_QTouchEvent::touchDisabledByDefault() |
199 void tst_QTouchEvent::touchDisabledByDefault() |
199 { |
200 { |
200 // QWidget |
201 // QWidget |
1301 rawTouchPoints[1].setState(Qt::TouchPointReleased); |
1302 rawTouchPoints[1].setState(Qt::TouchPointReleased); |
1302 rawTouchPoints[2].setState(Qt::TouchPointReleased); |
1303 rawTouchPoints[2].setState(Qt::TouchPointReleased); |
1303 qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
1304 qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
1304 } |
1305 } |
1305 |
1306 |
|
1307 void tst_QTouchEvent::crashInQGraphicsSceneAfterNotHandlingTouchBegin() |
|
1308 { |
|
1309 QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 100, 100); |
|
1310 rect->setAcceptTouchEvents(true); |
|
1311 |
|
1312 QGraphicsRectItem *mainRect = new QGraphicsRectItem(0, 0, 100, 100, rect); |
|
1313 mainRect->setBrush(Qt::lightGray); |
|
1314 |
|
1315 QGraphicsRectItem *button = new QGraphicsRectItem(-20, -20, 40, 40, mainRect); |
|
1316 button->setPos(50, 50); |
|
1317 button->setBrush(Qt::darkGreen); |
|
1318 |
|
1319 QGraphicsView view; |
|
1320 QGraphicsScene scene; |
|
1321 scene.addItem(rect); |
|
1322 scene.setSceneRect(0,0,100,100); |
|
1323 view.setScene(&scene); |
|
1324 |
|
1325 view.show(); |
|
1326 QTest::qWaitForWindowShown(&view); |
|
1327 |
|
1328 QPoint centerPos = view.mapFromScene(rect->boundingRect().center()); |
|
1329 // Touch the button |
|
1330 QTest::touchEvent(view.viewport()).press(0, centerPos); |
|
1331 QTest::touchEvent(view.viewport()).release(0, centerPos); |
|
1332 // Touch outside of the button |
|
1333 QTest::touchEvent(view.viewport()).press(0, view.mapFromScene(QPoint(10, 10))); |
|
1334 QTest::touchEvent(view.viewport()).release(0, view.mapFromScene(QPoint(10, 10))); |
|
1335 } |
|
1336 |
1306 QTEST_MAIN(tst_QTouchEvent) |
1337 QTEST_MAIN(tst_QTouchEvent) |
1307 |
1338 |
1308 #include "tst_qtouchevent.moc" |
1339 #include "tst_qtouchevent.moc" |