diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 12f0989c3..fec6fdea6 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -28,9 +28,11 @@ file( sources src/*.cpp src/*.h + src/dialogs/*.h + src/dialogs/*.cpp src/validators/* src/widgets/*) -file(GLOB ui_files src/*.ui) +file(GLOB ui_files src/*.ui src/dialogs/*.ui) if(WIN32) set(rc_files ${res_dir}/win/app.rc ${PROJECT_BINARY_DIR}/src/version.rc) diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 0b36f83ca..8f9565fb5 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -21,12 +21,12 @@ #include "ServerConfigDialog.h" #include "common/constants.h" +#include "dialogs/AboutDialog.h" #include "gui/Logger.h" #include "gui/config/ConfigScopes.h" #include "gui/constants.h" #include "gui/core/CoreProcess.h" #include "gui/diagnostic.h" -#include "gui/dialogs/AboutDialog.h" #include "gui/dialogs/SettingsDialog.h" #include "gui/messages.h" #include "gui/string_utils.h" diff --git a/src/lib/gui/dialogs/AboutDialog.cpp b/src/gui/src/dialogs/AboutDialog.cpp similarity index 100% rename from src/lib/gui/dialogs/AboutDialog.cpp rename to src/gui/src/dialogs/AboutDialog.cpp diff --git a/src/lib/gui/dialogs/AboutDialog.h b/src/gui/src/dialogs/AboutDialog.h similarity index 100% rename from src/lib/gui/dialogs/AboutDialog.h rename to src/gui/src/dialogs/AboutDialog.h diff --git a/src/lib/gui/dialogs/AboutDialogBase.ui b/src/gui/src/dialogs/AboutDialogBase.ui similarity index 100% rename from src/lib/gui/dialogs/AboutDialogBase.ui rename to src/gui/src/dialogs/AboutDialogBase.ui diff --git a/src/test/unittests/gui/dialogs/AboutDialogTests.cpp b/src/test/unittests/gui/dialogs/AboutDialogTests.cpp deleted file mode 100644 index e9d75baed..000000000 --- a/src/test/unittests/gui/dialogs/AboutDialogTests.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * Copyright (C) 2024 Symless Ltd. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package 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 . - */ - -// `TestQtFullApp` freezes on Windows CI, so exclude this test for now. -#ifndef WIN32 - -#include "common/copyright.h" -#include "gui/dialogs/AboutDialog.h" -#include "shared/gui/TestQtFullApp.h" - -#include -#include -#include -#include - -using namespace testing; - -namespace { - -class DepsMock : public AboutDialog::Deps -{ -public: - MOCK_METHOD(bool, isDarkMode, (), (const, override)); -}; - -} // namespace - -TEST(AboutDialogTests, exec_setsDevelopersLabel) -{ - TestQtFullApp app; - const auto deps = std::make_shared>(); - AboutDialog aboutDialog(nullptr, deps); - QTimer::singleShot(0, &aboutDialog, &QDialog::accept); - - aboutDialog.exec(); - - const auto label = aboutDialog.findChild("m_pDevelopersLabel"); - EXPECT_TRUE(label->text().contains("Chris Schoeneman")); -} - -TEST(AboutDialogTests, exec_setsCopyrightLabel) -{ - TestQtFullApp app; - const auto deps = std::make_shared>(); - AboutDialog aboutDialog(nullptr, deps); - QTimer::singleShot(0, &aboutDialog, &QDialog::accept); - - aboutDialog.exec(); - - EXPECT_EQ( - aboutDialog.findChild("m_pCopyrightLabel")->text(), QString::fromStdString(deskflow::copyright()) - ); -} - -TEST(AboutDialogTests, exec_inDarkMode_usesDarkLogo) -{ - TestQtFullApp app; - const auto deps = std::make_shared>(); - AboutDialog aboutDialog(nullptr, deps); - QTimer::singleShot(0, &aboutDialog, &QDialog::accept); - EXPECT_CALL(*deps, isDarkMode()).WillOnce(Return(true)); - - aboutDialog.exec(); - - const QPixmap expectedLogo(":/image/logo-dark.png"); - const auto actualLogo = aboutDialog.findChild("m_pLabel_Logo")->pixmap(); - EXPECT_FALSE(actualLogo.isNull()); - EXPECT_EQ(actualLogo.toImage(), expectedLogo.toImage()); -} - -TEST(AboutDialogTests, exec_notInDarkMode_usesLightLogo) -{ - TestQtFullApp app; - const auto deps = std::make_shared>(); - AboutDialog aboutDialog(nullptr, deps); - QTimer::singleShot(0, &aboutDialog, &QDialog::accept); - EXPECT_CALL(*deps, isDarkMode()).WillOnce(Return(false)); - - aboutDialog.exec(); - - const QPixmap expectedLogo(":/image/logo-light.png"); - const auto actualLogo = aboutDialog.findChild("m_pLabel_Logo")->pixmap(); - EXPECT_FALSE(actualLogo.isNull()); - EXPECT_EQ(actualLogo.toImage(), expectedLogo.toImage()); -} - -#endif