Commit e9de4ae0 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

msvfw32: Test window creation with filename.

parent aeff5099
......@@ -153,6 +153,114 @@ static BOOL create_avi_file(char *fname)
return ret;
}
/* expected information for window creation */
static struct {
/* input */
const char* expectedA;
const WCHAR* expectedW;
/* output */
unsigned open_msg;
enum {NO_MATCH, PTR_ANSI_MATCH, PTR_UNICODE_MATCH, ANSI_MATCH, UNICODE_MATCH, TODO_WINE = 0x40} match;
} wnd_creation;
static WNDPROC old_MCIWndProc;
static LRESULT WINAPI proxy_MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
switch (wMsg)
{
case WM_CREATE:
{
CREATESTRUCTW* cs = (CREATESTRUCTW*)lParam;
if (cs->lpCreateParams)
{
if (cs->lpCreateParams == wnd_creation.expectedA)
wnd_creation.match = PTR_ANSI_MATCH;
else if (cs->lpCreateParams == wnd_creation.expectedW)
wnd_creation.match = PTR_UNICODE_MATCH;
else if (!strcmp(cs->lpCreateParams, wnd_creation.expectedA))
wnd_creation.match = ANSI_MATCH;
else if (!wcscmp(cs->lpCreateParams, wnd_creation.expectedW))
wnd_creation.match = UNICODE_MATCH;
}
}
break;
case MCIWNDM_OPENA:
case MCIWNDM_OPENW:
wnd_creation.open_msg = wMsg;
break;
default:
break;
}
return old_MCIWndProc(hWnd, wMsg, wParam, lParam);
}
static LRESULT CALLBACK hook_proc( int code, WPARAM wp, LPARAM lp )
{
if (code == HCBT_CREATEWND && lp)
{
CREATESTRUCTW* cs = ((CBT_CREATEWNDW *)lp)->lpcs;
if (cs && ((ULONG_PTR)cs->lpszClass >> 16) && !wcsicmp(cs->lpszClass, L"MCIWndClass"))
{
old_MCIWndProc = (WNDPROC)SetWindowLongPtrW((HWND)wp, GWLP_WNDPROC, (LPARAM)proxy_MCIWndProc);
ok(old_MCIWndProc != NULL, "No wnd proc\n");
}
}
return CallNextHookEx( NULL, code, wp, lp );
}
static void test_window_create(unsigned line, const char* fname, HWND parent,
BOOL with_mci, BOOL call_ansi, unsigned match)
{
HMODULE hinst = GetModuleHandleA(NULL);
WCHAR fnameW[MAX_PATH];
HWND window;
char error[200];
LRESULT ret;
BOOL expect_ansi = (match & ~TODO_WINE) == PTR_ANSI_MATCH || (match & ~TODO_WINE) == ANSI_MATCH;
MultiByteToWideChar(CP_ACP, 0, fname, -1, fnameW, ARRAY_SIZE(fnameW));
wnd_creation.expectedA = fname;
wnd_creation.expectedW = fnameW;
wnd_creation.open_msg = 0;
wnd_creation.match = NO_MATCH;
if (call_ansi)
{
if (with_mci)
window = MCIWndCreateA(parent, hinst, MCIWNDF_NOERRORDLG, fname);
else
window = CreateWindowExA(0, "MCIWndClass", NULL,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | MCIWNDF_NOERRORDLG,
0, 0, 300, 0,
parent, 0, hinst, expect_ansi ? (LPVOID)fname : (LPVOID)fnameW);
}
else
{
if (with_mci)
window = MCIWndCreateW(parent, hinst, MCIWNDF_NOERRORDLG, fnameW);
else
window = CreateWindowExW(0, L"MCIWndClass", NULL,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | MCIWNDF_NOERRORDLG,
0, 0, 300, 0,
parent, 0, hinst, expect_ansi ? (LPVOID)fname : (LPVOID)fnameW);
}
ok_(__FILE__, line)(window != NULL, "Failed to create an MCIWnd window\n");
ok_(__FILE__, line)(wnd_creation.match == (match & ~TODO_WINE), "unexpected match %u\n", wnd_creation.match);
todo_wine_if(match & TODO_WINE)
ok_(__FILE__, line)((expect_ansi && wnd_creation.open_msg == MCIWNDM_OPENA) ||
(!expect_ansi && wnd_creation.open_msg == MCIWNDM_OPENW),
"bad open message %u %s%u\n", match,
wnd_creation.open_msg >= WM_USER ? "WM_USER+" : "",
wnd_creation.open_msg >= WM_USER ? wnd_creation.open_msg - WM_USER : wnd_creation.open_msg);
ret = SendMessageA(window, MCIWNDM_GETERRORA, sizeof(error), (LPARAM)error);
todo_wine_if(match & TODO_WINE)
ok_(__FILE__, line)(!ret || broken(ret == ERROR_INVALID_HANDLE) /* w2003std, w2008s64 */,
"Unexpected error %Id\n", ret);
DestroyWindow(window);
}
static void test_MCIWndCreate(void)
{
HWND parent, window;
......@@ -160,32 +268,46 @@ static void test_MCIWndCreate(void)
char fname[MAX_PATH];
char invalid_fname[] = "invalid.avi";
char error[200];
HHOOK hook;
LRESULT ret;
create_avi_file(fname);
window = MCIWndCreateA(NULL, hinst, MCIWNDF_NOERRORDLG, fname);
ok(window != NULL, "Failed to create an MCIWnd window without parent\n");
hook = SetWindowsHookExW( WH_CBT, hook_proc, NULL, GetCurrentThreadId() );
ret = SendMessageA(window, MCIWNDM_GETERRORA, sizeof(error), (LPARAM)error);
ok(!ret || broken(ret == ERROR_INVALID_HANDLE) /* w2003std, w2008s64 */,
"Unexpected error %Id\n", ret);
DestroyWindow(window);
test_window_create( __LINE__, fname, NULL, TRUE, TRUE, UNICODE_MATCH | TODO_WINE );
test_window_create( __LINE__, fname, NULL, TRUE, FALSE, PTR_UNICODE_MATCH | TODO_WINE );
test_window_create( __LINE__, fname, NULL, FALSE, TRUE, PTR_ANSI_MATCH );
test_window_create( __LINE__, fname, NULL, FALSE, FALSE, PTR_ANSI_MATCH );
parent = CreateWindowExA(0, "static", "msvfw32 test",
WS_POPUP, 0, 0, 100, 100,
0, 0, 0, NULL);
ok(parent != NULL, "Failed to create a window\n");
window = MCIWndCreateA(parent, hinst, MCIWNDF_NOERRORDLG, fname);
ok(window != NULL, "Failed to create an MCIWnd window\n");
ok(!IsWindowUnicode(parent), "Expecting ansi parent window\n");
ret = SendMessageA(window, MCIWNDM_GETERRORA, sizeof(error), (LPARAM)error);
ok(!ret || broken(ret == ERROR_INVALID_HANDLE) /* w2003std, w2008s64 */,
"Unexpected error %Id\n", ret);
test_window_create( __LINE__, fname, parent, TRUE, TRUE, UNICODE_MATCH | TODO_WINE );
test_window_create( __LINE__, fname, parent, TRUE, FALSE, PTR_UNICODE_MATCH | TODO_WINE );
test_window_create( __LINE__, fname, parent, FALSE, TRUE, PTR_ANSI_MATCH );
test_window_create( __LINE__, fname, parent, FALSE, FALSE, PTR_ANSI_MATCH );
DestroyWindow(parent);
parent = CreateWindowExW(0, L"static", L"msvfw32 test",
WS_POPUP, 0, 0, 100, 100,
0, 0, 0, NULL);
ok(parent != NULL, "Failed to create a window\n");
ok(IsWindowUnicode(parent), "Expecting unicode parent window\n");
test_window_create( __LINE__, fname, parent, TRUE, TRUE, UNICODE_MATCH );
test_window_create( __LINE__, fname, parent, TRUE, FALSE, PTR_UNICODE_MATCH );
test_window_create( __LINE__, fname, parent, FALSE, TRUE, PTR_UNICODE_MATCH );
test_window_create( __LINE__, fname, parent, FALSE, FALSE, PTR_UNICODE_MATCH );
DestroyWindow(parent);
UnhookWindowsHookEx( hook );
window = MCIWndCreateA(NULL, hinst, MCIWNDF_NOERRORDLG, invalid_fname);
ok(window != NULL, "Failed to create an MCIWnd window\n");
......
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