misc: fix QML tests

Moreover, add two accounts (for ChatView testing)

Change-Id: Ifb2a45002dd9e86921868257124561764e9b94c5
This commit is contained in:
Sébastien Blin
2023-12-22 15:49:35 -05:00
committed by Adrien Béraud
parent f1c90f316a
commit 2d664eacb1
14 changed files with 198 additions and 1751 deletions

View File

@@ -50,8 +50,9 @@ Q_INVOKABLE void
FilesToSendListModel::addToPending(QString filePath)
{
auto fileInfo = QFileInfo(filePath);
if (!fileInfo.exists())
if (!fileInfo.exists()) {
return;
}
// QImageReader will treat .gz file (Jami archive) as svgz image format
// so decideFormatFromContent is needed

View File

@@ -111,6 +111,7 @@ Rectangle {
ChatViewHeader {
id: chatViewHeader
objectName: "chatViewHeader"
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true

View File

@@ -224,6 +224,7 @@ Rectangle {
JamiPushButton {
id: sendContactRequestButton
objectName: "sendContactRequestButton"
visible: CurrentConversation.isTemporary || CurrentConversation.isBanned
source: JamiResources.add_people_24dp_svg
@@ -234,6 +235,7 @@ Rectangle {
JamiPushButton {
id: detailsButton
objectName: "detailsButton"
checkable: true
checked: extrasPanel.isOpen(ChatView.SwarmDetailsPanel)

View File

@@ -47,7 +47,7 @@ Rectangle {
}
function clearAllTextFields() {
chooseUsernameButton.enabled = true;
joinJamiButton.enabled = true;
encryptButton.enabled = true;
customizeButton.enabled = true;
usernameEdit.dynamicText = "";
@@ -220,9 +220,9 @@ Rectangle {
}
}
KeyNavigation.tab: chooseUsernameButton
KeyNavigation.tab: joinJamiButton
KeyNavigation.up: usernameEdit
KeyNavigation.down: chooseUsernameButton
KeyNavigation.down: joinJamiButton
}
objectName: "usernameEdit"
@@ -266,7 +266,7 @@ Rectangle {
}
MaterialButton {
id: chooseUsernameButton
id: joinJamiButton
z: -1
TextMetrics {
@@ -274,10 +274,10 @@ Rectangle {
font.weight: Font.Bold
font.pixelSize: JamiTheme.wizardViewButtonFontPixelSize
font.capitalization: Font.AllUppercase
text: chooseUsernameButton.text
text: joinJamiButton.text
}
objectName: "chooseUsernameButton"
objectName: "joinJamiButton"
Layout.alignment: Qt.AlignCenter
Layout.topMargin: JamiTheme.wizardViewBlocMarginSize
@@ -338,7 +338,7 @@ Rectangle {
toolTipText: JamiStrings.encryptWithPassword
KeyNavigation.tab: customizeButton
KeyNavigation.up: chooseUsernameButton
KeyNavigation.up: joinJamiButton
KeyNavigation.down: backButton
KeyNavigation.right: customizeButton
@@ -371,7 +371,7 @@ Rectangle {
toolTipText: JamiStrings.customizeYourProfile
KeyNavigation.tab: backButton
KeyNavigation.up: chooseUsernameButton
KeyNavigation.up: joinJamiButton
KeyNavigation.left: encryptButton
KeyNavigation.down: backButton
@@ -393,7 +393,7 @@ Rectangle {
visible: false
onJoinClicked: {
chooseUsernameButton.enabled = false;
joinJamiButton.enabled = false;
customizeButton.enabled = false;
encryptButton.enabled = false;
}

View File

@@ -22,6 +22,10 @@
#include "qmlregister.h"
#include "systemtray.h"
#include "videoprovider.h"
#include "api/profile.h"
#include "api/account.h"
#include "api/conversationmodel.h"
#include "api/contactmodel.h"
#include <atomic>
@@ -30,6 +34,7 @@
#include <QQmlEngine>
#include <QScopedPointer>
#include <QtQuickTest/quicktest.h>
#include <QSignalSpy>
#ifdef WITH_WEBENGINE
#include <QtWebEngineCore>
@@ -40,6 +45,9 @@
#include <windows.h>
#endif
#include <thread>
using namespace std::literals::chrono_literals;
class Setup : public QObject
{
Q_OBJECT
@@ -49,6 +57,16 @@ public:
: muteDaemon_(muteDaemon)
{}
~Setup()
{
QSignalSpy accountRemovedSpy(&lrcInstance_->accountModel(), &AccountModel::accountRemoved);
lrcInstance_->accountModel().removeAccount(aliceId);
lrcInstance_->accountModel().removeAccount(bobId);
while (accountRemovedSpy.count() != 2) {
accountRemovedSpy.wait();
}
}
public Q_SLOTS:
/*
@@ -69,6 +87,31 @@ public Q_SLOTS:
auto downloadPath = settingsManager_->getValue(Settings::Key::DownloadPath);
lrcInstance_->accountModel().downloadDirectory = downloadPath.toString() + "/";
// Create 2 Account
QSignalSpy accountStatusChangedSpy(&lrcInstance_->accountModel(),
&AccountModel::accountStatusChanged);
QSignalSpy accountAddedSpy(&lrcInstance_->accountModel(), &AccountModel::accountAdded);
aliceId = lrcInstance_->accountModel().createNewAccount(profile::Type::JAMI, "Alice");
accountAddedSpy.wait(15000);
QCOMPARE(accountAddedSpy.count(), 1);
bobId = lrcInstance_->accountModel().createNewAccount(profile::Type::JAMI, "Bob");
accountAddedSpy.wait(15000);
QCOMPARE(accountAddedSpy.count(), 2);
// Create a conversation
auto& aliceInfo = lrcInstance_->accountModel().getAccountInfo(aliceId);
auto& bobInfo = lrcInstance_->accountModel().getAccountInfo(bobId);
ConversationModel* bobCM = bobInfo.conversationModel.get();
QSignalSpy conversationReqSpy(&*bobCM, &ConversationModel::newConversation);
contact::Info bobContact;
bobContact.profileInfo.uri = bobInfo.profileInfo.uri;
bobContact.profileInfo.type = profile::Type::TEMPORARY;
aliceInfo.contactModel->addContact(bobContact);
conversationReqSpy.wait(15000);
QCOMPARE(conversationReqSpy.count(), 1);
}
/*
@@ -83,7 +126,9 @@ public Q_SLOTS:
*/
void qmlEngineAvailable(QQmlEngine* engine)
{
lrcInstance_->set_currentAccountId();
lrcInstance_->set_currentAccountId(aliceId);
auto& aliceInfo = lrcInstance_->accountModel().getAccountInfo(aliceId);
lrcInstance_->set_selectedConvUid(aliceInfo.conversationModel->getConversations()[0].uid);
// Expose custom types to the QML engine.
Utils::registerTypes(engine,
@@ -119,6 +164,8 @@ private:
ScreenInfo screenInfo_;
bool muteDaemon_ {false};
QString aliceId;
QString bobId;
};
int

View File

@@ -1,6 +1,5 @@
<RCC>
<qresource prefix="/">
<file>src/tst_LocalAccount.qml</file>
<file>src/tst_WizardView.qml</file>
<file>src/tst_NewSwarmPage.qml</file>
<file>src/tst_MessageOptions.qml</file>

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2021-2023 Savoir-faire Linux Inc.
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick
import QtTest
import net.jami.Adapters 1.1
import net.jami.Models 1.1
import net.jami.Constants 1.1
import net.jami.Enums 1.1
import "../../../src/app/"
import "../../../src/app/mainview"
import "../../../src/app/mainview/components"
import "../../../src/app/commoncomponents"
ListSelectionView {
id: viewNode
objectName: "ConversationView"
managed: false
leftPaneItem: Rectangle {}
rightPaneItem: ChatView {
id: uut
inCallView: false
TestCase {
name: "Check basic visibility for header buttons"
function test_checkBasicVisibility() {
var chatviewHeader = findChild(uut, "chatViewHeader")
var detailsButton = findChild(chatviewHeader, "detailsButton")
var sendContactRequestButton = findChild(chatviewHeader, "sendContactRequestButton")
compare(detailsButton.visible, true)
compare(sendContactRequestButton.visible, false)
}
}
}
}

View File

@@ -50,15 +50,15 @@ ColumnLayout {
function test_add_remove_file_test() {
// Add animated image file
uut.filesToSendListModel.addToPending(":/src/app/resources/gif_test.gif")
uut.filesToSendListModel.addToPending(":/src/resources/gif_test.gif")
compare(uut.filesToSendCount, 1)
// Add image file
uut.filesToSendListModel.addToPending(":/src/app/resources/png_test.png")
uut.filesToSendListModel.addToPending(":/src/resources/png_test.png")
compare(uut.filesToSendCount, 2)
// Add normal file
uut.filesToSendListModel.addToPending(":/src/app/resources/gz_test.gz")
uut.filesToSendListModel.addToPending(":/src/resources/gz_test.gz")
compare(uut.filesToSendCount, 3)
// Flush

View File

@@ -1,32 +0,0 @@
/*
* Copyright (C) 2021-2023 Savoir-faire Linux Inc.
* Author: Albert Babí Oller <albert.babi@savoirfairelinux.com>
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick
import QtTest
import net.jami.Adapters 1.1
TestCase {
name: "Local Account Test"
when: windowShown
function test_initially_no_account() {
compare(UtilsAdapter.getAccountListSize(), 0)
}
}

View File

@@ -1,61 +0,0 @@
/*
* Copyright (C) 2023 Savoir-faire Linux Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtTest
import "../../../src/app/"
import "../../../src/app/settingsview/components"
ColumnLayout {
id: root
spacing: 0
width: 300
height: 300
Item {
id: dummy
}
SettingsMaterialTextEdit {
id: uut
property bool focusLeft: false
isPassword: true
TestCase {
name: "Test password un-focus"
when: windowShown
function test_unfocusPassword() {
// Open the recorder and take a picture
uut.forceActiveFocus()
dummy.forceActiveFocus()
compare(uut.focusLeft, true)
}
}
onEditFinished: focusLeft = true
Layout.fillWidth: true
Layout.fillHeight: true
}
}

View File

@@ -24,17 +24,14 @@ import net.jami.Models 1.1
import net.jami.Constants 1.1
import net.jami.Enums 1.1
import "../../../src/app/"
import "../../../src/app/wizardview"
import "../../../src/app/commoncomponents"
WizardView {
id: uut
property ViewManager viewManager: ViewManager {}
property ViewCoordinator viewCoordinator: ViewCoordinator {
viewManager: uut.viewManager
}
width: 400
height: 600
function clearSignalSpy() {
spyAccountIsReady.clear()
@@ -95,63 +92,80 @@ WizardView {
}
TestCase {
name: "Create Jami account ui flow (no registered name)"
name: "WelcomePage to different account creation page and return back"
when: windowShown
function test_createEmptyJamiAccountUiFlow() {
uut.clearSignalSpy()
function test_welcomePageStepInStepOut() {
var controlPanelStackView = findChild(uut, "controlPanelStackView")
var welcomePage = findChild(uut, "welcomePage")
var createAccountPage = findChild(uut, "createAccountPage")
var usernameEdit = findChild(createAccountPage, "usernameEdit")
var popup = findChild(createAccountPage, "popup")
var joinButton = findChild(popup, "joinButton")
var createAccountStack = findChild(createAccountPage, "createAccountStack")
var chooseUsernameButton = findChild(createAccountPage, "chooseUsernameButton")
// WelcomePage initially
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
welcomePage)
var importFromDevicePage = findChild(uut, "importFromDevicePage")
var importFromBackupPage = findChild(uut, "importFromBackupPage")
var connectToAccountManagerPage = findChild(uut, "connectToAccountManagerPage")
var createSIPAccountPage = findChild(uut, "createSIPAccountPage")
// Go to createAccount page
WizardViewStepModel.startAccountCreationFlow(
WizardViewStepModel.AccountCreationOption.CreateJamiAccount)
compare(createAccountStack.currentIndex, 0)
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
createAccountPage)
WizardViewStepModel.previousStep()
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
welcomePage)
compare(usernameEdit.visible, true)
// Go to CreateRendezVous page
WizardViewStepModel.startAccountCreationFlow(
WizardViewStepModel.AccountCreationOption.CreateRendezVous)
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
createAccountPage)
WizardViewStepModel.previousStep()
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
welcomePage)
// This will show the popup because no username
compare(popup.visible, false)
chooseUsernameButton.clicked()
compare(popup.visible, true)
compare(joinButton.visible, true)
// Go to CreateRendezVous page
WizardViewStepModel.startAccountCreationFlow(
WizardViewStepModel.AccountCreationOption.ImportFromDevice)
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
importFromDevicePage)
WizardViewStepModel.previousStep()
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
welcomePage)
// Create jami account
joinButton.clicked()
// Go to ImportFromBackup page
WizardViewStepModel.startAccountCreationFlow(
WizardViewStepModel.AccountCreationOption.ImportFromBackup)
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
importFromBackupPage)
WizardViewStepModel.previousStep()
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
welcomePage)
// Wait until the account creation is finished
spyAccountIsReady.wait()
compare(spyAccountIsReady.count, 1)
// Go to ConnectToAccountManager page
WizardViewStepModel.startAccountCreationFlow(
WizardViewStepModel.AccountCreationOption.ConnectToAccountManager)
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
connectToAccountManagerPage)
WizardViewStepModel.previousStep()
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
welcomePage)
spyAccountConfigFinalized.wait()
compare(spyAccountConfigFinalized.count, 1)
AccountAdapter.deleteCurrentAccount()
// Wait until the account removal is finished
spyAccountIsRemoved.wait()
compare(spyAccountIsRemoved.count, 1)
// Go to CreateSipAccount page
WizardViewStepModel.startAccountCreationFlow(
WizardViewStepModel.AccountCreationOption.CreateSipAccount)
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
createSIPAccountPage)
WizardViewStepModel.previousStep()
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
welcomePage)
}
}
TestCase {
name: "Create SIP account ui flow"
name: "Create Sip account ui flow"
when: windowShown
function test_createEmptyJamiAccountUiFlow() {
function test_createSipAccountUiFlow() {
uut.clearSignalSpy()
var controlPanelStackView = findChild(uut, "controlPanelStackView")
@@ -159,30 +173,40 @@ WizardView {
var welcomePage = findChild(uut, "welcomePage")
var createSIPAccountPage = findChild(uut, "createSIPAccountPage")
var sipUsernameEdit = findChild(createSIPAccountPage, "sipUsernameEdit")
var sipPasswordEdit = findChild(createSIPAccountPage, "sipPasswordEdit")
var sipServernameEdit = findChild(createSIPAccountPage, "sipServernameEdit")
var createAccountStack = findChild(createSIPAccountPage, "createAccountStack")
var createSIPAccountButton = findChild(createSIPAccountPage, "createSIPAccountButton")
var createAccountButton = findChild(createSIPAccountPage, "createSIPAccountButton")
// WelcomePage initially
compare(controlPanelStackView.children[controlPanelStackView.currentIndex],
welcomePage)
// Go to createAccount page
// Go to createSipAccount page
WizardViewStepModel.startAccountCreationFlow(
WizardViewStepModel.AccountCreationOption.CreateSipAccount)
compare(createAccountStack.currentIndex, 0)
compare(sipServernameEdit.visible, true)
// Set up paras
var userName = "testUserName"
var serverName = "testServerName"
var password = "testPassword"
var proxy = "testProxy"
// Create SIP Account
createSIPAccountButton.clicked()
sipUsernameEdit.dynamicText = userName
sipPasswordEdit.dynamicText = password
sipServernameEdit.dynamicText = serverName
createAccountButton.clicked()
// Wait until the account creation is finished
spyAccountIsReady.wait()
compare(spyAccountIsReady.count, 1)
spyAccountConfigFinalized.wait()
compare(spyAccountConfigFinalized.count, 1)
// Check if paras match with setup
compare(CurrentAccount.username, userName)
compare(CurrentAccount.hostname, serverName)
compare(CurrentAccount.password, password)
WizardViewStepModel.nextStep()
spyCloseWizardView.wait()
compare(spyCloseWizardView.count, 1)
AccountAdapter.deleteCurrentAccount()

File diff suppressed because it is too large Load Diff