Commit d1158610 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

compstui: Test that callbacks are executed.

parent f590f72e
......@@ -22,6 +22,42 @@
#include "wine/test.h"
#define DEFINE_EXPECT(func) \
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
#define SET_EXPECT(func) \
do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
#define CHECK_EXPECT2(func) \
do { \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define CHECK_EXPECT(func) \
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)
#define CHECK_CALLED(func) \
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define CLEAR_CALLED(func) \
expect_ ## func = called_ ## func = FALSE
DEFINE_EXPECT(page_proc_WM_INITDIALOG);
DEFINE_EXPECT(page_proc2_WM_INITDIALOG);
DEFINE_EXPECT(device_PROPSHEETUI_REASON_INIT);
DEFINE_EXPECT(device_PROPSHEETUI_REASON_DESTROY);
DEFINE_EXPECT(callback_PROPSHEETUI_REASON_BEFORE_INIT);
DEFINE_EXPECT(callback_PROPSHEETUI_REASON_INIT);
DEFINE_EXPECT(callback_PROPSHEETUI_REASON_GET_INFO_HEADER);
DEFINE_EXPECT(callback_PROPSHEETUI_REASON_DESTROY);
typedef struct {
WORD cbSize;
WORD Flags;
......@@ -40,6 +76,8 @@ static INT_PTR CALLBACK prop_page_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
{
HWND dlg = GetParent(hwnd);
CHECK_EXPECT(page_proc_WM_INITDIALOG);
PostMessageW(dlg, PSM_PRESSBUTTON, PSBTN_OK, 0);
}
return FALSE;
......@@ -53,6 +91,8 @@ static INT_PTR CALLBACK prop_page_proc2(HWND hwnd, UINT msg, WPARAM wparam, LPAR
PSPINFO *info = (PSPINFO*)((BYTE*)lparam + psp->dwSize);
HWND dlg = GetParent(hwnd);
CHECK_EXPECT(page_proc2_WM_INITDIALOG);
ok(psp->dwSize == sizeof(PROPSHEETPAGEW), "psp->dwSize = %ld\n", psp->dwSize);
ok(psp->pfnDlgProc == prop_page_proc2, "psp->pfnDlgProc != prop_page_proc2\n");
ok(!psp->lParam, "psp->lParam = %Ix\n", psp->lParam);
......@@ -70,6 +110,11 @@ static INT_PTR CALLBACK prop_page_proc2(HWND hwnd, UINT msg, WPARAM wparam, LPAR
static LONG WINAPI device_property_sheets(PROPSHEETUI_INFO *info, LPARAM lparam)
{
if (info->Reason == PROPSHEETUI_REASON_INIT)
CHECK_EXPECT(device_PROPSHEETUI_REASON_INIT);
else
CHECK_EXPECT(device_PROPSHEETUI_REASON_DESTROY);
ok(info->cbSize == sizeof(*info), "info->cbSize = %hd\n", info->cbSize);
ok(info->Version == PROPSHEETUI_INFO_VERSION, "info->Version = %hd\n", info->Version);
ok(info->Flags == info->lParamInit ? PSUIINFO_UNICODE : 0, "info->Flags = %hd\n", info->Flags);
......@@ -98,6 +143,7 @@ static LONG WINAPI propsheetui_callback(PROPSHEETUI_INFO *info, LPARAM lparam)
switch(info->Reason)
{
case PROPSHEETUI_REASON_BEFORE_INIT:
CHECK_EXPECT(callback_PROPSHEETUI_REASON_BEFORE_INIT);
ok(!info->Version, "info->Version = %hd\n", info->Version);
ok(!info->Flags, "info->Flags = %hd\n", info->Flags);
ok(!info->hComPropSheet, "info->hComPropSheet = %p\n", info->hComPropSheet);
......@@ -105,6 +151,7 @@ static LONG WINAPI propsheetui_callback(PROPSHEETUI_INFO *info, LPARAM lparam)
ok(!info->Result, "info->Result = %Ix\n", info->Result);
break;
case PROPSHEETUI_REASON_INIT:
CHECK_EXPECT(callback_PROPSHEETUI_REASON_INIT);
ok(info->Version == PROPSHEETUI_INFO_VERSION, "info->Version = %hd\n", info->Version);
ok(info->Flags == PSUIINFO_UNICODE, "info->Flags = %hd\n", info->Flags);
ok(info->hComPropSheet != NULL, "info->hComPropSheet = NULL\n");
......@@ -113,6 +160,7 @@ static LONG WINAPI propsheetui_callback(PROPSHEETUI_INFO *info, LPARAM lparam)
ok(!info->Result, "info->Result = %Ix\n", info->Result);
break;
case PROPSHEETUI_REASON_GET_INFO_HEADER:
CHECK_EXPECT(callback_PROPSHEETUI_REASON_GET_INFO_HEADER);
ok(info->Version == PROPSHEETUI_INFO_VERSION, "info->Version = %hd\n", info->Version);
ok(info->Flags == PSUIINFO_UNICODE, "info->Flags = %hd\n", info->Flags);
ok(info->hComPropSheet != NULL, "info->hComPropSheet = NULL\n");
......@@ -135,11 +183,18 @@ static LONG WINAPI propsheetui_callback(PROPSHEETUI_INFO *info, LPARAM lparam)
PROPSHEETPAGEW psp;
LONG_PTR ret;
SET_EXPECT(device_PROPSHEETUI_REASON_INIT);
SET_EXPECT(device_PROPSHEETUI_REASON_DESTROY);
ret = info->pfnComPropSheet(info->hComPropSheet, CPSFUNC_ADD_PFNPROPSHEETUIA, (LPARAM)device_property_sheets, 0);
ok(!ret, "ret = %Ix\n", ret);
CHECK_CALLED(device_PROPSHEETUI_REASON_INIT);
CHECK_CALLED(device_PROPSHEETUI_REASON_DESTROY);
SET_EXPECT(device_PROPSHEETUI_REASON_INIT);
ret = info->pfnComPropSheet(info->hComPropSheet, CPSFUNC_ADD_PFNPROPSHEETUIW, (LPARAM)device_property_sheets, 1);
ok(ret, "ret = 0\n");
CHECK_CALLED(device_PROPSHEETUI_REASON_INIT);
SET_EXPECT(device_PROPSHEETUI_REASON_DESTROY);
memset(&psp, 0, sizeof(psp));
psp.dwSize = sizeof(psp);
......@@ -156,8 +211,12 @@ static LONG WINAPI propsheetui_callback(PROPSHEETUI_INFO *info, LPARAM lparam)
}
break;
case PROPSHEETUI_REASON_DESTROY:
CHECK_EXPECT(callback_PROPSHEETUI_REASON_DESTROY);
if (info->lParamInit & ADD_PAGES)
{
CHECK_CALLED(device_PROPSHEETUI_REASON_DESTROY);
ok(lparam, "lparam = 0\n");
}
else
ok(!lparam, "lparam = %Ix\n", lparam);
......@@ -188,15 +247,35 @@ static void test_CommonPropertySheetUI(void)
ok(res == 0xdeadbeef, "res = %lx\n", res);
ok(!GetLastError(), "CommonPropertySheetUIW error %ld\n", GetLastError());
SET_EXPECT(callback_PROPSHEETUI_REASON_BEFORE_INIT);
SET_EXPECT(callback_PROPSHEETUI_REASON_INIT);
SET_EXPECT(callback_PROPSHEETUI_REASON_GET_INFO_HEADER);
SET_EXPECT(callback_PROPSHEETUI_REASON_DESTROY);
res = 0xdeadbeef;
ret = CommonPropertySheetUIW((HWND)0x4321, propsheetui_callback, 0, &res);
ok(ret == ERR_CPSUI_NO_PROPSHEETPAGE, "CommonPropertySheetUIW returned %ld\n", ret);
ok(!res, "res = %lx\n", res);
CLEAR_CALLED(callback_PROPSHEETUI_REASON_BEFORE_INIT);
CHECK_CALLED(callback_PROPSHEETUI_REASON_INIT);
CHECK_CALLED(callback_PROPSHEETUI_REASON_GET_INFO_HEADER);
CHECK_CALLED(callback_PROPSHEETUI_REASON_DESTROY);
SET_EXPECT(callback_PROPSHEETUI_REASON_BEFORE_INIT);
SET_EXPECT(callback_PROPSHEETUI_REASON_INIT);
SET_EXPECT(callback_PROPSHEETUI_REASON_GET_INFO_HEADER);
SET_EXPECT(page_proc2_WM_INITDIALOG);
SET_EXPECT(page_proc_WM_INITDIALOG);
SET_EXPECT(callback_PROPSHEETUI_REASON_DESTROY);
res = 0xdeadbeef;
ret = CommonPropertySheetUIW((HWND)0x4321, propsheetui_callback, ADD_PAGES, &res);
ok(ret == CPSUI_OK, "CommonPropertySheetUIW returned %ld\n", ret);
ok(!res, "res = %lx\n", res);
CLEAR_CALLED(callback_PROPSHEETUI_REASON_BEFORE_INIT);
CHECK_CALLED(callback_PROPSHEETUI_REASON_INIT);
CHECK_CALLED(callback_PROPSHEETUI_REASON_GET_INFO_HEADER);
CHECK_CALLED(page_proc2_WM_INITDIALOG);
CHECK_CALLED(page_proc_WM_INITDIALOG);
CHECK_CALLED(callback_PROPSHEETUI_REASON_DESTROY);
}
START_TEST(compstui)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment