push 16813bf814fcb5d03ddef80ecfd11fc0f25812b5
[wine/hacks.git] / dlls / shell32 / tests / systray.c
blob56758068453b811e22817e5ef761604be91da52c
1 /* Unit tests for systray
3 * Copyright 2007 Mikolaj Zalewski
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.
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.
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
19 #define _WIN32_IE 0x600
20 #include <assert.h>
21 #include <stdarg.h>
23 #include <windows.h>
25 #include "wine/test.h"
28 static HWND hMainWnd;
29 static BOOL (WINAPI *pShell_NotifyIconW)(DWORD,PNOTIFYICONDATAW);
31 void test_cbsize(void)
33 NOTIFYICONDATAA nidA;
35 if (pShell_NotifyIconW)
37 NOTIFYICONDATAW nidW;
39 ZeroMemory(&nidW, sizeof(nidW));
40 nidW.cbSize = NOTIFYICONDATAW_V1_SIZE;
41 nidW.hWnd = hMainWnd;
42 nidW.uID = 1;
43 nidW.uFlags = NIF_ICON|NIF_MESSAGE;
44 nidW.hIcon = LoadIcon(NULL, IDI_APPLICATION);
45 nidW.uCallbackMessage = WM_USER+17;
46 ok(pShell_NotifyIconW(NIM_ADD, &nidW), "NIM_ADD failed!\n");
48 /* using an invalid cbSize does work */
49 nidW.cbSize = 3;
50 nidW.hWnd = hMainWnd;
51 nidW.uID = 1;
52 ok(pShell_NotifyIconW(NIM_DELETE, &nidW), "NIM_DELETE failed!\n");
53 /* as icon doesn't exist anymore - now there will be an error */
54 nidW.cbSize = sizeof(nidW);
55 ok(!pShell_NotifyIconW(NIM_DELETE, &nidW), "The icon was not deleted\n");
58 /* same for Shell_NotifyIconA */
59 ZeroMemory(&nidA, sizeof(nidA));
60 nidA.cbSize = NOTIFYICONDATAA_V1_SIZE;
61 nidA.hWnd = hMainWnd;
62 nidA.uID = 1;
63 nidA.uFlags = NIF_ICON|NIF_MESSAGE;
64 nidA.hIcon = LoadIcon(NULL, IDI_APPLICATION);
65 nidA.uCallbackMessage = WM_USER+17;
66 ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n");
68 /* using an invalid cbSize does work */
69 nidA.cbSize = 3;
70 nidA.hWnd = hMainWnd;
71 nidA.uID = 1;
72 ok(Shell_NotifyIconA(NIM_DELETE, &nidA), "NIM_DELETE failed!\n");
73 /* as icon doesn't exist anymore - now there will be an error */
74 nidA.cbSize = sizeof(nidA);
75 ok(!Shell_NotifyIconA(NIM_DELETE, &nidA), "The icon was not deleted\n");
78 START_TEST(systray)
80 WNDCLASSA wc;
81 MSG msg;
82 RECT rc;
83 HMODULE hshell32;
85 hshell32 = GetModuleHandleA("shell32.dll");
86 pShell_NotifyIconW = (void*)GetProcAddress(hshell32, "Shell_NotifyIconW");
88 wc.style = CS_HREDRAW | CS_VREDRAW;
89 wc.cbClsExtra = 0;
90 wc.cbWndExtra = 0;
91 wc.hInstance = GetModuleHandleA(NULL);
92 wc.hIcon = NULL;
93 wc.hCursor = LoadCursorA(NULL, IDC_IBEAM);
94 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
95 wc.lpszMenuName = NULL;
96 wc.lpszClassName = "MyTestWnd";
97 wc.lpfnWndProc = DefWindowProc;
98 RegisterClassA(&wc);
100 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
101 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
102 GetClientRect(hMainWnd, &rc);
103 ShowWindow(hMainWnd, SW_SHOW);
105 test_cbsize();
107 PostQuitMessage(0);
108 while(GetMessageA(&msg,0,0,0)) {
109 TranslateMessage(&msg);
110 DispatchMessageA(&msg);
112 DestroyWindow(hMainWnd);