kernel32: Make CopyFile() call CopyFileEx() instead of the other way around.
[wine] / dlls / shell32 / tests / systray.c
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 #define _WIN32_IE 0x600
20 #include <stdarg.h>
21
22 #include <windows.h>
23
24 #include "wine/test.h"
25
26
27 static HWND hMainWnd;
28 static BOOL (WINAPI *pShell_NotifyIconW)(DWORD,PNOTIFYICONDATAW);
29
30 static void test_cbsize(void)
31 {
32     NOTIFYICONDATAA nidA;
33     BOOL ret;
34
35     if (pShell_NotifyIconW)
36     {
37         NOTIFYICONDATAW nidW;
38
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         ret = pShell_NotifyIconW(NIM_ADD, &nidW);
47         /* using an invalid cbSize does work */
48         nidW.cbSize = 3;
49         nidW.hWnd = hMainWnd;
50         nidW.uID = 1;
51         ret = pShell_NotifyIconW(NIM_DELETE, &nidW);
52         ok( ret || broken(!ret), /* nt4 */ "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) != !ret, "The icon was not deleted\n");
56     }
57
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");
67
68     /* using an invalid cbSize does work */
69     nidA.cbSize = 3;
70     nidA.hWnd = hMainWnd;
71     nidA.uID = 1;
72     ret = Shell_NotifyIconA(NIM_DELETE, &nidA);
73     ok(ret, "NIM_DELETE failed!\n");
74     /* as icon doesn't exist anymore - now there will be an error */
75     nidA.cbSize = sizeof(nidA);
76     ok(!Shell_NotifyIconA(NIM_DELETE, &nidA) != !ret, "The icon was not deleted\n");
77 }
78
79 START_TEST(systray)
80 {
81     WNDCLASSA wc;
82     MSG msg;
83     RECT rc;
84     HMODULE hshell32;
85
86     hshell32 = GetModuleHandleA("shell32.dll");
87     pShell_NotifyIconW = (void*)GetProcAddress(hshell32, "Shell_NotifyIconW");
88
89     wc.style = CS_HREDRAW | CS_VREDRAW;
90     wc.cbClsExtra = 0;
91     wc.cbWndExtra = 0;
92     wc.hInstance = GetModuleHandleA(NULL);
93     wc.hIcon = NULL;
94     wc.hCursor = LoadCursorA(NULL, IDC_IBEAM);
95     wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
96     wc.lpszMenuName = NULL;
97     wc.lpszClassName = "MyTestWnd";
98     wc.lpfnWndProc = DefWindowProc;
99     RegisterClassA(&wc);
100
101     hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
102       CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
103     GetClientRect(hMainWnd, &rc);
104     ShowWindow(hMainWnd, SW_SHOW);
105
106     test_cbsize();
107
108     PostQuitMessage(0);
109     while(GetMessageA(&msg,0,0,0)) {
110         TranslateMessage(&msg);
111         DispatchMessageA(&msg);
112     }
113     DestroyWindow(hMainWnd);
114 }