Merge pull request #3 from status-im/testing_methods

Add test functions and git ignore file
This commit is contained in:
Boris Melnik 2021-10-08 11:12:35 +03:00 committed by GitHub
commit 7289c8b782
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 83 additions and 3 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.DS_Store
*.pro.user
*.moc
*.o

50
base/Helpers.qml Normal file
View File

@ -0,0 +1,50 @@
import QtQuick 2.14
QtObject {
function checkClassName(item, name) {
let stringy = item.toString()
return stringy.indexOf(name) !== -1
}
function topChildAt(item, x, y) {
var obj = item.childAt(x, y)
if (!!obj) {
for (var idx in obj.children) {
var child = obj.children[idx]
var position = mapToItem(child, x, y)
if (position.x < 0 || position.y <= 0) {
continue
} else {
return topChildAt(child, position.x, position.y)
}
}
return obj
}
return null
}
function findChildByClassName(item, className) {
for (var idx in item.children) {
let child = item.children[idx]
let cname = child.toString();
if (cname.indexOf(className) !== -1) {
return child;
}
}
return null;
}
function checkIfItemExists(parent, x, y, className) {
var obj = parent.childAt(x, y)
if (className !== undefined) {
return !!obj && checkClassName(obj, className);
} else {
return !!obj
}
}
}

16
base/WindowTestCase.qml Normal file
View File

@ -0,0 +1,16 @@
import QtQuick 2.14
import QtTest 1.14
import QtQuick.Window 2.14
TestCase {
id: root
readonly property Window window: baseWindow
Window {
id: baseWindow
width: 800
height: 600
}
}

View File

@ -2,6 +2,7 @@ import QtQuick 2.14
import QtQuick.Window 2.14 import QtQuick.Window 2.14
import QtTest 1.14 import QtTest 1.14
import "base"
import "status-desktop/ui/app/AppLayouts/Chat/components" as DesktopComponents import "status-desktop/ui/app/AppLayouts/Chat/components" as DesktopComponents
@ -9,6 +10,8 @@ TestCase {
name: "ProfilePopup" name: "ProfilePopup"
when: windowShown when: windowShown
Helpers { id: helpers }
/// TODO: add good test data /// TODO: add good test data
QtObject { QtObject {
id: chatsModel id: chatsModel
@ -45,7 +48,7 @@ TestCase {
} }
Window { Window {
id: tstWindow id: window
width: 800 width: 800
height: 600 height: 600
DesktopComponents.ProfilePopup { DesktopComponents.ProfilePopup {
@ -55,7 +58,7 @@ TestCase {
/////// ///////
function initTestCase() { function initTestCase() {
tstWindow.show() window.show()
} }
function cleanupTestCase() { function cleanupTestCase() {
@ -65,8 +68,8 @@ TestCase {
function test_case1() { function test_case1() {
propfilePopup.openPopup(true, "Test user", "Some author", "", "bla bla test it bitch", "Nickname") propfilePopup.openPopup(true, "Test user", "Some author", "", "bla bla test it bitch", "Nickname")
wait(2000) // for show how its works wait(2000) // for show how its works
print(propfilePopup.contentItem, propfilePopup.width - 65)
mouseClick(propfilePopup.background, propfilePopup.width - 65, 20, Qt.LeftButton) mouseClick(propfilePopup.background, propfilePopup.width - 65, 20, Qt.LeftButton)
verify(helpers.checkIfItemExists(propfilePopup.background, propfilePopup.width - 65, 20, "StatusFlatRoundButton"))
wait(2000) // for show how its works wait(2000) // for show how its works
verify(propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible") verify(propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible")
propfilePopup.contentItem.qrCodePopup.close() propfilePopup.contentItem.qrCodePopup.close()

View File

@ -1,11 +1,15 @@
import QtQuick 2.14 import QtQuick 2.14
import QtTest 1.14 import QtTest 1.14
import "base"
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
TestCase { TestCase {
name: "initialTest" name: "initialTest"
Helpers { id: helpers }
function initTestCase() { function initTestCase() {
} }
@ -14,5 +18,6 @@ TestCase {
function test_case1() { function test_case1() {
verify(!!Theme.palette, "Theme available"); verify(!!Theme.palette, "Theme available");
verify(helpers.checkClassName(Theme.palette, "StatusLightTheme"))
} }
} }

View File

@ -7,6 +7,8 @@ DESTDIR += $${PWD}/bin
DEFINES += PROJECT_PATH=\"$${PWD}\" DEFINES += PROJECT_PATH=\"$${PWD}\"
DISTFILES += \ DISTFILES += \
base/Helpers.qml \
base/WindowTestCase.qml \
tst_Modals.qml \ tst_Modals.qml \
tst_initialtest.qml tst_initialtest.qml