ReactOS 0.4.15-dev-8227-g32d615f
systray.c
Go to the documentation of this file.
1/* Unit tests for systray
2 *
3 * Copyright 2007 Mikolaj Zalewski
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include <stdarg.h>
21
22#include <windows.h>
23#include "shellapi.h"
24
25#include "wine/test.h"
26
27
29static BOOL (WINAPI *pShell_NotifyIconW)(DWORD,PNOTIFYICONDATAW);
30
31static void test_cbsize(void)
32{
33 NOTIFYICONDATAA nidA;
34 BOOL ret;
35
36 if (pShell_NotifyIconW)
37 {
38 NOTIFYICONDATAW nidW;
39
40 ZeroMemory(&nidW, sizeof(nidW));
42 nidW.hWnd = hMainWnd;
43 nidW.uID = 1;
46 nidW.uCallbackMessage = WM_USER+17;
47 ret = pShell_NotifyIconW(NIM_ADD, &nidW);
48 ok(ret, "NIM_ADD failed!\n");
49 /* using an invalid cbSize does work */
50 nidW.cbSize = 3;
51 nidW.hWnd = hMainWnd;
52 nidW.uID = 1;
53 ret = pShell_NotifyIconW(NIM_DELETE, &nidW);
54 ok( ret || broken(!ret), /* nt4 */ "NIM_DELETE failed!\n");
55 /* as icon doesn't exist anymore - now there will be an error */
56 nidW.cbSize = sizeof(nidW);
57 ok(!pShell_NotifyIconW(NIM_DELETE, &nidW) != !ret, "The icon was not deleted\n");
58 }
59
60 /* same for Shell_NotifyIconA */
61 ZeroMemory(&nidA, sizeof(nidA));
63 nidA.hWnd = hMainWnd;
64 nidA.uID = 1;
67 nidA.uCallbackMessage = WM_USER+17;
68 ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n");
69
70 /* using an invalid cbSize does work */
71 nidA.cbSize = 3;
72 nidA.hWnd = hMainWnd;
73 nidA.uID = 1;
75 ok(ret, "NIM_DELETE failed!\n");
76 /* as icon doesn't exist anymore - now there will be an error */
77 nidA.cbSize = sizeof(nidA);
78 ok(!Shell_NotifyIconA(NIM_DELETE, &nidA) != !ret, "The icon was not deleted\n");
79}
80
81START_TEST(systray)
82{
83 WNDCLASSA wc;
84 MSG msg;
85 RECT rc;
86 HMODULE hshell32;
87
88 hshell32 = GetModuleHandleA("shell32.dll");
89 pShell_NotifyIconW = (void*)GetProcAddress(hshell32, "Shell_NotifyIconW");
90
92 wc.cbClsExtra = 0;
93 wc.cbWndExtra = 0;
95 wc.hIcon = NULL;
98 wc.lpszMenuName = NULL;
99 wc.lpszClassName = "MyTestWnd";
101 RegisterClassA(&wc);
102
103 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
107
108 test_cbsize();
109
111 while(GetMessageA(&msg,0,0,0)) {
114 }
116}
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
unsigned int BOOL
Definition: ntddk_ex.h:94
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define NOTIFYICONDATAW_V1_SIZE
Definition: shellapi.h:287
#define NOTIFYICONDATAA_V1_SIZE
Definition: shellapi.h:286
#define NIM_DELETE
Definition: shellapi.h:96
#define NIF_ICON
Definition: shellapi.h:106
#define NIF_MESSAGE
Definition: shellapi.h:105
#define NIM_ADD
Definition: shellapi.h:94
UINT uCallbackMessage
Definition: shellapi.h:231
UINT uCallbackMessage
Definition: shellapi.h:261
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
static void test_cbsize(void)
Definition: systray.c:31
static PNOTIFYICONDATAW
Definition: systray.c:29
static HWND hMainWnd
Definition: systray.c:28
BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
Definition: systray.cpp:31
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
int ret
#define ZeroMemory
Definition: winbase.h:1712
#define WINAPI
Definition: msvc.h:6
#define CS_VREDRAW
Definition: winuser.h:658
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define COLOR_WINDOW
Definition: winuser.h:918
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDI_APPLICATION
Definition: winuser.h:704
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2091
#define IDC_IBEAM
Definition: winuser.h:688
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WM_USER
Definition: winuser.h:1895
#define SW_SHOW
Definition: winuser.h:775
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2121
char * LPSTR
Definition: xmlstorage.h:182