ntdll: Added parsing of public key token in manifests.
[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
30 void test_cbsize()
31 {
32     NOTIFYICONDATAW nidW;
33     NOTIFYICONDATAA nidA;
34
35     ZeroMemory(&nidW, sizeof(nidW));
36     nidW.cbSize = NOTIFYICONDATAW_V1_SIZE;
37     nidW.hWnd = hMainWnd;
38     nidW.uID = 1;
39     nidW.uFlags = NIF_ICON|NIF_MESSAGE;
40     nidW.hIcon = LoadIcon(NULL, IDI_APPLICATION);
41     nidW.uCallbackMessage = WM_USER+17;
42     ok(Shell_NotifyIconW(NIM_ADD, &nidW), "NIM_ADD failed!\n");
43
44     /* using an invalid cbSize does work */
45     nidW.cbSize = 3;
46     nidW.hWnd = hMainWnd;
47     nidW.uID = 1;
48     ok(Shell_NotifyIconW(NIM_DELETE, &nidW), "NIM_DELETE failed!\n");
49     /* as icon doesn't exist anymore - now there will be an error */
50     nidW.cbSize = sizeof(nidW);
51     /* wine currently doesn't return error code put prints an ERR(...) */
52     todo_wine ok(!Shell_NotifyIconW(NIM_DELETE, &nidW), "The icon was not deleted\n");
53
54     /* same for Shell_NotifyIconA */
55     ZeroMemory(&nidA, sizeof(nidA));
56     nidA.cbSize = NOTIFYICONDATAA_V1_SIZE;
57     nidA.hWnd = hMainWnd;
58     nidA.uID = 1;
59     nidA.uFlags = NIF_ICON|NIF_MESSAGE;
60     nidA.hIcon = LoadIcon(NULL, IDI_APPLICATION);
61     nidA.uCallbackMessage = WM_USER+17;
62     ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n");
63
64     /* using an invalid cbSize does work */
65     nidA.cbSize = 3;
66     nidA.hWnd = hMainWnd;
67     nidA.uID = 1;
68     ok(Shell_NotifyIconA(NIM_DELETE, &nidA), "NIM_DELETE failed!\n");
69     /* as icon doesn't exist anymore - now there will be an error */
70     nidA.cbSize = sizeof(nidA);
71     /* wine currently doesn't return error code put prints an ERR(...) */
72     todo_wine ok(!Shell_NotifyIconA(NIM_DELETE, &nidA), "The icon was not deleted\n");
73 }
74
75 START_TEST(systray)
76 {
77     WNDCLASSA wc;
78     MSG msg;
79     RECT rc;
80
81     wc.style = CS_HREDRAW | CS_VREDRAW;
82     wc.cbClsExtra = 0;
83     wc.cbWndExtra = 0;
84     wc.hInstance = GetModuleHandleA(NULL);
85     wc.hIcon = NULL;
86     wc.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_IBEAM));
87     wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
88     wc.lpszMenuName = NULL;
89     wc.lpszClassName = "MyTestWnd";
90     wc.lpfnWndProc = DefWindowProc;
91     RegisterClassA(&wc);
92
93     hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
94       CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
95     GetClientRect(hMainWnd, &rc);
96     ShowWindow(hMainWnd, SW_SHOW);
97
98     test_cbsize();
99
100     PostQuitMessage(0);
101     while(GetMessageA(&msg,0,0,0)) {
102         TranslateMessage(&msg);
103         DispatchMessageA(&msg);
104     }
105     DestroyWindow(hMainWnd);
106 }