2007-05-09 23:47:36 +02:00
|
|
|
/* Unit tests for systray
|
|
|
|
*
|
|
|
|
* Copyright 2007 Mikolaj Zalewski
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#define _WIN32_IE 0x600
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include <windows.h>
|
2013-10-26 21:10:26 +02:00
|
|
|
#include "shellapi.h"
|
2007-05-09 23:47:36 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
|
|
|
|
static HWND hMainWnd;
|
2007-12-18 10:01:14 +01:00
|
|
|
static BOOL (WINAPI *pShell_NotifyIconW)(DWORD,PNOTIFYICONDATAW);
|
2007-05-09 23:47:36 +02:00
|
|
|
|
2008-12-12 10:21:52 +01:00
|
|
|
static void test_cbsize(void)
|
2007-05-09 23:47:36 +02:00
|
|
|
{
|
|
|
|
NOTIFYICONDATAA nidA;
|
2008-11-20 22:56:52 +01:00
|
|
|
BOOL ret;
|
2007-05-09 23:47:36 +02:00
|
|
|
|
2007-12-18 10:01:14 +01:00
|
|
|
if (pShell_NotifyIconW)
|
|
|
|
{
|
|
|
|
NOTIFYICONDATAW nidW;
|
2007-05-09 23:47:36 +02:00
|
|
|
|
2007-12-18 10:01:14 +01:00
|
|
|
ZeroMemory(&nidW, sizeof(nidW));
|
|
|
|
nidW.cbSize = NOTIFYICONDATAW_V1_SIZE;
|
|
|
|
nidW.hWnd = hMainWnd;
|
|
|
|
nidW.uID = 1;
|
|
|
|
nidW.uFlags = NIF_ICON|NIF_MESSAGE;
|
2013-10-26 21:10:26 +02:00
|
|
|
nidW.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION);
|
2007-12-18 10:01:14 +01:00
|
|
|
nidW.uCallbackMessage = WM_USER+17;
|
2008-11-20 22:56:52 +01:00
|
|
|
ret = pShell_NotifyIconW(NIM_ADD, &nidW);
|
2015-03-04 09:50:59 +01:00
|
|
|
ok(ret, "NIM_ADD failed!\n");
|
2011-02-25 00:40:28 +01:00
|
|
|
/* using an invalid cbSize does work */
|
|
|
|
nidW.cbSize = 3;
|
|
|
|
nidW.hWnd = hMainWnd;
|
|
|
|
nidW.uID = 1;
|
|
|
|
ret = pShell_NotifyIconW(NIM_DELETE, &nidW);
|
|
|
|
ok( ret || broken(!ret), /* nt4 */ "NIM_DELETE failed!\n");
|
|
|
|
/* as icon doesn't exist anymore - now there will be an error */
|
|
|
|
nidW.cbSize = sizeof(nidW);
|
|
|
|
ok(!pShell_NotifyIconW(NIM_DELETE, &nidW) != !ret, "The icon was not deleted\n");
|
2007-12-18 10:01:14 +01:00
|
|
|
}
|
2007-05-09 23:47:36 +02:00
|
|
|
|
|
|
|
/* same for Shell_NotifyIconA */
|
|
|
|
ZeroMemory(&nidA, sizeof(nidA));
|
|
|
|
nidA.cbSize = NOTIFYICONDATAA_V1_SIZE;
|
|
|
|
nidA.hWnd = hMainWnd;
|
|
|
|
nidA.uID = 1;
|
|
|
|
nidA.uFlags = NIF_ICON|NIF_MESSAGE;
|
2013-10-26 21:10:26 +02:00
|
|
|
nidA.hIcon = LoadIconA(NULL, (LPSTR)IDI_APPLICATION);
|
2007-05-09 23:47:36 +02:00
|
|
|
nidA.uCallbackMessage = WM_USER+17;
|
|
|
|
ok(Shell_NotifyIconA(NIM_ADD, &nidA), "NIM_ADD failed!\n");
|
|
|
|
|
|
|
|
/* using an invalid cbSize does work */
|
|
|
|
nidA.cbSize = 3;
|
|
|
|
nidA.hWnd = hMainWnd;
|
|
|
|
nidA.uID = 1;
|
2008-11-20 22:56:52 +01:00
|
|
|
ret = Shell_NotifyIconA(NIM_DELETE, &nidA);
|
2011-02-25 00:40:28 +01:00
|
|
|
ok(ret, "NIM_DELETE failed!\n");
|
2007-05-09 23:47:36 +02:00
|
|
|
/* as icon doesn't exist anymore - now there will be an error */
|
|
|
|
nidA.cbSize = sizeof(nidA);
|
2008-11-20 22:56:52 +01:00
|
|
|
ok(!Shell_NotifyIconA(NIM_DELETE, &nidA) != !ret, "The icon was not deleted\n");
|
2007-05-09 23:47:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(systray)
|
|
|
|
{
|
|
|
|
WNDCLASSA wc;
|
|
|
|
MSG msg;
|
|
|
|
RECT rc;
|
2008-09-02 22:08:20 +02:00
|
|
|
HMODULE hshell32;
|
2008-03-07 20:05:57 +01:00
|
|
|
|
|
|
|
hshell32 = GetModuleHandleA("shell32.dll");
|
|
|
|
pShell_NotifyIconW = (void*)GetProcAddress(hshell32, "Shell_NotifyIconW");
|
2007-12-18 10:01:14 +01:00
|
|
|
|
2007-05-09 23:47:36 +02:00
|
|
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = GetModuleHandleA(NULL);
|
|
|
|
wc.hIcon = NULL;
|
2013-10-26 21:10:26 +02:00
|
|
|
wc.hCursor = LoadCursorA(NULL, (LPSTR)IDC_IBEAM);
|
2007-05-09 23:47:36 +02:00
|
|
|
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = "MyTestWnd";
|
2013-10-26 21:10:26 +02:00
|
|
|
wc.lpfnWndProc = DefWindowProcA;
|
2007-05-09 23:47:36 +02:00
|
|
|
RegisterClassA(&wc);
|
|
|
|
|
|
|
|
hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
|
|
|
|
GetClientRect(hMainWnd, &rc);
|
|
|
|
ShowWindow(hMainWnd, SW_SHOW);
|
|
|
|
|
|
|
|
test_cbsize();
|
|
|
|
|
|
|
|
PostQuitMessage(0);
|
|
|
|
while(GetMessageA(&msg,0,0,0)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageA(&msg);
|
|
|
|
}
|
|
|
|
DestroyWindow(hMainWnd);
|
|
|
|
}
|