From 84a59889e3fc838a2cf4d0c8be3f324c8ff0a773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Simon=20Fauteux-Chapleau?= Date: Wed, 16 Jul 2025 16:17:16 -0400 Subject: [PATCH] tests/qml: fix undefined references to appWindow GitLab: #1780 Change-Id: I166f68c7abdf0f21d8d5dcec85e377c27de798a3 --- tests/qml/src/tst_ChatView.qml | 48 ++-- tests/qml/src/tst_SettingsSidePanel.qml | 66 ++--- tests/qml/src/tst_WizardView.qml | 336 ++++++++++++------------ 3 files changed, 228 insertions(+), 222 deletions(-) diff --git a/tests/qml/src/tst_ChatView.qml b/tests/qml/src/tst_ChatView.qml index 90d511c5..1690f66e 100644 --- a/tests/qml/src/tst_ChatView.qml +++ b/tests/qml/src/tst_ChatView.qml @@ -28,34 +28,36 @@ import "../../../src/app/mainview" import "../../../src/app/mainview/components" import "../../../src/app/commoncomponents" -ListSelectionView { - id: viewNode - objectName: "ConversationView" - managed: false +TestWrapper { + ListSelectionView { + id: viewNode + objectName: "ConversationView" + managed: false - leftPaneItem: Rectangle {} + leftPaneItem: Rectangle {} - rightPaneItem: ChatView { - id: uut + rightPaneItem: ChatView { + id: uut - inCallView: false + inCallView: false - TestCase { - name: "Check basic visibility for header buttons" - function test_checkBasicVisibility() { - var chatviewHeader = findChild(uut, "chatViewHeader") - var detailsButton = findChild(chatviewHeader, "detailsButton") - compare(detailsButton.visible, true) + TestCase { + name: "Check basic visibility for header buttons" + function test_checkBasicVisibility() { + var chatviewHeader = findChild(uut, "chatViewHeader") + var detailsButton = findChild(chatviewHeader, "detailsButton") + compare(detailsButton.visible, true) - var chatViewFooter = findChild(uut, "chatViewFooter") - CurrentConversation.isTemporary = true - compare(chatViewFooter.visible, true) - CurrentConversation.isTemporary = false - CurrentConversation.isRequest = true - compare(chatViewFooter.visible, false) - CurrentConversation.isRequest = false - CurrentConversation.needsSyncing = true - compare(chatViewFooter.visible, false) + var chatViewFooter = findChild(uut, "chatViewFooter") + CurrentConversation.isTemporary = true + compare(chatViewFooter.visible, true) + CurrentConversation.isTemporary = false + CurrentConversation.isRequest = true + compare(chatViewFooter.visible, false) + CurrentConversation.isRequest = false + CurrentConversation.needsSyncing = true + compare(chatViewFooter.visible, false) + } } } } diff --git a/tests/qml/src/tst_SettingsSidePanel.qml b/tests/qml/src/tst_SettingsSidePanel.qml index 5023779f..1f3052cf 100644 --- a/tests/qml/src/tst_SettingsSidePanel.qml +++ b/tests/qml/src/tst_SettingsSidePanel.qml @@ -26,40 +26,42 @@ import net.jami.Enums 1.1 import "../../../src/app/settingsview" import "../../../src/app/commoncomponents" -SettingsSidePanel { - id: uut +TestWrapper { + SettingsSidePanel { + id: uut - SignalSpy { - id: spyUpdated + SignalSpy { + id: spyUpdated - target: uut - signalName: "updated" - } - - SignalSpy { - id: spyChangeLang - - target: UtilsAdapter - signalName: "changeLanguage" - } - - TestCase { - name: "WelcomePage to different account creation page and return back" - when: windowShown - - function test_retranslate() { - spyUpdated.clear() - UtilsAdapter.setAppValue(Settings.Key.LANG, "en_EN") - spyChangeLang.wait(1000) - compare(spyChangeLang.count, 1) - spyUpdated.wait(1000) - compare(spyUpdated.count, 1) - UtilsAdapter.setAppValue(Settings.Key.LANG, "fr") - spyChangeLang.wait(1000) - compare(spyChangeLang.count, 2) - spyUpdated.wait(1000) - compare(spyUpdated.count, 2) + target: uut + signalName: "updated" } - } + SignalSpy { + id: spyChangeLang + + target: UtilsAdapter + signalName: "changeLanguage" + } + + TestCase { + name: "WelcomePage to different account creation page and return back" + when: windowShown + + function test_retranslate() { + spyUpdated.clear() + UtilsAdapter.setAppValue(Settings.Key.LANG, "en_EN") + spyChangeLang.wait(1000) + compare(spyChangeLang.count, 1) + spyUpdated.wait(1000) + compare(spyUpdated.count, 1) + UtilsAdapter.setAppValue(Settings.Key.LANG, "fr") + spyChangeLang.wait(1000) + compare(spyChangeLang.count, 2) + spyUpdated.wait(1000) + compare(spyUpdated.count, 2) + } + } + + } } diff --git a/tests/qml/src/tst_WizardView.qml b/tests/qml/src/tst_WizardView.qml index 6ab599c8..55fc0c9b 100644 --- a/tests/qml/src/tst_WizardView.qml +++ b/tests/qml/src/tst_WizardView.qml @@ -26,192 +26,194 @@ import net.jami.Enums 1.1 import "../../../src/app/wizardview" import "../../../src/app/commoncomponents" -WizardView { - id: uut +TestWrapper { + WizardView { + id: uut - width: 400 - height: 600 + width: 400 + height: 600 - function clearSignalSpy() { - spyAccountIsReady.clear() - spyAccountIsRemoved.clear() - spyAccountConfigFinalized.clear() - spyReportFailure.clear() - spyCloseWizardView.clear() + function clearSignalSpy() { + spyAccountIsReady.clear() + spyAccountIsRemoved.clear() + spyAccountConfigFinalized.clear() + spyReportFailure.clear() + spyCloseWizardView.clear() - spyBackButtonVisible.target = undefined - } - - SignalSpy { - id: spyAccountIsReady - - target: WizardViewStepModel - signalName: "accountIsReady" - } - - SignalSpy { - id: spyAccountIsRemoved - - target: AccountAdapter - signalName: "accountRemoved" - } - - SignalSpy { - id: spyAccountStatusChanged - - target: AccountAdapter - signalName: "accountStatusChanged" - } - - SignalSpy { - id: spyAccountConfigFinalized - - target: AccountAdapter - signalName: "accountConfigFinalized" - } - - SignalSpy { - id: spyReportFailure - - target: AccountAdapter - signalName: "reportFailure" - } - - SignalSpy { - id: spyCloseWizardView - - target: WizardViewStepModel - signalName: "closeWizardView" - } - - SignalSpy { - id: spyBackButtonVisible - - signalName: "visibleChanged" - } - - TestCase { - name: "WelcomePage to different account creation page and return back" - when: windowShown - - function test_welcomePageStepInStepOut() { - var controlPanelStackView = findChild(uut, "controlPanelStackView") - - var welcomePage = findChild(uut, "welcomePage") - var createAccountPage = findChild(uut, "createAccountPage") - 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(controlPanelStackView.children[controlPanelStackView.currentIndex], - createAccountPage) - WizardViewStepModel.previousStep() - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - welcomePage) - - // Go to CreateRendezVous page - WizardViewStepModel.startAccountCreationFlow( - WizardViewStepModel.AccountCreationOption.CreateRendezVous) - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - createAccountPage) - WizardViewStepModel.previousStep() - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - welcomePage) - - // Go to CreateRendezVous page - WizardViewStepModel.startAccountCreationFlow( - WizardViewStepModel.AccountCreationOption.ImportFromDevice) - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - importFromDevicePage) - WizardViewStepModel.previousStep() - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - welcomePage) - - // Go to ImportFromBackup page - WizardViewStepModel.startAccountCreationFlow( - WizardViewStepModel.AccountCreationOption.ImportFromBackup) - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - importFromBackupPage) - WizardViewStepModel.previousStep() - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - welcomePage) - - // Go to ConnectToAccountManager page - WizardViewStepModel.startAccountCreationFlow( - WizardViewStepModel.AccountCreationOption.ConnectToAccountManager) - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - connectToAccountManagerPage) - WizardViewStepModel.previousStep() - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - welcomePage) - - // Go to CreateSipAccount page - WizardViewStepModel.startAccountCreationFlow( - WizardViewStepModel.AccountCreationOption.CreateSipAccount) - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - createSIPAccountPage) - WizardViewStepModel.previousStep() - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - welcomePage) + spyBackButtonVisible.target = undefined } - } - TestCase { - name: "Create Sip account ui flow" - when: windowShown + SignalSpy { + id: spyAccountIsReady - function test_createSipAccountUiFlow() { - uut.clearSignalSpy() + target: WizardViewStepModel + signalName: "accountIsReady" + } - var controlPanelStackView = findChild(uut, "controlPanelStackView") + SignalSpy { + id: spyAccountIsRemoved - var welcomePage = findChild(uut, "welcomePage") - var createSIPAccountPage = findChild(uut, "createSIPAccountPage") + target: AccountAdapter + signalName: "accountRemoved" + } - var sipUsernameEdit = findChild(createSIPAccountPage, "sipUsernameEdit") - var sipPasswordEdit = findChild(createSIPAccountPage, "sipPasswordEdit") - var sipServernameEdit = findChild(createSIPAccountPage, "sipServernameEdit") - var createAccountButton = findChild(createSIPAccountPage, "createSIPAccountButton") + SignalSpy { + id: spyAccountStatusChanged - // Go to createSipAccount page - WizardViewStepModel.startAccountCreationFlow( - WizardViewStepModel.AccountCreationOption.CreateSipAccount) + target: AccountAdapter + signalName: "accountStatusChanged" + } - // Set up paras - var userName = "testUserName" - var serverName = "testServerName" - var password = "testPassword" - var proxy = "testProxy" + SignalSpy { + id: spyAccountConfigFinalized - sipUsernameEdit.dynamicText = userName - sipPasswordEdit.dynamicText = password - sipServernameEdit.dynamicText = serverName + target: AccountAdapter + signalName: "accountConfigFinalized" + } - createAccountButton.clicked() + SignalSpy { + id: spyReportFailure - // Wait until the account creation is finished - spyAccountIsReady.wait() - compare(spyAccountIsReady.count, 1) + target: AccountAdapter + signalName: "reportFailure" + } - // Check if paras match with setup - compare(CurrentAccount.username, userName) - compare(CurrentAccount.hostname, serverName) - compare(CurrentAccount.password, password) + SignalSpy { + id: spyCloseWizardView - WizardViewStepModel.nextStep() + target: WizardViewStepModel + signalName: "closeWizardView" + } - spyCloseWizardView.wait() - compare(spyCloseWizardView.count, 1) + SignalSpy { + id: spyBackButtonVisible - AccountAdapter.deleteCurrentAccount() + signalName: "visibleChanged" + } - // Wait until the account removal is finished - spyAccountIsRemoved.wait() - compare(spyAccountIsRemoved.count, 1) + TestCase { + name: "WelcomePage to different account creation page and return back" + when: windowShown + + function test_welcomePageStepInStepOut() { + var controlPanelStackView = findChild(uut, "controlPanelStackView") + + var welcomePage = findChild(uut, "welcomePage") + var createAccountPage = findChild(uut, "createAccountPage") + 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(controlPanelStackView.children[controlPanelStackView.currentIndex], + createAccountPage) + WizardViewStepModel.previousStep() + compare(controlPanelStackView.children[controlPanelStackView.currentIndex], + welcomePage) + + // Go to CreateRendezVous page + WizardViewStepModel.startAccountCreationFlow( + WizardViewStepModel.AccountCreationOption.CreateRendezVous) + compare(controlPanelStackView.children[controlPanelStackView.currentIndex], + createAccountPage) + WizardViewStepModel.previousStep() + compare(controlPanelStackView.children[controlPanelStackView.currentIndex], + welcomePage) + + // Go to CreateRendezVous page + WizardViewStepModel.startAccountCreationFlow( + WizardViewStepModel.AccountCreationOption.ImportFromDevice) + compare(controlPanelStackView.children[controlPanelStackView.currentIndex], + importFromDevicePage) + WizardViewStepModel.previousStep() + compare(controlPanelStackView.children[controlPanelStackView.currentIndex], + welcomePage) + + // Go to ImportFromBackup page + WizardViewStepModel.startAccountCreationFlow( + WizardViewStepModel.AccountCreationOption.ImportFromBackup) + compare(controlPanelStackView.children[controlPanelStackView.currentIndex], + importFromBackupPage) + WizardViewStepModel.previousStep() + compare(controlPanelStackView.children[controlPanelStackView.currentIndex], + welcomePage) + + // Go to ConnectToAccountManager page + WizardViewStepModel.startAccountCreationFlow( + WizardViewStepModel.AccountCreationOption.ConnectToAccountManager) + compare(controlPanelStackView.children[controlPanelStackView.currentIndex], + connectToAccountManagerPage) + WizardViewStepModel.previousStep() + compare(controlPanelStackView.children[controlPanelStackView.currentIndex], + welcomePage) + + // 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" + when: windowShown + + function test_createSipAccountUiFlow() { + uut.clearSignalSpy() + + var controlPanelStackView = findChild(uut, "controlPanelStackView") + + 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 createAccountButton = findChild(createSIPAccountPage, "createSIPAccountButton") + + // Go to createSipAccount page + WizardViewStepModel.startAccountCreationFlow( + WizardViewStepModel.AccountCreationOption.CreateSipAccount) + + // Set up paras + var userName = "testUserName" + var serverName = "testServerName" + var password = "testPassword" + var proxy = "testProxy" + + sipUsernameEdit.dynamicText = userName + sipPasswordEdit.dynamicText = password + sipServernameEdit.dynamicText = serverName + + createAccountButton.clicked() + + // Wait until the account creation is finished + spyAccountIsReady.wait() + compare(spyAccountIsReady.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() + + // Wait until the account removal is finished + spyAccountIsRemoved.wait() + compare(spyAccountIsRemoved.count, 1) + } } } }