From b34f5d072f44776ae6af54aaa7c4d65a0cca1b20 Mon Sep 17 00:00:00 2001 From: Xavier Michelon Date: Tue, 31 Oct 2023 18:19:44 +0100 Subject: [PATCH] feat(GODT-3046): added addressChanged and addressChangedLogout to gui-tester. --- .../bridge-gui-tester/GRPCService.cpp | 2 +- .../bridge-gui-tester/Tabs/SettingsTab.cpp | 29 ++++--- .../bridge-gui-tester/Tabs/SettingsTab.h | 8 +- .../bridge-gui-tester/Tabs/SettingsTab.ui | 81 ++++++++++++++----- 4 files changed, 86 insertions(+), 34 deletions(-) diff --git a/internal/frontend/bridge-gui/bridge-gui-tester/GRPCService.cpp b/internal/frontend/bridge-gui/bridge-gui-tester/GRPCService.cpp index ac171993..b5c077cc 100644 --- a/internal/frontend/bridge-gui/bridge-gui-tester/GRPCService.cpp +++ b/internal/frontend/bridge-gui/bridge-gui-tester/GRPCService.cpp @@ -786,7 +786,7 @@ Status GRPCService::InstallTLSCertificate(ServerContext *, Empty const *, Empty app().log().debug(__FUNCTION__); SPStreamEvent event; qtProxy_.installTLSCertificate(); - switch (app().mainWindow().settingsTab().nextTLSCertIntallResult()) { + switch (app().mainWindow().settingsTab().nextTLSCertInstallResult()) { case SettingsTab::TLSCertInstallResult::Success: event = newCertificateInstallSuccessEvent(); break; diff --git a/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.cpp b/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.cpp index 1399b8b8..b4e3bbda 100644 --- a/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.cpp +++ b/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.cpp @@ -31,6 +31,18 @@ QString const colorSchemeLight = "light"; ///< THe light color scheme name. } +//**************************************************************************************************************************************************** +/// \brief Connect an address error button to the generation of an address error event. +/// +/// \param[in] button The error button. +/// \param[in] edit The edit containing the address. +/// \param[in] eventGenerator The factory function creating the event. +//**************************************************************************************************************************************************** +void connectAddressError(QPushButton *button, QLineEdit* edit, bridgepp::SPStreamEvent (*eventGenerator)(QString const &)) { + QObject::connect(button, &QPushButton::clicked, [edit, eventGenerator]() { app().grpc().sendEvent(eventGenerator(edit->text())); }); +} + + //**************************************************************************************************************************************************** /// \param[in] parent The parent widget of the tab. //**************************************************************************************************************************************************** @@ -50,10 +62,9 @@ SettingsTab::SettingsTab(QWidget *parent) app().grpc().sendEvent( newDiskCacheErrorEvent(grpc::DiskCacheErrorType::DISK_FULL_ERROR)); }); - connect(ui_.buttonNoActiveKeyForRecipient, &QPushButton::clicked, [&]() { - app().grpc().sendEvent( - newNoActiveKeyForRecipientEvent(ui_.editNoActiveKeyForRecipient->text())); - }); + connectAddressError(ui_.buttonNoActiveKeyForRecipient, ui_.editAddressErrors, newNoActiveKeyForRecipientEvent); + connectAddressError(ui_.buttonAddressChanged, ui_.editAddressErrors, newAddressChangedEvent); + connectAddressError(ui_.buttonAddressChangedLogout, ui_.editAddressErrors, newAddressChangedLogoutEvent); connect(ui_.checkNextCacheChangeWillSucceed, &QCheckBox::toggled, this, &SettingsTab::updateGUIState); connect(ui_.buttonUpdateError, &QPushButton::clicked, [&]() { app().grpc().sendEvent(newUpdateErrorEvent(static_cast(ui_.comboUpdateError->currentIndex()))); @@ -154,7 +165,7 @@ bool SettingsTab::showSplashScreen() const { //**************************************************************************************************************************************************** -/// \return true iff autosart is on. +/// \return true iff autostart is on. //**************************************************************************************************************************************************** bool SettingsTab::isAutostartOn() const { return ui_.checkAutostart->isChecked(); @@ -305,7 +316,7 @@ void SettingsTab::setBugReport(QString const &osType, QString const &osVersion, //**************************************************************************************************************************************************** void SettingsTab::installTLSCertificate() { ui_.labelLastTLSCertInstall->setText(QString("Last install: %1").arg(QDateTime::currentDateTime().toString(Qt::ISODateWithMs))); - ui_.checkTLSCertIsInstalled->setChecked(this->nextTLSCertIntallResult() == TLSCertInstallResult::Success); + ui_.checkTLSCertIsInstalled->setChecked(this->nextTLSCertInstallResult() == TLSCertInstallResult::Success); } @@ -313,9 +324,7 @@ void SettingsTab::installTLSCertificate() { /// \param[in] folderPath The folder path. //**************************************************************************************************************************************************** void SettingsTab::exportTLSCertificates(QString const &folderPath) { - ui_.labeLastTLSCertExport->setText(QString("%1 Export to %2") - .arg(QDateTime::currentDateTime().toString(Qt::ISODateWithMs)) - .arg(folderPath)); + ui_.labeLastTLSCertExport->setText(QString("%1 Export to %2").arg(QDateTime::currentDateTime().toString(Qt::ISODateWithMs),folderPath)); } @@ -338,7 +347,7 @@ bool SettingsTab::isTLSCertificateInstalled() const { //**************************************************************************************************************************************************** /// \return The value for the 'Next TLS cert install result'. //**************************************************************************************************************************************************** -SettingsTab::TLSCertInstallResult SettingsTab::nextTLSCertIntallResult() const { +SettingsTab::TLSCertInstallResult SettingsTab::nextTLSCertInstallResult() const { return TLSCertInstallResult(ui_.comboNextTLSCertInstallResult->currentIndex()); } diff --git a/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.h b/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.h index 8412082d..af8e5b6b 100644 --- a/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.h +++ b/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.h @@ -33,13 +33,13 @@ public: // data types. Success = 0, Canceled = 1, Failure = 2 - }; ///< Enumberation for the result of a TLS certificate installation. + }; ///< Enumeration for the result of a TLS certificate installation. public: // member functions. explicit SettingsTab(QWidget *parent = nullptr); ///< Default constructor. SettingsTab(SettingsTab const &) = delete; ///< Disabled copy-constructor. SettingsTab(SettingsTab &&) = delete; ///< Disabled assignment copy-constructor. - ~SettingsTab() = default; ///< Destructor. + ~SettingsTab() override = default; ///< Destructor. SettingsTab &operator=(SettingsTab const &) = delete; ///< Disabled assignment operator. SettingsTab &operator=(SettingsTab &&) = delete; ///< Disabled move assignment operator. @@ -62,7 +62,7 @@ public: // member functions. QString landingPageLink() const; ///< Get the content of the 'Landing Page Link' edit. bool nextBugReportWillSucceed() const; ///< Get the status of the 'Next Bug Report Will Fail' check box. bool isTLSCertificateInstalled() const; ///< Get the status of the 'TLS Certificate is installed' check box. - TLSCertInstallResult nextTLSCertIntallResult() const; ///< Get the value of the 'Next TLS Certificate install result' combo box. + TLSCertInstallResult nextTLSCertInstallResult() const; ///< Get the value of the 'Next TLS Certificate install result' combo box. bool nextTLSCertExportWillSucceed() const; ///< Get the status of the 'Next TLS Cert export will succeed' check box. bool nextTLSKeyExportWillSucceed() const; ///< Get the status of the 'Next TLS Key export will succeed' check box. QString hostname() const; ///< Get the value of the 'Hostname' edit. @@ -99,7 +99,7 @@ private: // member functions. void resetUI(); ///< Reset the widget. private: // data members. - Ui::SettingsTab ui_; ///< The GUI for the tab + Ui::SettingsTab ui_ {}; ///< The GUI for the tab }; diff --git a/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.ui b/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.ui index 916bb40a..b9ba18c6 100644 --- a/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.ui +++ b/internal/frontend/bridge-gui/bridge-gui-tester/Tabs/SettingsTab.ui @@ -6,8 +6,8 @@ 0 0 - 1131 - 762 + 1212 + 857 @@ -778,6 +778,9 @@ ms + + -1 + 3600000 @@ -785,7 +788,7 @@ 100 - 1000 + 0 @@ -868,22 +871,62 @@ - - - - - No Active Key For Recipient - - - - - - - dummy.user@proton.me - - - - + + + + 0 + 0 + + + + Address related errors + + + + + + + + Address + + + + + + + dummy.user@proton.me + + + + + + + + + + + Address Changed + + + + + + + Address Changed Logout + + + + + + + No Active Key For Recipient + + + + + + +