From 3df9f46ab4a2e260f4c09e9488ea1f8d93d75e29 Mon Sep 17 00:00:00 2001 From: Nick Logozzo Date: Tue, 11 Jun 2024 01:36:28 -0400 Subject: [PATCH] Tests - Code Cleanup (Might break...) --- tests/auratests.cpp | 9 ++------- tests/ipctests.cpp | 17 +++++++++-------- tests/main.cpp | 3 +++ tests/notifyicontests.cpp | 7 +------ 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/tests/auratests.cpp b/tests/auratests.cpp index d50ae1a..d3706d1 100644 --- a/tests/auratests.cpp +++ b/tests/auratests.cpp @@ -1,5 +1,6 @@ #include #include "app/aura.h" +#include "app/configurationbase.h" #include "app/windowgeometry.h" #include "filesystem/userdirectories.h" #include "notifications/shellnotification.h" @@ -58,12 +59,6 @@ class AuraTest : public testing::Test { public: static void SetUpTestSuite() - { - Aura::getActive().init("org.nickvision.aura.test", "Nickvision Aura Tests", "Aura"); - Aura::getActive().getAppInfo().setHtmlDocsStore("https://github.com/NickvisionApps/Denaro/blob/main/NickvisionMoney.Shared/Docs/html"); - } - - static void TearDownTestSuite() { std::filesystem::remove(UserDirectories::getApplicationConfig() / ("config.json")); } @@ -119,7 +114,7 @@ TEST_F(AuraTest, DependencyCheck) ASSERT_TRUE(std::filesystem::exists(dependency)); ShellNotificationSentEventArgs args{ "Dependency Found!", dependency.string(), NotificationSeverity::Success, "open", dependency.string() }; #ifdef _WIN32 - if (Environment::getVariable("GITHUB_ACTIONS").empty() && GetConsoleWindow()) + if (GetConsoleWindow()) { ASSERT_NO_THROW(ShellNotification::send(args, GetConsoleWindow())); } diff --git a/tests/ipctests.cpp b/tests/ipctests.cpp index 5e39054..f01caa6 100644 --- a/tests/ipctests.cpp +++ b/tests/ipctests.cpp @@ -15,8 +15,12 @@ class IPCTest : public testing::Test public: static void SetUpTestSuite() { - Aura::getActive().init("org.nickvision.aura.test", "Nickvision Aura Tests", "Aura Tests"); - Aura::getActive().getIPC().commandReceived() += onCommandReceived; + m_handlerId = Aura::getActive().getIPC().commandReceived() += onCommandReceived; + } + + static void TearDownTestSuite() + { + Aura::getActive().getIPC().commandReceived() -= m_handlerId; } static int getReceived() @@ -28,6 +32,7 @@ class IPCTest : public testing::Test private: static std::mutex m_mutex; static int m_received; + static HandlerId m_handlerId; static void onCommandReceived(const ParamEventArgs>& e) { @@ -38,6 +43,7 @@ class IPCTest : public testing::Test std::mutex IPCTest::m_mutex = {}; int IPCTest::m_received = 0; +HandlerId IPCTest::m_handlerId = 0; TEST_F(IPCTest, CheckServerStatus) { @@ -46,11 +52,6 @@ TEST_F(IPCTest, CheckServerStatus) TEST_F(IPCTest, Client1Send) { - if (!Environment::getVariable("GITHUB_ACTIONS").empty()) - { - ASSERT_TRUE(true); - return; - } InterProcessCommunicator client{ Aura::getActive().getAppInfo().getId() }; ASSERT_TRUE(client.isClient()); ASSERT_TRUE(client.communicate(args)); @@ -59,5 +60,5 @@ TEST_F(IPCTest, Client1Send) TEST_F(IPCTest, CheckServerReceived) { std::this_thread::sleep_for(std::chrono::seconds(5)); - ASSERT_TRUE(getReceived() > 0 || !Environment::getVariable("GITHUB_ACTIONS").empty()); + ASSERT_TRUE(getReceived() > 0); } \ No newline at end of file diff --git a/tests/main.cpp b/tests/main.cpp index 0be3c90..c738784 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,7 +1,10 @@ #include +#include "app/aura.h" int main(int argc, char* argv[]) { + Nickvision::App::Aura::getActive().init("org.nickvision.aura.test", "Nickvision Aura Tests", "Aura"); + Nickvision::App::Aura::getActive().getAppInfo().setHtmlDocsStore("https://github.com/NickvisionApps/Denaro/blob/main/NickvisionMoney.Shared/Docs/html"); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/notifyicontests.cpp b/tests/notifyicontests.cpp index 4b6a9f7..75d7314 100644 --- a/tests/notifyicontests.cpp +++ b/tests/notifyicontests.cpp @@ -15,18 +15,13 @@ class NotifyIconTest : public testing::Test { public: static std::unique_ptr m_notifyIcon; - - static void SetUpTestSuite() - { - Aura::getActive().init("org.nickvision.aura.test", "Nickvision Aura Tests", "Aura Tests"); - } }; std::unique_ptr NotifyIconTest::m_notifyIcon = nullptr; TEST_F(NotifyIconTest, CreateIcon) { - if (Environment::getVariable("GITHUB_ACTIONS").empty() && GetConsoleWindow()) + if (GetConsoleWindow()) { bool waiting{ true }; NotifyIconMenu contextMenu;