Commit 7a300d4d3a89d7002643bd7e70b1525d72967681

Fixed the context menu test case in the qgraphicsscene autotest.

When creating a custom QContextMenuEvent to send to a viewport we should use
the viewport to convert the mouse cursor position to screen coordinates.

Reviewed-by: Olivier Goffart
tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
(4 / 4)
  
28062806
28072807 {
28082808 QPoint pos(50, 50);
2809 QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.mapToGlobal(pos));
2809 QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos));
28102810 event.ignore();
28112811 QApplication::sendEvent(view.viewport(), &event);
28122812 QVERIFY(event.isAccepted());
28132813 }
28142814 {
28152815 QPoint pos(150, 150);
2816 QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.mapToGlobal(pos));
2816 QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos));
28172817 event.ignore();
28182818 QApplication::sendEvent(view.viewport(), &event);
28192819 QVERIFY(!event.isAccepted());
28212821 view.scale(1.5, 1.5);
28222822 {
28232823 QPoint pos(25, 25);
2824 QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.mapToGlobal(pos));
2824 QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos));
28252825 event.ignore();
28262826 QApplication::sendEvent(view.viewport(), &event);
28272827 QVERIFY(event.isAccepted());
28282828 }
28292829 {
28302830 QPoint pos(55, 55);
2831 QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.mapToGlobal(pos));
2831 QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos));
28322832 event.ignore();
28332833 QApplication::sendEvent(view.viewport(), &event);
28342834 QVERIFY(!event.isAccepted());

Comments

Add a new comment:

Login or create an account to post a comment

Add your comment