diff options
Diffstat (limited to 'tests/auto/input/inputchord/tst_inputchord.cpp')
-rw-r--r-- | tests/auto/input/inputchord/tst_inputchord.cpp | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/tests/auto/input/inputchord/tst_inputchord.cpp b/tests/auto/input/inputchord/tst_inputchord.cpp index 093bd29f7..afc324a9d 100644 --- a/tests/auto/input/inputchord/tst_inputchord.cpp +++ b/tests/auto/input/inputchord/tst_inputchord.cpp @@ -55,7 +55,7 @@ private Q_SLOTS: inputChord.addChord(&actionInput); // WHEN - simulateInitialization(&inputChord, &backendInputChord); + simulateInitializationSync(&inputChord, &backendInputChord); // THEN QCOMPARE(backendInputChord.peerId(), inputChord.id()); @@ -89,7 +89,7 @@ private Q_SLOTS: inputChord.addChord(&actionInput); // WHEN - simulateInitialization(&inputChord, &backendInputChord); + simulateInitializationSync(&inputChord, &backendInputChord); backendInputChord.cleanup(); // THEN @@ -101,41 +101,37 @@ private Q_SLOTS: void shouldHandlePropertyChanges() { // GIVEN + Qt3DInput::QInputChord inputChord; Qt3DInput::Input::InputChord backendInputChord; + simulateInitializationSync(&inputChord, &backendInputChord); // WHEN - Qt3DCore::QPropertyUpdatedChangePtr updateChange(new Qt3DCore::QPropertyUpdatedChange(Qt3DCore::QNodeId())); - updateChange->setValue(250); - updateChange->setPropertyName("timeout"); - backendInputChord.sceneChangeEvent(updateChange); + inputChord.setTimeout(250); + backendInputChord.syncFromFrontEnd(&inputChord, false); // THEN QCOMPARE(backendInputChord.timeout(), 250000000); // WHEN - updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId()); - updateChange->setPropertyName("enabled"); - updateChange->setValue(true); - backendInputChord.sceneChangeEvent(updateChange); + inputChord.setEnabled(false); + backendInputChord.syncFromFrontEnd(&inputChord, false); // THEN - QCOMPARE(backendInputChord.isEnabled(), true); + QCOMPARE(backendInputChord.isEnabled(), false); // WHEN Qt3DInput::QActionInput input; const Qt3DCore::QNodeId inputId = input.id(); - const auto nodeAddedChange = Qt3DCore::QPropertyNodeAddedChangePtr::create(Qt3DCore::QNodeId(), &input); - nodeAddedChange->setPropertyName("chord"); - backendInputChord.sceneChangeEvent(nodeAddedChange); + inputChord.addChord(&input); + backendInputChord.syncFromFrontEnd(&inputChord, false); // THEN QCOMPARE(backendInputChord.chords().size(), 1); QCOMPARE(backendInputChord.chords().first(), inputId); // WHEN - const auto nodeRemovedChange = Qt3DCore::QPropertyNodeRemovedChangePtr::create(Qt3DCore::QNodeId(), &input); - nodeRemovedChange->setPropertyName("chord"); - backendInputChord.sceneChangeEvent(nodeRemovedChange); + inputChord.removeChord(&input); + backendInputChord.syncFromFrontEnd(&inputChord, false); // THEN QCOMPARE(backendInputChord.chords().size(), 0); @@ -154,13 +150,13 @@ private Q_SLOTS: firstInput->setButtons(QVector<int>() << Qt::Key_Q << Qt::Key_W); firstInput->setSourceDevice(device); auto backendFirstInput = handler.actionInputManager()->getOrCreateResource(firstInput->id()); - simulateInitialization(firstInput, backendFirstInput); + simulateInitializationSync(firstInput, backendFirstInput); auto secondInput = new Qt3DInput::QActionInput; secondInput->setButtons(QVector<int>() << Qt::Key_A << Qt::Key_S); secondInput->setSourceDevice(device); auto backendSecondInput = handler.actionInputManager()->getOrCreateResource(secondInput->id()); - simulateInitialization(secondInput, backendSecondInput); + simulateInitializationSync(secondInput, backendSecondInput); Qt3DInput::Input::InputChord backendInputChord; Qt3DInput::QInputChord inputChord; @@ -168,7 +164,7 @@ private Q_SLOTS: inputChord.setTimeout(300); inputChord.addChord(firstInput); inputChord.addChord(secondInput); - simulateInitialization(&inputChord, &backendInputChord); + simulateInitializationSync(&inputChord, &backendInputChord); // WHEN deviceBackend->setButtonPressed(Qt::Key_Up, true); @@ -242,13 +238,13 @@ private Q_SLOTS: firstInput->setButtons(QVector<int>() << Qt::Key_Q); firstInput->setSourceDevice(device); auto backendFirstInput = handler.actionInputManager()->getOrCreateResource(firstInput->id()); - simulateInitialization(firstInput, backendFirstInput); + simulateInitializationSync(firstInput, backendFirstInput); auto secondInput = new Qt3DInput::QActionInput; secondInput->setButtons(QVector<int>() << Qt::Key_W); secondInput->setSourceDevice(device); auto backendSecondInput = handler.actionInputManager()->getOrCreateResource(secondInput->id()); - simulateInitialization(secondInput, backendSecondInput); + simulateInitializationSync(secondInput, backendSecondInput); Qt3DInput::Input::InputChord backendInputChord; Qt3DInput::QInputChord inputChord; @@ -256,7 +252,7 @@ private Q_SLOTS: inputChord.setTimeout(300); inputChord.addChord(firstInput); inputChord.addChord(secondInput); - simulateInitialization(&inputChord, &backendInputChord); + simulateInitializationSync(&inputChord, &backendInputChord); // WHEN deviceBackend->setButtonPressed(Qt::Key_Q, true); @@ -290,13 +286,13 @@ private Q_SLOTS: firstInput->setButtons(QVector<int>() << Qt::Key_Q); firstInput->setSourceDevice(device); auto backendFirstInput = handler.actionInputManager()->getOrCreateResource(firstInput->id()); - simulateInitialization(firstInput, backendFirstInput); + simulateInitializationSync(firstInput, backendFirstInput); auto secondInput = new Qt3DInput::QActionInput; secondInput->setButtons(QVector<int>() << Qt::Key_W); secondInput->setSourceDevice(device); auto backendSecondInput = handler.actionInputManager()->getOrCreateResource(secondInput->id()); - simulateInitialization(secondInput, backendSecondInput); + simulateInitializationSync(secondInput, backendSecondInput); Qt3DInput::Input::InputChord backendInputChord; Qt3DInput::QInputChord inputChord; @@ -304,7 +300,7 @@ private Q_SLOTS: inputChord.setTimeout(300); inputChord.addChord(firstInput); inputChord.addChord(secondInput); - simulateInitialization(&inputChord, &backendInputChord); + simulateInitializationSync(&inputChord, &backendInputChord); // WHEN deviceBackend->setButtonPressed(Qt::Key_Q, true); |