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
25 #include "wine/test.h"
29 static BOOL (WINAPI *pShell_NotifyIconW)(DWORD,PNOTIFYICONDATAW);
31 void test_cbsize(void)
35 if (pShell_NotifyIconW)
39 ZeroMemory(&nidW, sizeof(nidW));
40 nidW.cbSize = NOTIFYICONDATAW_V1_SIZE;
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 */
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;
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 */
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 static void test_SHAppBarMessage(void)
84 memset(&abd, 0xcc, sizeof(abd));
85 abd.cbSize = sizeof(abd);
86 abd.uEdge = ABE_BOTTOM;
88 hwnd = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
89 ok(hwnd == NULL || IsWindow(hwnd), "ret %p which is not a window\n", hwnd);
90 ok(abd.hWnd == (HWND)0xcccccccc, "hWnd overwritten\n");
92 /* Presumably one can pass a hwnd with ABM_GETAUTOHIDEBAR to specify a monitor.
93 Pass the foreground window and check */
94 foregnd = GetForegroundWindow();
98 hwnd = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
99 ok(hwnd == NULL || IsWindow(hwnd), "ret %p which is not a window\n", hwnd);
100 ok(abd.hWnd == foregnd, "hWnd overwritten\n");
103 HMONITOR appbar_mon, foregnd_mon;
104 appbar_mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
105 foregnd_mon = MonitorFromWindow(foregnd, MONITOR_DEFAULTTONEAREST);
106 ok(appbar_mon == foregnd_mon, "Windows on different monitors\n");
110 memset(&abd, 0xcc, sizeof(abd));
111 abd.cbSize = sizeof(abd);
112 ret = SHAppBarMessage(ABM_GETTASKBARPOS, &abd);
115 ok(abd.hWnd == (HWND)0xcccccccc, "hWnd overwritten\n");
118 ok(abd.uEdge >= ABE_LEFT && abd.uEdge <= ABE_BOTTOM, "uEdge not returned\n");
119 ok(abd.rc.left != 0xcccccccc, "rc not updated\n");
133 hdll = GetModuleHandleA("shell32.dll");
134 pShell_NotifyIconW = (void*)GetProcAddress(hdll, "Shell_NotifyIconW");
136 wc.style = CS_HREDRAW | CS_VREDRAW;
139 wc.hInstance = GetModuleHandleA(NULL);
141 wc.hCursor = LoadCursorA(NULL, IDC_IBEAM);
142 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
143 wc.lpszMenuName = NULL;
144 wc.lpszClassName = "MyTestWnd";
145 wc.lpfnWndProc = DefWindowProc;
148 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
149 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
150 GetClientRect(hMainWnd, &rc);
151 ShowWindow(hMainWnd, SW_SHOW);
156 while(GetMessageA(&msg,0,0,0)) {
157 TranslateMessage(&msg);
158 DispatchMessageA(&msg);
160 DestroyWindow(hMainWnd);
162 test_SHAppBarMessage();