Commit 609a3998 authored by Detlef Riekenberg's avatar Detlef Riekenberg Committed by Alexandre Julliard

user32/tests: Fix crash on win9x in the dde test.

parent aa1effe3
...@@ -1055,9 +1055,14 @@ static void test_msg_client() ...@@ -1055,9 +1055,14 @@ static void test_msg_client()
/* WM_DDE_POKE, no ddepoke */ /* WM_DDE_POKE, no ddepoke */
lparam = PackDDElParam(WM_DDE_POKE, 0, item); lparam = PackDDElParam(WM_DDE_POKE, 0, item);
PostMessageA(server_hwnd, WM_DDE_POKE, (WPARAM)client_hwnd, lparam); /* win9x returns 0 here and crashes in PostMessageA */
if (lparam) {
PostMessageA(server_hwnd, WM_DDE_POKE, (WPARAM)client_hwnd, lparam);
flush_events();
}
else
win_skip("no lparam for WM_DDE_POKE\n");
flush_events();
/* WM_DDE_POKE, no item */ /* WM_DDE_POKE, no item */
lparam = PackDDElParam(WM_DDE_POKE, (UINT_PTR)hglobal, 0); lparam = PackDDElParam(WM_DDE_POKE, (UINT_PTR)hglobal, 0);
...@@ -1522,15 +1527,9 @@ static void test_DdeCreateDataHandle(void) ...@@ -1522,15 +1527,9 @@ static void test_DdeCreateDataHandle(void)
item = DdeCreateStringHandleA(dde_inst, "item", CP_WINANSI); item = DdeCreateStringHandleA(dde_inst, "item", CP_WINANSI);
ok(item != NULL, "Expected non-NULL hsz\n"); ok(item != NULL, "Expected non-NULL hsz\n");
/* invalid instance id */ if (0) {
DdeGetLastError(dde_inst); /* do not test with an invalid instance id: that crashes on win9x */
hdata = DdeCreateDataHandle(0xdeadbeef, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0); hdata = DdeCreateDataHandle(0xdeadbeef, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0);
err = DdeGetLastError(dde_inst);
todo_wine
{
ok(hdata == NULL, "Expected NULL, got %p\n", hdata);
ok(err == DMLERR_INVALIDPARAMETER,
"Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
} }
/* 0 instance id */ /* 0 instance id */
...@@ -1826,19 +1825,24 @@ static void test_PackDDElParam(void) ...@@ -1826,19 +1825,24 @@ static void test_PackDDElParam(void)
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
lparam = PackDDElParam(WM_DDE_ADVISE, 0xcafe, 0xbeef); lparam = PackDDElParam(WM_DDE_ADVISE, 0xcafe, 0xbeef);
ptr = GlobalLock((HGLOBAL)lparam); /* win9x returns 0 here */
ok(ptr != NULL, "Expected non-NULL ptr\n"); if (lparam) {
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]); ptr = GlobalLock((HGLOBAL)lparam);
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]); ok(ptr != NULL, "Expected non-NULL ptr\n");
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
ret = GlobalUnlock((HGLOBAL)lparam); ret = GlobalUnlock((HGLOBAL)lparam);
ok(ret == 1, "Expected 1, got %d\n", ret); ok(ret == 1, "Expected 1, got %d\n", ret);
lo = hi = 0; lo = hi = 0;
ret = UnpackDDElParam(WM_DDE_ADVISE, lparam, &lo, &hi); ret = UnpackDDElParam(WM_DDE_ADVISE, lparam, &lo, &hi);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo); ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi); ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
}
else
win_skip("no lparam for WM_DDE_ADVISE\n");
ret = FreeDDElParam(WM_DDE_ADVISE, lparam); ret = FreeDDElParam(WM_DDE_ADVISE, lparam);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
...@@ -1865,42 +1869,52 @@ static void test_PackDDElParam(void) ...@@ -1865,42 +1869,52 @@ static void test_PackDDElParam(void)
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
lparam = PackDDElParam(WM_DDE_ACK, 0xcafe, 0xbeef); lparam = PackDDElParam(WM_DDE_ACK, 0xcafe, 0xbeef);
ptr = GlobalLock((HGLOBAL)lparam); /* win9x returns the input (0xbeef<<16 | 0xcafe) here */
ok(ptr != NULL, "Expected non-NULL ptr\n"); if (lparam != 0xbeefcafe) {
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]); ptr = GlobalLock((HGLOBAL)lparam);
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]); ok(ptr != NULL, "Expected non-NULL ptr\n");
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
ret = GlobalUnlock((HGLOBAL)lparam); ret = GlobalUnlock((HGLOBAL)lparam);
ok(ret == 1, "Expected 1, got %d\n", ret); ok(ret == 1, "Expected 1, got %d\n", ret);
lo = hi = 0; lo = hi = 0;
ret = UnpackDDElParam(WM_DDE_ACK, lparam, &lo, &hi); ret = UnpackDDElParam(WM_DDE_ACK, lparam, &lo, &hi);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo); ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi); ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
ret = FreeDDElParam(WM_DDE_ACK, lparam); ret = FreeDDElParam(WM_DDE_ACK, lparam);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
hglobal = GlobalFree((HGLOBAL)lparam); hglobal = GlobalFree((HGLOBAL)lparam);
ok(hglobal == (HGLOBAL)lparam, "Expected lparam, got %d\n", ret); ok(hglobal == (HGLOBAL)lparam, "Expected lparam, got %d\n", ret);
ok(GetLastError() == ERROR_INVALID_HANDLE, ok(GetLastError() == ERROR_INVALID_HANDLE,
"Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
}
else
win_skip("got lparam 0x%lx for WM_DDE_ACK\n", lparam);
lparam = PackDDElParam(WM_DDE_DATA, 0xcafe, 0xbeef); lparam = PackDDElParam(WM_DDE_DATA, 0xcafe, 0xbeef);
ptr = GlobalLock((HGLOBAL)lparam); /* win9x returns 0 here */
ok(ptr != NULL, "Expected non-NULL ptr\n"); if (lparam) {
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]); ptr = GlobalLock((HGLOBAL)lparam);
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]); ok(ptr != NULL, "Expected non-NULL ptr\n");
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
ret = GlobalUnlock((HGLOBAL)lparam); ret = GlobalUnlock((HGLOBAL)lparam);
ok(ret == 1, "Expected 1, got %d\n", ret); ok(ret == 1, "Expected 1, got %d\n", ret);
lo = hi = 0; lo = hi = 0;
ret = UnpackDDElParam(WM_DDE_DATA, lparam, &lo, &hi); ret = UnpackDDElParam(WM_DDE_DATA, lparam, &lo, &hi);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo); ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi); ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
}
else
win_skip("no lparam for WM_DDE_DATA\n");
ret = FreeDDElParam(WM_DDE_DATA, lparam); ret = FreeDDElParam(WM_DDE_DATA, lparam);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
...@@ -1927,19 +1941,24 @@ static void test_PackDDElParam(void) ...@@ -1927,19 +1941,24 @@ static void test_PackDDElParam(void)
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
lparam = PackDDElParam(WM_DDE_POKE, 0xcafe, 0xbeef); lparam = PackDDElParam(WM_DDE_POKE, 0xcafe, 0xbeef);
ptr = GlobalLock((HGLOBAL)lparam); /* win9x returns 0 here */
ok(ptr != NULL, "Expected non-NULL ptr\n"); if (lparam) {
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]); ptr = GlobalLock((HGLOBAL)lparam);
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]); ok(ptr != NULL, "Expected non-NULL ptr\n");
ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
ret = GlobalUnlock((HGLOBAL)lparam); ret = GlobalUnlock((HGLOBAL)lparam);
ok(ret == 1, "Expected 1, got %d\n", ret); ok(ret == 1, "Expected 1, got %d\n", ret);
lo = hi = 0; lo = hi = 0;
ret = UnpackDDElParam(WM_DDE_POKE, lparam, &lo, &hi); ret = UnpackDDElParam(WM_DDE_POKE, lparam, &lo, &hi);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo); ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi); ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
}
else
win_skip("no lparam for WM_DDE_POKE\n");
ret = FreeDDElParam(WM_DDE_POKE, lparam); ret = FreeDDElParam(WM_DDE_POKE, lparam);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
......
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