Merge pull request #20 from status-im/feat/listitem

Add tests for StatusListItem
This commit is contained in:
Boris Melnik 2021-10-18 15:32:41 +03:00 committed by GitHub
commit aa56ef4a5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 2 deletions

View File

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

View File

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

View File

@ -3,7 +3,7 @@ import QtQuick.Window 2.14
import QtTest 1.14
import "base"
import "status-desktop/ui/onboarding" as DesktopComponents
import "status-desktop/ui/app/AppLayouts/Onboarding/popups" as DesktopComponents
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");
}
}