Skip to content

Commit

Permalink
Tests - Code Cleanup (Might break...)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Jun 11, 2024
1 parent 524168a commit 3df9f46
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
9 changes: 2 additions & 7 deletions tests/auratests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>
#include "app/aura.h"
#include "app/configurationbase.h"
#include "app/windowgeometry.h"
#include "filesystem/userdirectories.h"
#include "notifications/shellnotification.h"
Expand Down Expand Up @@ -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"));
}
Expand Down Expand Up @@ -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()));
}
Expand Down
17 changes: 9 additions & 8 deletions tests/ipctests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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<std::vector<std::string>>& e)
{
Expand All @@ -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)
{
Expand All @@ -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));
Expand All @@ -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);
}
3 changes: 3 additions & 0 deletions tests/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include <gtest/gtest.h>
#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();
}
7 changes: 1 addition & 6 deletions tests/notifyicontests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@ class NotifyIconTest : public testing::Test
{
public:
static std::unique_ptr<NotifyIcon> m_notifyIcon;

static void SetUpTestSuite()
{
Aura::getActive().init("org.nickvision.aura.test", "Nickvision Aura Tests", "Aura Tests");
}
};

std::unique_ptr<NotifyIcon> NotifyIconTest::m_notifyIcon = nullptr;

TEST_F(NotifyIconTest, CreateIcon)
{
if (Environment::getVariable("GITHUB_ACTIONS").empty() && GetConsoleWindow())
if (GetConsoleWindow())
{
bool waiting{ true };
NotifyIconMenu contextMenu;
Expand Down

0 comments on commit 3df9f46

Please sign in to comment.