diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-11 13:51:35 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-16 10:58:52 +0100 |
commit | 55318c95d6bf72132ded283971450b4f56674997 (patch) | |
tree | ca751a92797b75b483a420a10370f206eecf97b2 /tests/auto/quick/qquickmousearea | |
parent | 10c2a8315977e8eb5fc36cf793cfc74d8913dbb0 (diff) |
Don't copy or assign QEvent instances in tests
Copying/assigning polymorphic types is a code smell, use separate
instances instead in the tests. Those should perhaps be rewritten
to use a data driven testing approach, there's a lot of code
repetition.
In the test API implementation, first evaluate the parameters for
the event, then construct the event once with the correct values.
Change-Id: I2572772698cb0204f5ff950741b9fe3805fae15d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickmousearea')
-rw-r--r-- | tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 6a9d5cedc0..9691e1fd80 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -1018,8 +1018,8 @@ void tst_QQuickMouseArea::doubleClick() QCOMPARE(window.rootObject()->property("released").toInt(), 1); QGuiApplication::sendEvent(&window, &pressEvent); - pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), button, button, {}); - QGuiApplication::sendEvent(&window, &pressEvent); + QMouseEvent pressEvent2 = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), button, button, {}); + QGuiApplication::sendEvent(&window, &pressEvent2); QGuiApplication::sendEvent(&window, &releaseEvent); QCOMPARE(window.rootObject()->property("clicked").toInt(), 1); @@ -1055,8 +1055,9 @@ void tst_QQuickMouseArea::clickTwice() QCOMPARE(window.rootObject()->property("clicked").toInt(), 1); QGuiApplication::sendEvent(&window, &pressEvent); - pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), button, button, {}); - QGuiApplication::sendEvent(&window, &pressEvent); + + QMouseEvent pressEvent2 = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), button, button, {}); + QGuiApplication::sendEvent(&window, &pressEvent2); QGuiApplication::sendEvent(&window, &releaseEvent); QCOMPARE(window.rootObject()->property("pressed").toInt(), 2); @@ -1091,8 +1092,8 @@ void tst_QQuickMouseArea::invalidClick() QCOMPARE(window.rootObject()->property("released").toInt(), 0); QGuiApplication::sendEvent(&window, &pressEvent); - pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), button, button, {}); - QGuiApplication::sendEvent(&window, &pressEvent); + QMouseEvent pressEvent2 = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), button, button, {}); + QGuiApplication::sendEvent(&window, &pressEvent2); QGuiApplication::sendEvent(&window, &releaseEvent); QCOMPARE(window.rootObject()->property("clicked").toInt(), 0); |