Add tests for StatusListItem

This commit is contained in:
B.Melnik 2021-10-18 15:31:21 +03:00
parent a8944d8c72
commit fbdc3a6a13
No known key found for this signature in database
GPG Key ID: 4A9B2E42E3BD4727
4 changed files with 57 additions and 2 deletions

View File

@ -12,5 +12,6 @@
<file>base/ProfileModelData.qml</file> <file>base/ProfileModelData.qml</file>
<file>base/WindowTestCase.qml</file> <file>base/WindowTestCase.qml</file>
<file>tst_chatinfotoolbar.qml</file> <file>tst_chatinfotoolbar.qml</file>
<file>tst_statuslistitem.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -3,7 +3,7 @@ import QtQuick.Window 2.14
import QtTest 1.14 import QtTest 1.14
import "base" import "base"
import "status-desktop/ui/onboarding" as DesktopComponents import "status-desktop/ui/app/AppLayouts/Onboarding/popups" as DesktopComponents
WindowTestCase { WindowTestCase {

View File

@ -3,7 +3,7 @@ import QtQuick.Window 2.14
import QtTest 1.14 import QtTest 1.14
import "base" import "base"
import "status-desktop/ui/onboarding" as DesktopComponents import "status-desktop/ui/app/AppLayouts/Onboarding/popups" as DesktopComponents
WindowTestCase { WindowTestCase {

54
tst_statuslistitem.qml Normal file
View File

@ -0,0 +1,54 @@
import QtQuick 2.14
import QtTest 1.14
import "base"
import StatusQ.Components 0.1
WindowTestCase {
name: "StatusListItem test"
SignalSpy {
id: clickedSpy
target: listItem
signalName: "clicked"
}
SignalSpy {
id: titleClickedSpy
target: listItem
signalName: "titleClicked"
}
StatusListItem {
id: listItem
parent: windowContent
itemId: "someId"
title: "Title"
subTitle: "Subtitle"
}
function initTestCase() {
window.show()
}
function cleanupTestCase() {
window.close()
}
function test_clickFunctions() {
// Verify than signal exists
verify(clickedSpy.valid, "Signal " + clickedSpy.signalName + "is not valid")
verify(titleClickedSpy.valid, "Signal " + titleClickedSpy.signalName + "is not valid")
compare(clickedSpy.count, 0)
mouseClick(listItem, 1, 1, Qt.LeftButton)
compare(clickedSpy.count, 1, "Signal clicked is not called")
compare(titleClickedSpy.count, 0)
mouseClick(listItem, listItem.leftPadding + 1, listItem.implicitHeight / 2, Qt.LeftButton)
compare(titleClickedSpy.count, 1, "Signal titleClicked is not called");
}
}