From 2f4a680ba113f2618a01fd27d1655184cd968fd6 Mon Sep 17 00:00:00 2001 From: Ankur Bavisa Date: Wed, 5 Jul 2023 18:00:23 +0530 Subject: [PATCH] add new unit files with template --- src/gui/folderman.h | 6 +++++ src/gui/folderstatusmodel.h | 2 ++ test/CMakeLists.txt | 18 ++++++++++++++ test/nextcloud_add_test.cmake | 6 ++++- test/testaccountsettings.cpp | 24 ++++++++++++++++++ test/testconfigfile.cpp | 22 +++++++++++++++++ test/testflow2authwidget.cpp | 22 +++++++++++++++++ test/testfolderman.cpp | 5 ++-- test/testfolderstatusdelegate.cpp | 27 ++++++++++++++++++++ test/testfolderstatusmodel.cpp | 34 ++++++++++++++++++++++++++ test/testfolderwizard.cpp | 29 ++++++++++++++++++++++ test/testgeneralsettings.cpp | 29 ++++++++++++++++++++++ test/testheaderbutton.cpp | 28 +++++++++++++++++++++ test/testowncloudadvancedsetuppage.cpp | 24 ++++++++++++++++++ test/testowncloudsetuppage.cpp | 23 +++++++++++++++++ test/testowncloudwizard.cpp | 23 +++++++++++++++++ test/testsettingsdialog.cpp | 25 +++++++++++++++++++ test/testuserline.cpp | 26 ++++++++++++++++++++ test/testusermodel.cpp | 31 +++++++++++++++++++++++ test/testwelcome.cpp | 26 ++++++++++++++++++++ test/testwindow.cpp | 29 ++++++++++++++++++++++ 21 files changed, 455 insertions(+), 4 deletions(-) create mode 100644 test/testaccountsettings.cpp create mode 100644 test/testconfigfile.cpp create mode 100644 test/testflow2authwidget.cpp create mode 100644 test/testfolderstatusdelegate.cpp create mode 100644 test/testfolderstatusmodel.cpp create mode 100644 test/testfolderwizard.cpp create mode 100644 test/testgeneralsettings.cpp create mode 100644 test/testheaderbutton.cpp create mode 100644 test/testowncloudadvancedsetuppage.cpp create mode 100644 test/testowncloudsetuppage.cpp create mode 100644 test/testowncloudwizard.cpp create mode 100644 test/testsettingsdialog.cpp create mode 100644 test/testuserline.cpp create mode 100644 test/testusermodel.cpp create mode 100644 test/testwelcome.cpp create mode 100644 test/testwindow.cpp diff --git a/src/gui/folderman.h b/src/gui/folderman.h index 6c236ce8e8a4b..2e5581165d852 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -31,6 +31,9 @@ class TestShareModel; class ShareTestHelper; class EndToEndTestHelper; class TestSyncConflictsModel; +class TestFolderWizard; +class TestSettingsDialog; +class TestGeneralSettings; namespace OCC { @@ -396,6 +399,9 @@ private slots: friend class ::TestCfApiShellExtensionsIPC; friend class ::ShareTestHelper; friend class ::EndToEndTestHelper; + friend class ::TestFolderWizard; + friend class ::TestSettingsDialog; + friend class ::TestGeneralSettings; }; } // namespace OCC diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h index 96b7467d14ddc..559de31bec173 100644 --- a/src/gui/folderstatusmodel.h +++ b/src/gui/folderstatusmodel.h @@ -23,6 +23,7 @@ #include class QNetworkReply; +class TestFolderStatusModel; namespace OCC { Q_DECLARE_LOGGING_CATEGORY(lcFolderStatus) @@ -153,6 +154,7 @@ private slots: bool _dirty = false; // If the selective sync checkboxes were changed bool _isSyncRunningForAwhile = false; + friend class:: TestFolderStatusModel;// for Unit Test /** * Keeps track of items that are fetching data from the server. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2dbb5a9b7f134..41194c073bdfc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -114,6 +114,24 @@ nextcloud_add_test(RemoteWipe) nextcloud_add_test(OAuth) +nextcloud_add_test(UserModel) +nextcloud_add_test(ConfigFile) +nextcloud_add_test(FolderWizard) +nextcloud_add_test(OwncloudWizard) +nextcloud_add_test(SettingsDialog) +nextcloud_add_test(Flow2AuthWidget) +nextcloud_add_test(AccountSettings) +nextcloud_add_test(GeneralSettings) +nextcloud_add_test(FolderStatusModel) +nextcloud_add_test(OwncloudSetupPage) +nextcloud_add_test(FolderStatusDelegate) +nextcloud_add_test(OwncloudAdvancedSetupPage) + +nextcloud_add_test(Window) +nextcloud_add_test(Welcome) +nextcloud_add_test(UserLine) +nextcloud_add_test(HeaderButton) + configure_file(test_journal.db "${PROJECT_BINARY_DIR}/bin/test_journal.db" COPYONLY) find_package(CMocka) diff --git a/test/nextcloud_add_test.cmake b/test/nextcloud_add_test.cmake index 6bbcdf30f6059..cfceb0141db72 100644 --- a/test/nextcloud_add_test.cmake +++ b/test/nextcloud_add_test.cmake @@ -1,4 +1,6 @@ find_package(Qt5 COMPONENTS Core Test Xml Network Qml Quick REQUIRED) +get_property(nextcloudCoreName TARGET nextcloudCore PROPERTY NAME) +set(nextcloudCoreAutogenInclude ${CMAKE_BINARY_DIR}/src/gui/${nextcloudCoreName}_autogen/include) macro(nextcloud_build_test test_class) set(CMAKE_AUTOMOC TRUE) @@ -32,6 +34,7 @@ macro(nextcloud_build_test test_class) target_include_directories(${OWNCLOUD_TEST_CLASS}Test PRIVATE "${CMAKE_SOURCE_DIR}/test/" + ${nextcloudCoreAutogenInclude} ${CMAKE_SOURCE_DIR}/src/3rdparty/qtokenizer ) set_target_properties(${OWNCLOUD_TEST_CLASS}Test PROPERTIES FOLDER Tests) @@ -81,8 +84,9 @@ macro(nextcloud_add_test test_class) target_include_directories(${OWNCLOUD_TEST_CLASS}Test PRIVATE "${CMAKE_SOURCE_DIR}/test/" + ${nextcloudCoreAutogenInclude} ${CMAKE_SOURCE_DIR}/src/3rdparty/qtokenizer - ) + ) set_target_properties(${OWNCLOUD_TEST_CLASS}Test PROPERTIES FOLDER Tests) endmacro() diff --git a/test/testaccountsettings.cpp b/test/testaccountsettings.cpp new file mode 100644 index 0000000000000..47d668d1194c8 --- /dev/null +++ b/test/testaccountsettings.cpp @@ -0,0 +1,24 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include + +#include "ui_accountsettings.h" +#include "accountsettings.h" + +using namespace OCC; + +class TestAccountSettings: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestAccountSettings) +#include "testaccountsettings.moc" diff --git a/test/testconfigfile.cpp b/test/testconfigfile.cpp new file mode 100644 index 0000000000000..29a8bad63b5d1 --- /dev/null +++ b/test/testconfigfile.cpp @@ -0,0 +1,22 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include +#include "configfile.h" + +using namespace OCC; + +class TestConfigFile: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestConfigFile) +#include "testconfigfile.moc" diff --git a/test/testflow2authwidget.cpp b/test/testflow2authwidget.cpp new file mode 100644 index 0000000000000..eae61547ff5a4 --- /dev/null +++ b/test/testflow2authwidget.cpp @@ -0,0 +1,22 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include +#include "wizard/flow2authwidget.h" + +using namespace OCC; + +class TestFlow2AuthWidget: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestFlow2AuthWidget) +#include "testflow2authwidget.moc" diff --git a/test/testfolderman.cpp b/test/testfolderman.cpp index dfa6873261175..e6a600eae9c7b 100644 --- a/test/testfolderman.cpp +++ b/test/testfolderman.cpp @@ -5,16 +5,15 @@ * */ -#include +#include #include #include -#include "QtTest/qtestcase.h" #include "common/utility.h" #include "folderman.h" #include "account.h" #include "accountstate.h" -#include +#include "accountmanager.h" #include "configfile.h" #include "syncenginetestutils.h" #include "testhelper.h" diff --git a/test/testfolderstatusdelegate.cpp b/test/testfolderstatusdelegate.cpp new file mode 100644 index 0000000000000..dac6113bcda2d --- /dev/null +++ b/test/testfolderstatusdelegate.cpp @@ -0,0 +1,27 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include +#include + +#include "folderstatusmodel.h" +#define private public +#include "folderstatusdelegate.h" +#undef private + +using namespace OCC; + +class TestFolderStatusDelegate: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestFolderStatusDelegate) +#include "testfolderstatusdelegate.moc" diff --git a/test/testfolderstatusmodel.cpp b/test/testfolderstatusmodel.cpp new file mode 100644 index 0000000000000..6c7e9c479e8ca --- /dev/null +++ b/test/testfolderstatusmodel.cpp @@ -0,0 +1,34 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include + +#include "localdiscoverytracker.h" +#include "folderstatusmodel.h" +#include "syncrunfilelog.h" +#include "syncengine.h" +#include "account.h" + +#define private public +#include "accountstate.h" +#include "syncresult.h" +#include "folder.h" +#include "theme.h" +#undef private + +using namespace OCC; + +class TestFolderStatusModel: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_GUILESS_MAIN(TestFolderStatusModel) +#include "testfolderstatusmodel.moc" diff --git a/test/testfolderwizard.cpp b/test/testfolderwizard.cpp new file mode 100644 index 0000000000000..20c245bf0adee --- /dev/null +++ b/test/testfolderwizard.cpp @@ -0,0 +1,29 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include +#include + +#include "creds/abstractcredentials.h" +#include "folderwizard.h" +#include "accountstate.h" +#include "testhelper.h" +#include "folderman.h" +#include "account.h" + +using namespace OCC; + +class TestFolderWizard: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestFolderWizard) +#include "testfolderwizard.moc" diff --git a/test/testgeneralsettings.cpp b/test/testgeneralsettings.cpp new file mode 100644 index 0000000000000..56f8de10aa05d --- /dev/null +++ b/test/testgeneralsettings.cpp @@ -0,0 +1,29 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include + +#include "theme.h" +#include "folderman.h" +#include "configfile.h" +#define private public +#include "generalsettings.h" +#undef private +#include "ui_generalsettings.h" + +using namespace OCC; + +class TestGeneralSettings: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestGeneralSettings) +#include "testgeneralsettings.moc" diff --git a/test/testheaderbutton.cpp b/test/testheaderbutton.cpp new file mode 100644 index 0000000000000..487f7724de5f1 --- /dev/null +++ b/test/testheaderbutton.cpp @@ -0,0 +1,28 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include +#include +#include +#include + +#include "theme.h" + +using namespace OCC; + +class TestHeaderButton: public QObject +{ + Q_OBJECT + +public: + +private slots: + +}; + +QTEST_MAIN(TestHeaderButton) +#include "testheaderbutton.moc" diff --git a/test/testowncloudadvancedsetuppage.cpp b/test/testowncloudadvancedsetuppage.cpp new file mode 100644 index 0000000000000..e072d51189442 --- /dev/null +++ b/test/testowncloudadvancedsetuppage.cpp @@ -0,0 +1,24 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include + +#include "wizard/owncloudadvancedsetuppage.h" +#include "wizard/owncloudwizard.h" + +using namespace OCC; + +class TestOwncloudAdvancedSetupPage: public QWidget +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestOwncloudAdvancedSetupPage) +#include "testowncloudadvancedsetuppage.moc" diff --git a/test/testowncloudsetuppage.cpp b/test/testowncloudsetuppage.cpp new file mode 100644 index 0000000000000..5b08b8741ab3c --- /dev/null +++ b/test/testowncloudsetuppage.cpp @@ -0,0 +1,23 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include + +#include "wizard/owncloudsetuppage.h" + +using namespace OCC; + +class TestOwncloudSetupPage: public QWidget +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestOwncloudSetupPage) +#include "testowncloudsetuppage.moc" diff --git a/test/testowncloudwizard.cpp b/test/testowncloudwizard.cpp new file mode 100644 index 0000000000000..9f0d556e5823f --- /dev/null +++ b/test/testowncloudwizard.cpp @@ -0,0 +1,23 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include + +#include "wizard/owncloudwizard.h" + +using namespace OCC; + +class TestOwncloudWizard: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestOwncloudWizard) +#include "testowncloudwizard.moc" diff --git a/test/testsettingsdialog.cpp b/test/testsettingsdialog.cpp new file mode 100644 index 0000000000000..0314e86955e5c --- /dev/null +++ b/test/testsettingsdialog.cpp @@ -0,0 +1,25 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include +#include + +#include "ui_settingsdialog.h" +#include "settingsdialog.h" + +using namespace OCC; + +class TestSettingsDialog: public QDialog +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestSettingsDialog) +#include "testsettingsdialog.moc" diff --git a/test/testuserline.cpp b/test/testuserline.cpp new file mode 100644 index 0000000000000..e6c90c9a6898e --- /dev/null +++ b/test/testuserline.cpp @@ -0,0 +1,26 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include +#include +#include +#include + +#include "theme.h" + +using namespace OCC; + +class TestUserLine: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestUserLine) +#include "testuserline.moc" diff --git a/test/testusermodel.cpp b/test/testusermodel.cpp new file mode 100644 index 0000000000000..87a0d6eafa2fc --- /dev/null +++ b/test/testusermodel.cpp @@ -0,0 +1,31 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include + +#include "localdiscoverytracker.h" +#include "syncrunfilelog.h" +#include "syncengine.h" +#include "account.h" +#define private public +#include "accountstate.h" +#include "folder.h" +#include "tray/usermodel.h" +#undef private + +using namespace OCC; + +class TestUserModel: public QObject +{ + Q_OBJECT + +private slots: + +}; + +QTEST_MAIN(TestUserModel) +#include "testusermodel.moc" diff --git a/test/testwelcome.cpp b/test/testwelcome.cpp new file mode 100644 index 0000000000000..cb49749d405d9 --- /dev/null +++ b/test/testwelcome.cpp @@ -0,0 +1,26 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include +#include +#include +#include + +#include "theme.h" + +using namespace OCC; + +class TestWelcome: public QObject +{ + Q_OBJECT + +public slots: + +}; + +QTEST_MAIN(TestWelcome) +#include "testwelcome.moc" diff --git a/test/testwindow.cpp b/test/testwindow.cpp new file mode 100644 index 0000000000000..18e059e62cdb5 --- /dev/null +++ b/test/testwindow.cpp @@ -0,0 +1,29 @@ +/* + * This software is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + * + */ + +#include +#include +#include +#include +#include + +#include "tray/usermodel.h" +#include "systray.h" +#include "theme.h" + +using namespace OCC; + +class TestWindow: public QObject +{ + Q_OBJECT + +public: + +}; + +QTEST_MAIN(TestWindow) +#include "testwindow.moc"