wined3d: Clear the renderbuffer IDs on unload.
[wine.git] / dlls / shell32 / tests / systray.c
blob0d815a6011e12dce629384a5d516455cd1651d4c
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 <stdarg.h>
22 #include <windows.h>
23 #include "shellapi.h"
25 #include "wine/test.h"
28 static HWND hMainWnd;
29 static BOOL (WINAPI *pShell_NotifyIconW)(DWORD,PNOTIFYICONDATAW);
31 static void test_cbsize(void)
33 NOTIFYICONDATAA nidA;
34 BOOL ret;
36 if (pShell_NotifyIconW)
38 NOTIFYICONDATAW nidW;
40 ZeroMemory(&nidW, sizeof(nidW));
41 nidW.cbSize = NOTIFYICONDATAW_V1_SIZE;
42 nidW.hWnd = hMainWnd;
43 nidW.uID = 1;
44 nidW.uFlags = NIF_ICON|NIF_MESSAGE;
45 nidW.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION);
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");
60 /* same for Shell_NotifyIconA */
61 ZeroMemory(&nidA, sizeof(nidA));
62 nidA.cbSize = NOTIFYICONDATAA_V1_SIZE;
63 nidA.hWnd = hMainWnd;
64 nidA.uID = 1;
65 nidA.uFlags = NIF_ICON|NIF_MESSAGE;
66 nidA.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION);
67 nidA.uCallbackMessage = WM_USER+17;
68 ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n");
70 /* using an invalid cbSize does work */
71 nidA.cbSize = 3;
72 nidA.hWnd = hMainWnd;
73 nidA.uID = 1;
74 ret = Shell_NotifyIconA(NIM_DELETE, &nidA);
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");
81 START_TEST(systray)
83 WNDCLASSA wc;
84 MSG msg;
85 RECT rc;
86 HMODULE hshell32;
88 hshell32 = GetModuleHandleA("shell32.dll");
89 pShell_NotifyIconW = (void*)GetProcAddress(hshell32, "Shell_NotifyIconW");
91 wc.style = CS_HREDRAW | CS_VREDRAW;
92 wc.cbClsExtra = 0;
93 wc.cbWndExtra = 0;
94 wc.hInstance = GetModuleHandleA(NULL);
95 wc.hIcon = NULL;
96 wc.hCursor = LoadCursorA(NULL, (LPSTR)IDC_IBEAM);
97 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
98 wc.lpszMenuName = NULL;
99 wc.lpszClassName = "MyTestWnd";
100 wc.lpfnWndProc = DefWindowProcA;
101 RegisterClassA(&wc);
103 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
104 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
105 GetClientRect(hMainWnd, &rc);
106 ShowWindow(hMainWnd, SW_SHOW);
108 test_cbsize();
110 PostQuitMessage(0);
111 while(GetMessageA(&msg,0,0,0)) {
112 TranslateMessage(&msg);
113 DispatchMessageA(&msg);
115 DestroyWindow(hMainWnd);