Add test for qr code opening in ProfilePopup

This commit is contained in:
B.Melnik 2021-09-28 23:47:01 +03:00
parent 707adb46a4
commit 3c12e8b242
No known key found for this signature in database
GPG Key ID: 4A9B2E42E3BD4727
9 changed files with 173 additions and 0 deletions

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "StatusQ"]
path = StatusQ
url = https://github.com/status-im/StatusQ
[submodule "status-desktop"]
path = status-desktop
url = https://github.com/status-im/status-desktop.git

1
StatusQ Submodule

@ -0,0 +1 @@
Subproject commit b6a6e220f732ca8c1a16d7bb69d6993c45d7a491

6
main.cpp Normal file
View File

@ -0,0 +1,6 @@
#include <QtQuickTest/quicktest.h>
#include "setup.h"
QUICK_TEST_MAIN_WITH_SETUP(ui-tests, Setup)

6
setup.cpp Normal file
View File

@ -0,0 +1,6 @@
#include "setup.h"
Setup::Setup(QObject *parent) : QObject(parent)
{
}

32
setup.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef SETUP_H
#define SETUP_H
#include <QObject>
#include <QQmlEngine>
#include <QQmlContext>
#include <QDebug>
#define STR(x) #x
#ifdef PROJECT_PATH
#define PWD(x) STR(x)
#endif
class Setup : public QObject
{
Q_OBJECT
public:
explicit Setup(QObject *parent = nullptr);
public slots:
void qmlEngineAvailable(QQmlEngine *engine)
{
engine->rootContext()->setContextProperty("myContextProperty", QVariant(true));
qDebug() << "StatusQ Path: " << QString(PWD(PROJECT_PATH));
engine->addImportPath(QString(PWD(PROJECT_PATH)) + "/StatusQ/src");
engine->addImportPath(QString(PWD(PROJECT_PATH)) + "/status-desktop/ui/imports");
}
};
#endif // SETUP_H

1
status-desktop Submodule

@ -0,0 +1 @@
Subproject commit 4b73d6849025c8272c3fc882855f73a0d113ced6

82
tst_Modals.qml Normal file
View File

@ -0,0 +1,82 @@
import QtQuick 2.14
import QtQuick.Window 2.14
import QtTest 1.14
import "status-desktop/ui/app/AppLayouts/Chat/components" as DesktopComponents
TestCase {
name: "ProfilePopup"
when: windowShown
/// TODO: add good test data
QtObject {
id: chatsModel
property var ensView: QtObject {
function isEnsVerified(author) {
return true;
}
}
function alias(author) {
return "some alias"
}
}
QtObject {
id: profileModel
property var contacts: QtObject {
function isContactBlocked(author) {
return false;
}
function isAdded(author) {
return true
}
}
property var profile: QtObject {
property string pubKey: "Some author"
}
function qrCode(author) {
return ""
}
}
Window {
id: tstWindow
width: 800
height: 600
DesktopComponents.ProfilePopup {
id: propfilePopup
}
}
///////
function initTestCase() {
tstWindow.show()
}
function cleanupTestCase() {
}
function test_case1() {
propfilePopup.openPopup(true, "Test user", "Some author", "", "bla bla test it bitch", "Nickname")
wait(2000) // for show how its works
print(propfilePopup.contentItem, propfilePopup.width - 65)
mouseClick(propfilePopup.background, propfilePopup.width - 65, 20, Qt.LeftButton)
wait(2000) // for show how its works
verify(propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible")
propfilePopup.contentItem.qrCodePopup.close()
verify(!propfilePopup.contentItem.qrCodePopup.visible, "Qr code should be visible")
}
function test_case2() {
mouseClick(propfilePopup.background, propfilePopup.width - 25, 20, Qt.LeftButton)
wait(2000)
verify(!propfilePopup.visible, "Profile popup should be invisible")
}
}

18
tst_initialtest.qml Normal file
View File

@ -0,0 +1,18 @@
import QtQuick 2.14
import QtTest 1.14
import StatusQ.Core.Theme 0.1
TestCase {
name: "initialTest"
function initTestCase() {
}
function cleanupTestCase() {
}
function test_case1() {
verify(!!Theme.palette, "Theme available");
}
}

21
ui-tests.pro Normal file
View File

@ -0,0 +1,21 @@
CONFIG += warn_on qmltestcase
TEMPLATE = app
DESTDIR += $${PWD}/bin
DEFINES += PROJECT_PATH=\"$${PWD}\"
DISTFILES += \
tst_Modals.qml \
tst_initialtest.qml
DISTFILES += $$files("StatusQ/src/*", true)
DISTFILES += $$files("status-desktop/ui/app/*", true)
SOURCES += \
main.cpp \
setup.cpp
HEADERS += \
setup.h