mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:25:41 +00:00
[ApiTest]
- Add Thomas Faber API test from CORE-8703. svn path=/trunk/; revision=66233
This commit is contained in:
parent
c34281f198
commit
8f317b9b09
4 changed files with 198 additions and 0 deletions
|
@ -3,6 +3,7 @@ list(APPEND SOURCE
|
||||||
AttachThreadInput.c
|
AttachThreadInput.c
|
||||||
helper.c
|
helper.c
|
||||||
CreateIconFromResourceEx.c
|
CreateIconFromResourceEx.c
|
||||||
|
CreateWindowEx.c
|
||||||
DeferWindowPos.c
|
DeferWindowPos.c
|
||||||
DestroyCursorIcon.c
|
DestroyCursorIcon.c
|
||||||
DrawIconEx.c
|
DrawIconEx.c
|
||||||
|
|
189
rostests/apitests/user32/CreateWindowEx.c
Normal file
189
rostests/apitests/user32/CreateWindowEx.c
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS API tests
|
||||||
|
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
||||||
|
* PURPOSE: Test for CreateWindow stuff
|
||||||
|
* PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <apitest.h>
|
||||||
|
|
||||||
|
#include <winuser.h>
|
||||||
|
#include "helper.h"
|
||||||
|
|
||||||
|
static HWND hWndList[5 + 1];
|
||||||
|
static const int hWndCount = sizeof(hWndList) / sizeof(hWndList[0]) - 1;
|
||||||
|
static DWORD dwThreadId;
|
||||||
|
|
||||||
|
#define ok_hwnd(val, exp) do \
|
||||||
|
{ \
|
||||||
|
HWND _val = (val), _exp = (exp); \
|
||||||
|
int _ival = get_iwnd(_val, FALSE); \
|
||||||
|
int _iexp = get_iwnd(_exp, FALSE); \
|
||||||
|
ok(_val == _exp, #val " = %p (%d), expected %p (%d)\n", _val, _ival, _exp, _iexp); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
static
|
||||||
|
int
|
||||||
|
get_iwnd(
|
||||||
|
_In_ HWND hWnd,
|
||||||
|
_In_ BOOL set)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if (!hWnd)
|
||||||
|
return 0;
|
||||||
|
for (i = 1; i <= hWndCount; i++)
|
||||||
|
{
|
||||||
|
if (hWndList[i] == hWnd)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
if (!set)
|
||||||
|
return 0;
|
||||||
|
for (i = 1; i <= hWndCount; i++)
|
||||||
|
{
|
||||||
|
if (hWndList[i] == NULL)
|
||||||
|
{
|
||||||
|
hWndList[i] = hWnd;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ok(0, "Too many windows!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
BOOL
|
||||||
|
CALLBACK
|
||||||
|
EnumProc(
|
||||||
|
_In_ HWND hWnd,
|
||||||
|
_In_ LPARAM lParam)
|
||||||
|
{
|
||||||
|
HWND hLookingFor = (HWND)lParam;
|
||||||
|
return hWnd != hLookingFor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
LRESULT
|
||||||
|
CALLBACK
|
||||||
|
WndProc(
|
||||||
|
_In_ HWND hWnd,
|
||||||
|
_In_ UINT message,
|
||||||
|
_In_ WPARAM wParam,
|
||||||
|
_In_ LPARAM lParam)
|
||||||
|
{
|
||||||
|
HWND hTest;
|
||||||
|
int iwnd = get_iwnd(hWnd, TRUE);
|
||||||
|
|
||||||
|
ok(GetCurrentThreadId() == dwThreadId, "Thread 0x%lx instead of 0x%lx\n", GetCurrentThreadId(), dwThreadId);
|
||||||
|
if (message > WM_USER || IsDWmMsg(message) || IseKeyMsg(message))
|
||||||
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
|
|
||||||
|
RECOND_MESSAGE(iwnd, message, SENT, wParam, lParam);
|
||||||
|
|
||||||
|
switch(message)
|
||||||
|
{
|
||||||
|
case WM_DESTROY:
|
||||||
|
if (GetParent(hWnd))
|
||||||
|
{
|
||||||
|
/* child window */
|
||||||
|
ok(EnumThreadWindows(dwThreadId, EnumProc, (LPARAM)hWnd), "Child window %p (%d) enumerated\n", hWnd, iwnd);
|
||||||
|
ok(!EnumChildWindows(GetParent(hWnd), EnumProc, (LPARAM)hWnd), "Child window %p (%d) not enumerated\n", hWnd, iwnd);
|
||||||
|
ok(!EnumThreadWindows(dwThreadId, EnumProc, (LPARAM)GetParent(hWnd)), "Parent window of %p (%d) not enumerated\n", hWnd, iwnd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* top-level window */
|
||||||
|
ok(!EnumThreadWindows(dwThreadId, EnumProc, (LPARAM)hWnd), "Window %p (%d) not enumerated in WM_DESTROY\n", hWnd, iwnd);
|
||||||
|
}
|
||||||
|
if (hWnd == hWndList[3])
|
||||||
|
{
|
||||||
|
hTest = SetParent(hWndList[4], hWndList[2]);
|
||||||
|
ok_hwnd(hTest, hWndList[1]);
|
||||||
|
hTest = SetParent(hWndList[5], hWndList[1]);
|
||||||
|
ok_hwnd(hTest, hWndList[2]);
|
||||||
|
|
||||||
|
ok_hwnd(GetParent(hWndList[1]), NULL);
|
||||||
|
ok_hwnd(GetParent(hWndList[2]), NULL);
|
||||||
|
ok_hwnd(GetParent(hWndList[3]), hWndList[1]);
|
||||||
|
ok_hwnd(GetParent(hWndList[4]), hWndList[2]);
|
||||||
|
ok_hwnd(GetParent(hWndList[5]), hWndList[1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
START_TEST(CreateWindowEx)
|
||||||
|
{
|
||||||
|
HWND hWnd;
|
||||||
|
MSG msg;
|
||||||
|
|
||||||
|
SetCursorPos(0,0);
|
||||||
|
|
||||||
|
dwThreadId = GetCurrentThreadId();
|
||||||
|
hWndList[0] = INVALID_HANDLE_VALUE;
|
||||||
|
RegisterSimpleClass(WndProc, L"CreateTest");
|
||||||
|
|
||||||
|
hWnd = CreateWindowExW(0, L"CreateTest", NULL, 0, 10, 10, 20, 20, NULL, NULL, 0, NULL);
|
||||||
|
ok(hWnd != NULL, "CreateWindow failed\n");
|
||||||
|
ok(hWnd == hWndList[1], "Got %p, expected %p\n", hWnd, hWndList[1]);
|
||||||
|
|
||||||
|
hWnd = CreateWindowExW(0, L"CreateTest", NULL, 0, 40, 10, 20, 20, NULL, NULL, 0, NULL);
|
||||||
|
ok(hWnd != NULL, "CreateWindow failed\n");
|
||||||
|
ok(hWnd == hWndList[2], "Got %p, expected %p\n", hWnd, hWndList[2]);
|
||||||
|
|
||||||
|
hWnd = CreateWindowExW(0, L"CreateTest", NULL, WS_CHILD, 60, 10, 20, 20, hWndList[1], NULL, 0, NULL);
|
||||||
|
ok(hWnd != NULL, "CreateWindow failed\n");
|
||||||
|
ok(hWnd == hWndList[3], "Got %p, expected %p\n", hWnd, hWndList[3]);
|
||||||
|
|
||||||
|
hWnd = CreateWindowExW(0, L"CreateTest", NULL, WS_CHILD, 80, 10, 20, 20, hWndList[1], NULL, 0, NULL);
|
||||||
|
ok(hWnd != NULL, "CreateWindow failed\n");
|
||||||
|
ok(hWnd == hWndList[4], "Got %p, expected %p\n", hWnd, hWndList[4]);
|
||||||
|
|
||||||
|
hWnd = CreateWindowExW(0, L"CreateTest", NULL, WS_CHILD, 60, 10, 20, 20, hWndList[2], NULL, 0, NULL);
|
||||||
|
ok(hWnd != NULL, "CreateWindow failed\n");
|
||||||
|
ok(hWnd == hWndList[5], "Got %p, expected %p\n", hWnd, hWndList[5]);
|
||||||
|
|
||||||
|
trace("\n");
|
||||||
|
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
|
||||||
|
{
|
||||||
|
int iwnd = get_iwnd(msg.hwnd, FALSE);
|
||||||
|
if(!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
|
||||||
|
RECOND_MESSAGE(iwnd, msg.message, POST, 0, 0);
|
||||||
|
DispatchMessageA( &msg );
|
||||||
|
}
|
||||||
|
trace("\n");
|
||||||
|
TRACE_CACHE();
|
||||||
|
trace("\n");
|
||||||
|
|
||||||
|
ok_hwnd(GetParent(hWndList[1]), NULL);
|
||||||
|
ok_hwnd(GetParent(hWndList[2]), NULL);
|
||||||
|
ok_hwnd(GetParent(hWndList[3]), hWndList[1]);
|
||||||
|
ok_hwnd(GetParent(hWndList[4]), hWndList[1]);
|
||||||
|
ok_hwnd(GetParent(hWndList[5]), hWndList[2]);
|
||||||
|
|
||||||
|
DestroyWindow(hWndList[1]);
|
||||||
|
ok(!IsWindow(hWndList[1]), "\n");
|
||||||
|
ok( IsWindow(hWndList[2]), "\n");
|
||||||
|
ok(!IsWindow(hWndList[3]), "\n");
|
||||||
|
ok( IsWindow(hWndList[4]), "\n");
|
||||||
|
ok(!IsWindow(hWndList[5]), "\n");
|
||||||
|
|
||||||
|
ok_hwnd(GetParent(hWndList[1]), NULL);
|
||||||
|
ok_hwnd(GetParent(hWndList[2]), NULL);
|
||||||
|
ok_hwnd(GetParent(hWndList[3]), NULL);
|
||||||
|
ok_hwnd(GetParent(hWndList[4]), hWndList[2]);
|
||||||
|
ok_hwnd(GetParent(hWndList[5]), NULL);
|
||||||
|
|
||||||
|
trace("\n");
|
||||||
|
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
|
||||||
|
{
|
||||||
|
int iwnd = get_iwnd(msg.hwnd, FALSE);
|
||||||
|
if(!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
|
||||||
|
RECOND_MESSAGE(iwnd, msg.message, POST, 0, 0);
|
||||||
|
DispatchMessageA( &msg );
|
||||||
|
}
|
||||||
|
trace("\n");
|
||||||
|
TRACE_CACHE();
|
||||||
|
}
|
|
@ -23,6 +23,12 @@ static char* get_msg_name(UINT msg)
|
||||||
{
|
{
|
||||||
switch(msg)
|
switch(msg)
|
||||||
{
|
{
|
||||||
|
case WM_CREATE: return "WM_CREATE";
|
||||||
|
case WM_NCCREATE: return "WM_NCCREATE";
|
||||||
|
case WM_PARENTNOTIFY: return "WM_PARENTNOTIFY";
|
||||||
|
case WM_DESTROY: return "WM_DESTROY";
|
||||||
|
case WM_NCDESTROY: return "WM_NCDESTROY";
|
||||||
|
case WM_CHILDACTIVATE: return "WM_CHILDACTIVATE";
|
||||||
case WM_NCACTIVATE: return "WM_NCACTIVATE";
|
case WM_NCACTIVATE: return "WM_NCACTIVATE";
|
||||||
case WM_ACTIVATE: return "WM_ACTIVATE";
|
case WM_ACTIVATE: return "WM_ACTIVATE";
|
||||||
case WM_ACTIVATEAPP: return "WM_ACTIVATEAPP";
|
case WM_ACTIVATEAPP: return "WM_ACTIVATEAPP";
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
extern void func_AttachThreadInput(void);
|
extern void func_AttachThreadInput(void);
|
||||||
extern void func_CreateIconFromResourceEx(void);
|
extern void func_CreateIconFromResourceEx(void);
|
||||||
|
extern void func_CreateWindowEx(void);
|
||||||
extern void func_DeferWindowPos(void);
|
extern void func_DeferWindowPos(void);
|
||||||
extern void func_DestroyCursorIcon(void);
|
extern void func_DestroyCursorIcon(void);
|
||||||
extern void func_DrawIconEx(void);
|
extern void func_DrawIconEx(void);
|
||||||
|
@ -33,6 +34,7 @@ const struct test winetest_testlist[] =
|
||||||
{
|
{
|
||||||
{ "AttachThreadInput", func_AttachThreadInput },
|
{ "AttachThreadInput", func_AttachThreadInput },
|
||||||
{ "CreateIconFromResourceEx", func_CreateIconFromResourceEx },
|
{ "CreateIconFromResourceEx", func_CreateIconFromResourceEx },
|
||||||
|
{ "CreateWindowEx", func_CreateWindowEx },
|
||||||
{ "DeferWindowPos", func_DeferWindowPos },
|
{ "DeferWindowPos", func_DeferWindowPos },
|
||||||
{ "DestroyCursorIcon", func_DestroyCursorIcon },
|
{ "DestroyCursorIcon", func_DestroyCursorIcon },
|
||||||
{ "DrawIconEx", func_DrawIconEx },
|
{ "DrawIconEx", func_DrawIconEx },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue