wined3d: Get rid of wined3d_buffer_get_desc().
[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 <assert.h>
21 #include <stdarg.h>
22
23 #include <windows.h>
24
25 #include "wine/test.h"
26
27
28 static HWND hMainWnd;
29 static BOOL (WINAPI *pShell_NotifyIconW)(DWORD,PNOTIFYICONDATAW);
30
31 static 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));
41         nidW.cbSize = NOTIFYICONDATAW_V1_SIZE;
42         nidW.hWnd = hMainWnd;
43         nidW.uID = 1;
44         nidW.uFlags = NIF_ICON|NIF_MESSAGE;
45         nidW.hIcon = LoadIcon(NULL, IDI_APPLICATION);
46         nidW.uCallbackMessage = WM_USER+17;
47         ret = pShell_NotifyIconW(NIM_ADD, &nidW);
48         /* using an invalid cbSize does work */
49         nidW.cbSize = 3;
50         nidW.hWnd = hMainWnd;
51         nidW.uID = 1;
52         ret = pShell_NotifyIconW(NIM_DELETE, &nidW);
53         ok( ret || broken(!ret), /* nt4 */ "NIM_DELETE failed!\n");
54         /* as icon doesn't exist anymore - now there will be an error */
55         nidW.cbSize = sizeof(nidW);
56         ok(!pShell_NotifyIconW(NIM_DELETE, &nidW) != !ret, "The icon was not deleted\n");
57     }
58
59     /* same for Shell_NotifyIconA */
60     ZeroMemory(&nidA, sizeof(nidA));
61     nidA.cbSize = NOTIFYICONDATAA_V1_SIZE;
62     nidA.hWnd = hMainWnd;
63     nidA.uID = 1;
64     nidA.uFlags = NIF_ICON|NIF_MESSAGE;
65     nidA.hIcon = LoadIcon(NULL, IDI_APPLICATION);
66     nidA.uCallbackMessage = WM_USER+17;
67     ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n");
68
69     /* using an invalid cbSize does work */
70     nidA.cbSize = 3;
71     nidA.hWnd = hMainWnd;
72     nidA.uID = 1;
73     ret = Shell_NotifyIconA(NIM_DELETE, &nidA);
74     ok(ret, "NIM_DELETE failed!\n");
75     /* as icon doesn't exist anymore - now there will be an error */
76     nidA.cbSize = sizeof(nidA);
77     ok(!Shell_NotifyIconA(NIM_DELETE, &nidA) != !ret, "The icon was not deleted\n");
78 }
79
80 START_TEST(systray)
81 {
82     WNDCLASSA wc;
83     MSG msg;
84     RECT rc;
85     HMODULE hshell32;
86
87     hshell32 = GetModuleHandleA("shell32.dll");
88     pShell_NotifyIconW = (void*)GetProcAddress(hshell32, "Shell_NotifyIconW");
89
90     wc.style = CS_HREDRAW | CS_VREDRAW;
91     wc.cbClsExtra = 0;
92     wc.cbWndExtra = 0;
93     wc.hInstance = GetModuleHandleA(NULL);
94     wc.hIcon = NULL;
95     wc.hCursor = LoadCursorA(NULL, IDC_IBEAM);
96     wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
97     wc.lpszMenuName = NULL;
98     wc.lpszClassName = "MyTestWnd";
99     wc.lpfnWndProc = DefWindowProc;
100     RegisterClassA(&wc);
101
102     hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
103       CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
104     GetClientRect(hMainWnd, &rc);
105     ShowWindow(hMainWnd, SW_SHOW);
106
107     test_cbsize();
108
109     PostQuitMessage(0);
110     while(GetMessageA(&msg,0,0,0)) {
111         TranslateMessage(&msg);
112         DispatchMessageA(&msg);
113     }
114     DestroyWindow(hMainWnd);
115 }