desktop-ui-tests/tst_status_button.qml

85 lines
2.5 KiB
QML
Raw Permalink Normal View History

2021-10-18 12:22:40 +00:00
import QtQuick 2.14
import QtQuick.Window 2.14
import QtTest 1.14
import "base"
import StatusQ.Controls 0.1
import StatusQ.Popups 0.1
2021-10-18 12:22:40 +00:00
WindowTestCase {
name: "statusButton test"
2021-10-18 12:22:40 +00:00
when: windowShown
SignalSpy {
id: statusButtonClickedSpy
target: statusButton
2021-10-18 12:22:40 +00:00
signalName: "clicked"
}
SignalSpy {
id: statusButtonReleasedSpy
target: statusButton
2021-10-18 12:22:40 +00:00
signalName: "released"
}
SignalSpy {
id: statusButtonPressedSpy
target: statusButton
2021-10-18 12:22:40 +00:00
signalName: "pressed"
}
SignalSpy {
id: statusButtonPressedAndHoldSpy
target: statusButton
2021-10-18 12:22:40 +00:00
signalName: "pressAndHold"
}
StatusButton {
id: statusButton
parent: windowContent
text: "Status Button"
2021-10-18 12:22:40 +00:00
}
function test_case1_statusButton_signals_valid() {
2021-10-18 12:22:40 +00:00
// checking if signals are present
2021-10-18 12:22:40 +00:00
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")
2021-10-18 12:22:40 +00:00
}
function test_case2_statusButton_clicked() {
compare(statusButtonClickedSpy.count, 0)
mouseClick(statusButton, 1, 1, Qt.LeftButton)
compare(statusButtonClickedSpy.count, 1, "Status Button was not clicked")
mouseRelease(statusButton, 1, 1, Qt.LeftButton)
2021-10-18 12:22:40 +00:00
}
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")
2021-10-18 12:22:40 +00:00
}
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")
}
2021-10-18 12:22:40 +00:00
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")
}
2021-10-18 12:22:40 +00:00
}