Skip to content

Commit 6e6ec72

Browse files
test
1 parent ecb0880 commit 6e6ec72

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/unit/test_tray.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
#if defined(_WIN32) || defined(_WIN64)
99
#include <windows.h>
10+
// clang-format off
11+
// build fails if shellapi.h is included before windows.h
12+
#include <shellapi.h>
13+
// clang-format on
1014
#define TRAY_WINAPI 1
1115
#elif defined(__linux__) || defined(linux) || defined(__linux)
1216
#define TRAY_APPINDICATOR 1
@@ -276,6 +280,14 @@ TEST_F(TrayTest, TestSubmenuCallback) {
276280
TEST_F(TrayTest, TestNotificationDisplay) {
277281
#if !(defined(_WIN32) || defined(__linux__) || defined(__APPLE__))
278282
GTEST_SKIP() << "Notifications only supported on desktop platforms";
283+
#endif
284+
285+
#if defined(_WIN32)
286+
QUERY_USER_NOTIFICATION_STATE notification_state;
287+
HRESULT ns = SHQueryUserNotificationState(&notification_state);
288+
if (ns != S_OK || notification_state != QUNS_ACCEPTS_NOTIFICATIONS) {
289+
GTEST_SKIP() << "Notifications not accepted in this environment. SHQueryUserNotificationState result: " << ns << ", state: " << notification_state;
290+
}
279291
#endif
280292

281293
int initResult = tray_init(&testTray);
@@ -304,6 +316,14 @@ TEST_F(TrayTest, TestNotificationCallback) {
304316
GTEST_SKIP() << "Notifications only supported on desktop platforms";
305317
#endif
306318

319+
#if defined(_WIN32)
320+
QUERY_USER_NOTIFICATION_STATE notification_state;
321+
HRESULT ns = SHQueryUserNotificationState(&notification_state);
322+
if (ns != S_OK || notification_state != QUNS_ACCEPTS_NOTIFICATIONS) {
323+
GTEST_SKIP() << "Notifications not accepted in this environment. SHQueryUserNotificationState result: " << ns << ", state: " << notification_state;
324+
}
325+
#endif
326+
307327
static bool callbackInvoked = false;
308328
auto notification_callback = []() {
309329
callbackInvoked = true;

0 commit comments

Comments
 (0)