|
7 | 7 |
|
8 | 8 | #if defined(_WIN32) || defined(_WIN64) |
9 | 9 | #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 |
10 | 14 | #define TRAY_WINAPI 1 |
11 | 15 | #elif defined(__linux__) || defined(linux) || defined(__linux) |
12 | 16 | #define TRAY_APPINDICATOR 1 |
@@ -276,6 +280,14 @@ TEST_F(TrayTest, TestSubmenuCallback) { |
276 | 280 | TEST_F(TrayTest, TestNotificationDisplay) { |
277 | 281 | #if !(defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) |
278 | 282 | 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(¬ification_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 | + } |
279 | 291 | #endif |
280 | 292 |
|
281 | 293 | int initResult = tray_init(&testTray); |
@@ -304,6 +316,14 @@ TEST_F(TrayTest, TestNotificationCallback) { |
304 | 316 | GTEST_SKIP() << "Notifications only supported on desktop platforms"; |
305 | 317 | #endif |
306 | 318 |
|
| 319 | +#if defined(_WIN32) |
| 320 | + QUERY_USER_NOTIFICATION_STATE notification_state; |
| 321 | + HRESULT ns = SHQueryUserNotificationState(¬ification_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 | + |
307 | 327 | static bool callbackInvoked = false; |
308 | 328 | auto notification_callback = []() { |
309 | 329 | callbackInvoked = true; |
|
0 commit comments