2017-03-07 22:29:48 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for DrawThemeParentBackground
|
|
|
|
* PROGRAMMERS: Giannis Adamopoulos
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <apitest.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <uxtheme.h>
|
|
|
|
#include <undocuser.h>
|
|
|
|
#include <msgtrace.h>
|
|
|
|
#include <user32testhelpers.h>
|
|
|
|
|
|
|
|
HWND hWnd1, hWnd2;
|
|
|
|
|
|
|
|
static int get_iwnd(HWND hWnd)
|
|
|
|
{
|
|
|
|
if(hWnd == hWnd1) return 1;
|
|
|
|
else if(hWnd == hWnd2) return 2;
|
|
|
|
else return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK TestProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
int iwnd = get_iwnd(hwnd);
|
|
|
|
|
|
|
|
if(message > WM_USER || !iwnd || message == WM_GETICON)
|
|
|
|
return DefWindowProc(hwnd, message, wParam, lParam);
|
|
|
|
|
|
|
|
RECORD_MESSAGE(iwnd, message, SENT, 0,0);
|
|
|
|
return DefWindowProc(hwnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void FlushMessages()
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
|
|
|
|
{
|
|
|
|
int iwnd = get_iwnd(msg.hwnd);
|
|
|
|
if(iwnd && msg.message <= WM_USER)
|
|
|
|
RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
|
|
|
|
DispatchMessageW( &msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MSG_ENTRY draw_parent_chain[]={{1, WM_ERASEBKGND},
|
|
|
|
{1, WM_PRINTCLIENT},
|
|
|
|
{0,0}};
|
|
|
|
|
|
|
|
void Test_Messages()
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
RegisterSimpleClass(TestProc, L"testClass");
|
|
|
|
|
|
|
|
hWnd1 = CreateWindowW(L"testClass", L"Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, NULL, NULL, NULL);
|
|
|
|
ok (hWnd1 != NULL, "Expected CreateWindowW to succeed\n");
|
|
|
|
|
|
|
|
hWnd2 = CreateWindowW(L"testClass", L"test window", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, hWnd1, NULL, NULL, NULL);
|
|
|
|
ok (hWnd2 != NULL, "Expected CreateWindowW to succeed\n");
|
2017-03-08 14:46:36 +00:00
|
|
|
|
|
|
|
FlushMessages();
|
|
|
|
EMPTY_CACHE();
|
|
|
|
|
|
|
|
hdc = GetDC(hWnd1);
|
|
|
|
|
|
|
|
DrawThemeParentBackground(hWnd2, hdc, NULL);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(draw_parent_chain);
|
|
|
|
|
|
|
|
DrawThemeParentBackground(hWnd1, hdc, NULL);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
|
|
|
|
ShowWindow(hWnd1, SW_SHOW);
|
|
|
|
UpdateWindow(hWnd1);
|
2017-03-07 22:29:48 +00:00
|
|
|
ShowWindow(hWnd2, SW_SHOW);
|
|
|
|
UpdateWindow(hWnd2);
|
|
|
|
|
|
|
|
FlushMessages();
|
|
|
|
EMPTY_CACHE();
|
|
|
|
|
|
|
|
DrawThemeParentBackground(hWnd2, NULL, NULL);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
|
|
|
|
DrawThemeParentBackground(hWnd1, NULL, NULL);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
2017-03-08 14:46:36 +00:00
|
|
|
|
2017-03-07 22:29:48 +00:00
|
|
|
DrawThemeParentBackground(hWnd2, hdc, NULL);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(draw_parent_chain);
|
|
|
|
|
|
|
|
DrawThemeParentBackground(hWnd1, hdc, NULL);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
|
|
|
|
memset(&rc, 0, sizeof(rc));
|
|
|
|
|
|
|
|
DrawThemeParentBackground(hWnd2, hdc, &rc);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(draw_parent_chain);
|
|
|
|
|
|
|
|
DrawThemeParentBackground(hWnd1, hdc, &rc);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
}
|
|
|
|
|
2017-03-08 14:46:36 +00:00
|
|
|
BOOL bGotException;
|
|
|
|
|
|
|
|
static LONG WINAPI VEHandler_1(PEXCEPTION_POINTERS ExceptionInfo)
|
|
|
|
{
|
|
|
|
ok(FALSE, "VEHandler_1 called!\n");
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG WINAPI VEHandler_2(PEXCEPTION_POINTERS ExceptionInfo)
|
|
|
|
{
|
|
|
|
bGotException = TRUE;
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Test_Params()
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HDC hdc;
|
|
|
|
PVOID pVEH;
|
|
|
|
|
|
|
|
bGotException = FALSE;
|
|
|
|
|
|
|
|
pVEH = AddVectoredExceptionHandler(1, VEHandler_1);
|
|
|
|
|
|
|
|
hr = DrawThemeParentBackground(NULL, NULL, NULL);
|
|
|
|
ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
|
|
|
|
|
2018-07-14 10:32:57 +00:00
|
|
|
hr = DrawThemeParentBackground((HWND)(ULONG_PTR)0xdeaddeaddeaddeadULL, NULL, NULL);
|
2017-03-08 14:46:36 +00:00
|
|
|
ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
|
|
|
|
|
2018-07-14 10:32:57 +00:00
|
|
|
hr = DrawThemeParentBackground(NULL, (HDC)(ULONG_PTR)0xdeaddeaddeaddeadULL, NULL);
|
2017-03-08 14:46:36 +00:00
|
|
|
ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
|
|
|
|
|
2018-07-14 10:32:57 +00:00
|
|
|
hr = DrawThemeParentBackground((HWND)(ULONG_PTR)0xdeaddeaddeaddeadULL, (HDC)(ULONG_PTR)0xdeaddeaddeaddeadULL, NULL);
|
2017-03-08 14:46:36 +00:00
|
|
|
ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
|
|
|
|
|
|
|
|
RemoveVectoredExceptionHandler(pVEH);
|
|
|
|
|
|
|
|
RegisterSimpleClass(DefWindowProcW, L"testClass2");
|
|
|
|
|
|
|
|
hWnd1 = CreateWindowW(L"testClass2", L"Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, NULL, NULL, NULL);
|
|
|
|
ok (hWnd1 != NULL, "Expected CreateWindowW to succeed\n");
|
|
|
|
hWnd2 = CreateWindowW(L"testClass2", L"test window", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, hWnd1, NULL, NULL, NULL);
|
|
|
|
ok (hWnd2 != NULL, "Expected CreateWindowW to succeed\n");
|
|
|
|
|
|
|
|
ShowWindow(hWnd1, SW_SHOW);
|
|
|
|
UpdateWindow(hWnd1);
|
|
|
|
ShowWindow(hWnd2, SW_SHOW);
|
|
|
|
UpdateWindow(hWnd2);
|
|
|
|
|
|
|
|
hr = DrawThemeParentBackground(hWnd1, NULL, NULL);
|
|
|
|
ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
|
|
|
|
|
|
|
|
hdc = GetDC(hWnd1);
|
|
|
|
ok (hdc != NULL, "Expected GetDC to succeed\n");
|
|
|
|
|
|
|
|
hr = DrawThemeParentBackground(NULL, hdc, NULL);
|
|
|
|
ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
|
|
|
|
|
|
|
|
hr = DrawThemeParentBackground(hWnd1, hdc, NULL);
|
|
|
|
ok (hr == S_OK, "Expected success got 0x%lx error\n", hr);
|
2017-03-08 14:54:02 +00:00
|
|
|
|
2018-07-14 10:32:57 +00:00
|
|
|
hr = DrawThemeParentBackground(hWnd1, (HDC)(ULONG_PTR)0xdeaddeaddeaddeadULL, NULL);
|
2017-03-08 14:54:02 +00:00
|
|
|
ok (hr == S_OK, "Expected success got 0x%lx error\n", hr);
|
2017-03-08 14:46:36 +00:00
|
|
|
|
|
|
|
pVEH = AddVectoredExceptionHandler(1, VEHandler_2);
|
2018-07-14 10:32:57 +00:00
|
|
|
hr = DrawThemeParentBackground(hWnd1, hdc, (RECT*)(ULONG_PTR)0xdeaddeaddeaddeadULL);
|
2017-03-08 14:46:36 +00:00
|
|
|
ok (hr == E_POINTER, "Expected success got 0x%lx error\n", hr);
|
|
|
|
RemoveVectoredExceptionHandler(pVEH);
|
|
|
|
ok (bGotException == TRUE, "Excepted a handled exception\n");
|
|
|
|
|
|
|
|
hr = DrawThemeParentBackground(hWnd2, NULL, NULL);
|
|
|
|
ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
|
|
|
|
|
|
|
|
hr = DrawThemeParentBackground(hWnd2, hdc, NULL);
|
|
|
|
ok (hr == S_FALSE, "Expected S_FALSE got 0x%lx error\n", hr);
|
|
|
|
|
|
|
|
ReleaseDC(hWnd1, hdc);
|
|
|
|
hdc = GetDC(hWnd2);
|
|
|
|
ok (hdc != NULL, "Expected GetDC to succeed\n");
|
|
|
|
|
|
|
|
hr = DrawThemeParentBackground(hWnd1, hdc, NULL);
|
|
|
|
ok (hr == S_OK, "Expected success got 0x%lx error\n", hr);
|
|
|
|
|
|
|
|
hr = DrawThemeParentBackground(hWnd2, hdc, NULL);
|
|
|
|
ok (hr == S_FALSE, "Expected S_FALSE got 0x%lx error\n", hr);
|
|
|
|
ReleaseDC(hWnd2, hdc);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-03-07 22:29:48 +00:00
|
|
|
START_TEST(DrawThemeParentBackground)
|
|
|
|
{
|
|
|
|
Test_Messages();
|
2017-03-08 14:46:36 +00:00
|
|
|
Test_Params();
|
2017-03-07 22:29:48 +00:00
|
|
|
}
|