Skip to content

Commit

Permalink
App - Fix Linux Build
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Jun 15, 2024
1 parent 413709f commit 2a38c34
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 57 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ if (BUILD_TESTING)
"tests/loggingtests.cpp"
"tests/main.cpp"
"tests/networktests.cpp"
"tests/notifyicontests.cpp"
"tests/passwordtests.cpp"
"tests/storetests.cpp"
"tests/stringtests.cpp"
Expand Down
5 changes: 2 additions & 3 deletions src/app/aura.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ using namespace Nickvision::Filesystem;
using namespace Nickvision::Helpers;
using namespace Nickvision::Localization;
using namespace Nickvision::Logging;
using namespace Nickvision::Notifications;
using namespace Nickvision::System;

namespace Nickvision::App
Expand Down Expand Up @@ -217,11 +216,11 @@ namespace Nickvision::App
}

#ifdef _WIN32
NotifyIcon& Aura::getNotifyIcon(HWND hwnd)
Notifications::NotifyIcon& Aura::getNotifyIcon(HWND hwnd)
{
if (!m_notifyIcon)
{
m_notifyIcon = std::make_unique<NotifyIcon>(hwnd, StringHelpers::wstr(m_appInfo.getName()), NotifyIconMenu(), true);
m_notifyIcon = std::make_unique<Notifications::NotifyIcon>(hwnd, StringHelpers::wstr(m_appInfo.getName()), Notifications::NotifyIconMenu{}, true);
}
return *m_notifyIcon;
}
Expand Down
45 changes: 45 additions & 0 deletions tests/auratests.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <gtest/gtest.h>
#include <thread>
#include "app/aura.h"
#include "app/configurationbase.h"
#include "app/windowgeometry.h"
#include "filesystem/userdirectories.h"
#include "notifications/notifyicon.h"
#include "notifications/notifyiconmenu.h"
#include "notifications/shellnotification.h"
#include "system/environment.h"

Expand Down Expand Up @@ -142,3 +145,45 @@ TEST_F(AuraTest, HelpUrlChecks)
ASSERT_EQ(Aura::getActive().getHelpUrl("index"), "help:aura/index");
#endif
}

#ifdef _WIN32
TEST_F(AuraTest, NotifyIconContextMenu)
{
if (GetConsoleWindow())
{
bool waiting{ true };
NotifyIconMenu contextMenu;
contextMenu.addAction("Continue", [&waiting]()
{
waiting = false;
});
contextMenu.addSeparator();
contextMenu.addAction("PLACEHOLDER", [](){});
NotifyIcon& notifyIcon{ Aura::getActive().getNotifyIcon(GetConsoleWindow()) };
ASSERT_TRUE(notifyIcon.show());
ASSERT_TRUE(notifyIcon.setContextMenu(contextMenu));
std::cout << "Click \"Continue\" via the context menu of the NotifyIcon to continue..." << std::endl;
while (waiting)
{
MSG msg = { };
if(PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE) > 0)
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
ASSERT_TRUE(true);
}

TEST_F(AuraTest, NotifyIconNotify)
{
if (GetConsoleWindow())
{
NotifyIcon& notifyIcon{ Aura::getActive().getNotifyIcon(GetConsoleWindow()) };
ASSERT_NO_THROW(notifyIcon.notify({ "Test", "Hello from Notifications::NotifyIcon::notify()!", NotificationSeverity::Success }));
}
ASSERT_TRUE(true);
}
#endif
53 changes: 0 additions & 53 deletions tests/notifyicontests.cpp

This file was deleted.

0 comments on commit 2a38c34

Please sign in to comment.