From 2ec2261b343ac1009776bc32eaf1b84e5b68ec03 Mon Sep 17 00:00:00 2001 From: Anastasiya S Date: Wed, 20 Oct 2021 22:57:27 +0300 Subject: [PATCH] refactor(tst_statusButton.qml): refactored test --- tst_onboarding_choose_chat_name_modal.qml | 5 -- tst_statusButton.qml | 104 +++++++++------------- 2 files changed, 43 insertions(+), 66 deletions(-) delete mode 100644 tst_onboarding_choose_chat_name_modal.qml diff --git a/tst_onboarding_choose_chat_name_modal.qml b/tst_onboarding_choose_chat_name_modal.qml deleted file mode 100644 index 9c36e13..0000000 --- a/tst_onboarding_choose_chat_name_modal.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Item { - -} diff --git a/tst_statusButton.qml b/tst_statusButton.qml index 53b9558..5018952 100644 --- a/tst_statusButton.qml +++ b/tst_statusButton.qml @@ -3,100 +3,82 @@ import QtQuick.Window 2.14 import QtTest 1.14 import "base" -import "status-desktop/ui/StatusQ/src/StatusQ/Controls" as DesktopControls +import StatusQ.Controls 0.1 +import StatusQ.Popups 0.1 WindowTestCase { - name: "statusButton" + name: "statusButton test" when: windowShown - Helpers { id: helpers } - - - Component { - id: popupComponent - DesktopControls.StatusButton { - id: statusButton - } - } - SignalSpy { id: statusButtonClickedSpy + target: statusButton signalName: "clicked" } SignalSpy { id: statusButtonReleasedSpy + target: statusButton signalName: "released" } SignalSpy { id: statusButtonPressedSpy + target: statusButton signalName: "pressed" } SignalSpy { id: statusButtonPressedAndHoldSpy + target: statusButton signalName: "pressAndHold" } + StatusButton { + id: statusButton + parent: windowContent + text: "Status Button" + } - function test_case1_statusButton_clicked() { + function test_case1_statusButton_signals_valid() { - var statusButton = popupComponent.createObject(window) - statusButton.text = "Status Button" - wait(2000) - statusButtonClickedSpy.target = statusButton + // checking if signals are present + + verify(statusButtonClickedSpy.valid, "Signal " + statusButtonClickedSpy.signalName + "is not found") + verify(statusButtonPressedSpy.valid, "Signal " + statusButtonPressedSpy.signalName + "is not found") + verify(statusButtonPressedAndHoldSpy.valid, "Signal " + statusButtonPressedAndHoldSpy.signalName + "is not found") + verify(statusButtonReleasedSpy.valid, "Signal " + statusButtonReleasedSpy.signalName + "is not found") + } + + + function test_case2_statusButton_clicked() { compare(statusButtonClickedSpy.count, 0) mouseClick(statusButton, 1, 1, Qt.LeftButton) - wait(2000) - compare(statusButtonClickedSpy.count, 1, "Status button was not clicked") - statusButton.destroy() - } - - function test_case2_statusButton_pressed() { - - var statusButton = popupComponent.createObject(window) - statusButton.text = "Status Button" - wait(2000) - statusButtonPressedSpy.target = statusButton - compare(statusButtonPressedSpy.count, 0) - mousePress(statusButton, 1, 1, Qt.LeftButton) - wait(2000) - compare(statusButtonPressedSpy.count, 1, "Status button was not pressed") - statusButton.destroy() - - } - - function test_case3_statusButton_pressedAndHold() { - - var statusButton = popupComponent.createObject(window) - statusButton.text = "Status Button" - wait(2000) - statusButtonPressedAndHoldSpy.target = statusButton - compare(statusButtonPressedAndHoldSpy.count, 0) - mousePress(statusButton, 1, 1, Qt.LeftButton, Qt.NoModifier, 1000) - wait(2000) - compare(statusButtonPressedAndHoldSpy.count, 1, "Status button was not press and hold for 1000 ms") - statusButton.destroy() - - } - - function test_case4_statusButton_released() { - - var statusButton = popupComponent.createObject(window) - statusButton.text = "Status Button" - wait(2000) - statusButtonReleasedSpy.target = statusButton - compare(statusButtonReleasedSpy.count, 0) - mousePress(statusButton, 1, 1, Qt.LeftButton, Qt.NoModifier, 1000) + compare(statusButtonClickedSpy.count, 1, "Status Button was not clicked") mouseRelease(statusButton, 1, 1, Qt.LeftButton) - wait(2000) - compare(statusButtonReleasedSpy.count, 1, "Status button was not released") - statusButton.destroy() + } + + function test_case3_statusButton_pressed() { + statusButtonPressedSpy.clear() + compare(statusButtonPressedSpy.count, 0) + mousePress(statusButton, 5, 5, Qt.LeftButton) + compare(statusButtonPressedSpy.count, 1, "Status Button was not pressed") } + function test_case4_statusButton_pressedAndHold() { + statusButtonPressedAndHoldSpy.clear() + compare(statusButtonPressedAndHoldSpy.count, 0) + mousePress(statusButton, 5, 5, Qt.LeftButton, Qt.NoModifier, 1000) + compare(statusButtonPressedAndHoldSpy.count, 1, "Status Button was not pressed and held") + } + function test_case5_statusButton_released() { + statusButtonReleasedSpy.clear() + mousePress(statusButton, 5, 5, Qt.LeftButton, Qt.NoModifier, 1000) + mouseRelease(statusButton, 5, 5, Qt.LeftButton) + compare(statusButtonReleasedSpy.count, 1, "Status Button was not released") + } }