mirror of
https://github.com/status-im/desktop-ui-tests.git
synced 2025-02-19 16:14:29 +00:00
refactor(tst_statusButton.qml): refactored test
This commit is contained in:
parent
f701240610
commit
2ec2261b34
@ -1,5 +0,0 @@
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
|
||||
}
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user