ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
April 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
26 participants
247 discussions
Start a n
N
ew thread
01/01: [XINPUT1_3_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c63fc7f345894433a344e…
commit c63fc7f345894433a344ed085303fc92dbe85cd1 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:52:18 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:52:18 2018 +0100 [XINPUT1_3_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/xinput1_3/xinput.c | 34 ++++++++++++--------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/modules/rostests/winetests/xinput1_3/xinput.c b/modules/rostests/winetests/xinput1_3/xinput.c index 87f9929782..f26fda90eb 100644 --- a/modules/rostests/winetests/xinput1_3/xinput.c +++ b/modules/rostests/winetests/xinput1_3/xinput.c @@ -24,7 +24,7 @@ #include "wine/test.h" static DWORD (WINAPI *pXInputGetState)(DWORD, XINPUT_STATE*); -static DWORD (WINAPI *pXInputGetStateEx)(DWORD, XINPUT_STATE_EX*); +static DWORD (WINAPI *pXInputGetStateEx)(DWORD, XINPUT_STATE*); static DWORD (WINAPI *pXInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*); static DWORD (WINAPI *pXInputSetState)(DWORD, XINPUT_VIBRATION*); static void (WINAPI *pXInputEnable)(BOOL); @@ -91,23 +91,19 @@ static void test_set_state(void) static void test_get_state(void) { - union - { - XINPUT_STATE state; - XINPUT_STATE_EX state_ex; - } xinput; + XINPUT_STATE state; DWORD controllerNum, i, result, good = XUSER_MAX_COUNT; for (i = 0; i < (pXInputGetStateEx ? 2 : 1); i++) { for (controllerNum = 0; controllerNum < XUSER_MAX_COUNT; controllerNum++) { - ZeroMemory(&xinput, sizeof(xinput)); + ZeroMemory(&state, sizeof(state)); if (i == 0) - result = pXInputGetState(controllerNum, &xinput.state); + result = pXInputGetState(controllerNum, &state); else - result = pXInputGetStateEx(controllerNum, &xinput.state_ex); + result = pXInputGetStateEx(controllerNum, &state); ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "%s failed with (%d)\n", i == 0 ? "XInputGetState" : "XInputGetStateEx", result); @@ -125,39 +121,39 @@ static void test_get_state(void) } else trace("XInputGetStateEx: %d\n", result); - trace("State->dwPacketNumber: %d\n", xinput.state.dwPacketNumber); - dump_gamepad(&xinput.state.Gamepad); + trace("State->dwPacketNumber: %d\n", state.dwPacketNumber); + dump_gamepad(&state.Gamepad); } } - result = pXInputGetState(XUSER_MAX_COUNT, &xinput.state); + result = pXInputGetState(XUSER_MAX_COUNT, &state); ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result); - result = pXInputGetState(XUSER_MAX_COUNT+1, &xinput.state); + result = pXInputGetState(XUSER_MAX_COUNT+1, &state); ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result); if (pXInputGetStateEx) { - result = pXInputGetStateEx(XUSER_MAX_COUNT, &xinput.state_ex); + result = pXInputGetStateEx(XUSER_MAX_COUNT, &state); ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result); - result = pXInputGetStateEx(XUSER_MAX_COUNT+1, &xinput.state_ex); + result = pXInputGetStateEx(XUSER_MAX_COUNT+1, &state); ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result); } if (winetest_interactive && good < XUSER_MAX_COUNT) { DWORD now = GetTickCount(), packet = 0; - XINPUT_GAMEPAD *game = &xinput.state.Gamepad; + XINPUT_GAMEPAD *game = &state.Gamepad; trace("You have 20 seconds to test the joystick freely\n"); do { Sleep(100); - pXInputGetState(good, &xinput.state); - if (xinput.state.dwPacketNumber == packet) + pXInputGetState(good, &state); + if (state.dwPacketNumber == packet) continue; - packet = xinput.state.dwPacketNumber; + packet = state.dwPacketNumber; trace("Buttons 0x%04X Triggers %3d/%3d LT %6d/%6d RT %6d/%6d\n", game->wButtons, game->bLeftTrigger, game->bRightTrigger, game->sThumbLX, game->sThumbLY, game->sThumbRX, game->sThumbRY);
6 years, 8 months
1
0
0
0
01/01: [WSCRIPT_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3c774903aa7ed5cf3888e…
commit 3c774903aa7ed5cf3888ecf1f43ed0dd31f67c4f Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:51:45 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:51:45 2018 +0100 [WSCRIPT_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/wscript/run.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/rostests/winetests/wscript/run.c b/modules/rostests/winetests/wscript/run.c index 2df2c27c81..770fd8fd28 100644 --- a/modules/rostests/winetests/wscript/run.c +++ b/modules/rostests/winetests/wscript/run.c @@ -18,17 +18,16 @@ #include <stdio.h> -#define WIN32_NO_STATUS -#define _INC_WINDOWS #define COBJMACROS #define CONST_VTABLE -#include <windef.h> -#include <winbase.h> -#include <objbase.h> +#define PSAPI_VERSION 1 +#include <initguid.h> +#include <windows.h> #include <psapi.h> +#include <oaidl.h> -#include <wine/test.h> +#include "wine/test.h" #define DEFINE_EXPECT(func) \ static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
6 years, 8 months
1
0
0
0
01/01: [WS2_32_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=67c66593ea3bfb80d6d1e…
commit 67c66593ea3bfb80d6d1e59dc56f37f3d2eedda5 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:51:13 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:51:13 2018 +0100 [WS2_32_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/ws2_32/sock.c | 1242 +++++++++++++++++++++++++----- 1 file changed, 1048 insertions(+), 194 deletions(-) diff --git a/modules/rostests/winetests/ws2_32/sock.c b/modules/rostests/winetests/ws2_32/sock.c index 58c21ac703..2dc9fd8b9e 100644 --- a/modules/rostests/winetests/ws2_32/sock.c +++ b/modules/rostests/winetests/ws2_32/sock.c @@ -4,6 +4,7 @@ * Copyright 2002 Martin Wilck * Copyright 2005 Thomas Kho * Copyright 2008 Jeff Zaroyko + * Copyright 2017 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,14 +21,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#ifdef __REACTOS__ #undef _WIN32_WINNT #define _WIN32_WINNT 0x0600 +#endif #include <ntstatus.h> #define WIN32_NO_STATUS -#include <wine/test.h> #include <winsock2.h> -#include <wine/winternl.h> +#include <windows.h> +#include <winternl.h> #include <ws2tcpip.h> #include <wsipx.h> #include <wsnwlink.h> @@ -35,7 +38,7 @@ #include <mstcpip.h> #include <iphlpapi.h> #include <stdio.h> - +#include "wine/test.h" // ReactOS: Wine has this in mstcpip.h, but it doesn't belong there #define WSA_CMSG_ALIGN(len) (((len) + sizeof(SIZE_T) - 1) & ~(sizeof(SIZE_T) - 1)) @@ -98,6 +101,9 @@ static NTSTATUS (WINAPI *pNtQueryInformationFile)(HANDLE, PIO_STATUS_BLOCK, PVOI static DWORD (WINAPI *pGetAdaptersInfo)(PIP_ADAPTER_INFO,PULONG); static DWORD (WINAPI *pGetIpForwardTable)(PMIB_IPFORWARDTABLE,PULONG,BOOL); +/* Function pointers from ntdll */ +static DWORD (WINAPI *pNtClose)(HANDLE); + /**************** Structs and typedefs ***************/ typedef struct thread_info @@ -284,6 +290,56 @@ end: return -1; } +static int tcp_socketpair_ovl(SOCKET *src, SOCKET *dst) +{ + SOCKET server = INVALID_SOCKET; + struct sockaddr_in addr; + int len, ret; + + *src = INVALID_SOCKET; + *dst = INVALID_SOCKET; + + *src = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); + if (*src == INVALID_SOCKET) + goto end; + + server = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); + if (server == INVALID_SOCKET) + goto end; + + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + ret = bind(server, (struct sockaddr *)&addr, sizeof(addr)); + if (ret != 0) + goto end; + + len = sizeof(addr); + ret = getsockname(server, (struct sockaddr *)&addr, &len); + if (ret != 0) + goto end; + + ret = listen(server, 1); + if (ret != 0) + goto end; + + ret = connect(*src, (struct sockaddr *)&addr, sizeof(addr)); + if (ret != 0) + goto end; + + len = sizeof(addr); + *dst = accept(server, (struct sockaddr *)&addr, &len); + +end: + if (server != INVALID_SOCKET) + closesocket(server); + if (*src != INVALID_SOCKET && *dst != INVALID_SOCKET) + return 0; + closesocket(*src); + closesocket(*dst); + return -1; +} + static void set_so_opentype ( BOOL overlapped ) { int optval = !overlapped, newval, len = sizeof (int); @@ -1137,7 +1193,7 @@ static void test_WithWSAStartup(void) struct { SOCKET src, dst, dup_src, dup_dst; - } pairs[128]; + } pairs[32]; DWORD error; res = WSAStartup( version, &data ); @@ -1223,8 +1279,7 @@ static void test_WithWSAStartup(void) WSASetLastError(0xdeadbeef); res = WSACleanup(); error = WSAGetLastError(); - ok ( (res == SOCKET_ERROR && error == WSANOTINITIALISED) || - broken(res == 0), /* WinME */ + ok ( res == SOCKET_ERROR && error == WSANOTINITIALISED, "WSACleanup returned %d WSAGetLastError is %d\n", res, error); } @@ -1234,8 +1289,7 @@ static void Init (void) { WORD ver = MAKEWORD (2, 2); WSADATA data; - HMODULE hws2_32 = GetModuleHandleA("ws2_32.dll"), hiphlpapi; - HMODULE hntdll = GetModuleHandleA("ntdll.dll"); + HMODULE hws2_32 = GetModuleHandleA("ws2_32.dll"), hiphlpapi, ntdll; pfreeaddrinfo = (void *)GetProcAddress(hws2_32, "freeaddrinfo"); pgetaddrinfo = (void *)GetProcAddress(hws2_32, "getaddrinfo"); @@ -1255,9 +1309,6 @@ static void Init (void) pWSAEnumNameSpaceProvidersW = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersW"); pWSAPoll = (void *)GetProcAddress(hws2_32, "WSAPoll"); - pNtSetInformationFile = (void *)GetProcAddress(hntdll, "NtSetInformationFile"); - pNtQueryInformationFile = (void *)GetProcAddress(hntdll, "NtQueryInformationFile"); - hiphlpapi = LoadLibraryA("iphlpapi.dll"); if (hiphlpapi) { @@ -1265,6 +1316,14 @@ static void Init (void) pGetAdaptersInfo = (void *)GetProcAddress(hiphlpapi, "GetAdaptersInfo"); } + ntdll = LoadLibraryA("ntdll.dll"); + if (ntdll) + { + pNtClose = (void *)GetProcAddress(ntdll, "NtClose"); + pNtSetInformationFile = (void *)GetProcAddress(ntdll, "NtSetInformationFile"); + pNtQueryInformationFile = (void *)GetProcAddress(ntdll, "NtQueryInformationFile"); + } + ok ( WSAStartup ( ver, &data ) == 0, "WSAStartup failed\n" ); tls = TlsAlloc(); } @@ -1609,10 +1668,8 @@ todo_wine trace("provider name '%s', family %d, type %d, proto %d\n", infoA.szProtocol, prottest[i].family, prottest[i].type, prottest[i].proto); - ok(infoA.szProtocol[0] || broken(!infoA.szProtocol[0]) /* NT4 */, - "WSAPROTOCOL_INFOA was not filled\n"); - ok(infoW.szProtocol[0] || broken(!infoA.szProtocol[0]) /* NT4 */, - "WSAPROTOCOL_INFOW was not filled\n"); + ok(infoA.szProtocol[0], "WSAPROTOCOL_INFOA was not filled\n"); + ok(infoW.szProtocol[0], "WSAPROTOCOL_INFOW was not filled\n"); WideCharToMultiByte(CP_ACP, 0, infoW.szProtocol, -1, providername, sizeof(providername), NULL, NULL); @@ -1724,8 +1781,8 @@ todo_wine ok(!csinfoA.cs.LocalAddr.iSockaddrLength, "Expected 0, got %d\n", csinfoA.cs.LocalAddr.iSockaddrLength); ok(csinfoA.cs.LocalAddr.lpSockaddr == NULL, "Expected NULL, got %p\n", csinfoA.cs.LocalAddr.lpSockaddr); /* Socket is not connected, no information provided */ - ok(!csinfoA.cs.RemoteAddr.iSockaddrLength, "Expected 0, got %d\n", csinfoA.cs.LocalAddr.iSockaddrLength); - ok(csinfoA.cs.RemoteAddr.lpSockaddr == NULL, "Expected NULL, got %p\n", csinfoA.cs.LocalAddr.lpSockaddr); + ok(!csinfoA.cs.RemoteAddr.iSockaddrLength, "Expected 0, got %d\n", csinfoA.cs.RemoteAddr.iSockaddrLength); + ok(csinfoA.cs.RemoteAddr.lpSockaddr == NULL, "Expected NULL, got %p\n", csinfoA.cs.RemoteAddr.lpSockaddr); err = bind(s, (struct sockaddr*)&saddr, sizeof(saddr)); ok(!err, "Expected 0, got %d\n", err); @@ -1737,8 +1794,8 @@ todo_wine ok(csinfoA.cs.LocalAddr.iSockaddrLength, "Expected non-zero\n"); ok(csinfoA.cs.LocalAddr.lpSockaddr != NULL, "Expected non-null\n"); /* Socket is not connected, no information provided */ - ok(!csinfoA.cs.RemoteAddr.iSockaddrLength, "Expected 0, got %d\n", csinfoA.cs.LocalAddr.iSockaddrLength); - ok(csinfoA.cs.RemoteAddr.lpSockaddr == NULL, "Expected NULL, got %p\n", csinfoA.cs.LocalAddr.lpSockaddr); + ok(!csinfoA.cs.RemoteAddr.iSockaddrLength, "Expected 0, got %d\n", csinfoA.cs.RemoteAddr.iSockaddrLength); + ok(csinfoA.cs.RemoteAddr.lpSockaddr == NULL, "Expected NULL, got %p\n", csinfoA.cs.RemoteAddr.lpSockaddr); err = bind(s2, (struct sockaddr*)&saddr, sizeof(saddr)); ok(!err, "Expected 0, got %d\n", err); @@ -2905,10 +2962,6 @@ static void test_WSAEnumNetworkEvents(void) struct sockaddr_in address; HANDLE event; WSANETWORKEVENTS net_events; - /* Windows 2000 Pro without SP installed (testbot) will crash if - * WSAEnumNetworkEvents have a NULL event, so skip this test in <= 2000 */ - DWORD ver = GetVersion() & 0xFFFF; - BOOL supports_null = ((ver & 0xFF) << 8 | (ver >> 8)) > 0x0500; memset(&address, 0, sizeof(address)); address.sin_addr.s_addr = htonl(INADDR_ANY); @@ -2917,8 +2970,6 @@ static void test_WSAEnumNetworkEvents(void) /* This test follows the steps from bugs 10204 and 24946 */ for (l = 0; l < 2; l++) { - if (l == 1 && !supports_null && broken(1)) continue; - for (i = 0; i < sizeof(sock_type) / sizeof(sock_type[0]); i++) { if (i == 2) @@ -2957,7 +3008,7 @@ static void test_WSAEnumNetworkEvents(void) } for (k = 0; k < FD_MAX_EVENTS; k++) { - if (i >= 1 && j == 0 && k == 1) /* first UDP and connected TCP test, FD_WRITE bit no error*/ + if (net_events.lNetworkEvents & (1 << k)) { ok (net_events.iErrorCode[k] == 0x0, "Test[%d][%d]: expected 0x0, got 0x%x\n", i, k, net_events.iErrorCode[k]); @@ -2965,7 +3016,6 @@ static void test_WSAEnumNetworkEvents(void) else { /* Bits that are not set in lNetworkEvents MUST not be changed */ - todo_wine ok (net_events.iErrorCode[k] == 0xABABABAB, "Test[%d][%d]: expected 0xABABABAB, got 0x%x\n", i, k, net_events.iErrorCode[k]); } @@ -3002,13 +3052,8 @@ static void test_WSAAddressToStringA(void) CHAR expect6_1[] = "::1"; CHAR expect6_2[] = "20ab::1"; CHAR expect6_3[] = "[20ab::2001]:33274"; - CHAR expect6_3_nt[] = "20ab::2001@33274"; - CHAR expect6_3_w2k[] = "20ab::2001"; CHAR expect6_3_2[] = "[20ab::2001%4660]:33274"; - CHAR expect6_3_2_nt[] = "4660/20ab::2001@33274"; - CHAR expect6_3_2_w2k[] = "20ab::2001%4660"; CHAR expect6_3_3[] = "20ab::2001%4660"; - CHAR expect6_3_3_nt[] = "4660/20ab::2001"; len = 0; @@ -3111,14 +3156,8 @@ static void test_WSAAddressToStringA(void) ret = WSAAddressToStringA( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len ); ok( !ret, "WSAAddressToStringA() failed unexpectedly: %d\n", WSAGetLastError() ); - ok( !strcmp( address6, expect6_3 ) || - broken( !strcmp( address6, expect6_3_nt ) ) || /* NT4 */ - broken( !strcmp( address6, expect6_3_w2k ) ), /* Win2000 */ - "Expected: %s, got: %s\n", expect6_3, address6 ); - ok( len == sizeof(expect6_3) || - broken( len == sizeof(expect6_3_nt) ) || /* NT4 */ - broken( len == sizeof(expect6_3_w2k) ), /* Win2000 */ - "Got size %d\n", len); + ok( !strcmp( address6, expect6_3 ), "Expected: %s, got: %s\n", expect6_3, address6 ); + ok( len == sizeof(expect6_3), "Got size %d\n", len ); /* Test IPv6 address, port number and scope_id */ len = sizeof(address6); @@ -3130,14 +3169,8 @@ static void test_WSAAddressToStringA(void) ret = WSAAddressToStringA( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len ); ok( !ret, "WSAAddressToStringA() failed unexpectedly: %d\n", WSAGetLastError() ); - ok( !strcmp( address6, expect6_3_2 ) || - broken( !strcmp( address6, expect6_3_2_nt ) ) || /* NT4 */ - broken( !strcmp( address6, expect6_3_2_w2k ) ), /* Win2000 */ - "Expected: %s, got: %s\n", expect6_3_2, address6 ); - ok( len == sizeof(expect6_3_2) || - broken( len == sizeof(expect6_3_2_nt) ) || /* NT4 */ - broken( len == sizeof(expect6_3_2_w2k) ), /* Win2000 */ - "Got size %d\n", len); + ok( !strcmp( address6, expect6_3_2 ), "Expected: %s, got: %s\n", expect6_3_2, address6 ); + ok( len == sizeof(expect6_3_2), "Got size %d\n", len ); /* Test IPv6 address and scope_id */ len = sizeof(address6); @@ -3149,12 +3182,8 @@ static void test_WSAAddressToStringA(void) ret = WSAAddressToStringA( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len ); ok( !ret, "WSAAddressToStringA() failed unexpectedly: %d\n", WSAGetLastError() ); - ok( !strcmp( address6, expect6_3_3 ) || - broken( !strcmp( address6, expect6_3_3_nt ) ), /* NT4 */ - "Expected: %s, got: %s\n", expect6_3_3, address6 ); - ok( len == sizeof(expect6_3_3) || - broken( len == sizeof(expect6_3_3_nt) ), /* NT4 */ - "Got size %d\n", len); + ok( !strcmp( address6, expect6_3_3 ), "Expected: %s, got: %s\n", expect6_3_3, address6 ); + ok( len == sizeof(expect6_3_3), "Got size %d\n", len ); end: if (v6 != INVALID_SOCKET) @@ -3186,13 +3215,8 @@ static void test_WSAAddressToStringW(void) WCHAR expect6_1[] = {':',':','1',0}; WCHAR expect6_2[] = {'2','0','a','b',':',':','1',0}; WCHAR expect6_3[] = {'[','2','0','a','b',':',':','2','0','0','1',']',':','3','3','2','7','4',0}; - WCHAR expect6_3_nt[] = {'2','0','a','b',':',':','2','0','0','1','@','3','3','2','7','4',0}; - WCHAR expect6_3_w2k[] = {'2','0','a','b',':',':','2','0','0','1',0}; WCHAR expect6_3_2[] = {'[','2','0','a','b',':',':','2','0','0','1','%','4','6','6','0',']',':','3','3','2','7','4',0}; - WCHAR expect6_3_2_nt[] = {'4','6','6','0','/','2','0','a','b',':',':','2','0','0','1','@','3','3','2','7','4',0}; - WCHAR expect6_3_2_w2k[] = {'2','0','a','b',':',':','2','0','0','1','%','4','6','6','0',0}; WCHAR expect6_3_3[] = {'2','0','a','b',':',':','2','0','0','1','%','6','5','5','3','4',0}; - WCHAR expect6_3_3_nt[] = {'6','5','5','3','4','/','2','0','a','b',':',':','2','0','0','1',0}; len = 0; @@ -3297,15 +3321,9 @@ static void test_WSAAddressToStringW(void) ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len ); ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() ); - ok( !lstrcmpW( address6, expect6_3 ) || - broken( !lstrcmpW( address6, expect6_3_nt ) ) || /* NT4 */ - broken( !lstrcmpW( address6, expect6_3_w2k ) ), /* Win2000 */ - "Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3), - wine_dbgstr_w(address6) ); - ok( len == sizeof(expect6_3)/sizeof(WCHAR) || - broken(len == sizeof(expect6_3_nt)/sizeof(WCHAR) ) || /* NT4 */ - broken(len == sizeof(expect6_3_w2k)/sizeof(WCHAR) ), /* Win2000 */ - "Got %d\n", len); + ok( !lstrcmpW( address6, expect6_3 ), + "Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3), wine_dbgstr_w(address6) ); + ok( len == sizeof(expect6_3)/sizeof(WCHAR), "Got %d\n", len ); /* Test IPv6 address, port number and scope_id */ len = sizeof(address6)/sizeof(WCHAR); @@ -3317,15 +3335,9 @@ static void test_WSAAddressToStringW(void) ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len ); ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() ); - ok( !lstrcmpW( address6, expect6_3_2 ) || - broken( !lstrcmpW( address6, expect6_3_2_nt ) ) || /* NT4 */ - broken( !lstrcmpW( address6, expect6_3_2_w2k ) ), /* Win2000 */ - "Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3_2), - wine_dbgstr_w(address6) ); - ok( len == sizeof(expect6_3_2)/sizeof(WCHAR) || - broken( len == sizeof(expect6_3_2_nt)/sizeof(WCHAR) ) || /* NT4 */ - broken( len == sizeof(expect6_3_2_w2k)/sizeof(WCHAR) ), /* Win2000 */ - "Got %d\n", len); + ok( !lstrcmpW( address6, expect6_3_2 ), + "Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3_2), wine_dbgstr_w(address6) ); + ok( len == sizeof(expect6_3_2)/sizeof(WCHAR), "Got %d\n", len ); /* Test IPv6 address and scope_id */ len = sizeof(address6)/sizeof(WCHAR); @@ -3337,13 +3349,9 @@ static void test_WSAAddressToStringW(void) ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len ); ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() ); - ok( !lstrcmpW( address6, expect6_3_3 ) || - broken( !lstrcmpW( address6, expect6_3_3_nt ) ), /* NT4 */ - "Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3_3), - wine_dbgstr_w(address6) ); - ok( len == sizeof(expect6_3_3)/sizeof(WCHAR) || - broken( len == sizeof(expect6_3_3_nt)/sizeof(WCHAR) ), /* NT4 */ - "Got %d\n", len); + ok( !lstrcmpW( address6, expect6_3_3 ), + "Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3_3), wine_dbgstr_w(address6) ); + ok( len == sizeof(expect6_3_3)/sizeof(WCHAR), "Got %d\n", len ); end: if (v6 != INVALID_SOCKET) @@ -3554,9 +3562,7 @@ static void test_WSAStringToAddressW(void) ok( (ret == 0 && sin->sin_addr.s_addr == 0xffffffff && sin->sin_port == 0xffff) || (ret == SOCKET_ERROR && (GLE == ERROR_INVALID_PARAMETER || GLE == WSAEINVAL)), "WSAStringToAddressW() failed unexpectedly: %d\n", GLE ); - ok( len == sizeof(SOCKADDR_IN) || - broken(len == sizeof(SOCKADDR_STORAGE)) /* NT4/2k */, - "unexpected length %d\n", len ); + ok( len == sizeof(SOCKADDR_IN), "unexpected length %d\n", len ); len = sizeof(sockaddr); @@ -3842,9 +3848,7 @@ static void test_select(void) ok ( (ret == 0), "closesocket failed unexpectedly: %d\n", ret); WaitForSingleObject (thread_handle, 1000); - ok ( (thread_params.ReadKilled) || - broken(thread_params.ReadKilled == 0), /*Win98*/ - "closesocket did not wakeup select\n"); + ok ( thread_params.ReadKilled, "closesocket did not wake up select\n"); ret = recv(fdRead, &buffer, 1, MSG_PEEK); ok( (ret == -1), "peek at closed socket expected -1 got %d\n", ret); @@ -4052,14 +4056,11 @@ static void test_select(void) tmp_buf[0] = 0xAF; SetLastError(0xdeadbeef); ret = recv(fdRead, tmp_buf, sizeof(tmp_buf), MSG_OOB); - if (ret == SOCKET_ERROR) /* can't recv with MSG_OOB if OOBINLINED */ - { - ok(GetLastError() == WSAEINVAL, "expected 10022, got %d\n", GetLastError()); - ret = recv(fdRead, tmp_buf, sizeof(tmp_buf), 0); - ok(ret == 1, "expected 1, got %d\n", ret); - ok(tmp_buf[0] == 'A', "expected 'A', got 0x%02X\n", tmp_buf[0]); - } - else ok(broken(ret == 1) /* <= NT4 */, "expected error, got 1\n"); + ok(ret == SOCKET_ERROR, "expected SOCKET_ERROR, got %d\n", ret); + ok(GetLastError() == WSAEINVAL, "expected 10022, got %d\n", GetLastError()); + ret = recv(fdRead, tmp_buf, sizeof(tmp_buf), 0); + ok(ret == 1, "expected 1, got %d\n", ret); + ok(tmp_buf[0] == 'A', "expected 'A', got 0x%02X\n", tmp_buf[0]); /* When the connection is closed the socket is set in the read descriptor */ ret = closesocket(fdRead); @@ -4309,8 +4310,7 @@ static void test_accept(void) } WaitForSingleObject(thread_handle, 1000); - ok(thread_params.ReadKilled || broken(!thread_params.ReadKilled) /* Win98/ME, after accept */, - "closesocket did not wakeup accept\n"); + ok(thread_params.ReadKilled, "closesocket did not wake up accept\n"); closesocket(accepted); closesocket(connector); @@ -4582,8 +4582,7 @@ static void test_getsockname(void) } ret = memcmp(sa_get.sin_zero, null_padding, 8); - ok(ret == 0 || broken(ret != 0), /* NT4 */ - "getsockname did not zero the sockaddr_in structure\n"); + ok(ret == 0, "getsockname did not zero the sockaddr_in structure\n"); closesocket(sock); @@ -5151,6 +5150,7 @@ static void test_ioctlsocket(void) { SOCKET sock, src, dst; struct tcp_keepalive kalive; + struct sockaddr_in address; int ret, optval; static const LONG cmds[] = {FIONBIO, FIONREAD, SIOCATMARK}; UINT i, bytes_rec; @@ -5210,30 +5210,61 @@ static void test_ioctlsocket(void) ret = WSAGetLastError(); ok(ret == WSAEFAULT || broken(ret == WSAEINVAL), "expected WSAEFAULT, got %d instead\n", ret); - /* broken used to catch W95, W98, NT4 */ make_keepalive(kalive, 0, 0, 0); ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kalive, sizeof(struct tcp_keepalive), NULL, 0, &arg, NULL, NULL); - ok(ret == 0 || broken(ret == SOCKET_ERROR), "WSAIoctl failed unexpectedly\n"); + ok(ret == 0, "WSAIoctl failed unexpectedly\n"); make_keepalive(kalive, 1, 0, 0); ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kalive, sizeof(struct tcp_keepalive), NULL, 0, &arg, NULL, NULL); - ok(ret == 0 || broken(ret == SOCKET_ERROR), "WSAIoctl failed unexpectedly\n"); + ok(ret == 0, "WSAIoctl failed unexpectedly\n"); make_keepalive(kalive, 1, 1000, 1000); ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kalive, sizeof(struct tcp_keepalive), NULL, 0, &arg, NULL, NULL); - ok(ret == 0 || broken(ret == SOCKET_ERROR), "WSAIoctl failed unexpectedly\n"); + ok(ret == 0, "WSAIoctl failed unexpectedly\n"); make_keepalive(kalive, 1, 10000, 10000); ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kalive, sizeof(struct tcp_keepalive), NULL, 0, &arg, NULL, NULL); - ok(ret == 0 || broken(ret == SOCKET_ERROR), "WSAIoctl failed unexpectedly\n"); + ok(ret == 0, "WSAIoctl failed unexpectedly\n"); make_keepalive(kalive, 1, 100, 100); ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kalive, sizeof(struct tcp_keepalive), NULL, 0, &arg, NULL, NULL); - ok(ret == 0 || broken(ret == SOCKET_ERROR), "WSAIoctl failed unexpectedly\n"); + ok(ret == 0, "WSAIoctl failed unexpectedly\n"); make_keepalive(kalive, 0, 100, 100); ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kalive, sizeof(struct tcp_keepalive), NULL, 0, &arg, NULL, NULL); - ok(ret == 0 || broken(ret == SOCKET_ERROR), "WSAIoctl failed unexpectedly\n"); + ok(ret == 0, "WSAIoctl failed unexpectedly\n"); + + closesocket(sock); + + sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ok(sock != INVALID_SOCKET, "Creating the socket failed: %d\n", WSAGetLastError()); + if(sock == INVALID_SOCKET) + { + skip("Can't continue without a socket.\n"); + return; + } + + /* test FIONREAD with a fresh and non-connected socket */ + arg = 0xdeadbeef; + ret = ioctlsocket(sock, FIONREAD, &arg); + ok(ret == 0, "ioctlsocket failed unexpectedly with error %d\n", WSAGetLastError()); + ok(arg == 0, "expected 0, got %u\n", arg); + + memset(&address, 0, sizeof(address)); + address.sin_family = AF_INET; + address.sin_addr.s_addr = inet_addr( SERVERIP ); + address.sin_port = htons( SERVERPORT ); + ret = bind(sock, (struct sockaddr *)&address, sizeof(address)); + ok(ret == 0, "bind failed unexpectedly with error %d\n", WSAGetLastError()); + + ret = listen(sock, SOMAXCONN); + ok(ret == 0, "listen failed unexpectedly with error %d\n", WSAGetLastError()); + + /* test FIONREAD with listening socket */ + arg = 0xdeadbeef; + ret = ioctlsocket(sock, FIONREAD, &arg); + ok(ret == 0, "ioctlsocket failed unexpectedly with error %d\n", WSAGetLastError()); + ok(arg == 0, "expected 0, got %u\n", arg); closesocket(sock); @@ -5276,18 +5307,15 @@ static void test_ioctlsocket(void) i = MSG_OOB; SetLastError(0xdeadbeef); ret = recv(dst, &data, 1, i); - if (ret == SOCKET_ERROR) - { - ret = GetLastError(); - ok(ret == WSAEINVAL, "expected 10022, got %d\n", ret); - bufs.len = sizeof(char); - bufs.buf = &data; - ret = WSARecv(dst, &bufs, 1, &bytes_rec, &i, NULL, NULL); - ok(ret == SOCKET_ERROR, "expected -1, got %d\n", ret); - ret = GetLastError(); - ok(ret == WSAEINVAL, "expected 10022, got %d\n", ret); - } - else ok(broken(ret == 1) /* <= NT4 */, "expected error, got 1\n"); + ok(ret == SOCKET_ERROR, "expected SOCKET_ERROR, got %d\n", ret); + ret = GetLastError(); + ok(ret == WSAEINVAL, "expected 10022, got %d\n", ret); + bufs.len = sizeof(char); + bufs.buf = &data; + ret = WSARecv(dst, &bufs, 1, &bytes_rec, &i, NULL, NULL); + ok(ret == SOCKET_ERROR, "expected -1, got %d\n", ret); + ret = GetLastError(); + ok(ret == WSAEINVAL, "expected 10022, got %d\n", ret); closesocket(dst); optval = 0xdeadbeef; @@ -5419,7 +5447,7 @@ static void test_send(void) if (dwRet == WAIT_OBJECT_0) { bret = GetOverlappedResult((HANDLE)dst, &ov, &bytes_sent, FALSE); - ok((bret && bytes_sent == buflen) || broken(!bret && GetLastError() == ERROR_IO_INCOMPLETE) /* win9x */, + ok(bret && bytes_sent == buflen, "Got %d instead of %d (%d - %d)\n", bytes_sent, buflen, bret, GetLastError()); } @@ -6135,11 +6163,6 @@ static void test_events(int useMessages) "Got %d instead of 1 (%d - %d)\n", bytesReturned, bret, GetLastError()); ok(buffer[0] == '2', "Got %c instead of 2\n", buffer[0]); } - else if (dwRet == WAIT_TIMEOUT) - { - /* this happens on win98. We get an FD_READ later on the next test */ - CancelIo((HANDLE) src); - } if (0) { ret = recv(src, buffer, 1, MSG_OOB); @@ -6897,6 +6920,195 @@ end: WSACloseEvent(event); } +struct write_watch_thread_args +{ + int func; + SOCKET dest; + void *base; + DWORD size; + const char *expect; +}; + +static DWORD CALLBACK write_watch_thread( void *arg ) +{ + struct write_watch_thread_args *args = arg; + struct sockaddr addr; + int addr_len = sizeof(addr), ret; + DWORD bytes, flags = 0; + WSABUF buf[1]; + + switch (args->func) + { + case 0: + ret = recv( args->dest, args->base, args->size, 0 ); + ok( ret == strlen(args->expect) + 1, "wrong len %d\n", ret ); + ok( !strcmp( args->base, args->expect ), "wrong data\n" ); + break; + case 1: + ret = recvfrom( args->dest, args->base, args->size, 0, &addr, &addr_len ); + ok( ret == strlen(args->expect) + 1, "wrong len %d\n", ret ); + ok( !strcmp( args->base, args->expect ), "wrong data\n" ); + break; + case 2: + buf[0].len = args->size; + buf[0].buf = args->base; + ret = WSARecv( args->dest, buf, 1, &bytes, &flags, NULL, NULL ); + ok( !ret, "WSARecv failed %u\n", GetLastError() ); + ok( bytes == strlen(args->expect) + 1, "wrong len %d\n", bytes ); + ok( !strcmp( args->base, args->expect ), "wrong data\n" ); + break; + case 3: + buf[0].len = args->size; + buf[0].buf = args->base; + ret = WSARecvFrom( args->dest, buf, 1, &bytes, &flags, &addr, &addr_len, NULL, NULL ); + ok( !ret, "WSARecvFrom failed %u\n", GetLastError() ); + ok( bytes == strlen(args->expect) + 1, "wrong len %d\n", bytes ); + ok( !strcmp( args->base, args->expect ), "wrong data\n" ); + break; + } + return 0; +} + +static void test_write_watch(void) +{ + SOCKET src, dest; + WSABUF bufs[2]; + WSAOVERLAPPED ov; + struct write_watch_thread_args args; + DWORD bytesReturned, flags, size; + struct sockaddr addr; + int addr_len, ret; + HANDLE thread, event; + char *base; + void *results[64]; + ULONG_PTR count; + ULONG pagesize; + UINT (WINAPI *pGetWriteWatch)(DWORD,LPVOID,SIZE_T,LPVOID*,ULONG_PTR*,ULONG*); + + pGetWriteWatch = (void *)GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetWriteWatch" ); + if (!pGetWriteWatch) + { + win_skip( "write watched not supported\n" ); + return; + } + + tcp_socketpair(&src, &dest); + if (src == INVALID_SOCKET || dest == INVALID_SOCKET) + { + skip("failed to create sockets\n"); + return; + } + + memset(&ov, 0, sizeof(ov)); + ov.hEvent = event = CreateEventA(NULL, FALSE, FALSE, NULL); + ok(ov.hEvent != NULL, "could not create event object, errno = %d\n", GetLastError()); + + flags = 0; + + size = 0x10000; + base = VirtualAlloc( 0, size, MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, PAGE_READWRITE ); + ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() ); + + memset( base, 0, size ); + count = 64; + ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize ); + ok( !ret, "GetWriteWatch failed %u\n", GetLastError() ); + ok( count == 16, "wrong count %lu\n", count ); + + bufs[0].len = 5; + bufs[0].buf = base; + bufs[1].len = 0x8000; + bufs[1].buf = base + 0x4000; + + ret = WSARecv( dest, bufs, 2, NULL, &flags, &ov, NULL); + ok(ret == SOCKET_ERROR && GetLastError() == ERROR_IO_PENDING, + "WSARecv failed - %d error %d\n", ret, GetLastError()); + + count = 64; + ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize ); + ok( !ret, "GetWriteWatch failed %u\n", GetLastError() ); + ok( count == 9, "wrong count %lu\n", count ); + ok( !base[0], "data set\n" ); + + send(src, "test message", sizeof("test message"), 0); + + ret = GetOverlappedResult( (HANDLE)dest, &ov, &bytesReturned, TRUE ); + ok( ret, "GetOverlappedResult failed %u\n", GetLastError() ); + ok( bytesReturned == sizeof("test message"), "wrong size %u\n", bytesReturned ); + ok( !memcmp( base, "test ", 5 ), "wrong data %s\n", base ); + ok( !memcmp( base + 0x4000, "message", 8 ), "wrong data %s\n", base + 0x4000 ); + + count = 64; + ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize ); + ok( !ret, "GetWriteWatch failed %u\n", GetLastError() ); + ok( count == 0, "wrong count %lu\n", count ); + + memset( base, 0, size ); + count = 64; + ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize ); + ok( !ret, "GetWriteWatch failed %u\n", GetLastError() ); + ok( count == 16, "wrong count %lu\n", count ); + + bufs[1].len = 0x4000; + bufs[1].buf = base + 0x2000; + ret = WSARecvFrom( dest, bufs, 2, NULL, &flags, &addr, &addr_len, &ov, NULL); + ok(ret == SOCKET_ERROR && GetLastError() == ERROR_IO_PENDING, + "WSARecv failed - %d error %d\n", ret, GetLastError()); + + count = 64; + ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize ); + ok( !ret, "GetWriteWatch failed %u\n", GetLastError() ); + ok( count == 5, "wrong count %lu\n", count ); + ok( !base[0], "data set\n" ); + + send(src, "test message", sizeof("test message"), 0); + + ret = GetOverlappedResult( (HANDLE)dest, &ov, &bytesReturned, TRUE ); + ok( ret, "GetOverlappedResult failed %u\n", GetLastError() ); + ok( bytesReturned == sizeof("test message"), "wrong size %u\n", bytesReturned ); + ok( !memcmp( base, "test ", 5 ), "wrong data %s\n", base ); + ok( !memcmp( base + 0x2000, "message", 8 ), "wrong data %s\n", base + 0x2000 ); + + count = 64; + ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize ); + ok( !ret, "GetWriteWatch failed %u\n", GetLastError() ); + ok( count == 0, "wrong count %lu\n", count ); + + memset( base, 0, size ); + count = 64; + ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize ); + ok( !ret, "GetWriteWatch failed %u\n", GetLastError() ); + ok( count == 16, "wrong count %lu\n", count ); + + args.dest = dest; + args.base = base; + args.size = 0x7002; + args.expect = "test message"; + for (args.func = 0; args.func < 4; args.func++) + { + thread = CreateThread( NULL, 0, write_watch_thread, &args, 0, NULL ); + Sleep( 200 ); + + count = 64; + ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize ); + ok( !ret, "GetWriteWatch failed %u\n", GetLastError() ); + ok( count == 8, "wrong count %lu\n", count ); + + send(src, "test message", sizeof("test message"), 0); + WaitForSingleObject( thread, 10000 ); + CloseHandle( thread ); + + count = 64; + ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize ); + ok( !ret, "GetWriteWatch failed %u\n", GetLastError() ); + ok( count == 0, "wrong count %lu\n", count ); + } + WSACloseEvent( event ); + closesocket( dest ); + closesocket( src ); + VirtualFree( base, 0, MEM_FREE ); +} + #define POLL_CLEAR() ix = 0 #define POLL_SET(s, ev) {fds[ix].fd = s; fds[ix++].events = ev;} #define POLL_ISSET(s, rev) poll_isset(fds, ix, s, rev) @@ -7227,7 +7439,11 @@ static void test_GetAddrInfoW(void) ret = pGetAddrInfoW(empty, NULL, NULL, &result2); ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError()); +#ifdef __REACTOS__ ok(result2 != NULL, "GetAddrInfoW failed\n"); +#else + ok(result != NULL, "GetAddrInfoW failed\n"); +#endif compare_addrinfow(result, result2); pFreeAddrInfoW(result); pFreeAddrInfoW(result2); @@ -7238,7 +7454,11 @@ static void test_GetAddrInfoW(void) ret = pGetAddrInfoW(empty, empty, NULL, &result2); ok(!ret, "GetAddrInfoW failed with %d\n", WSAGetLastError()); +#ifdef __REACTOS__ ok(result2 != NULL, "GetAddrInfoW failed\n"); +#else + ok(result != NULL, "GetAddrInfoW failed\n"); +#endif compare_addrinfow(result, result2); pFreeAddrInfoW(result); pFreeAddrInfoW(result2); @@ -7458,10 +7678,13 @@ static void test_GetAddrInfoExW(void) ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal); ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n"); ok(result != NULL, "result == NULL\n"); - ok(!result->ai_blob, "ai_blob != NULL\n"); - ok(!result->ai_bloblen, "ai_bloblen != 0\n"); - ok(!result->ai_provider, "ai_provider = %s\n", wine_dbgstr_guid(result->ai_provider)); - pFreeAddrInfoExW(result); + if (result != NULL) + { + ok(!result->ai_blob, "ai_blob != NULL\n"); + ok(!result->ai_bloblen, "ai_bloblen != 0\n"); + ok(!result->ai_provider, "ai_provider = %s\n", wine_dbgstr_guid(result->ai_provider)); + pFreeAddrInfoExW(result); + } result = (void*)0xdeadbeef; memset(&overlapped, 0xcc, sizeof(overlapped)); @@ -7606,22 +7829,38 @@ static void test_getaddrinfo(void) * as if requesting with an empty host name. */ ret = pgetaddrinfo(name, NULL, NULL, &result); ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError()); +#ifdef __REACTOS__ ok(result != NULL, "getaddrinfo failed\n"); +#else + ok(result != NULL, "GetAddrInfoW failed\n"); +#endif ret = pgetaddrinfo("", NULL, NULL, &result2); ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError()); +#ifdef __REACTOS__ ok(result2 != NULL, "getaddrinfo failed\n"); +#else + ok(result != NULL, "GetAddrInfoW failed\n"); +#endif compare_addrinfo(result, result2); pfreeaddrinfo(result); pfreeaddrinfo(result2); ret = pgetaddrinfo(name, "", NULL, &result); ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError()); +#ifdef __REACTOS__ ok(result != NULL, "getaddrinfo failed\n"); +#else + ok(result != NULL, "GetAddrInfoW failed\n"); +#endif ret = pgetaddrinfo("", "", NULL, &result2); ok(!ret, "getaddrinfo failed with %d\n", WSAGetLastError()); +#ifdef __REACTOS__ ok(result2 != NULL, "getaddrinfo failed\n"); +#else + ok(result != NULL, "GetAddrInfoW failed\n"); +#endif compare_addrinfo(result, result2); pfreeaddrinfo(result); pfreeaddrinfo(result2); @@ -8087,14 +8326,12 @@ todo_wine bret = pAcceptEx(listener, acceptor, NULL, sizeof(buffer) - 2*(sizeof(struct sockaddr_in) + 16), sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in) + 16, &bytesReturned, &overlapped); - ok(bret == FALSE && - (WSAGetLastError() == WSAEINVAL || - broken(WSAGetLastError() == WSAEFAULT)), /* NT4 */ + todo_wine ok(bret == FALSE && WSAGetLastError() == WSAEFAULT, "AcceptEx on NULL buffer returned %d + errno %d\n", bret, WSAGetLastError()); bret = pAcceptEx(listener, acceptor, buffer, 0, 0, sizeof(struct sockaddr_in) + 16, &bytesReturned, &overlapped); - ok(bret == FALSE && (WSAGetLastError() == ERROR_IO_PENDING || broken(WSAGetLastError() == WSAEINVAL)) /* NT4 */, + ok(bret == FALSE && WSAGetLastError() == ERROR_IO_PENDING, "AcceptEx on too small local address size returned %d + errno %d\n", bret, WSAGetLastError()); bret = CancelIo((HANDLE) listener); @@ -8110,12 +8347,12 @@ todo_wine bret = pAcceptEx(listener, acceptor, buffer, 0, sizeof(struct sockaddr_in) + 16, 0, &bytesReturned, &overlapped); - ok(bret == FALSE && (WSAGetLastError() == WSAEFAULT || broken(WSAGetLastError() == WSAEINVAL)) /* NT4 */, + ok(bret == FALSE && WSAGetLastError() == WSAEFAULT, "AcceptEx on too small remote address size returned %d + errno %d\n", bret, WSAGetLastError()); bret = pAcceptEx(listener, acceptor, buffer, 0, sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in) + 15, &bytesReturned, &overlapped); - ok(bret == FALSE && (WSAGetLastError() == ERROR_IO_PENDING || broken(WSAGetLastError() == WSAEINVAL)) /* NT4 */, + ok(bret == FALSE && WSAGetLastError() == ERROR_IO_PENDING, "AcceptEx on too small remote address size returned %d + errno %d\n", bret, WSAGetLastError()); bret = CancelIo((HANDLE) listener); ok(bret, "Failed to cancel pending accept socket\n"); @@ -8144,7 +8381,7 @@ todo_wine bret = pAcceptEx(listener, acceptor, buffer, 0, sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in) + 16, &bytesReturned, &overlapped); - todo_wine ok((bret == FALSE && WSAGetLastError() == WSAEINVAL) || broken(bret == FALSE && WSAGetLastError() == ERROR_IO_PENDING) /* NT4 */, + todo_wine ok(bret == FALSE && WSAGetLastError() == WSAEINVAL, "AcceptEx on already pending socket returned %d + errno %d\n", bret, WSAGetLastError()); if (bret == FALSE && WSAGetLastError() == ERROR_IO_PENDING) { /* We need to cancel this call, otherwise things fail */ @@ -8160,7 +8397,7 @@ todo_wine } iret = connect(acceptor, (struct sockaddr*)&bindAddress, sizeof(bindAddress)); - todo_wine ok((iret == SOCKET_ERROR && WSAGetLastError() == WSAEINVAL) || broken(!iret) /* NT4 */, + todo_wine ok(iret == SOCKET_ERROR && WSAGetLastError() == WSAEINVAL, "connecting to acceptex acceptor succeeded? return %d + errno %d\n", iret, WSAGetLastError()); if (!iret || (iret == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)) { /* We need to cancel this call, otherwise things fail */ @@ -8408,6 +8645,7 @@ todo_wine dwret = WaitForSingleObject(overlapped.hEvent, 1000); ok(dwret == WAIT_OBJECT_0, "Waiting for accept event failed with %d + errno %d\n", dwret, GetLastError()); + bytesReturned = 123456; bret = GetOverlappedResult((HANDLE)listener, &overlapped, &bytesReturned, FALSE); ok(bret, "GetOverlappedResult failed, error %d\n", GetLastError()); ok(bytesReturned == 0, "bytesReturned isn't supposed to be %d\n", bytesReturned); @@ -8429,7 +8667,7 @@ todo_wine closesocket(acceptor); dwret = WaitForSingleObject(overlapped.hEvent, 1000); - todo_wine ok(dwret == WAIT_OBJECT_0 || broken(dwret == WAIT_TIMEOUT) /* NT4/2000 */, + todo_wine ok(dwret == WAIT_OBJECT_0, "Waiting for accept event failed with %d + errno %d\n", dwret, GetLastError()); if (dwret != WAIT_TIMEOUT) { @@ -8872,8 +9110,7 @@ static void test_getpeername(void) ret = getpeername(sock, NULL, NULL); ok(ret == SOCKET_ERROR, "Expected getpeername to return SOCKET_ERROR, got %d\n", ret); - ok(WSAGetLastError() == WSAENOTCONN || - broken(WSAGetLastError() == WSAEFAULT), /* Win9x and WinMe */ + ok(WSAGetLastError() == WSAENOTCONN, "Expected WSAGetLastError() to return WSAENOTCONN, got %d\n", WSAGetLastError()); memset(&sa, 0, sizeof(sa)); @@ -8888,8 +9125,7 @@ static void test_getpeername(void) ret = getpeername(sock, NULL, NULL); ok(ret == SOCKET_ERROR, "Expected getpeername to return SOCKET_ERROR, got %d\n", ret); - ok(WSAGetLastError() == WSAENOTCONN || - broken(WSAGetLastError() == WSAEFAULT), /* Win9x and WinMe */ + ok(WSAGetLastError() == WSAENOTCONN, "Expected WSAGetLastError() to return WSAENOTCONN, got %d\n", WSAGetLastError()); ret = connect(sock, (struct sockaddr*)&sa, sizeof(sa)); @@ -8963,40 +9199,27 @@ static void test_sioRoutingInterfaceQuery(void) "expected WSAEFAULT, got %d\n", WSAGetLastError()); ret = WSAIoctl(sock, SIO_ROUTING_INTERFACE_QUERY, &sin, sizeof(sin), NULL, 0, &bytesReturned, NULL, NULL); - ok(ret == SOCKET_ERROR && - (WSAGetLastError() == WSAEFAULT /* Win98 */ || - WSAGetLastError() == WSAEINVAL /* NT4 */|| - WSAGetLastError() == WSAEAFNOSUPPORT), - "expected WSAEFAULT or WSAEINVAL or WSAEAFNOSUPPORT, got %d\n", - WSAGetLastError()); + todo_wine ok(ret == SOCKET_ERROR && WSAGetLastError() == WSAEAFNOSUPPORT, + "expected WSAEAFNOSUPPORT, got %d\n", WSAGetLastError()); sin.sin_family = AF_INET; ret = WSAIoctl(sock, SIO_ROUTING_INTERFACE_QUERY, &sin, sizeof(sin), NULL, 0, &bytesReturned, NULL, NULL); - ok(ret == SOCKET_ERROR && - (WSAGetLastError() == WSAEFAULT /* Win98 */ || - WSAGetLastError() == WSAEINVAL), - "expected WSAEFAULT or WSAEINVAL, got %d\n", WSAGetLastError()); + todo_wine ok(ret == SOCKET_ERROR && WSAGetLastError() == WSAEINVAL, + "expected WSAEINVAL, got %d\n", WSAGetLastError()); sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); ret = WSAIoctl(sock, SIO_ROUTING_INTERFACE_QUERY, &sin, sizeof(sin), NULL, 0, &bytesReturned, NULL, NULL); - ok(ret == SOCKET_ERROR && - (WSAGetLastError() == WSAEINVAL /* NT4 */ || - WSAGetLastError() == WSAEFAULT), - "expected WSAEINVAL or WSAEFAULT, got %d\n", WSAGetLastError()); + ok(ret == SOCKET_ERROR && WSAGetLastError() == WSAEFAULT, + "expected WSAEFAULT, got %d\n", WSAGetLastError()); ret = WSAIoctl(sock, SIO_ROUTING_INTERFACE_QUERY, &sin, sizeof(sin), &sout, sizeof(sout), &bytesReturned, NULL, NULL); - ok(!ret || broken(WSAGetLastError() == WSAEINVAL /* NT4 */), - "WSAIoctl failed: %d\n", WSAGetLastError()); - if (!ret) - { - ok(sout.sin_family == AF_INET, "expected AF_INET, got %d\n", - sout.sin_family); - /* We expect the source address to be INADDR_LOOPBACK as well, but - * there's no guarantee that a route to the loopback address exists, - * so rather than introduce spurious test failures we do not test the - * source address. - */ - } + ok(!ret, "WSAIoctl failed: %d\n", WSAGetLastError()); + ok(sout.sin_family == AF_INET, "expected AF_INET, got %d\n", sout.sin_family); + /* We expect the source address to be INADDR_LOOPBACK as well, but + * there's no guarantee that a route to the loopback address exists, + * so rather than introduce spurious test failures we do not test the + * source address. + */ closesocket(sock); } @@ -10052,16 +10275,6 @@ static void test_completion_port(void) io_port = CreateIoCompletionPort((HANDLE)dest, previous_port, 236, 0); ok(io_port != NULL, "failed to create completion port %u\n", GetLastError()); - io_info.Flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS; - status = pNtSetInformationFile((HANDLE)src, &io, &io_info, sizeof(io_info), FileIoCompletionNotificationInformation); - ok(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */, - "expected STATUS_SUCCESS, got %08x\n", status); - - io_info.Flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS; - status = pNtSetInformationFile((HANDLE)dest, &io, &io_info, sizeof(io_info), FileIoCompletionNotificationInformation); - ok(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */, - "expected STATUS_SUCCESS, got %08x\n", status); - bret = pAcceptEx(src, dest, buf, sizeof(buf) - 2*(sizeof(struct sockaddr_in) + 16), sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in) + 16, &num_bytes, &ov); @@ -10087,13 +10300,6 @@ static void test_completion_port(void) ok(olp == &ov, "Overlapped structure is at %p\n", olp); ok(olp && (olp->Internal == (ULONG)STATUS_SUCCESS), "Internal status is %lx\n", olp ? olp->Internal : 0); - io_info.Flags = 0; - status = pNtQueryInformationFile((HANDLE)dest, &io, &io_info, sizeof(io_info), FileIoCompletionNotificationInformation); - ok(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */, - "expected STATUS_SUCCESS, got %08x\n", status); - if (status == STATUS_SUCCESS) - ok((io_info.Flags & FILE_SKIP_COMPLETION_PORT_ON_SUCCESS) != 0, "got %08x\n", io_info.Flags); - SetLastError(0xdeadbeef); key = 0xdeadbeef; num_bytes = 0xdeadbeef; @@ -10134,6 +10340,16 @@ static void test_completion_port(void) io_port = CreateIoCompletionPort((HANDLE)dest, previous_port, 236, 0); ok(io_port != NULL, "failed to create completion port %u\n", GetLastError()); + io_info.Flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS; + status = pNtSetInformationFile((HANDLE)src, &io, &io_info, sizeof(io_info), FileIoCompletionNotificationInformation); + ok(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */, + "expected STATUS_SUCCESS, got %08x\n", status); + + io_info.Flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS; + status = pNtSetInformationFile((HANDLE)dest, &io, &io_info, sizeof(io_info), FileIoCompletionNotificationInformation); + ok(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */, + "expected STATUS_SUCCESS, got %08x\n", status); + bret = pAcceptEx(src, dest, buf, sizeof(buf) - 2*(sizeof(struct sockaddr_in) + 16), sizeof(struct sockaddr_in) + 16, sizeof(struct sockaddr_in) + 16, &num_bytes, &ov); @@ -10164,6 +10380,13 @@ static void test_completion_port(void) ok(olp == &ov, "Overlapped structure is at %p\n", olp); ok(olp && (olp->Internal == (ULONG)STATUS_SUCCESS), "Internal status is %lx\n", olp ? olp->Internal : 0); + io_info.Flags = 0; + status = pNtQueryInformationFile((HANDLE)dest, &io, &io_info, sizeof(io_info), FileIoCompletionNotificationInformation); + ok(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */, + "expected STATUS_SUCCESS, got %08x\n", status); + if (status == STATUS_SUCCESS) + ok((io_info.Flags & FILE_SKIP_COMPLETION_PORT_ON_SUCCESS) != 0, "got %08x\n", io_info.Flags); + SetLastError(0xdeadbeef); key = 0xdeadbeef; num_bytes = 0xdeadbeef; @@ -10273,12 +10496,6 @@ static void test_address_list_query(void) bytes_returned = 0; ret = WSAIoctl(s, SIO_ADDRESS_LIST_QUERY, NULL, 0, NULL, 0, &bytes_returned, NULL, NULL); ok(ret == SOCKET_ERROR, "Got unexpected ret %d.\n", ret); - if(WSAGetLastError() == WSAEINVAL) - { - win_skip("Windows <= NT4 is not supported in this test\n"); - closesocket(s); - return; - } ok(WSAGetLastError() == WSAEFAULT, "Got unexpected error %d.\n", WSAGetLastError()); ok(bytes_returned >= FIELD_OFFSET(SOCKET_ADDRESS_LIST, Address[0]), "Got unexpected bytes_returned %u.\n", bytes_returned); @@ -10698,7 +10915,642 @@ todo_wine HeapFree(GetProcessHeap(), 0, name); } -/**************** Main program ***************/ +static void sync_read(SOCKET src, SOCKET dst) +{ + int ret; + char data[512]; + + ret = send(dst, "Hello World!", 12, 0); + ok(ret == 12, "send returned %d\n", ret); + + memset(data, 0, sizeof(data)); + ret = recv(src, data, sizeof(data), 0); + ok(ret == 12, "expected 12, got %d\n", ret); + ok(!memcmp(data, "Hello World!", 12), "got %u bytes (%*s)\n", ret, ret, data); +} + +static void iocp_async_read(SOCKET src, SOCKET dst) +{ + HANDLE port; + WSAOVERLAPPED ovl, *ovl_iocp; + WSABUF buf; + int ret; + char data[512]; + DWORD flags, bytes; + ULONG_PTR key; + + memset(data, 0, sizeof(data)); + memset(&ovl, 0, sizeof(ovl)); + + port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0); + ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError()); + + buf.len = sizeof(data); + buf.buf = data; + bytes = 0xdeadbeef; + flags = 0; + SetLastError(0xdeadbeef); + ret = WSARecv(src, &buf, 1, &bytes, &flags, &ovl, NULL); + ok(ret == SOCKET_ERROR, "got %d\n", ret); + ok(GetLastError() == ERROR_IO_PENDING, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); + ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %#lx\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + + ret = send(dst, "Hello World!", 12, 0); + ok(ret == 12, "send returned %d\n", ret); + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = NULL; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(ret, "got %d\n", ret); + ok(bytes == 12, "got bytes %u\n", bytes); + ok(key == 0x12345678, "got key %#lx\n", key); + ok(ovl_iocp == &ovl, "got ovl %p\n", ovl_iocp); + if (ovl_iocp) + { + ok(ovl_iocp->InternalHigh == 12, "got %#lx\n", ovl_iocp->InternalHigh); + ok(!ovl_iocp->Internal , "got %#lx\n", ovl_iocp->Internal); + ok(!memcmp(data, "Hello World!", 12), "got %u bytes (%*s)\n", bytes, bytes, data); + } + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); + ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %#lx\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + + CloseHandle(port); +} + +static void iocp_async_read_closesocket(SOCKET src, int how_to_close) +{ + HANDLE port; + WSAOVERLAPPED ovl, *ovl_iocp; + WSABUF buf; + int ret; + char data[512]; + DWORD flags, bytes; + ULONG_PTR key; + HWND hwnd; + MSG msg; + + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, + 0, 0, 0, 0, NULL, NULL, 0, NULL); + ok(hwnd != 0, "CreateWindowEx failed\n"); + + ret = WSAAsyncSelect(src, hwnd, WM_SOCKET, FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE); + ok(!ret, "got %d\n", ret); + + Sleep(100); + memset(&msg, 0, sizeof(msg)); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(ret, "got %d\n", ret); + ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd); + ok(msg.message == WM_SOCKET, "got %04x\n", msg.message); + ok(msg.wParam == src, "got %08lx\n", msg.wParam); + ok(msg.lParam == 2, "got %08lx\n", msg.lParam); + + memset(data, 0, sizeof(data)); + memset(&ovl, 0, sizeof(ovl)); + + port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0); + ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError()); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + buf.len = sizeof(data); + buf.buf = data; + bytes = 0xdeadbeef; + flags = 0; + SetLastError(0xdeadbeef); + ret = WSARecv(src, &buf, 1, &bytes, &flags, &ovl, NULL); + ok(ret == SOCKET_ERROR, "got %d\n", ret); + ok(GetLastError() == ERROR_IO_PENDING, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); + ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %#lx\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + switch (how_to_close) + { + case 0: + closesocket(src); + break; + case 1: + CloseHandle((HANDLE)src); + break; + case 2: + pNtClose((HANDLE)src); + break; + default: + ok(0, "wrong value %d\n", how_to_close); + break; + } + + Sleep(200); + memset(&msg, 0, sizeof(msg)); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + switch (how_to_close) + { + case 0: + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + break; + case 1: + case 2: +todo_wine +{ + ok(ret, "got %d\n", ret); + ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd); + ok(msg.message == WM_SOCKET, "got %04x\n", msg.message); + ok(msg.wParam == src, "got %08lx\n", msg.wParam); + ok(msg.lParam == 0x20, "got %08lx\n", msg.lParam); +} + break; + default: + ok(0, "wrong value %d\n", how_to_close); + break; + } + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = NULL; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); +todo_wine + ok(GetLastError() == ERROR_CONNECTION_ABORTED || GetLastError() == ERROR_NETNAME_DELETED /* XP */, "got %u\n", GetLastError()); + ok(!bytes, "got bytes %u\n", bytes); + ok(key == 0x12345678, "got key %#lx\n", key); + ok(ovl_iocp == &ovl, "got ovl %p\n", ovl_iocp); + if (ovl_iocp) + { + ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh); +todo_wine + ok(ovl_iocp->Internal == (ULONG)STATUS_CONNECTION_ABORTED || ovl_iocp->Internal == (ULONG)STATUS_LOCAL_DISCONNECT /* XP */, "got %#lx\n", ovl_iocp->Internal); + } + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); + ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %#lx\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + + CloseHandle(port); + + DestroyWindow(hwnd); +} + +static void iocp_async_closesocket(SOCKET src) +{ + HANDLE port; + WSAOVERLAPPED *ovl_iocp; + int ret; + DWORD bytes; + ULONG_PTR key; + HWND hwnd; + MSG msg; + + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, + 0, 0, 0, 0, NULL, NULL, 0, NULL); + ok(hwnd != 0, "CreateWindowEx failed\n"); + + ret = WSAAsyncSelect(src, hwnd, WM_SOCKET, FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE); + ok(!ret, "got %d\n", ret); + + Sleep(100); + memset(&msg, 0, sizeof(msg)); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(ret, "got %d\n", ret); + ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd); + ok(msg.message == WM_SOCKET, "got %04x\n", msg.message); + ok(msg.wParam == src, "got %08lx\n", msg.wParam); + ok(msg.lParam == 2, "got %08lx\n", msg.lParam); + + port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0); + ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError()); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); + ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %lu\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + closesocket(src); + + Sleep(100); + memset(&msg, 0, sizeof(msg)); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); + ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %lu\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + + CloseHandle(port); + + DestroyWindow(hwnd); +} + +struct wsa_async_select_info +{ + SOCKET sock; + HWND hwnd; +}; + +static DWORD WINAPI wsa_async_select_thread(void *param) +{ + struct wsa_async_select_info *info = param; + int ret; + + ret = WSAAsyncSelect(info->sock, info->hwnd, WM_SOCKET, FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE); + ok(!ret, "got %d\n", ret); + + return 0; +} + +struct wsa_recv_info +{ + SOCKET sock; + WSABUF wsa_buf; + WSAOVERLAPPED ovl; +}; + +static DWORD WINAPI wsa_recv_thread(void *param) +{ + struct wsa_recv_info *info = param; + int ret; + DWORD flags, bytes; + + bytes = 0xdeadbeef; + flags = 0; + SetLastError(0xdeadbeef); + ret = WSARecv(info->sock, &info->wsa_buf, 1, &bytes, &flags, &info->ovl, NULL); + ok(ret == SOCKET_ERROR, "got %d\n", ret); + ok(GetLastError() == ERROR_IO_PENDING, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + + return 0; +} + +static void iocp_async_read_thread_closesocket(SOCKET src) +{ + struct wsa_async_select_info select_info; + struct wsa_recv_info recv_info; + HANDLE port, thread; + WSAOVERLAPPED *ovl_iocp; + int ret; + char data[512]; + DWORD bytes, tid; + ULONG_PTR key; + HWND hwnd; + MSG msg; + + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, + 0, 0, 0, 0, NULL, NULL, 0, NULL); + ok(hwnd != 0, "CreateWindowEx failed\n"); + + select_info.sock = src; + select_info.hwnd = hwnd; + thread = CreateThread(NULL, 0, wsa_async_select_thread, &select_info, 0, &tid); + ok(thread != 0, "CreateThread error %u\n", GetLastError()); + ret = WaitForSingleObject(thread, 10000); + ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n"); + + Sleep(100); + memset(&msg, 0, sizeof(msg)); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(ret, "got %d\n", ret); + ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd); + ok(msg.message == WM_SOCKET, "got %04x\n", msg.message); + ok(msg.wParam == src, "got %08lx\n", msg.wParam); + ok(msg.lParam == 2, "got %08lx\n", msg.lParam); + + port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0); + ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError()); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + memset(data, 0, sizeof(data)); + memset(&recv_info.ovl, 0, sizeof(recv_info.ovl)); + recv_info.sock = src; + recv_info.wsa_buf.len = sizeof(data); + recv_info.wsa_buf.buf = data; + thread = CreateThread(NULL, 0, wsa_recv_thread, &recv_info, 0, &tid); + ok(thread != 0, "CreateThread error %u\n", GetLastError()); + ret = WaitForSingleObject(thread, 10000); + ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n"); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); + ok(GetLastError() == WAIT_TIMEOUT || broken(GetLastError() == ERROR_OPERATION_ABORTED) /* XP */, + "got %u\n", GetLastError()); + if (GetLastError() == WAIT_TIMEOUT) + { + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %lx\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + } + else /* document XP behaviour */ + { + ok(!bytes, "got bytes %u\n", bytes); + ok(key == 0x12345678, "got key %#lx\n", key); + ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp); + if (ovl_iocp) + { + ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh); + ok(ovl_iocp->Internal == STATUS_CANCELLED, "got %#lx\n", ovl_iocp->Internal); + } + + closesocket(src); + goto xp_is_broken; + } + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + closesocket(src); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = NULL; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); +todo_wine + ok(GetLastError() == ERROR_CONNECTION_ABORTED || GetLastError() == ERROR_NETNAME_DELETED /* XP */, "got %u\n", GetLastError()); + ok(!bytes, "got bytes %u\n", bytes); + ok(key == 0x12345678, "got key %#lx\n", key); + ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp); + if (ovl_iocp) + { + ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh); +todo_wine + ok(ovl_iocp->Internal == (ULONG)STATUS_CONNECTION_ABORTED || ovl_iocp->Internal == (ULONG)STATUS_LOCAL_DISCONNECT /* XP */, "got %#lx\n", ovl_iocp->Internal); + } + +xp_is_broken: + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); + ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError()); + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %lu\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + + CloseHandle(port); + + DestroyWindow(hwnd); +} + +static void iocp_async_read_thread(SOCKET src, SOCKET dst) +{ + struct wsa_async_select_info select_info; + struct wsa_recv_info recv_info; + HANDLE port, thread; + WSAOVERLAPPED *ovl_iocp; + int ret; + char data[512]; + DWORD bytes, tid; + ULONG_PTR key; + HWND hwnd; + MSG msg; + + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, + 0, 0, 0, 0, NULL, NULL, 0, NULL); + ok(hwnd != 0, "CreateWindowEx failed\n"); + + select_info.sock = src; + select_info.hwnd = hwnd; + thread = CreateThread(NULL, 0, wsa_async_select_thread, &select_info, 0, &tid); + ok(thread != 0, "CreateThread error %u\n", GetLastError()); + ret = WaitForSingleObject(thread, 10000); + ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n"); + + Sleep(100); + memset(&msg, 0, sizeof(msg)); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(ret, "got %d\n", ret); + ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd); + ok(msg.message == WM_SOCKET, "got %04x\n", msg.message); + ok(msg.wParam == src, "got %08lx\n", msg.wParam); + ok(msg.lParam == 2, "got %08lx\n", msg.lParam); + + port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0); + ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError()); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + memset(data, 0, sizeof(data)); + memset(&recv_info.ovl, 0, sizeof(recv_info.ovl)); + recv_info.sock = src; + recv_info.wsa_buf.len = sizeof(data); + recv_info.wsa_buf.buf = data; + thread = CreateThread(NULL, 0, wsa_recv_thread, &recv_info, 0, &tid); + ok(thread != 0, "CreateThread error %u\n", GetLastError()); + ret = WaitForSingleObject(thread, 10000); + ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n"); + + Sleep(100); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(!ret, "got %d\n", ret); + ok(GetLastError() == WAIT_TIMEOUT || broken(GetLastError() == ERROR_OPERATION_ABORTED) /* XP */, "got %u\n", GetLastError()); + if (GetLastError() == WAIT_TIMEOUT) + { + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %lu\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + } + else /* document XP behaviour */ + { + ok(bytes == 0, "got bytes %u\n", bytes); + ok(key == 0x12345678, "got key %#lx\n", key); + ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp); + if (ovl_iocp) + { + ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh); + ok(ovl_iocp->Internal == STATUS_CANCELLED, "got %#lx\n", ovl_iocp->Internal); + } + } + + Sleep(100); + memset(&msg, 0, sizeof(msg)); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret || broken(msg.hwnd == hwnd) /* XP */, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + if (ret) /* document XP behaviour */ + { + ok(msg.message == WM_SOCKET, "got %04x\n", msg.message); + ok(msg.wParam == src, "got %08lx\n", msg.wParam); + ok(msg.lParam == 1, "got %08lx\n", msg.lParam); + } + + ret = send(dst, "Hello World!", 12, 0); + ok(ret == 12, "send returned %d\n", ret); + + Sleep(100); + memset(&msg, 0, sizeof(msg)); + ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE); + ok(!ret || broken(msg.hwnd == hwnd) /* XP */, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam); + if (ret) /* document XP behaviour */ + { + ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd); + ok(msg.message == WM_SOCKET, "got %04x\n", msg.message); + ok(msg.wParam == src, "got %08lx\n", msg.wParam); + ok(msg.lParam == 1, "got %08lx\n", msg.lParam); + } + + bytes = 0xdeadbeef; + key = 0xdeadbeef; + ovl_iocp = (void *)0xdeadbeef; + SetLastError(0xdeadbeef); + ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100); + ok(ret || broken(GetLastError() == WAIT_TIMEOUT) /* XP */, "got %u\n", GetLastError()); + if (ret) + { + ok(bytes == 12, "got bytes %u\n", bytes); + ok(key == 0x12345678, "got key %#lx\n", key); + ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp); + if (ovl_iocp) + { + ok(ovl_iocp->InternalHigh == 12, "got %#lx\n", ovl_iocp->InternalHigh); + ok(!ovl_iocp->Internal , "got %#lx\n", ovl_iocp->Internal); + ok(!memcmp(data, "Hello World!", 12), "got %u bytes (%*s)\n", bytes, bytes, data); + } + } + else /* document XP behaviour */ + { + ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes); + ok(key == 0xdeadbeef, "got key %lu\n", key); + ok(!ovl_iocp, "got ovl %p\n", ovl_iocp); + } + + CloseHandle(port); + + DestroyWindow(hwnd); +} + +static void test_iocp(void) +{ + SOCKET src, dst; + int i, ret; + + ret = tcp_socketpair_ovl(&src, &dst); + ok(!ret, "creating socket pair failed\n"); + sync_read(src, dst); + iocp_async_read(src, dst); + closesocket(src); + closesocket(dst); + + ret = tcp_socketpair_ovl(&src, &dst); + ok(!ret, "creating socket pair failed\n"); + iocp_async_read_thread(src, dst); + closesocket(src); + closesocket(dst); + + for (i = 0; i <= 2; i++) + { + ret = tcp_socketpair_ovl(&src, &dst); + ok(!ret, "creating socket pair failed\n"); + iocp_async_read_closesocket(src, i); + closesocket(dst); + } + + ret = tcp_socketpair_ovl(&src, &dst); + ok(!ret, "creating socket pair failed\n"); + iocp_async_closesocket(src); + closesocket(dst); + + ret = tcp_socketpair_ovl(&src, &dst); + ok(!ret, "creating socket pair failed\n"); + iocp_async_read_thread_closesocket(src); + closesocket(dst); +} START_TEST( sock ) { @@ -10756,6 +11608,8 @@ START_TEST( sock ) test_WSASendTo(); test_WSARecv(); test_WSAPoll(); + test_write_watch(); + test_iocp(); test_events(0); test_events(1);
6 years, 8 months
1
0
0
0
01/01: [WINMM_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1c6244081eb0f89492052…
commit 1c6244081eb0f894920527c78627808f5288ba6c Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:50:40 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:50:40 2018 +0100 [WINMM_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/winmm/mci.c | 2 +- modules/rostests/winetests/winmm/midi.c | 1 + modules/rostests/winetests/winmm/wave.c | 14 ++++++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/rostests/winetests/winmm/mci.c b/modules/rostests/winetests/winmm/mci.c index 52790c8756..7c8aee8273 100644 --- a/modules/rostests/winetests/winmm/mci.c +++ b/modules/rostests/winetests/winmm/mci.c @@ -848,7 +848,7 @@ static void test_playWAVE(HWND hwnd) err = mciSendStringA("play mysound from 250 to 0", NULL, 0, NULL); ok(err==MCIERR_OUTOFRANGE,"mci play from 250 to 0 returned %s\n", dbg_mcierr(err)); - Sleep(50); /* Give play from 0 to 0 time to finish. */ + Sleep(100); /* Give play from 0 to 0 time to finish. */ todo_wine test_notification(hwnd, "play from 0 to 0", MCI_NOTIFY_SUCCESSFUL); err = mciSendStringA("status mysound mode", buf, sizeof(buf), hwnd); diff --git a/modules/rostests/winetests/winmm/midi.c b/modules/rostests/winetests/winmm/midi.c index bf2682aab3..3417aee5d3 100644 --- a/modules/rostests/winetests/winmm/midi.c +++ b/modules/rostests/winetests/winmm/midi.c @@ -24,6 +24,7 @@ #include <stddef.h> #include "windows.h" #include "mmsystem.h" +#include "objbase.h" #include "wine/test.h" extern const char* mmsys_error(MMRESULT error); /* from wave.c */ diff --git a/modules/rostests/winetests/winmm/wave.c b/modules/rostests/winetests/winmm/wave.c index 45c0377d04..d498558aa1 100644 --- a/modules/rostests/winetests/winmm/wave.c +++ b/modules/rostests/winetests/winmm/wave.c @@ -32,15 +32,18 @@ #define NOBITMAP #include "mmddk.h" #include "mmreg.h" -//#include "ks.h" -//#include "ksguid.h" -//#include "ksmedia.h" +#include "ks.h" +#include "ksguid.h" +#ifndef __REACTOS__ +#include "ksmedia.h" +#endif #include "winmm_test.h" -/* FIXME */ +#ifdef __REACTOS__ /* FIXME */ DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); +#endif static DWORD g_tid; @@ -981,7 +984,10 @@ static void wave_out_test_device(UINT_PTR device) "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n", dev_name(device),wave_out_error(rc)); if (rc!=MMSYSERR_NOERROR) + { + HeapFree(GetProcessHeap(), 0, nameA); return; + } trace(" %s: \"%s\" (%s) %d.%d (%d:%d)\n",dev_name(device),capsA.szPname, (nameA?nameA:"failed"),capsA.vDriverVersion >> 8,
6 years, 8 months
1
0
0
0
01/01: [USER32_WINETEST] Sync everything except win.c with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d558fc75a234a98c954f9…
commit d558fc75a234a98c954f91f5bb8ef4831ab152bd Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:49:56 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:49:56 2018 +0100 [USER32_WINETEST] Sync everything except win.c with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/user32/broadcast.c | 88 ++--- modules/rostests/winetests/user32/class.c | 340 ++++++++++++++++-- modules/rostests/winetests/user32/clipboard.c | 415 ++++------------------ modules/rostests/winetests/user32/combo.c | 184 ++++++++-- modules/rostests/winetests/user32/cursoricon.c | 21 +- modules/rostests/winetests/user32/dce.c | 137 +++++++- modules/rostests/winetests/user32/dde.c | 16 +- modules/rostests/winetests/user32/dialog.c | 467 ++++++++++++++++++++++++- modules/rostests/winetests/user32/edit.c | 267 ++++++++++++-- modules/rostests/winetests/user32/generated.c | 12 +- modules/rostests/winetests/user32/input.c | 152 +++++++- modules/rostests/winetests/user32/listbox.c | 67 +++- modules/rostests/winetests/user32/menu.c | 27 +- modules/rostests/winetests/user32/monitor.c | 5 +- modules/rostests/winetests/user32/msg.c | 237 +++++++++++-- modules/rostests/winetests/user32/precomp.h | 10 +- modules/rostests/winetests/user32/resource.c | 5 +- modules/rostests/winetests/user32/scroll.c | 7 +- modules/rostests/winetests/user32/static.c | 10 +- modules/rostests/winetests/user32/sysparams.c | 34 +- modules/rostests/winetests/user32/text.c | 9 +- modules/rostests/winetests/user32/uitools.c | 6 +- modules/rostests/winetests/user32/winstation.c | 9 +- modules/rostests/winetests/user32/wsprintf.c | 8 +- 24 files changed, 1948 insertions(+), 585 deletions(-) diff --git a/modules/rostests/winetests/user32/broadcast.c b/modules/rostests/winetests/user32/broadcast.c index d4041500fa..949d1e865f 100644 --- a/modules/rostests/winetests/user32/broadcast.c +++ b/modules/rostests/winetests/user32/broadcast.c @@ -18,14 +18,23 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#ifndef __REACTOS__ +#define _WIN32_WINNT 0x0501 +#endif + +#include <stdarg.h> +#include <stdio.h> + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winnls.h" + +#include "wine/test.h" typedef LONG (WINAPI *PBROADCAST)( DWORD,LPDWORD,UINT,WPARAM,LPARAM ); typedef LONG (WINAPI *PBROADCASTEX)( DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO ); -static PBROADCAST pBroadcastA; -static PBROADCAST pBroadcastW; -static PBROADCASTEX pBroadcastExA; -static PBROADCASTEX pBroadcastExW; static HANDLE hevent; static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) @@ -48,20 +57,6 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR static BOOL init_procs(void) { WNDCLASSA cls; - HANDLE user32 = GetModuleHandleA("user32.dll"); - pBroadcastA = (PBROADCAST)GetProcAddress(user32, "BroadcastSystemMessageA"); - if (!pBroadcastA) - pBroadcastA = (PBROADCAST)GetProcAddress(user32, "BroadcastSystemMessage"); - ok(pBroadcastA != NULL, "No BroadcastSystemMessage found\n"); - if (!pBroadcastA) - { - win_skip("BroadcastA is not available\n"); - return FALSE; - } - - pBroadcastW = (PBROADCAST)GetProcAddress(user32, "BroadcastSystemMessageW"); - pBroadcastExA = (PBROADCASTEX)GetProcAddress(user32, "BroadcastSystemMessageExA"); - pBroadcastExW = (PBROADCASTEX)GetProcAddress(user32, "BroadcastSystemMessageExW"); hevent = CreateEventA(NULL, TRUE, FALSE, "Asynchronous checking event"); @@ -253,12 +248,8 @@ if (0) /* TODO: Check the hang flags */ PulseEvent(hevent); } -static BOOL (WINAPI *pOpenProcessToken)(HANDLE, DWORD, HANDLE*); -static BOOL (WINAPI *pAdjustTokenPrivileges)(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD); - static void test_noprivileges(void) { - HANDLE advapi32 = GetModuleHandleA("advapi32"); HANDLE token; DWORD recips; BOOL ret; @@ -266,14 +257,12 @@ static void test_noprivileges(void) static const DWORD BSM_ALL_RECIPS = BSM_VXDS | BSM_NETDRIVER | BSM_INSTALLABLEDRIVERS | BSM_APPLICATIONS; - pOpenProcessToken = (void *)GetProcAddress(advapi32, "OpenProcessToken"); - pAdjustTokenPrivileges = (void *)GetProcAddress(advapi32, "AdjustTokenPrivileges"); - if (!pOpenProcessToken || !pAdjustTokenPrivileges || !pOpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token)) + if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token)) { skip("Can't open security token for process\n"); return; } - if (!pAdjustTokenPrivileges(token, TRUE, NULL, 0, NULL, NULL)) + if (!AdjustTokenPrivileges(token, TRUE, NULL, 0, NULL, NULL)) { skip("Can't adjust security token for process\n"); return; @@ -283,7 +272,7 @@ static void test_noprivileges(void) SetLastError(0xcafebabe); recips = BSM_ALLDESKTOPS; ResetEvent(hevent); - ret = pBroadcastExW( BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); + ret = BroadcastSystemMessageExW( BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); ok(ret==1, "Returned: %d error %u\n", ret, GetLastError()); ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); ok(recips == BSM_ALLDESKTOPS || @@ -294,7 +283,7 @@ static void test_noprivileges(void) SetLastError(0xcafebabe); recips = BSM_ALLCOMPONENTS; ResetEvent(hevent); - ret = pBroadcastExW( BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); + ret = BroadcastSystemMessageExW( BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); ok(ret==1, "Returned: %d error %u\n", ret, GetLastError()); ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); ok(recips == BSM_ALLCOMPONENTS || @@ -305,7 +294,7 @@ static void test_noprivileges(void) SetLastError(0xcafebabe); recips = BSM_ALLDESKTOPS|BSM_APPLICATIONS; ResetEvent(hevent); - ret = pBroadcastExW( BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); + ret = BroadcastSystemMessageExW( BSF_QUERY, &recips, WM_NULL, 100, 0, NULL ); ok(ret==1, "Returned: %d error %u\n", ret, GetLastError()); ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); ok(recips == (BSM_ALLDESKTOPS|BSM_APPLICATIONS) || @@ -316,7 +305,7 @@ static void test_noprivileges(void) SetLastError(0xcafebabe); recips = BSM_ALLDESKTOPS|BSM_APPLICATIONS; ResetEvent(hevent); - ret = pBroadcastExW( BSF_QUERY, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY, NULL ); + ret = BroadcastSystemMessageExW( BSF_QUERY, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY, NULL ); ok(!ret, "Returned: %d\n", ret); ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); ok(recips == (BSM_ALLDESKTOPS|BSM_APPLICATIONS) || @@ -331,28 +320,17 @@ START_TEST(broadcast) return; trace("Running BroadcastSystemMessageA tests\n"); - test_parameters(pBroadcastA, "BroadcastSystemMessageA"); - if (pBroadcastW) - { - trace("Running BroadcastSystemMessageW tests\n"); - test_parameters(pBroadcastW, "BroadcastSystemMessageW"); - } - else - win_skip("No BroadcastSystemMessageW, skipping\n"); - if (pBroadcastExA) - { - trace("Running BroadcastSystemMessageExA tests\n"); - test_parametersEx(pBroadcastExA); - } - else - win_skip("No BroadcastSystemMessageExA, skipping\n"); - if (pBroadcastExW) - { - trace("Running BroadcastSystemMessageExW tests\n"); - test_parametersEx(pBroadcastExW); - trace("Attempting privileges checking tests\n"); - test_noprivileges(); - } - else - win_skip("No BroadcastSystemMessageExW, skipping\n"); + test_parameters(BroadcastSystemMessageA, "BroadcastSystemMessageA"); + + trace("Running BroadcastSystemMessageW tests\n"); + test_parameters(BroadcastSystemMessageW, "BroadcastSystemMessageW"); + + trace("Running BroadcastSystemMessageExA tests\n"); + test_parametersEx(BroadcastSystemMessageExA); + + trace("Running BroadcastSystemMessageExW tests\n"); + test_parametersEx(BroadcastSystemMessageExW); + + trace("Attempting privileges checking tests\n"); + test_noprivileges(); } diff --git a/modules/rostests/winetests/user32/class.c b/modules/rostests/winetests/user32/class.c index 0d358c2ad9..934ea0bfee 100755 --- a/modules/rostests/winetests/user32/class.c +++ b/modules/rostests/winetests/user32/class.c @@ -18,14 +18,64 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +/* To get CS_DROPSHADOW with the MSVC headers */ +#ifndef __REACTOS__ +#define _WIN32_WINNT 0x0501 +#endif + +#include <stdlib.h> +#include <stdarg.h> +#include <stdio.h> -#include <commctrl.h> +#include "wine/test.h" +#include "windef.h" +#include "winbase.h" +#include "winnls.h" +#include "winreg.h" +#include "wingdi.h" +#include "winuser.h" +#include "commctrl.h" #define NUMCLASSWORDS 4 #define IS_WNDPROC_HANDLE(x) (((ULONG_PTR)(x) >> 16) == (~0u >> 16)) +#ifdef __i386__ +#define ARCH "x86" +#elif defined __x86_64__ +#define ARCH "amd64" +#elif defined __arm__ +#define ARCH "arm" +#elif defined __aarch64__ +#define ARCH "arm64" +#else +#define ARCH "none" +#endif + +static const char comctl32_manifest[] = +"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n" +" <assemblyIdentity\n" +" type=\"win32\"\n" +" name=\"Wine.User32.Tests\"\n" +" version=\"1.0.0.0\"\n" +" processorArchitecture=\"" ARCH "\"\n" +" />\n" +"<description>Wine comctl32 test suite</description>\n" +"<dependency>\n" +" <dependentAssembly>\n" +" <assemblyIdentity\n" +" type=\"win32\"\n" +" name=\"microsoft.windows.common-controls\"\n" +" version=\"6.0.0.0\"\n" +" processorArchitecture=\"" ARCH "\"\n" +" publicKeyToken=\"6595b64144ccf1df\"\n" +" language=\"*\"\n" +" />\n" +"</dependentAssembly>\n" +"</dependency>\n" +"</assembly>\n"; + static LRESULT WINAPI ClassTest_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_NCCREATE) return 1; @@ -1029,6 +1079,45 @@ static void test_icons(void) DestroyWindow(hwnd); } +static void create_manifest_file(const char *filename, const char *manifest) +{ + WCHAR path[MAX_PATH]; + HANDLE file; + DWORD size; + + MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH ); + file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError()); + WriteFile(file, manifest, strlen(manifest), &size, NULL); + CloseHandle(file); +} + +static HANDLE create_test_actctx(const char *file) +{ + WCHAR path[MAX_PATH]; + ACTCTXW actctx; + HANDLE handle; + + MultiByteToWideChar(CP_ACP, 0, file, -1, path, MAX_PATH); + memset(&actctx, 0, sizeof(ACTCTXW)); + actctx.cbSize = sizeof(ACTCTXW); + actctx.lpSource = path; + + handle = CreateActCtxW(&actctx); + ok(handle != INVALID_HANDLE_VALUE, "failed to create context, error %u\n", GetLastError()); + + ok(actctx.cbSize == sizeof(actctx), "cbSize=%d\n", actctx.cbSize); + ok(actctx.dwFlags == 0, "dwFlags=%d\n", actctx.dwFlags); + ok(actctx.lpSource == path, "lpSource=%p\n", actctx.lpSource); + ok(actctx.wProcessorArchitecture == 0, "wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture); + ok(actctx.wLangId == 0, "wLangId=%d\n", actctx.wLangId); + ok(actctx.lpAssemblyDirectory == NULL, "lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory); + ok(actctx.lpResourceName == NULL, "lpResourceName=%p\n", actctx.lpResourceName); + ok(actctx.lpApplicationName == NULL, "lpApplicationName=%p\n", actctx.lpApplicationName); + ok(actctx.hModule == NULL, "hModule=%p\n", actctx.hModule); + + return handle; +} static void test_comctl32_class( const char *name ) { WNDCLASSA wcA; @@ -1038,23 +1127,82 @@ static void test_comctl32_class( const char *name ) WCHAR nameW[20]; HWND hwnd; - module = GetModuleHandleA( "comctl32" ); - ok( !module, "comctl32 already loaded\n" ); - ret = GetClassInfoA( 0, name, &wcA ); - ok( ret || broken(!ret) /* <= winxp */, "GetClassInfoA failed for %s\n", name ); - if (!ret) return; - MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ); - ret = GetClassInfoW( 0, nameW, &wcW ); - ok( ret, "GetClassInfoW failed for %s\n", name ); - module = GetModuleHandleA( "comctl32" ); - ok( module != 0, "comctl32 not loaded\n" ); - FreeLibrary( module ); - module = GetModuleHandleA( "comctl32" ); - ok( !module, "comctl32 still loaded\n" ); - hwnd = CreateWindowA( name, "test", WS_OVERLAPPEDWINDOW, 0, 0, 10, 10, NULL, NULL, NULL, 0 ); - ok( hwnd != 0, "failed to create window for %s\n", name ); - module = GetModuleHandleA( "comctl32" ); - ok( module != 0, "comctl32 not loaded\n" ); + if (name[0] == '!') + { + char path[MAX_PATH]; + ULONG_PTR cookie; + HANDLE context; + + name++; + + GetTempPathA(sizeof(path)/sizeof(path[0]), path); + strcat(path, "comctl32_class.manifest"); + + create_manifest_file(path, comctl32_manifest); + context = create_test_actctx(path); + ret = DeleteFileA(path); + ok(ret, "Failed to delete manifest file, error %d.\n", GetLastError()); + + module = GetModuleHandleA( "comctl32" ); + ok( !module, "comctl32 already loaded\n" ); + + ret = ActivateActCtx(context, &cookie); + ok(ret, "Failed to activate context.\n"); + + /* Some systems load modules during context activation. In this case skip the rest of the test. */ + module = GetModuleHandleA( "comctl32" ); + ok( !module || broken(module != NULL) /* Vista/Win7 */, "comctl32 already loaded\n" ); + if (module) + { + win_skip("Module loaded during context activation. Skipping tests.\n"); + goto skiptest; + } + + ret = GetClassInfoA( 0, name, &wcA ); + ok( ret || broken(!ret) /* WinXP */, "GetClassInfoA failed for %s\n", name ); + if (!ret) + goto skiptest; + + MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ); + ret = GetClassInfoW( 0, nameW, &wcW ); + ok( ret, "GetClassInfoW failed for %s\n", name ); + module = GetModuleHandleA( "comctl32" ); + ok( module != 0, "comctl32 not loaded\n" ); + FreeLibrary( module ); + module = GetModuleHandleA( "comctl32" ); + ok( !module || broken(module != NULL) /* Vista */, "comctl32 still loaded\n" ); + hwnd = CreateWindowA( name, "test", WS_OVERLAPPEDWINDOW, 0, 0, 10, 10, NULL, NULL, NULL, 0 ); + ok( hwnd != 0, "failed to create window for %s\n", name ); + module = GetModuleHandleA( "comctl32" ); + ok( module != 0, "comctl32 not loaded\n" ); + DestroyWindow( hwnd ); + + skiptest: + ret = DeactivateActCtx(0, cookie); + ok(ret, "Failed to deactivate context.\n"); + ReleaseActCtx(context); + } + else + { + module = GetModuleHandleA( "comctl32" ); + ok( !module, "comctl32 already loaded\n" ); + ret = GetClassInfoA( 0, name, &wcA ); + ok( ret || broken(!ret) /* <= winxp */, "GetClassInfoA failed for %s\n", name ); + if (!ret) return; + MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, sizeof(nameW)/sizeof(WCHAR) ); + ret = GetClassInfoW( 0, nameW, &wcW ); + ok( ret, "GetClassInfoW failed for %s\n", name ); + module = GetModuleHandleA( "comctl32" ); + ok( module != 0, "comctl32 not loaded\n" ); + FreeLibrary( module ); + module = GetModuleHandleA( "comctl32" ); + ok( !module, "comctl32 still loaded\n" ); + hwnd = CreateWindowA( name, "test", WS_OVERLAPPEDWINDOW, 0, 0, 10, 10, NULL, NULL, NULL, 0 ); + ok( hwnd != 0, "failed to create window for %s\n", name ); + module = GetModuleHandleA( "comctl32" ); + ok( module != 0, "comctl32 not loaded\n" ); + DestroyWindow( hwnd ); + } } /* verify that comctl32 classes are automatically loaded by user32 */ @@ -1081,12 +1229,19 @@ static void test_comctl32_classes(void) PROGRESS_CLASSA, REBARCLASSNAMEA, STATUSCLASSNAMEA, + "SysLink", WC_TABCONTROLA, TOOLBARCLASSNAMEA, TOOLTIPS_CLASSA, TRACKBAR_CLASSA, WC_TREEVIEWA, - UPDOWN_CLASSA + UPDOWN_CLASSA, + "!Button", + "!Edit", + "!Static", + "!Listbox", + "!ComboBox", + "!ComboLBox", }; winetest_get_mainargs( &argv ); @@ -1149,6 +1304,150 @@ static void test_IME(void) ok(!lstrcmpiA(ptr, "user32.dll") || !lstrcmpiA(ptr, "ntdll.dll"), "IME window proc implemented in %s\n", ptr); } +static void test_actctx_classes(void) +{ + static const char main_manifest[] = + "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" + "<assemblyIdentity version=\"4.3.2.1\" name=\"Wine.WndClass.Test\" type=\"win32\" />" + "<file name=\"file.exe\">" + "<windowClass>MyTestClass</windowClass>" + "</file>" + "</assembly>"; + static const char *testclass = "MyTestClass"; + WNDCLASSA wc; + ULONG_PTR cookie; + HANDLE context; + BOOL ret; + ATOM class; + HINSTANCE hinst; + char buff[64]; + HWND hwnd; + char path[MAX_PATH]; + + GetTempPathA(sizeof(path)/sizeof(path[0]), path); + strcat(path, "actctx_classes.manifest"); + + create_manifest_file(path, main_manifest); + context = create_test_actctx(path); + ret = DeleteFileA(path); + ok(ret, "Failed to delete manifest file, error %d.\n", GetLastError()); + + ret = ActivateActCtx(context, &cookie); + ok(ret, "Failed to activate context.\n"); + + memset(&wc, 0, sizeof(wc)); + wc.lpfnWndProc = ClassTest_WndProc; + wc.hIcon = LoadIconW(0, (LPCWSTR)IDI_APPLICATION); + wc.lpszClassName = testclass; + + hinst = GetModuleHandleW(0); + + ret = GetClassInfoA(hinst, testclass, &wc); + ok(!ret, "Expected failure.\n"); + + class = RegisterClassA(&wc); + ok(class != 0, "Failed to register class.\n"); + + /* Class info is available by versioned and regular names. */ + ret = GetClassInfoA(hinst, testclass, &wc); + ok(ret, "Failed to get class info.\n"); + + hwnd = CreateWindowExA(0, testclass, "test", 0, 0, 0, 0, 0, 0, 0, hinst, 0); + ok(hwnd != NULL, "Failed to create a window.\n"); + + ret = GetClassNameA(hwnd, buff, sizeof(buff)); + ok(ret, "Failed to get class name.\n"); + ok(!strcmp(buff, testclass), "Unexpected class name.\n"); + + ret = GetClassInfoA(hinst, "4.3.2.1!MyTestClass", &wc); + ok(ret, "Failed to get class info.\n"); + + ret = UnregisterClassA(testclass, hinst); + ok(!ret, "Failed to unregister class.\n"); + + ret = DeactivateActCtx(0, cookie); + ok(ret, "Failed to deactivate context.\n"); + + ret = GetClassInfoA(hinst, testclass, &wc); + ok(!ret, "Unexpected ret val %d.\n", ret); + + ret = GetClassInfoA(hinst, "4.3.2.1!MyTestClass", &wc); + ok(ret, "Failed to get class info.\n"); + + ret = GetClassNameA(hwnd, buff, sizeof(buff)); + ok(ret, "Failed to get class name.\n"); + ok(!strcmp(buff, testclass), "Unexpected class name.\n"); + + DestroyWindow(hwnd); + + ret = UnregisterClassA("MyTestClass", hinst); + ok(!ret, "Unexpected ret value %d.\n", ret); + + ret = UnregisterClassA("4.3.2.1!MyTestClass", hinst); + ok(ret, "Failed to unregister class.\n"); + + /* Register versioned class without active context. */ + wc.lpszClassName = "4.3.2.1!MyTestClass"; + class = RegisterClassA(&wc); + ok(class != 0, "Failed to register class.\n"); + + ret = ActivateActCtx(context, &cookie); + ok(ret, "Failed to activate context.\n"); + + wc.lpszClassName = "MyTestClass"; + class = RegisterClassA(&wc); + ok(class == 0, "Expected failure.\n"); + + ret = DeactivateActCtx(0, cookie); + ok(ret, "Failed to deactivate context.\n"); + + ret = UnregisterClassA("4.3.2.1!MyTestClass", hinst); + ok(ret, "Failed to unregister class.\n"); + + /* Only versioned name is registered. */ + ret = ActivateActCtx(context, &cookie); + ok(ret, "Failed to activate context.\n"); + + wc.lpszClassName = "MyTestClass"; + class = RegisterClassA(&wc); + ok(class != 0, "Failed to register class\n"); + + ret = DeactivateActCtx(0, cookie); + ok(ret, "Failed to deactivate context.\n"); + + ret = GetClassInfoA(hinst, "MyTestClass", &wc); + ok(!ret, "Expected failure.\n"); + + ret = GetClassInfoA(hinst, "4.3.2.1!MyTestClass", &wc); + ok(ret, "Failed to get class info.\n"); + + ret = UnregisterClassA("4.3.2.1!MyTestClass", hinst); + ok(ret, "Failed to unregister class.\n"); + + /* Register regular name first, it's not considered when versioned name is registered. */ + wc.lpszClassName = "MyTestClass"; + class = RegisterClassA(&wc); + ok(class != 0, "Failed to register class.\n"); + + ret = ActivateActCtx(context, &cookie); + ok(ret, "Failed to activate context.\n"); + + wc.lpszClassName = "MyTestClass"; + class = RegisterClassA(&wc); + ok(class != 0, "Failed to register class.\n"); + + ret = DeactivateActCtx(0, cookie); + ok(ret, "Failed to deactivate context.\n"); + + ret = UnregisterClassA("4.3.2.1!MyTestClass", hinst); + ok(ret, "Failed to unregister class.\n"); + + ret = UnregisterClassA("MyTestClass", hinst); + ok(ret, "Failed to unregister class.\n"); + + ReleaseActCtx(context); +} + START_TEST(class) { char **argv; @@ -1178,6 +1477,7 @@ START_TEST(class) test_builtinproc(); test_icons(); test_comctl32_classes(); + test_actctx_classes(); /* this test unregisters the Button class so it should be executed at the end */ test_instances(); diff --git a/modules/rostests/winetests/user32/clipboard.c b/modules/rostests/winetests/user32/clipboard.c index f4aa4a60a3..2dced095b2 100755 --- a/modules/rostests/winetests/user32/clipboard.c +++ b/modules/rostests/winetests/user32/clipboard.c @@ -18,9 +18,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include "wine/test.h" +#include "winbase.h" +#include "winerror.h" +#include "wingdi.h" +#include "winuser.h" +#include "winnls.h" +#ifdef __REACTOS__ #define WM_CLIPBOARDUPDATE 0x031D +#endif static BOOL (WINAPI *pAddClipboardFormatListener)(HWND hwnd); static BOOL (WINAPI *pRemoveClipboardFormatListener)(HWND hwnd); @@ -381,6 +389,9 @@ static void test_RegisterClipboardFormatA(void) ok(len == lstrlenA("my_cool_clipboard_format"), "wrong format name length %d\n", len); ok(!lstrcmpA(buf, "my_cool_clipboard_format"), "wrong format name \"%s\"\n", buf); + len = GetClipboardFormatNameA(format_id, NULL, 0); + ok(len == 0, "wrong format name length %d\n", len); + lstrcpyA(buf, "foo"); SetLastError(0xdeadbeef); len = GetAtomNameA((ATOM)format_id, buf, 256); @@ -888,6 +899,7 @@ static UINT wm_renderformat; static UINT nb_formats; static BOOL cross_thread; static BOOL do_render_format; +static HANDLE update_event; static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { @@ -946,6 +958,7 @@ static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARA ok( msg_flags == ISMEX_NOSEND, "WM_CLIPBOARDUPDATE wrong flags %x\n", msg_flags ); EnterCriticalSection(&clipboard_cs); wm_clipboardupdate++; + SetEvent(update_event); LeaveCriticalSection(&clipboard_cs); break; case WM_USER: @@ -988,13 +1001,44 @@ static void get_clipboard_data_process(void) ok(r, "CloseClipboard failed: %d\n", GetLastError()); } +static UINT old_seq; + +static void check_messages_(int line, HWND win, UINT seq_diff, UINT draw, UINT update, UINT destroy, UINT render) +{ + MSG msg; + UINT count, fmt, seq; + + seq = GetClipboardSequenceNumber(); + ok_(__FILE__, line)(seq - old_seq == seq_diff, "sequence diff %d\n", seq - old_seq); + old_seq = seq; + + if (!cross_thread) + { + while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); + } + + if (update && !broken(!pAddClipboardFormatListener)) + ok(WaitForSingleObject(update_event, 1000) == WAIT_OBJECT_0, "wait failed\n"); + + count = SendMessageA( win, WM_USER + 1, 0, 0 ); + ok_(__FILE__, line)(count == draw, "WM_DRAWCLIPBOARD %sreceived\n", draw ? "not " : ""); + count = SendMessageA( win, WM_USER + 2, 0, 0 ); + ok_(__FILE__, line)(count == update || broken(!pAddClipboardFormatListener), + "WM_CLIPBOARDUPDATE %sreceived\n", update ? "not " : ""); + count = SendMessageA( win, WM_USER + 3, 0, 0 ); + ok_(__FILE__, line)(count == destroy, "WM_DESTROYCLIPBOARD %sreceived\n", destroy ? "not " : ""); + fmt = SendMessageA( win, WM_USER + 4, 0, 0 ); + ok_(__FILE__, line)(fmt == render, "WM_RENDERFORMAT received %04x, expected %04x\n", fmt, render); +} +#define check_messages(a,b,c,d,e,f) check_messages_(__LINE__,a,b,c,d,e,f) + static DWORD WINAPI clipboard_thread(void *param) { HWND ret, win = param; BOOL r; MSG msg; HANDLE handle; - UINT count, fmt, formats, old_seq = 0, seq; + UINT count, fmt, formats; cross_thread = (GetWindowThreadProcessId( win, NULL ) != GetCurrentThreadId()); trace( "%s-threaded test\n", cross_thread ? "multi" : "single" ); @@ -1038,21 +1082,7 @@ static DWORD WINAPI clipboard_thread(void *param) ok( r, "RemoveClipboardFormatListener failed err %d\n", GetLastError()); } - seq = GetClipboardSequenceNumber(); - ok( seq == old_seq, "sequence changed\n" ); - if (!cross_thread) - { - ok( wm_drawclipboard == 1, "WM_DRAWCLIPBOARD not received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER + 1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 0, 1, 0, 0, 0); SetLastError( 0xdeadbeef ); r = OpenClipboard( (HWND)0xdead ); @@ -1062,125 +1092,32 @@ static DWORD WINAPI clipboard_thread(void *param) r = OpenClipboard(win); ok(r, "OpenClipboard failed: %d\n", GetLastError()); - seq = GetClipboardSequenceNumber(); - ok( seq == old_seq, "sequence changed\n" ); - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 0, 0, 0, 0, 0); r = EmptyClipboard(); ok(r, "EmptyClipboard failed: %d\n", GetLastError()); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 1, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - count = SendMessageA( win, WM_USER+3, 0, 0 ); - ok( !count, "WM_DESTROYCLIPBOARD received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 1, 0, 0, 0, 0); r = EmptyClipboard(); ok(r, "EmptyClipboard failed: %d\n", GetLastError()); /* sequence changes again, even though it was already empty */ - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 1, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - count = SendMessageA( win, WM_USER+3, 0, 0 ); - ok( count, "WM_DESTROYCLIPBOARD not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 1, 0, 0, 1, 0); count = SendMessageA( win, WM_USER+5, 0, 0 ); ok( !count, "wrong format count %u on WM_DESTROYCLIPBOARD\n", count ); handle = SetClipboardData( CF_TEXT, create_textA() ); ok(handle != 0, "SetClipboardData failed: %d\n", GetLastError()); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 1, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 1, 0, 0, 0, 0); SetClipboardData( CF_UNICODETEXT, 0 ); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 1, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 1, 0, 0, 0, 0); SetClipboardData( CF_UNICODETEXT, 0 ); /* same data again */ - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 1, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 1, 0, 0, 0, 0); ok( IsClipboardFormatAvailable( CF_TEXT ), "CF_TEXT available\n" ); ok( IsClipboardFormatAvailable( CF_UNICODETEXT ), "CF_UNICODETEXT available\n" ); @@ -1191,40 +1128,12 @@ static DWORD WINAPI clipboard_thread(void *param) ok(r, "CloseClipboard failed: %d\n", GetLastError()); LeaveCriticalSection(&clipboard_cs); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 2, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( wm_drawclipboard == 1, "WM_DRAWCLIPBOARD not received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( count == 1 || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received %04x\n", fmt ); + check_messages(win, 2, 1, 1, 0, 0); r = OpenClipboard(win); ok(r, "OpenClipboard failed: %d\n", GetLastError()); - seq = GetClipboardSequenceNumber(); - ok( seq == old_seq, "sequence changed\n" ); - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 0, 0, 0, 0, 0); ok( IsClipboardFormatAvailable( CF_TEXT ), "CF_TEXT available\n" ); ok( IsClipboardFormatAvailable( CF_UNICODETEXT ), "CF_UNICODETEXT available\n" ); @@ -1244,65 +1153,19 @@ static DWORD WINAPI clipboard_thread(void *param) do_render_format = FALSE; SetClipboardData( CF_WAVE, 0 ); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 1, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received %04x\n", fmt ); + check_messages(win, 1, 0, 0, 0, 0); r = CloseClipboard(); ok(r, "CloseClipboard failed: %d\n", GetLastError()); /* no synthesized format, so CloseClipboard doesn't change the sequence */ - seq = GetClipboardSequenceNumber(); - ok( seq == old_seq, "sequence changed\n" ); - old_seq = seq; - if (!cross_thread) - { - ok( wm_drawclipboard == 1, "WM_DRAWCLIPBOARD not received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( count == 1 || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received %04x\n", fmt ); + check_messages(win, 0, 1, 1, 0, 0); r = OpenClipboard(win); ok(r, "OpenClipboard failed: %d\n", GetLastError()); r = CloseClipboard(); ok(r, "CloseClipboard failed: %d\n", GetLastError()); /* nothing changed */ - seq = GetClipboardSequenceNumber(); - ok( seq == old_seq, "sequence changed\n" ); - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - count = SendMessageA( win, WM_USER+3, 0, 0 ); - ok( !count, "WM_DESTROYCLIPBOARD received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received %04x\n", fmt ); + check_messages(win, 0, 0, 0, 0, 0); formats = CountClipboardFormats(); r = OpenClipboard(0); @@ -1312,195 +1175,67 @@ static DWORD WINAPI clipboard_thread(void *param) r = CloseClipboard(); ok(r, "CloseClipboard failed: %d\n", GetLastError()); - if (!cross_thread) - { - ok( wm_drawclipboard == 1, "WM_DRAWCLIPBOARD not received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( count == 1 || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" ); - count = SendMessageA( win, WM_USER+3, 0, 0 ); - ok( count == 1, "WM_DESTROYCLIPBOARD not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received %04x\n", fmt ); + check_messages(win, 1, 1, 1, 1, 0); count = SendMessageA( win, WM_USER+5, 0, 0 ); ok( count == formats, "wrong format count %u on WM_DESTROYCLIPBOARD\n", count ); r = OpenClipboard(win); ok(r, "OpenClipboard failed: %d\n", GetLastError()); SetClipboardData( CF_WAVE, GlobalAlloc( GMEM_FIXED, 1 )); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 2, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - count = SendMessageA( win, WM_USER+3, 0, 0 ); - ok( !count, "WM_DESTROYCLIPBOARD received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received %04x\n", fmt ); + check_messages(win, 1, 0, 0, 0, 0); EnterCriticalSection(&clipboard_cs); r = CloseClipboard(); ok(r, "CloseClipboard failed: %d\n", GetLastError()); LeaveCriticalSection(&clipboard_cs); - seq = GetClipboardSequenceNumber(); - ok( seq == old_seq, "sequence changed\n" ); - old_seq = seq; - if (!cross_thread) - { - ok( wm_drawclipboard == 1, "WM_DRAWCLIPBOARD not received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( count == 1 || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 0, 1, 1, 0, 0); run_process( "grab_clipboard 0" ); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 1, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; if (!cross_thread) { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); /* in this case we get a cross-thread WM_DRAWCLIPBOARD */ cross_thread = TRUE; while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); cross_thread = FALSE; } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( count == 1 || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 1, 1, 1, 0, 0); r = OpenClipboard(0); ok(r, "OpenClipboard failed: %d\n", GetLastError()); SetClipboardData( CF_WAVE, GlobalAlloc( GMEM_FIXED, 1 )); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 1, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 1, 0, 0, 0, 0); EnterCriticalSection(&clipboard_cs); r = CloseClipboard(); ok(r, "CloseClipboard failed: %d\n", GetLastError()); LeaveCriticalSection(&clipboard_cs); - seq = GetClipboardSequenceNumber(); - ok( seq == old_seq, "sequence changed\n" ); - old_seq = seq; - if (!cross_thread) - { - ok( wm_drawclipboard == 1, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( count == 1 || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 0, 1, 1, 0, 0); run_process( "grab_clipboard 1" ); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 2, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; if (!cross_thread) { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); /* in this case we get a cross-thread WM_DRAWCLIPBOARD */ cross_thread = TRUE; while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); cross_thread = FALSE; } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( count == 1 || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 2, 1, 1, 0, 0); r = OpenClipboard(0); ok(r, "OpenClipboard failed: %d\n", GetLastError()); SetClipboardData( CF_WAVE, GlobalAlloc( GMEM_FIXED, 1 )); - seq = GetClipboardSequenceNumber(); - ok( (int)(seq - old_seq) == 1, "sequence diff %d\n", seq - old_seq ); - old_seq = seq; - if (!cross_thread) - { - ok( !wm_drawclipboard, "WM_DRAWCLIPBOARD received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( !count, "WM_DRAWCLIPBOARD received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( !count, "WM_CLIPBOARDUPDATE received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 1, 0, 0, 0, 0); EnterCriticalSection(&clipboard_cs); r = CloseClipboard(); ok(r, "CloseClipboard failed: %d\n", GetLastError()); LeaveCriticalSection(&clipboard_cs); - seq = GetClipboardSequenceNumber(); - ok( seq == old_seq, "sequence changed\n" ); - old_seq = seq; - if (!cross_thread) - { - ok( wm_drawclipboard == 1, "WM_DRAWCLIPBOARD not received\n" ); - ok( !wm_clipboardupdate, "WM_CLIPBOARDUPDATE received\n" ); - ok( !wm_renderformat, "WM_RENDERFORMAT received\n" ); - while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); - } - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( count == 1 || broken(!pAddClipboardFormatListener), "WM_CLIPBOARDUPDATE not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( !fmt, "WM_RENDERFORMAT received\n" ); + check_messages(win, 0, 1, 1, 0, 0); if (cross_thread) { @@ -1515,16 +1250,9 @@ static DWORD WINAPI clipboard_thread(void *param) do_render_format = TRUE; old_seq = GetClipboardSequenceNumber(); run_process( "get_clipboard_data" ); - seq = GetClipboardSequenceNumber(); - ok( seq == old_seq, "sequence changed\n" ); do_render_format = FALSE; - count = SendMessageA( win, WM_USER+1, 0, 0 ); - ok( count == 1, "WM_DRAWCLIPBOARD not received\n" ); - count = SendMessageA( win, WM_USER+2, 0, 0 ); - ok( count == 1 || broken(!pAddClipboardFormatListener) /* < Vista */, "WM_CLIPBOARDUPDATE not received\n" ); - fmt = SendMessageA( win, WM_USER+4, 0, 0 ); - ok( fmt == CF_TEXT, "WM_RENDERFORMAT received\n" ); + check_messages(win, 0, 1, 1, 0, CF_TEXT); } r = PostMessageA(win, WM_USER, 0, 0); @@ -1555,6 +1283,7 @@ static void test_messages(void) DWORD tid; InitializeCriticalSection(&clipboard_cs); + update_event = CreateEventW(NULL, FALSE, FALSE, NULL); memset(&cls, 0, sizeof(cls)); cls.lpfnWndProc = clipboard_wnd_proc; @@ -1755,10 +1484,8 @@ static void test_handles( HWND hwnd ) h = SetClipboardData( 0xdeadbeef, hfixed ); ok( h == hfixed, "got %p\n", h ); ok( is_fixed( h ), "expected fixed mem %p\n", h ); -#ifndef _WIN64 - /* testing if hfixed2 is freed triggers an exception on Win64 */ - ok( is_freed( hfixed2 ) || broken( !is_freed( hfixed2 )) /* < Vista */, "expected freed mem %p\n", hfixed2 ); -#endif + if (0) /* this test is unreliable / crashes */ + ok( is_freed( hfixed2 ), "expected freed mem %p\n", hfixed2 ); r = CloseClipboard(); ok( r, "gle %d\n", GetLastError() ); diff --git a/modules/rostests/winetests/user32/combo.c b/modules/rostests/winetests/user32/combo.c index 6f42108bb9..ad706ea754 100644 --- a/modules/rostests/winetests/user32/combo.c +++ b/modules/rostests/winetests/user32/combo.c @@ -17,10 +17,20 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <limits.h> +#include <stdarg.h> +#include <stdio.h> + +#define STRICT +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +#include "wine/test.h" #define COMBO_ID 1995 +#define COMBO_YBORDERSIZE() 2 + static HWND hMainWnd; #define expect_eq(expr, value, type, fmt); { type val = expr; ok(val == (value), #expr " expected " #fmt " got " #fmt "\n", (value), val); } @@ -277,13 +287,6 @@ static void test_WM_LBUTTONDOWN(void) static const UINT choices[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72}; static const CHAR stringFormat[] = "%2d"; BOOL ret; - BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO); - - pGetComboBoxInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo"); - if (!pGetComboBoxInfo){ - win_skip("GetComboBoxInfo is not available\n"); - return; - } hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|CBS_DROPDOWN, 0, 0, 200, 150, hMainWnd, (HMENU)COMBO_ID, NULL, 0); @@ -297,7 +300,7 @@ static void test_WM_LBUTTONDOWN(void) cbInfo.cbSize = sizeof(COMBOBOXINFO); SetLastError(0xdeadbeef); - ret = pGetComboBoxInfo(hCombo, &cbInfo); + ret = GetComboBoxInfo(hCombo, &cbInfo); ok(ret, "Failed to get combobox info structure. LastError=%d\n", GetLastError()); hEdit = cbInfo.hwndItem; @@ -438,20 +441,13 @@ static void test_editselection(void) COMBOBOXINFO cbInfo; BOOL ret; DWORD len; - BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO); char edit[20]; - pGetComboBoxInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo"); - if (!pGetComboBoxInfo){ - win_skip("GetComboBoxInfo is not available\n"); - return; - } - /* Build a combo */ hCombo = build_combo(CBS_SIMPLE); cbInfo.cbSize = sizeof(COMBOBOXINFO); SetLastError(0xdeadbeef); - ret = pGetComboBoxInfo(hCombo, &cbInfo); + ret = GetComboBoxInfo(hCombo, &cbInfo); ok(ret, "Failed to get combobox info structure. LastError=%d\n", GetLastError()); hEdit = cbInfo.hwndItem; @@ -505,7 +501,7 @@ static void test_editselection(void) hCombo = build_combo(CBS_SIMPLE); cbInfo.cbSize = sizeof(COMBOBOXINFO); SetLastError(0xdeadbeef); - ret = pGetComboBoxInfo(hCombo, &cbInfo); + ret = GetComboBoxInfo(hCombo, &cbInfo); ok(ret, "Failed to get combobox info structure. LastError=%d\n", GetLastError()); hEdit = cbInfo.hwndItem; @@ -574,7 +570,6 @@ static LRESULT CALLBACK test_window_proc(HWND hwnd, UINT msg, WPARAM wParam, LPA static void test_editselection_focus(DWORD style) { - BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO); HWND hCombo, hEdit, hButton; COMBOBOXINFO cbInfo; BOOL ret; @@ -582,17 +577,10 @@ static void test_editselection_focus(DWORD style) char buffer[16] = {0}; DWORD len; - pGetComboBoxInfo = (void *)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo"); - if (!pGetComboBoxInfo) - { - win_skip("GetComboBoxInfo is not available\n"); - return; - } - hCombo = build_combo(style); cbInfo.cbSize = sizeof(COMBOBOXINFO); SetLastError(0xdeadbeef); - ret = pGetComboBoxInfo(hCombo, &cbInfo); + ret = GetComboBoxInfo(hCombo, &cbInfo); ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError()); hEdit = cbInfo.hwndItem; @@ -639,18 +627,11 @@ static void test_editselection_focus(DWORD style) static void test_listbox_styles(DWORD cb_style) { - BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO); HWND combo; COMBOBOXINFO info; DWORD style, exstyle, expect_style, expect_exstyle; BOOL ret; - pGetComboBoxInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo"); - if (!pGetComboBoxInfo){ - win_skip("GetComboBoxInfo is not available\n"); - return; - } - expect_style = WS_CHILD|WS_CLIPSIBLINGS|LBS_COMBOBOX|LBS_HASSTRINGS|LBS_NOTIFY; if (cb_style == CBS_SIMPLE) { @@ -666,7 +647,7 @@ static void test_listbox_styles(DWORD cb_style) combo = build_combo(cb_style); info.cbSize = sizeof(COMBOBOXINFO); SetLastError(0xdeadbeef); - ret = pGetComboBoxInfo(combo, &info); + ret = GetComboBoxInfo(combo, &info); ok(ret, "Failed to get combobox info structure.\n"); style = GetWindowLongW( info.hwndList, GWL_STYLE ); @@ -692,11 +673,143 @@ static void test_listbox_styles(DWORD cb_style) DestroyWindow(combo); } +static void test_listbox_size(DWORD style) +{ + HWND hCombo, hList; + COMBOBOXINFO cbInfo; + UINT x, y; + BOOL ret; + int i, test; + const char wine_test[] = "Wine Test"; + + static const struct list_size_info + { + int num_items; + int height_combo; + BOOL todo; + } info_height[] = { + {2, 24, TRUE}, + {2, 41, TRUE}, + {2, 42, TRUE}, + {2, 50, TRUE}, + {2, 60}, + {2, 80}, + {2, 89}, + {2, 90}, + {2, 100}, + + {10, 24, TRUE}, + {10, 41, TRUE}, + {10, 42, TRUE}, + {10, 50, TRUE}, + {10, 60, TRUE}, + {10, 80, TRUE}, + {10, 89, TRUE}, + {10, 90, TRUE}, + {10, 100, TRUE}, + }; + + for(test = 0; test < sizeof(info_height) / sizeof(info_height[0]); test++) + { + const struct list_size_info *info_test = &info_height[test]; + int height_item; /* Height of a list item */ + int height_list; /* Height of the list we got */ + int expected_count_list; + int expected_height_list; + int list_height_nonclient; + int list_height_calculated; + RECT rect_list_client, rect_list_complete; + + hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, + info_test->height_combo, hMainWnd, (HMENU)COMBO_ID, NULL, 0); + + cbInfo.cbSize = sizeof(COMBOBOXINFO); + SetLastError(0xdeadbeef); + ret = GetComboBoxInfo(hCombo, &cbInfo); + ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError()); + + hList = cbInfo.hwndList; + for (i = 0; i < info_test->num_items; i++) + SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM) wine_test); + + /* Click on the button to drop down the list */ + x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2; + y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2; + ret = SendMessageA(hCombo, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y)); + ok(ret, "WM_LBUTTONDOWN was not processed. LastError=%d\n", + GetLastError()); + ok(SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0), + "The dropdown list should have appeared after clicking the button.\n"); + + GetClientRect(hList, &rect_list_client); + GetWindowRect(hList, &rect_list_complete); + height_list = rect_list_client.bottom - rect_list_client.top; + height_item = (int)SendMessageA(hList, LB_GETITEMHEIGHT, 0, 0); + + list_height_nonclient = (rect_list_complete.bottom - rect_list_complete.top) + - (rect_list_client.bottom - rect_list_client.top); + + /* Calculate the expected client size of the listbox popup from the size of the combobox. */ + list_height_calculated = info_test->height_combo + - (cbInfo.rcItem.bottom + COMBO_YBORDERSIZE()) + - list_height_nonclient + - 1; + + expected_count_list = list_height_calculated / height_item; + if(expected_count_list < 0) + expected_count_list = 0; + expected_count_list = min(expected_count_list, info_test->num_items); + expected_height_list = expected_count_list * height_item; + + todo_wine_if(info_test->todo) + ok(expected_height_list == height_list, + "Test %d, expected list height to be %d, got %d\n", test, expected_height_list, height_list); + + DestroyWindow(hCombo); + } +} + +static void test_WS_VSCROLL(void) +{ + HWND hCombo, hList; + COMBOBOXINFO info; + DWORD style; + BOOL ret; + int i; + + info.cbSize = sizeof(info); + hCombo = build_combo(CBS_DROPDOWNLIST); + + SetLastError(0xdeadbeef); + ret = GetComboBoxInfo(hCombo, &info); + ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError()); + hList = info.hwndList; + + for(i = 0; i < 3; i++) + { + char buffer[2]; + sprintf(buffer, "%d", i); + SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)buffer); + } + + style = GetWindowLongA(info.hwndList, GWL_STYLE); + SetWindowLongA(hList, GWL_STYLE, style | WS_VSCROLL); + + SendMessageA(hCombo, CB_SHOWDROPDOWN, TRUE, 0); + SendMessageA(hCombo, CB_SHOWDROPDOWN, FALSE, 0); + + style = GetWindowLongA(hList, GWL_STYLE); + ok((style & WS_VSCROLL) != 0, "Style does not include WS_VSCROLL\n"); + + DestroyWindow(hCombo); +} + START_TEST(combo) { hMainWnd = CreateWindowA("static", "Test", WS_OVERLAPPEDWINDOW, 10, 10, 300, 300, NULL, NULL, NULL, 0); ShowWindow(hMainWnd, SW_SHOW); + test_WS_VSCROLL(); test_setfont(CBS_DROPDOWN); test_setfont(CBS_DROPDOWNLIST); test_setitemheight(CBS_DROPDOWN); @@ -711,6 +824,7 @@ START_TEST(combo) test_listbox_styles(CBS_SIMPLE); test_listbox_styles(CBS_DROPDOWN); test_listbox_styles(CBS_DROPDOWNLIST); + test_listbox_size(CBS_DROPDOWN); DestroyWindow(hMainWnd); } diff --git a/modules/rostests/winetests/user32/cursoricon.c b/modules/rostests/winetests/user32/cursoricon.c index 11c89c35fe..5099c08d70 100644 --- a/modules/rostests/winetests/user32/cursoricon.c +++ b/modules/rostests/winetests/user32/cursoricon.c @@ -20,7 +20,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdlib.h> +#include <stdarg.h> +#include <stdio.h> + +#include "wine/test.h" +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "wingdi.h" +#include "winuser.h" #include "pshpack1.h" @@ -1022,6 +1031,12 @@ static const unsigned char gif4pixel[42] = { 0x02,0x00,0x00,0x02,0x03,0x14,0x16,0x05,0x00,0x3b }; +/* An invalid cursor with an invalid dwDIBOffset */ +static const unsigned char invalid_dwDIBOffset[] = { + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 +}; + static const DWORD biSize_tests[] = { 0, sizeof(BITMAPCOREHEADER) - 1, @@ -1061,6 +1076,8 @@ static void test_LoadImageBitmap(const char * test_desc, HBITMAP hbm) ok(ret == bm.bmHeight, "%s: %d lines were converted, not %d\n", test_desc, ret, bm.bmHeight); ok(color_match(pixel, 0x00ffffff), "%s: Pixel is 0x%08x\n", test_desc, pixel); + + ReleaseDC(NULL, hdc); } static void test_LoadImageFile(const char * test_desc, const unsigned char * image_data, @@ -1309,6 +1326,8 @@ static void test_LoadImage(void) test_LoadImageFile("BMP (broken biSize)", bmpimage, sizeof(bmpimage), "bmp", 0); } bitmap_header->biSize = sizeof(BITMAPINFOHEADER); + + test_LoadImageFile("Cursor (invalid dwDIBOffset)", invalid_dwDIBOffset, sizeof(invalid_dwDIBOffset), "cur", 0); } #undef ARRAY_SIZE diff --git a/modules/rostests/winetests/user32/dce.c b/modules/rostests/winetests/user32/dce.c index 92f320cfd0..18ded3357d 100755 --- a/modules/rostests/winetests/user32/dce.c +++ b/modules/rostests/winetests/user32/dce.c @@ -18,7 +18,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdlib.h> +#include <stdarg.h> +#include <stdio.h> + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" + +#include "wine/test.h" #ifndef DCX_USESTYLE #define DCX_USESTYLE 0x00010000 @@ -31,7 +40,7 @@ static void test_dc_attributes(void) { HDC hdc, old_hdc; HDC hdcs[20]; - INT i, rop, def_rop; + INT i, rop, def_rop, caps; BOOL found_dc; /* test cache DC */ @@ -43,11 +52,14 @@ static void test_dc_attributes(void) rop = GetROP2( hdc ); ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( hdc ) == hwnd_cache, "wrong window\n" ); ReleaseDC( hwnd_cache, hdc ); + ok( WindowFromDC( hdc ) == 0, "wrong window\n" ); hdc = GetDC( hwnd_cache ); rop = GetROP2( hdc ); ok( rop == def_rop, "wrong ROP2 %d after release\n", rop ); SetROP2( hdc, R2_WHITE ); + ok( WindowFromDC( hdc ) == hwnd_cache, "wrong window\n" ); ReleaseDC( hwnd_cache, hdc ); old_hdc = hdc; @@ -106,6 +118,28 @@ static void test_dc_attributes(void) ok( rop == 0, "got %d\n", rop ); rop = GetROP2( old_hdc ); ok( rop == 0, "got %d\n", rop ); + caps = GetDeviceCaps( old_hdc, HORZRES ); + ok( caps == 0, "got %d\n", caps ); + caps = GetDeviceCaps( old_hdc, VERTRES ); + ok( caps == 0, "got %d\n", caps ); + caps = GetDeviceCaps( old_hdc, NUMCOLORS ); + ok( caps == 0, "got %d\n", caps ); + ok( WindowFromDC( old_hdc ) == 0, "wrong window\n" ); + + hdc = GetDC(0); + caps = GetDeviceCaps( hdc, HORZRES ); + ok( caps != 0, "got %d\n", caps ); + caps = GetDeviceCaps( hdc, VERTRES ); + ok( caps != 0, "got %d\n", caps ); + caps = GetDeviceCaps( hdc, NUMCOLORS ); + ok( caps != 0, "got %d\n", caps ); + ReleaseDC( 0, hdc ); + caps = GetDeviceCaps( hdc, HORZRES ); + ok( caps == 0, "got %d\n", caps ); + caps = GetDeviceCaps( hdc, VERTRES ); + ok( caps == 0, "got %d\n", caps ); + caps = GetDeviceCaps( hdc, NUMCOLORS ); + ok( caps == 0, "got %d\n", caps ); /* test own DC */ @@ -115,11 +149,14 @@ static void test_dc_attributes(void) ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); old_hdc = hdc; + ok( WindowFromDC( hdc ) == hwnd_owndc, "wrong window\n" ); ReleaseDC( hwnd_owndc, hdc ); + ok( WindowFromDC( hdc ) == hwnd_owndc, "wrong window\n" ); hdc = GetDC( hwnd_owndc ); ok( old_hdc == hdc, "didn't get same DC %p/%p\n", old_hdc, hdc ); rop = GetROP2( hdc ); ok( rop == R2_WHITE, "wrong ROP2 %d after release\n", rop ); + ok( WindowFromDC( hdc ) == hwnd_owndc, "wrong window\n" ); ReleaseDC( hwnd_owndc, hdc ); rop = GetROP2( hdc ); ok( rop == R2_WHITE, "wrong ROP2 %d after second release\n", rop ); @@ -132,11 +169,14 @@ static void test_dc_attributes(void) ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); old_hdc = hdc; + ok( WindowFromDC( hdc ) == hwnd_classdc, "wrong window\n" ); ReleaseDC( hwnd_classdc, hdc ); + ok( WindowFromDC( hdc ) == hwnd_classdc, "wrong window\n" ); hdc = GetDC( hwnd_classdc ); ok( old_hdc == hdc, "didn't get same DC %p/%p\n", old_hdc, hdc ); rop = GetROP2( hdc ); ok( rop == R2_WHITE, "wrong ROP2 %d after release\n", rop ); + ok( WindowFromDC( hdc ) == hwnd_classdc, "wrong window\n" ); ReleaseDC( hwnd_classdc, hdc ); rop = GetROP2( hdc ); ok( rop == R2_WHITE, "wrong ROP2 %d after second release\n", rop ); @@ -145,12 +185,15 @@ static void test_dc_attributes(void) old_hdc = GetDC( hwnd_classdc ); SetROP2( old_hdc, R2_BLACK ); + ok( WindowFromDC( old_hdc ) == hwnd_classdc, "wrong window\n" ); hdc = GetDC( hwnd_classdc2 ); ok( old_hdc == hdc, "didn't get same DC %p/%p\n", old_hdc, hdc ); rop = GetROP2( hdc ); ok( rop == R2_BLACK, "wrong ROP2 %d for other window\n", rop ); + ok( WindowFromDC( hdc ) == hwnd_classdc2, "wrong window\n" ); ReleaseDC( hwnd_classdc, old_hdc ); ReleaseDC( hwnd_classdc, hdc ); + ok( WindowFromDC( hdc ) == hwnd_classdc2, "wrong window\n" ); rop = GetROP2( hdc ); ok( rop == R2_BLACK, "wrong ROP2 %d after release\n", rop ); } @@ -588,19 +631,83 @@ static void test_dc_layout(void) static void test_destroyed_window(void) { - HDC dc; + HDC dc, old_dc; + HDC hdcs[30]; + int i, rop; - dc = GetDCEx(hwnd_cache, 0, DCX_USESTYLE); - ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc); + dc = GetDC( hwnd_cache ); + SetROP2( dc, R2_WHITE ); + rop = GetROP2( dc ); + ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( dc ) == hwnd_cache, "wrong window\n" ); + old_dc = dc; + + DestroyWindow( hwnd_cache ); + rop = GetROP2( dc ); + ok( rop == 0, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( dc ) == 0, "wrong window\n" ); + ok( !ReleaseDC( hwnd_cache, dc ), "ReleaseDC succeeded\n" ); + dc = GetDC( hwnd_cache ); + ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc ); + + for (i = 0; i < 30; i++) + { + dc = hdcs[i] = GetDCEx( hwnd_parent, 0, DCX_CACHE | DCX_USESTYLE ); + if (dc == old_dc) break; + } + ok( i < 30, "DC for destroyed window not reused\n" ); + while (i > 0) ReleaseDC( hwnd_parent, hdcs[--i] ); - dc = GetDCEx(hwnd_owndc, 0, DCX_USESTYLE); - ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc); + dc = GetDC( hwnd_classdc ); + SetROP2( dc, R2_WHITE ); + rop = GetROP2( dc ); + ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( dc ) == hwnd_classdc, "wrong window\n" ); + old_dc = dc; - dc = GetDCEx(hwnd_classdc, 0, DCX_USESTYLE); - ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc); + dc = GetDC( hwnd_classdc2 ); + ok( old_dc == dc, "wrong DC\n" ); + rop = GetROP2( dc ); + ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( dc ) == hwnd_classdc2, "wrong window\n" ); + DestroyWindow( hwnd_classdc2 ); - dc = GetDCEx(hwnd_classdc2, 0, DCX_USESTYLE); - ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc); + rop = GetROP2( dc ); + ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( dc ) == 0, "wrong window\n" ); + ok( !ReleaseDC( hwnd_classdc2, dc ), "ReleaseDC succeeded\n" ); + dc = GetDC( hwnd_classdc2 ); + ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc ); + + dc = GetDC( hwnd_classdc ); + ok( dc != 0, "Got NULL DC\n" ); + rop = GetROP2( dc ); + ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( dc ) == hwnd_classdc, "wrong window\n" ); + DestroyWindow( hwnd_classdc ); + + rop = GetROP2( dc ); + ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( dc ) == 0, "wrong window\n" ); + ok( !ReleaseDC( hwnd_classdc, dc ), "ReleaseDC succeeded\n" ); + dc = GetDC( hwnd_classdc ); + ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc ); + + dc = GetDC( hwnd_owndc ); + ok( dc != 0, "Got NULL DC\n" ); + rop = GetROP2( dc ); + ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( dc ) == hwnd_owndc, "wrong window\n" ); + DestroyWindow( hwnd_owndc ); + + rop = GetROP2( dc ); + ok( rop == 0, "wrong ROP2 %d\n", rop ); + ok( WindowFromDC( dc ) == 0, "wrong window\n" ); + ok( !ReleaseDC( hwnd_owndc, dc ), "ReleaseDC succeeded\n" ); + dc = GetDC( hwnd_owndc ); + ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc ); + + DestroyWindow( hwnd_parent ); } START_TEST(dce) @@ -652,12 +759,6 @@ START_TEST(dce) test_scroll_window(); test_invisible_create(); test_dc_layout(); - - DestroyWindow(hwnd_parent); - DestroyWindow(hwnd_classdc2); - DestroyWindow(hwnd_classdc); - DestroyWindow(hwnd_owndc); - DestroyWindow(hwnd_cache); - + /* this should be last */ test_destroyed_window(); } diff --git a/modules/rostests/winetests/user32/dde.c b/modules/rostests/winetests/user32/dde.c index ab76117654..d63a0f65aa 100755 --- a/modules/rostests/winetests/user32/dde.c +++ b/modules/rostests/winetests/user32/dde.c @@ -19,10 +19,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" - -#include <dde.h> -#include <ddeml.h> +#include <stdarg.h> +#include <stdio.h> + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winnls.h" +#include "dde.h" +#include "ddeml.h" +#include "winerror.h" + +#include "wine/test.h" static const WCHAR TEST_DDE_SERVICE[] = {'T','e','s','t','D','D','E','S','e','r','v','i','c','e',0}; diff --git a/modules/rostests/winetests/user32/dialog.c b/modules/rostests/winetests/user32/dialog.c index f18e626d55..679a76204c 100755 --- a/modules/rostests/winetests/user32/dialog.c +++ b/modules/rostests/winetests/user32/dialog.c @@ -29,7 +29,19 @@ * normally be met. */ -#include "precomp.h" +#ifndef __REACTOS__ +#define WINVER 0x0600 /* For NONCLIENTMETRICS with padding */ +#endif + +#include <assert.h> +#include <stdio.h> +#include <stdarg.h> + +#include "wine/test.h" +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" #define MAXHWNDS 1024 static HWND hwnd [MAXHWNDS]; @@ -1249,8 +1261,441 @@ static INT_PTR CALLBACK TestControlStyleDlgProc(HWND hdlg, UINT msg, return FALSE; } -static void test_DialogBoxParamA(void) +static const WCHAR testtextW[] = {'W','n','d','T','e','x','t',0}; +static const char *testtext = "WndText"; + +enum defdlgproc_text +{ + DLGPROCTEXT_SNDMSGA = 0, + DLGPROCTEXT_SNDMSGW, + DLGPROCTEXT_DLGPROCA, + DLGPROCTEXT_DLGPROCW, + DLGPROCTEXT_SETTEXTA, + DLGPROCTEXT_SETTEXTW, +}; + +static const char *testmodes[] = +{ + "SNDMSGA", + "SNDMSGW", + "DLGPROCA", + "DLGPROCW", + "SETTEXTA", + "SETTEXTW", +}; + +static INT_PTR CALLBACK test_aw_conversion_dlgprocA(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +{ + int mode = HandleToULong(GetPropA(hdlg, "test_mode")); + WCHAR *text = (WCHAR *)lparam; + char *textA = (char *)lparam; + + switch (msg) + { + case WM_SETTEXT: + case WM_WININICHANGE: + case WM_DEVMODECHANGE: + case CB_DIR: + case LB_DIR: + case LB_ADDFILE: + case EM_REPLACESEL: + switch (mode) + { + case DLGPROCTEXT_DLGPROCA: + ok(textA == testtext, "%s: %s, unexpected text %s.\n", IsWindowUnicode(hdlg) ? "U" : "A", + testmodes[mode], textA); + break; + case DLGPROCTEXT_DLGPROCW: + ok(text == testtextW, "%s: %s, unexpected text %s.\n", IsWindowUnicode(hdlg) ? "U" : "A", testmodes[mode], + wine_dbgstr_w(text)); + break; + case DLGPROCTEXT_SNDMSGA: + case DLGPROCTEXT_SETTEXTA: + if (IsWindowUnicode(hdlg)) + { + ok(text != testtextW && !lstrcmpW(text, testtextW), + "U: %s, unexpected text %s.\n", testmodes[mode], wine_dbgstr_w(text)); + } + else + ok(textA == testtext, "A: %s, unexpected text %s.\n", testmodes[mode], textA); + break; + case DLGPROCTEXT_SNDMSGW: + case DLGPROCTEXT_SETTEXTW: + if (IsWindowUnicode(hdlg)) + ok(text == testtextW, "U: %s, unexpected text %s.\n", testmodes[mode], wine_dbgstr_w(text)); + else + ok(textA != testtext && !strcmp(textA, testtext), "A: %s, unexpected text %s.\n", + testmodes[mode], textA); + break; + } + break; + }; + + return DefWindowProcW(hdlg, msg, wparam, lparam); +} + +static INT_PTR CALLBACK test_aw_conversion_dlgprocW(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +{ + int mode = HandleToULong(GetPropA(hdlg, "test_mode")); + WCHAR *text = (WCHAR *)lparam; + char *textA = (char *)lparam; + + switch (msg) + { + case WM_SETTEXT: + case WM_WININICHANGE: + case WM_DEVMODECHANGE: + case CB_DIR: + case LB_DIR: + case LB_ADDFILE: + case EM_REPLACESEL: + switch (mode) + { + case DLGPROCTEXT_DLGPROCA: + ok(textA == testtext, "%s: %s, unexpected text %s.\n", IsWindowUnicode(hdlg) ? "U" : "A", + testmodes[mode], textA); + break; + case DLGPROCTEXT_DLGPROCW: + ok(text == testtextW, "%s: %s, unexpected text %s.\n", IsWindowUnicode(hdlg) ? "U" : "A", testmodes[mode], + wine_dbgstr_w(text)); + break; + case DLGPROCTEXT_SNDMSGA: + case DLGPROCTEXT_SETTEXTA: + if (IsWindowUnicode(hdlg)) + ok(text != testtextW && !lstrcmpW(text, testtextW), + "U: %s, unexpected text %s.\n", testmodes[mode], wine_dbgstr_w(text)); + else + ok(textA == testtext, "A: %s, unexpected text %s.\n", testmodes[mode], textA); + break; + case DLGPROCTEXT_SNDMSGW: + case DLGPROCTEXT_SETTEXTW: + if (IsWindowUnicode(hdlg)) + ok(text == testtextW, "U: %s, unexpected text %s.\n", testmodes[mode], wine_dbgstr_w(text)); + else + ok(textA != testtext && !strcmp(textA, testtext), "A: %s, unexpected text %s.\n", + testmodes[mode], textA); + break; + } + break; + } + + return DefWindowProcA(hdlg, msg, wparam, lparam); +} + +static void dlg_test_aw_message(HWND hdlg, UINT msg) { + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SNDMSGA)); + SendMessageA(hdlg, msg, 0, (LPARAM)testtext); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SNDMSGW)); + SendMessageW(hdlg, msg, 0, (LPARAM)testtextW); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_DLGPROCA)); + DefDlgProcA(hdlg, msg, 0, (LPARAM)testtext); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_DLGPROCW)); + DefDlgProcW(hdlg, msg, 0, (LPARAM)testtextW); +} + +static INT_PTR CALLBACK test_aw_conversion_dlgproc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +{ + ULONG_PTR dlgproc, originalproc; + WCHAR buffW[64]; + char buff[64]; + BOOL ret; + INT len; + + switch (msg) + { + case WM_INITDIALOG: + ok(IsWindowUnicode(hdlg), "Expected unicode window.\n"); + + dlg_test_aw_message(hdlg, WM_WININICHANGE); + dlg_test_aw_message(hdlg, WM_DEVMODECHANGE); + dlg_test_aw_message(hdlg, CB_DIR); + dlg_test_aw_message(hdlg, LB_DIR); + dlg_test_aw_message(hdlg, LB_ADDFILE); + dlg_test_aw_message(hdlg, EM_REPLACESEL); + dlg_test_aw_message(hdlg, WM_SETTEXT); + + /* WM_SETTEXT/WM_GETTEXT */ + originalproc = GetWindowLongPtrW(hdlg, DWLP_DLGPROC); + ok(originalproc == (ULONG_PTR)test_aw_conversion_dlgproc, "Unexpected dlg proc %#lx.\n", originalproc); + + dlgproc = GetWindowLongPtrA(hdlg, DWLP_DLGPROC); + ok(dlgproc != (ULONG_PTR)test_aw_conversion_dlgproc, "Unexpected dlg proc %#lx.\n", dlgproc); + + dlgproc = SetWindowLongPtrA(hdlg, DWLP_DLGPROC, (UINT_PTR)test_aw_conversion_dlgprocA); + ok(IsWindowUnicode(hdlg), "Expected unicode window.\n"); + + dlgproc = GetWindowLongPtrW(hdlg, DWLP_DLGPROC); + ok(dlgproc != (ULONG_PTR)test_aw_conversion_dlgprocA, "Unexpected dlg proc %#lx.\n", dlgproc); + + dlgproc = GetWindowLongPtrA(hdlg, DWLP_DLGPROC); + ok(dlgproc == (ULONG_PTR)test_aw_conversion_dlgprocA, "Unexpected dlg proc %#lx.\n", dlgproc); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SETTEXTA)); + ret = SetWindowTextA(hdlg, testtext); + todo_wine + ok(ret, "Failed to set window text.\n"); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SETTEXTW)); + ret = SetWindowTextW(hdlg, testtextW); + todo_wine + ok(ret, "Failed to set window text.\n"); + + memset(buff, 'A', sizeof(buff)); + len = GetWindowTextA(hdlg, buff, sizeof(buff)); + ok(buff[0] == 0 && buff[1] == 'A' && len == 0, "Unexpected window text %#x, %#x, len %d\n", + (BYTE)buff[0], (BYTE)buff[1], len); + + memset(buffW, 0xff, sizeof(buffW)); + len = GetWindowTextW(hdlg, buffW, 64); + ok(!lstrcmpW(buffW, testtextW) && len == 0, "Unexpected window text %s, len %d\n", wine_dbgstr_w(buffW), len); + + dlg_test_aw_message(hdlg, WM_WININICHANGE); + dlg_test_aw_message(hdlg, WM_DEVMODECHANGE); + dlg_test_aw_message(hdlg, CB_DIR); + dlg_test_aw_message(hdlg, LB_DIR); + dlg_test_aw_message(hdlg, LB_ADDFILE); + dlg_test_aw_message(hdlg, EM_REPLACESEL); + dlg_test_aw_message(hdlg, WM_SETTEXT); + + dlgproc = SetWindowLongPtrW(hdlg, DWLP_DLGPROC, (UINT_PTR)test_aw_conversion_dlgprocW); + ok(IsWindowUnicode(hdlg), "Expected unicode window.\n"); + + dlgproc = GetWindowLongPtrW(hdlg, DWLP_DLGPROC); + ok(dlgproc == (ULONG_PTR)test_aw_conversion_dlgprocW, "Unexpected dlg proc %#lx.\n", dlgproc); + + dlgproc = GetWindowLongPtrA(hdlg, DWLP_DLGPROC); + ok(dlgproc != (ULONG_PTR)test_aw_conversion_dlgprocW, "Unexpected dlg proc %#lx.\n", dlgproc); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SETTEXTA)); + ret = SetWindowTextA(hdlg, testtext); + todo_wine + ok(ret, "Failed to set window text.\n"); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SETTEXTW)); + ret = SetWindowTextW(hdlg, testtextW); + todo_wine + ok(ret, "Failed to set window text.\n"); + + memset(buff, 'A', sizeof(buff)); + len = GetWindowTextA(hdlg, buff, sizeof(buff)); + ok(buff[0] == 0 && buff[1] == 'A' && len == 0, "Unexpected window text %#x, %#x, len %d\n", + (BYTE)buff[0], (BYTE)buff[1], len); + + memset(buffW, 0xff, sizeof(buffW)); + len = GetWindowTextW(hdlg, buffW, sizeof(buffW)/sizeof(buffW[0])); + ok(buffW[0] == 'W' && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n", + buffW[0], buffW[1], len); + + dlg_test_aw_message(hdlg, WM_WININICHANGE); + dlg_test_aw_message(hdlg, WM_DEVMODECHANGE); + dlg_test_aw_message(hdlg, CB_DIR); + dlg_test_aw_message(hdlg, LB_DIR); + dlg_test_aw_message(hdlg, LB_ADDFILE); + dlg_test_aw_message(hdlg, EM_REPLACESEL); + dlg_test_aw_message(hdlg, WM_SETTEXT); + + SetWindowLongPtrA(hdlg, DWLP_DLGPROC, originalproc); + EndDialog(hdlg, -123); + return TRUE; + } + return FALSE; +} + +static INT_PTR CALLBACK test_aw_conversion_dlgproc2(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +{ + ULONG_PTR dlgproc, originalproc; + WCHAR buffW[64]; + char buff[64]; + BOOL ret; + INT len; + + switch (msg) + { + case WM_INITDIALOG: + ok(!IsWindowUnicode(hdlg), "Unexpected unicode window.\n"); + + dlg_test_aw_message(hdlg, WM_WININICHANGE); + dlg_test_aw_message(hdlg, WM_DEVMODECHANGE); + dlg_test_aw_message(hdlg, CB_DIR); + dlg_test_aw_message(hdlg, LB_DIR); + dlg_test_aw_message(hdlg, LB_ADDFILE); + dlg_test_aw_message(hdlg, EM_REPLACESEL); + dlg_test_aw_message(hdlg, WM_SETTEXT); + + originalproc = GetWindowLongPtrW(hdlg, DWLP_DLGPROC); + ok(originalproc != (ULONG_PTR)test_aw_conversion_dlgproc2, "Unexpected dlg proc %#lx.\n", originalproc); + + dlgproc = GetWindowLongPtrA(hdlg, DWLP_DLGPROC); + ok(dlgproc == (ULONG_PTR)test_aw_conversion_dlgproc2, "Unexpected dlg proc %#lx.\n", dlgproc); + + dlgproc = SetWindowLongPtrA(hdlg, DWLP_DLGPROC, (UINT_PTR)test_aw_conversion_dlgprocW); + ok(!IsWindowUnicode(hdlg), "Unexpected unicode window.\n"); + + dlgproc = GetWindowLongPtrW(hdlg, DWLP_DLGPROC); + ok(dlgproc != (ULONG_PTR)test_aw_conversion_dlgprocW, "Unexpected dlg proc %#lx.\n", dlgproc); + + dlgproc = GetWindowLongPtrA(hdlg, DWLP_DLGPROC); + ok(dlgproc == (ULONG_PTR)test_aw_conversion_dlgprocW, "Unexpected dlg proc %#lx.\n", dlgproc); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SETTEXTA)); + ret = SetWindowTextA(hdlg, testtext); + todo_wine + ok(ret, "Failed to set window text.\n"); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SETTEXTW)); + ret = SetWindowTextW(hdlg, testtextW); + todo_wine + ok(ret, "Failed to set window text.\n"); + + memset(buff, 'A', sizeof(buff)); + len = GetWindowTextA(hdlg, buff, sizeof(buff)); + ok(!strcmp(buff, testtext) && len == 0, "Unexpected window text %s, len %d\n", buff, len); + + memset(buffW, 0xff, sizeof(buffW)); + len = GetWindowTextW(hdlg, buffW, 64); + ok(buffW[0] == 0 && buffW[1] == 0xffff && len == 0, "Unexpected window text %s, len %d\n", + wine_dbgstr_w(buffW), len); + + dlg_test_aw_message(hdlg, WM_WININICHANGE); + dlg_test_aw_message(hdlg, WM_DEVMODECHANGE); + dlg_test_aw_message(hdlg, CB_DIR); + dlg_test_aw_message(hdlg, LB_DIR); + dlg_test_aw_message(hdlg, LB_ADDFILE); + dlg_test_aw_message(hdlg, EM_REPLACESEL); + dlg_test_aw_message(hdlg, WM_SETTEXT); + + dlgproc = SetWindowLongPtrW(hdlg, DWLP_DLGPROC, (UINT_PTR)test_aw_conversion_dlgprocA); + ok(!IsWindowUnicode(hdlg), "Unexpected unicode window.\n"); + + dlgproc = GetWindowLongPtrW(hdlg, DWLP_DLGPROC); + ok(dlgproc == (ULONG_PTR)test_aw_conversion_dlgprocA, "Unexpected dlg proc %#lx.\n", dlgproc); + + dlgproc = GetWindowLongPtrA(hdlg, DWLP_DLGPROC); + ok(dlgproc != (ULONG_PTR)test_aw_conversion_dlgprocA, "Unexpected dlg proc %#lx.\n", dlgproc); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SETTEXTA)); + ret = SetWindowTextA(hdlg, testtext); + todo_wine + ok(ret, "Failed to set window text.\n"); + + SetPropA(hdlg, "test_mode", ULongToHandle(DLGPROCTEXT_SETTEXTW)); + ret = SetWindowTextW(hdlg, testtextW); + todo_wine + ok(ret, "Failed to set window text.\n"); + + memset(buff, 'A', sizeof(buff)); + len = GetWindowTextA(hdlg, buff, sizeof(buff)); + ok(!strcmp(buff, testtext) && len == 0, "Unexpected window text %s, len %d\n", buff, len); + + memset(buffW, 0xff, sizeof(buffW)); + len = GetWindowTextW(hdlg, buffW, sizeof(buffW)/sizeof(buffW[0])); + ok(buffW[0] == 0 && buffW[1] == 0xffff && len == 0, "Unexpected window text %#x, %#x, len %d\n", + buffW[0], buffW[1], len); + + dlg_test_aw_message(hdlg, WM_WININICHANGE); + dlg_test_aw_message(hdlg, WM_DEVMODECHANGE); + dlg_test_aw_message(hdlg, CB_DIR); + dlg_test_aw_message(hdlg, LB_DIR); + dlg_test_aw_message(hdlg, LB_ADDFILE); + dlg_test_aw_message(hdlg, EM_REPLACESEL); + dlg_test_aw_message(hdlg, WM_SETTEXT); + + SetWindowLongPtrA(hdlg, DWLP_DLGPROC, originalproc); + EndDialog(hdlg, -123); + return TRUE; + } + return FALSE; +} + +static LRESULT CALLBACK test_aw_conversion_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + int mode = HandleToULong(GetPropA(hwnd, "test_mode")); + WCHAR *text = (WCHAR *)lparam; + char *textA = (char *)lparam; + + switch (msg) + { + case WM_SETTEXT: + case WM_WININICHANGE: + case WM_DEVMODECHANGE: + case CB_DIR: + case LB_DIR: + case LB_ADDFILE: + case EM_REPLACESEL: + switch (mode) + { + case DLGPROCTEXT_SNDMSGA: + if (IsWindowUnicode(hwnd)) + ok(text != testtextW && !lstrcmpW(text, testtextW), + "U: %s, unexpected text %s.\n", testmodes[mode], wine_dbgstr_w(text)); + else + ok(textA == testtext, "A: %s, unexpected text %s.\n", testmodes[mode], textA); + break; + case DLGPROCTEXT_SNDMSGW: + if (IsWindowUnicode(hwnd)) + ok(text == testtextW, "U: %s, unexpected text %s.\n", testmodes[mode], wine_dbgstr_w(text)); + else + ok(textA != testtext && !strcmp(textA, testtext), "A: %s, unexpected text %s.\n", + testmodes[mode], textA); + break; + default: + ok(0, "Unexpected test mode %d.\n", mode); + } + break; + } + + return IsWindowUnicode(hwnd) ? CallWindowProcW(oldproc, hwnd, msg, wparam, lparam) : + CallWindowProcA(oldproc, hwnd, msg, wparam, lparam); +} + +static INT_PTR CALLBACK test_aw_conversion_dlgproc3(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +{ + BOOL is_unicode = !!lparam; + LONG_PTR oldproc; + + switch (msg) + { + case WM_INITDIALOG: + ok(is_unicode == IsWindowUnicode(hdlg), "Unexpected unicode window property.\n"); + + oldproc = SetWindowLongPtrA(hdlg, GWLP_WNDPROC, (LONG_PTR)test_aw_conversion_wndproc); + SetWindowLongPtrA(hdlg, GWLP_USERDATA, oldproc); + ok(!IsWindowUnicode(hdlg), "Unexpected unicode window.\n"); + + dlg_test_aw_message(hdlg, WM_WININICHANGE); + dlg_test_aw_message(hdlg, WM_DEVMODECHANGE); + dlg_test_aw_message(hdlg, CB_DIR); + dlg_test_aw_message(hdlg, LB_DIR); + dlg_test_aw_message(hdlg, LB_ADDFILE); + dlg_test_aw_message(hdlg, EM_REPLACESEL); + dlg_test_aw_message(hdlg, WM_SETTEXT); + + SetWindowLongPtrW(hdlg, GWLP_WNDPROC, (LONG_PTR)test_aw_conversion_wndproc); + ok(IsWindowUnicode(hdlg), "Expected unicode window.\n"); + + dlg_test_aw_message(hdlg, WM_WININICHANGE); + dlg_test_aw_message(hdlg, WM_DEVMODECHANGE); + dlg_test_aw_message(hdlg, CB_DIR); + dlg_test_aw_message(hdlg, LB_DIR); + dlg_test_aw_message(hdlg, LB_ADDFILE); + dlg_test_aw_message(hdlg, EM_REPLACESEL); + dlg_test_aw_message(hdlg, WM_SETTEXT); + + SetWindowLongPtrA(hdlg, GWLP_WNDPROC, oldproc); + EndDialog(hdlg, -123); + return TRUE; + } + return FALSE; +} + +static void test_DialogBoxParam(void) +{ + static const WCHAR nameW[] = {'T','E','S','T','_','E','M','P','T','Y','_','D','I','A','L','O','G',0}; INT_PTR ret; HWND hwnd_invalid = (HWND)0x4444; @@ -1302,7 +1747,21 @@ static void test_DialogBoxParamA(void) ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", 0, TestDefButtonDlgProc, 0); ok(ret == IDOK, "Expected IDOK\n"); - DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", 0, TestReturnKeyDlgProc, 0); + ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", 0, TestReturnKeyDlgProc, 0); + ok(ret == 0, "Unexpected ret value %ld.\n", ret); + + /* WM_SETTEXT handling in case of A/W dialog procedures vs A/W dialog window. */ + ret = DialogBoxParamW(GetModuleHandleA(NULL), nameW, 0, test_aw_conversion_dlgproc, 0); + ok(ret == -123, "Unexpected ret value %ld.\n", ret); + + ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", 0, test_aw_conversion_dlgproc2, 0); + ok(ret == -123, "Unexpected ret value %ld.\n", ret); + + ret = DialogBoxParamW(GetModuleHandleA(NULL), nameW, 0, test_aw_conversion_dlgproc3, 1); + ok(ret == -123, "Unexpected ret value %ld.\n", ret); + + ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", 0, test_aw_conversion_dlgproc3, 0); + ok(ret == -123, "Unexpected ret value %ld.\n", ret); } static void test_DisabledDialogTest(void) @@ -1713,7 +2172,7 @@ START_TEST(dialog) test_focus(); test_GetDlgItem(); test_GetDlgItemText(); - test_DialogBoxParamA(); + test_DialogBoxParam(); test_DisabledDialogTest(); test_MessageBoxFontTest(); test_SaveRestoreFocus(); diff --git a/modules/rostests/winetests/user32/edit.c b/modules/rostests/winetests/user32/edit.c index 012051cc67..01418bf551 100755 --- a/modules/rostests/winetests/user32/edit.c +++ b/modules/rostests/winetests/user32/edit.c @@ -18,7 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <assert.h> +#include <windows.h> +#include <commctrl.h> + +#include "wine/test.h" #ifndef ES_COMBO #define ES_COMBO 0x200 @@ -34,17 +38,6 @@ struct edit_notify { static struct edit_notify notifications; -static BOOL (WINAPI *pEndMenu) (void); -static BOOL (WINAPI *pGetMenuBarInfo)(HWND,LONG,LONG,PMENUBARINFO); - -static void init_function_pointers(void) -{ - HMODULE hdll = GetModuleHandleA("user32"); - - pEndMenu = (void*)GetProcAddress(hdll, "EndMenu"); - pGetMenuBarInfo = (void*)GetProcAddress(hdll, "GetMenuBarInfo"); -} - static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) { static int num_ok_commands = 0; @@ -564,6 +557,18 @@ static HWND create_editcontrol (DWORD style, DWORD exstyle) return handle; } +static HWND create_editcontrolW(DWORD style, DWORD exstyle) +{ + static const WCHAR testtextW[] = {'T','e','s','t',' ','t','e','x','t',0}; + static const WCHAR editW[] = {'E','d','i','t',0}; + HWND handle; + + handle = CreateWindowExW(exstyle, editW, testtextW, style, 10, 10, 300, 300, + NULL, NULL, hinst, NULL); + ok(handle != NULL, "Failed to create Edit control.\n"); + return handle; +} + static HWND create_child_editcontrol (DWORD style, DWORD exstyle) { HWND parentWnd; @@ -863,7 +868,7 @@ static LRESULT CALLBACK edit3_wnd_procA(HWND hWnd, UINT msg, WPARAM wParam, LPAR return DefWindowProcA(hWnd, msg, wParam, lParam); } -/* Test behaviour of WM_SETTEXT, WM_REPLACESEL and notificatisons sent in response +/* Test behaviour of WM_SETTEXT, WM_REPLACESEL and notifications sent in response * to these messages. */ static void test_edit_control_3(void) @@ -965,6 +970,19 @@ static void test_edit_control_3(void) ok(lstrlenA(str) == len, "text shouldn't have been truncated\n"); test_notify(1, 0, 1); + SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)""); + zero_notify(); + SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2); + len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0); + ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n"); + test_notify(1, 0, 1); + + zero_notify(); + SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2); + len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0); + ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n"); + test_notify(1, 0, 1); + SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0); SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)""); @@ -2277,7 +2295,7 @@ static LRESULT CALLBACK edit4_wnd_procA(HWND hWnd, UINT msg, WPARAM wParam, LPAR if (hWnd != (HWND)lParam) { got_wm_capturechanged = TRUE; - pEndMenu(); + EndMenu(); } break; } @@ -2295,9 +2313,8 @@ static LRESULT CALLBACK edit_proc_proxy(HWND hWnd, UINT msg, WPARAM wParam, LPAR memset(&mbi, 0, sizeof(mbi)); mbi.cbSize = sizeof(mbi); SetLastError(0xdeadbeef); - ret = pGetMenuBarInfo(ctx_menu, OBJID_CLIENT, 0, &mbi); - ok(ret || broken(!ret && GetLastError()==ERROR_INVALID_WINDOW_HANDLE) /* NT */, - "GetMenuBarInfo failed\n"); + ret = GetMenuBarInfo(ctx_menu, OBJID_CLIENT, 0, &mbi); + ok(ret, "GetMenuBarInfo failed\n"); if (ret) { ok(mbi.hMenu != NULL, "mbi.hMenu = NULL\n"); @@ -2309,9 +2326,8 @@ static LRESULT CALLBACK edit_proc_proxy(HWND hWnd, UINT msg, WPARAM wParam, LPAR memset(&mbi, 0, sizeof(mbi)); mbi.cbSize = sizeof(mbi); SetLastError(0xdeadbeef); - ret = pGetMenuBarInfo(ctx_menu, OBJID_CLIENT, 1, &mbi); - ok(ret || broken(!ret && GetLastError()==ERROR_INVALID_WINDOW_HANDLE) /* NT */, - "GetMenuBarInfo failed\n"); + ret = GetMenuBarInfo(ctx_menu, OBJID_CLIENT, 1, &mbi); + ok(ret, "GetMenuBarInfo failed\n"); if (ret) { ok(mbi.hMenu != NULL, "mbi.hMenu = NULL\n"); @@ -2320,7 +2336,7 @@ static LRESULT CALLBACK edit_proc_proxy(HWND hWnd, UINT msg, WPARAM wParam, LPAR ok(!mbi.fFocused, "mbi.fFocused = TRUE\n"); } - pEndMenu(); + EndMenu(); break; } } @@ -2341,7 +2357,7 @@ static LRESULT CALLBACK child_edit_menu_proc(HWND hwnd, UINT msg, WPARAM wParam, if (wParam == MSGF_MENU) { HWND hwndMenu = (HWND)lParam; MENUBARINFO mbi = { sizeof(MENUBARINFO) }; - if (pGetMenuBarInfo(hwndMenu, OBJID_CLIENT, 0, &mbi)) { + if (GetMenuBarInfo(hwndMenu, OBJID_CLIENT, 0, &mbi)) { MENUITEMINFOA mii = { sizeof(MENUITEMINFOA), MIIM_STATE }; if (GetMenuItemInfoA(mbi.hMenu, EM_SETSEL, FALSE, &mii)) { if (mii.fState & MFS_HILITE) { @@ -2387,11 +2403,8 @@ static void test_contextmenu(void) ok(got_en_setfocus, "edit box didn't get focused\n"); ok(got_wm_capturechanged, "main window capture did not change\n"); - if (pGetMenuBarInfo) - { - p_edit_proc = (void*)SetWindowLongPtrA(hwndEdit, GWLP_WNDPROC, (ULONG_PTR)edit_proc_proxy); - SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(10, 10)); - } + p_edit_proc = (void*)SetWindowLongPtrA(hwndEdit, GWLP_WNDPROC, (ULONG_PTR)edit_proc_proxy); + SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(10, 10)); DestroyWindow (hwndEdit); @@ -2718,6 +2731,7 @@ static void test_EM_GETHANDLE(void) { static const char str0[] = "untouched"; static const char str1[] = "1111+1111+1111#"; + static const char str1_1[] = "2111+1111+1111#"; static const char str2[] = "2222-2222-2222-2222#"; static const char str3[] = "3333*3333*3333*3333*3333#"; CHAR current[42]; @@ -2766,6 +2780,44 @@ static void test_EM_GETHANDLE(void) "got %d and \"%s\" (expected %d and \"%s\")\n", len, buffer, lstrlenA(str1), str1); LocalUnlock(hmem); + /* See if WM_GETTEXTLENGTH/WM_GETTEXT still work. */ + len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0); + ok(len == lstrlenA(str1), "Unexpected text length %d.\n", len); + + lstrcpyA(current, str0); + r = SendMessageA(hEdit, WM_GETTEXT, sizeof(current), (LPARAM)current); + ok((r == lstrlenA(str1)) && !lstrcmpA(current, str1), + "Unexpected retval %d and text \"%s\" (expected %d and \"%s\")\n", r, current, lstrlenA(str1), str1); + + /* Application altered buffer contents, see if WM_GETTEXTLENGTH/WM_GETTEXT pick that up. */ + buffer = LocalLock(hmem); + ok(buffer != NULL, "got %p (expected != NULL)\n", buffer); + buffer[0] = '2'; + LocalUnlock(hmem); + + len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0); + ok(len == lstrlenA(str1_1), "Unexpected text length %d.\n", len); + + lstrcpyA(current, str0); + r = SendMessageA(hEdit, WM_GETTEXT, sizeof(current), (LPARAM)current); + ok((r == lstrlenA(str1_1)) && !lstrcmpA(current, str1_1), + "Unexpected retval %d and text \"%s\" (expected %d and \"%s\")\n", r, current, lstrlenA(str1_1), str1_1); + + /* See if WM_SETTEXT/EM_REPLACESEL work. */ + r = SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)str1); + ok(r, "Failed to set text.\n"); + + buffer = LocalLock(hmem); + ok(buffer != NULL && buffer[0] == '1', "Unexpected buffer contents\n"); + LocalUnlock(hmem); + + r = SendMessageA(hEdit, EM_REPLACESEL, 0, (LPARAM)str1_1); + ok(r, "Failed to replace selection.\n"); + + buffer = LocalLock(hmem); + ok(buffer != NULL && buffer[0] == '2', "Unexpected buffer contents\n"); + LocalUnlock(hmem); + /* use LocalAlloc first to get a different handle */ halloc = LocalAlloc(LMEM_MOVEABLE, 42); ok(halloc != NULL, "got %p (expected != NULL)\n", halloc); @@ -2827,13 +2879,161 @@ static void test_EM_GETHANDLE(void) DestroyWindow(hEdit); } +static void test_paste(void) +{ + HWND hEdit, hMultilineEdit; + HANDLE hmem, hmem_ret; + char *buffer; + int r, len; + static const char *str = "this is a simple text"; + static const char *str2 = "first line\r\nsecond line"; + + hEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + hMultilineEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, 0); + + /* Prepare clipboard data with simple text */ + hmem = GlobalAlloc(GMEM_MOVEABLE, 255); + ok(hmem != NULL, "got %p (expected != NULL)\n", hmem); + buffer = GlobalLock(hmem); + ok(buffer != NULL, "got %p (expected != NULL)\n", buffer); + strcpy(buffer, str); + GlobalUnlock(hmem); + + r = OpenClipboard(hEdit); + ok(r == TRUE, "expected %d, got %d\n", TRUE, r); + r = EmptyClipboard(); + ok(r == TRUE, "expected %d, got %d\n", TRUE, r); + hmem_ret = SetClipboardData(CF_TEXT, hmem); + ok(hmem_ret == hmem, "expected %p, got %p\n", hmem, hmem_ret); + r = CloseClipboard(); + ok(r == TRUE, "expected %d, got %d\n", TRUE, r); + + /* Paste single line */ + SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)""); + r = SendMessageA(hEdit, WM_PASTE, 0, 0); + len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0); + ok(strlen(str) == len, "got %d\n", len); + + /* Prepare clipboard data with multiline text */ + hmem = GlobalAlloc(GMEM_MOVEABLE, 255); + ok(hmem != NULL, "got %p (expected != NULL)\n", hmem); + buffer = GlobalLock(hmem); + ok(buffer != NULL, "got %p (expected != NULL)\n", buffer); + strcpy(buffer, str2); + GlobalUnlock(hmem); + + r = OpenClipboard(hEdit); + ok(r == TRUE, "expected %d, got %d\n", TRUE, r); + r = EmptyClipboard(); + ok(r == TRUE, "expected %d, got %d\n", TRUE, r); + hmem_ret = SetClipboardData(CF_TEXT, hmem); + ok(hmem_ret == hmem, "expected %p, got %p\n", hmem, hmem_ret); + r = CloseClipboard(); + ok(r == TRUE, "expected %d, got %d\n", TRUE, r); + + /* Paste multiline text in singleline edit - should be cut */ + SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)""); + r = SendMessageA(hEdit, WM_PASTE, 0, 0); + len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0); + ok(strlen("first line") == len, "got %d\n", len); + + /* Paste multiline text in multiline edit */ + SendMessageA(hMultilineEdit, WM_SETTEXT, 0, (LPARAM)""); + r = SendMessageA(hMultilineEdit, WM_PASTE, 0, 0); + len = SendMessageA(hMultilineEdit, WM_GETTEXTLENGTH, 0, 0); + ok(strlen(str2) == len, "got %d\n", len); + + /* Cleanup */ + DestroyWindow(hEdit); + DestroyWindow(hMultilineEdit); +} + +static void test_EM_GETLINE(void) +{ + HWND hwnd[2]; + int i; + + hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + hwnd[1] = create_editcontrolW(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + + for (i = 0; i < sizeof(hwnd)/sizeof(hwnd[0]); i++) + { + static const WCHAR strW[] = {'t','e','x','t',0}; + static const char *str = "text"; + WCHAR buffW[16]; + char buff[16]; + int r; + + if (i == 0) + ok(!IsWindowUnicode(hwnd[i]), "Expected ansi window.\n"); + else + ok(IsWindowUnicode(hwnd[i]), "Expected unicode window.\n"); + + SendMessageA(hwnd[i], WM_SETTEXT, 0, (LPARAM)str); + + memset(buff, 0, sizeof(buff)); + *(WORD *)buff = sizeof(buff); + r = SendMessageA(hwnd[i], EM_GETLINE, 0, (LPARAM)buff); + ok(r == strlen(str), "Failed to get a line %d.\n", r); + ok(!strcmp(buff, str), "Unexpected line data %s.\n", buff); + + memset(buff, 0, sizeof(buff)); + *(WORD *)buff = sizeof(buff); + r = SendMessageA(hwnd[i], EM_GETLINE, 1, (LPARAM)buff); + ok(r == strlen(str), "Failed to get a line %d.\n", r); + ok(!strcmp(buff, str), "Unexpected line data %s.\n", buff); + + memset(buffW, 0, sizeof(buffW)); + *(WORD *)buffW = sizeof(buffW)/sizeof(buffW[0]); + r = SendMessageW(hwnd[i], EM_GETLINE, 0, (LPARAM)buffW); + ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r); + ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW)); + + memset(buffW, 0, sizeof(buffW)); + *(WORD *)buffW = sizeof(buffW)/sizeof(buffW[0]); + r = SendMessageW(hwnd[i], EM_GETLINE, 1, (LPARAM)buffW); + ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r); + ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW)); + + DestroyWindow(hwnd[i]); + } +} + +static int CALLBACK test_wordbreak_procA(char *text, int current, int length, int code) +{ + return -1; +} + +static void test_wordbreak_proc(void) +{ + EDITWORDBREAKPROCA proc; + LRESULT ret; + HWND hwnd; + + hwnd = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + + proc = (void *)SendMessageA(hwnd, EM_GETWORDBREAKPROC, 0, 0); + ok(proc == NULL, "Unexpected wordbreak proc %p.\n", proc); + + ret = SendMessageA(hwnd, EM_SETWORDBREAKPROC, 0, (LPARAM)test_wordbreak_procA); + ok(ret == 1, "Unexpected return value %ld.\n", ret); + + proc = (void *)SendMessageA(hwnd, EM_GETWORDBREAKPROC, 0, 0); + ok(proc == test_wordbreak_procA, "Unexpected wordbreak proc %p.\n", proc); + + ret = SendMessageA(hwnd, EM_SETWORDBREAKPROC, 0, 0); + ok(ret == 1, "Unexpected return value %ld.\n", ret); + + proc = (void *)SendMessageA(hwnd, EM_GETWORDBREAKPROC, 0, 0); + ok(proc == NULL, "Unexpected wordbreak proc %p.\n", proc); + + DestroyWindow(hwnd); +} START_TEST(edit) { BOOL b; - init_function_pointers(); - hinst = GetModuleHandleA(NULL); b = RegisterWindowClasses(); ok (b, "RegisterWindowClasses failed\n"); @@ -2861,12 +3061,11 @@ START_TEST(edit) test_child_edit_wmkeydown(); test_fontsize(); test_dialogmode(); - if (pEndMenu) - test_contextmenu(); - else - win_skip("EndMenu is not available\n"); - + test_contextmenu(); test_EM_GETHANDLE(); + test_paste(); + test_EM_GETLINE(); + test_wordbreak_proc(); UnregisterWindowClasses(); } diff --git a/modules/rostests/winetests/user32/generated.c b/modules/rostests/winetests/user32/generated.c index e80277ce1a..87dda5ec11 100644 --- a/modules/rostests/winetests/user32/generated.c +++ b/modules/rostests/winetests/user32/generated.c @@ -5,7 +5,17 @@ * Unit tests for data structure packing */ -#include "precomp.h" +#ifndef __REACTOS__ +#define WINVER 0x0501 +#define _WIN32_IE 0x0501 +#define _WIN32_WINNT 0x0501 +#endif + +#define WINE_NOWINSOCK + +#include "windows.h" + +#include "wine/test.h" /*********************************************************************** * Compatibility macros diff --git a/modules/rostests/winetests/user32/input.c b/modules/rostests/winetests/user32/input.c index 239cc09e9e..37fe0cee87 100755 --- a/modules/rostests/winetests/user32/input.c +++ b/modules/rostests/winetests/user32/input.c @@ -44,7 +44,25 @@ * */ -#include "precomp.h" +#ifndef __REACTOS__ +#define _WIN32_WINNT 0x401 +#define _WIN32_IE 0x0500 +#endif + +#include <stdarg.h> +#include <assert.h> + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "wingdi.h" +#include "winnls.h" + +#include "wine/test.h" + +#ifdef __REACTOS__ +#include <reactos/undocuser.h> +#endif /* globals */ static HWND hWndTest; @@ -924,8 +942,7 @@ static void test_Input_blackbox(void) empty_message_queue(); prevWndProc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR) WndProc2); - ok(prevWndProc != 0 || (prevWndProc == 0 && GetLastError() == 0), - "error: %d\n", (int) GetLastError()); + ok(prevWndProc != 0 || GetLastError() == 0, "error: %d\n", (int) GetLastError()); i.type = INPUT_KEYBOARD; i.u.ki.time = 0; @@ -1266,6 +1283,19 @@ static LRESULT CALLBACK hook_proc2( int code, WPARAM wparam, LPARAM lparam ) return CallNextHookEx( 0, code, wparam, lparam ); } +static LRESULT CALLBACK hook_proc3( int code, WPARAM wparam, LPARAM lparam ) +{ + POINT pt; + + if (code == HC_ACTION) + { + /* MSLLHOOKSTRUCT does not seem to be reliable and contains different data on each run. */ + GetCursorPos(&pt); + ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y); + } + return CallNextHookEx( 0, code, wparam, lparam ); +} + static void test_mouse_ll_hook(void) { HWND hwnd; @@ -1339,6 +1369,62 @@ static void test_mouse_ll_hook(void) ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y); UnhookWindowsHookEx(hook2); + hook1 = SetWindowsHookExA(WH_MOUSE_LL, hook_proc3, GetModuleHandleA(0), 0); + + SetRect(&rc, 150, 150, 150, 150); + ClipCursor(&rc); + clipped = TRUE; + + SetCursorPos(140, 140); + GetCursorPos(&pt_old); + ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y); + SetCursorPos(160, 160); + GetCursorPos(&pt_old); + todo_wine + ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y); + mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0); + GetCursorPos(&pt_old); + ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y); + mouse_event(MOUSEEVENTF_MOVE, +STEP, +STEP, 0, 0); + GetCursorPos(&pt_old); + todo_wine + ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y); + mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0); + GetCursorPos(&pt_old); + ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y); + mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0); + GetCursorPos(&pt_old); + todo_wine + ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y); + + clipped = FALSE; + ClipCursor(NULL); + + SetCursorPos(140, 140); + SetRect(&rc, 150, 150, 150, 150); + ClipCursor(&rc); + GetCursorPos(&pt_old); + ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y); + ClipCursor(NULL); + + SetCursorPos(160, 160); + SetRect(&rc, 150, 150, 150, 150); + ClipCursor(&rc); + GetCursorPos(&pt_old); + todo_wine + ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y); + ClipCursor(NULL); + + SetCursorPos(150, 150); + SetRect(&rc, 150, 150, 150, 150); + ClipCursor(&rc); + GetCursorPos(&pt_old); + todo_wine + ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y); + ClipCursor(NULL); + + UnhookWindowsHookEx(hook1); + done: DestroyWindow(hwnd); SetCursorPos(pt_org.x, pt_org.y); @@ -1911,6 +1997,23 @@ static DWORD WINAPI create_static_win(void *arg) return 0; } +static void get_dc_region(RECT *region, HWND hwnd, DWORD flags) +{ + int region_type; + HRGN hregion; + HDC hdc; + + hdc = GetDCEx(hwnd, 0, flags); + ok(hdc != NULL, "GetDCEx failed\n"); + hregion = CreateRectRgn(40, 40, 60, 60); + ok(hregion != NULL, "CreateRectRgn failed\n"); + GetRandomRgn(hdc, hregion, SYSRGN); + region_type = GetRgnBox(hregion, region); + ok(region_type == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", region_type); + DeleteObject(hregion); + ReleaseDC(hwnd, hdc); +} + static void test_Input_mouse(void) { BOOL got_button_down, got_button_up; @@ -1923,10 +2026,18 @@ static void test_Input_mouse(void) int region_type; HRGN hregion; RECT region; - BOOL ret; MSG msg; + BOOL ret; - GetCursorPos(&pt_org); + SetLastError(0xdeadbeef); + ret = GetCursorPos(NULL); + ok(!ret, "GetCursorPos succeed\n"); + ok(GetLastError() == 0xdeadbeef || GetLastError() == ERROR_NOACCESS, "error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = GetCursorPos(&pt_org); + ok(ret, "GetCursorPos failed\n"); + ok(GetLastError() == 0xdeadbeef, "error %u\n", GetLastError()); button_win = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP, 100, 100, 100, 100, 0, NULL, NULL, NULL); @@ -2043,6 +2154,7 @@ static void test_Input_mouse(void) } SetEvent(thread_data.end_event); WaitForSingleObject(thread, INFINITE); + CloseHandle(thread); ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n"); ok(!got_button_down, "unexpected WM_RBUTTONDOWN message\n"); ok(!got_button_up, "unexpected WM_RBUTTONUP message\n"); @@ -2145,6 +2257,10 @@ static void test_Input_mouse(void) WS_VISIBLE | WS_POPUP, 100, 100, 100, 100, button_win, NULL, NULL, NULL); ok(hwnd != NULL, "CreateWindowEx failed\n"); + static_win = CreateWindowA("static", "Title", WS_VISIBLE | WS_CHILD, + 10, 10, 20, 20, hwnd, NULL, NULL, NULL); + ok(static_win != NULL, "CreateWindowA failed %u\n", GetLastError()); + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetWindowLongA(hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); ret = SetLayeredWindowAttributes(hwnd, 0, 255, LWA_ALPHA); @@ -2256,6 +2372,25 @@ static void test_Input_mouse(void) ok(region_type == ERROR, "expected ERROR, got %d\n", region_type); } + get_dc_region(®ion, hwnd, DCX_PARENTCLIP); + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(®ion)); + get_dc_region(®ion, hwnd, DCX_WINDOW | DCX_USESTYLE); + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(®ion)); + get_dc_region(®ion, hwnd, DCX_USESTYLE); + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(®ion)); + get_dc_region(®ion, static_win, DCX_PARENTCLIP); + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(®ion)); + get_dc_region(®ion, static_win, DCX_WINDOW | DCX_USESTYLE); + ok(region.left == 110 && region.top == 110 && region.right == 130 && region.bottom == 130, + "expected region (110,110)-(130,130), got %s\n", wine_dbgstr_rect(®ion)); + get_dc_region(®ion, static_win, DCX_USESTYLE); + ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200, + "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(®ion)); + got_button_down = got_button_up = FALSE; simulate_click(TRUE, 150, 150); while (wait_for_message(&msg)) @@ -2343,6 +2478,7 @@ static void test_Input_mouse(void) ok(got_button_down, "expected WM_LBUTTONDOWN message\n"); ok(got_button_up, "expected WM_LBUTTONUP message\n"); + DestroyWindow(static_win); DestroyWindow(hwnd); SetCursorPos(pt_org.x, pt_org.y); @@ -2726,7 +2862,11 @@ static void test_OemKeyScan(void) ret = OemKeyScan( oem ); oem_char = LOBYTE( oem ); - if (!OemToCharBuffW( &oem_char, &wchr, 1 )) + /* OemKeyScan returns -1 for any character that cannot be mapped, + * whereas OemToCharBuff changes unmappable characters to question + * marks. The ASCII characters 0-127, including the real question mark + * character, are all mappable and are the same in all OEM codepages. */ + if (!OemToCharBuffW( &oem_char, &wchr, 1 ) || (wchr == '?' && oem_char < 0)) expect = -1; else { diff --git a/modules/rostests/winetests/user32/listbox.c b/modules/rostests/winetests/user32/listbox.c index 7033aa65cd..88d3adb728 100644 --- a/modules/rostests/winetests/user32/listbox.c +++ b/modules/rostests/winetests/user32/listbox.c @@ -17,7 +17,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <assert.h> +#include <stdarg.h> +#include <stdio.h> + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winnls.h" + +#include "wine/test.h" #ifdef VISIBLE #define WAIT Sleep (1000) @@ -36,6 +46,15 @@ static const char * const strings[4] = { static const char BAD_EXTENSION[] = "*.badtxt"; +static int strcmp_aw(LPCWSTR strw, const char *stra) +{ + WCHAR buf[1024]; + + if (!stra) return 1; + MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR)); + return lstrcmpW(strw, buf); +} + static HWND create_listbox (DWORD add_style, HWND parent) { @@ -229,6 +248,31 @@ static LRESULT WINAPI main_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARA { switch (msg) { + case WM_MEASUREITEM: + { + DWORD style = GetWindowLongA(GetWindow(hwnd, GW_CHILD), GWL_STYLE); + MEASUREITEMSTRUCT *mi = (void*)lparam; + + ok(wparam == mi->CtlID, "got wParam=%08lx, expected %08x\n", wparam, mi->CtlID); + ok(mi->CtlType == ODT_LISTBOX, "mi->CtlType = %u\n", mi->CtlType); + ok(mi->CtlID == 1, "mi->CtlID = %u\n", mi->CtlID); + ok(mi->itemHeight, "mi->itemHeight = 0\n"); + + if (mi->itemID > 4 || style & LBS_OWNERDRAWFIXED) + break; + + if (style & LBS_HASSTRINGS) + { + ok(!strcmp_aw((WCHAR*)mi->itemData, strings[mi->itemID]), + "mi->itemData = %s (%d)\n", wine_dbgstr_w((WCHAR*)mi->itemData), mi->itemID); + } + else + { + ok((void*)mi->itemData == strings[mi->itemID], + "mi->itemData = %08lx, expected %p\n", mi->itemData, strings[mi->itemID]); + } + break; + } case WM_DRAWITEM: { RECT rc_item, rc_client, rc_clip; @@ -1812,6 +1856,26 @@ static void test_extents(void) DestroyWindow(parent); } +static void test_WM_MEASUREITEM(void) +{ + HWND parent, listbox; + LRESULT data; + + parent = create_parent(); + listbox = create_listbox(WS_CHILD | LBS_OWNERDRAWVARIABLE, parent); + + data = SendMessageA(listbox, LB_GETITEMDATA, 0, 0); + ok(data == (LRESULT)strings[0], "data = %08lx, expected %p\n", data, strings[0]); + DestroyWindow(parent); + + parent = create_parent(); + listbox = create_listbox(WS_CHILD | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS, parent); + + data = SendMessageA(listbox, LB_GETITEMDATA, 0, 0); + ok(!data, "data = %08lx\n", data); + DestroyWindow(parent); +} + START_TEST(listbox) { const struct listbox_test SS = @@ -1895,4 +1959,5 @@ START_TEST(listbox) test_GetListBoxInfo(); test_missing_lbuttonup(); test_extents(); + test_WM_MEASUREITEM(); } diff --git a/modules/rostests/winetests/user32/menu.c b/modules/rostests/winetests/user32/menu.c index f3aac55609..3430ed687e 100755 --- a/modules/rostests/winetests/user32/menu.c +++ b/modules/rostests/winetests/user32/menu.c @@ -19,7 +19,23 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#ifndef __REACTOS__ +#define _WIN32_WINNT 0x0501 +#endif + +#include <stdarg.h> +#include <stdio.h> +#include <string.h> +#include <assert.h> + +#define OEMRESOURCE /* For OBM_MNARROW */ + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" + +#include "wine/test.h" static ATOM atomMenuCheckClass; @@ -27,7 +43,6 @@ static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO); static BOOL (WINAPI *pGetMenuBarInfo)(HWND,LONG,LONG,PMENUBARINFO); static UINT (WINAPI *pSendInput)(UINT, INPUT*, size_t); static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO); -static BOOL (WINAPI *pEndMenu) (void); static void init_function_pointers(void) { @@ -42,7 +57,6 @@ static void init_function_pointers(void) GET_PROC(GetMenuBarInfo) GET_PROC(SendInput) GET_PROC(SetMenuInfo) - GET_PROC(EndMenu) #undef GET_PROC } @@ -3504,7 +3518,7 @@ static LRESULT WINAPI menu_cancelmode_wnd_proc(HWND hwnd, UINT msg, PostMessageA( hwnd, WM_MOUSEMOVE, 0, 0); return SendMessageA( g_hwndtosend, WM_CANCELMODE, 0, 0); } - pEndMenu(); + EndMenu(); return TRUE; } } @@ -3517,10 +3531,7 @@ static void test_menu_cancelmode(void) HWND hwnd, hwndchild; HMENU menu, menubar; MSG msg; - if( !pEndMenu) { /* win95 */ - win_skip( "EndMenu is not available\n"); - return; - } + hwnd = CreateWindowExA( 0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, NULL, NULL); diff --git a/modules/rostests/winetests/user32/monitor.c b/modules/rostests/winetests/user32/monitor.c index 313e78ce45..886d63ccfe 100644 --- a/modules/rostests/winetests/user32/monitor.c +++ b/modules/rostests/winetests/user32/monitor.c @@ -19,7 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include "wine/test.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" static HMODULE hdll; static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID); diff --git a/modules/rostests/winetests/user32/msg.c b/modules/rostests/winetests/user32/msg.c index 722f8d4efe..39ce152582 100755 --- a/modules/rostests/winetests/user32/msg.c +++ b/modules/rostests/winetests/user32/msg.c @@ -20,9 +20,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#ifndef __REACTOS__ +#define _WIN32_WINNT 0x0600 /* For WM_CHANGEUISTATE,QS_RAWINPUT,WM_DWMxxxx */ +#define WINVER 0x0600 /* for WM_GETTITLEBARINFOEX */ +#endif + +#include <assert.h> +#include <limits.h> +#include <stdarg.h> +#include <stdio.h> -#include <dbt.h> +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winnls.h" +#include "dbt.h" + +#include "wine/test.h" #define MDI_FIRST_CHILD_ID 2004 @@ -6568,15 +6583,13 @@ static void test_button_messages(void) prevfont = SelectObject(hdc, hfont2); ok(prevfont == GetStockObject(SYSTEM_FONT), "Unexpected default font\n"); SendMessageA(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, 0); - todo_wine - ok(GetStockObject(SYSTEM_FONT) == GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PRINTCLIENT\n", i); + ok(hfont2 != GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PRINTCLIENT\n", i); SelectObject(hdc, prevfont); prevfont = SelectObject(hdc, hfont2); ok(prevfont == GetStockObject(SYSTEM_FONT), "Unexpected default font\n"); SendMessageA(hwnd, WM_PAINT, (WPARAM)hdc, 0); - todo_wine - ok(GetStockObject(SYSTEM_FONT) == GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PAINT\n", i); + ok(hfont2 != GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PAINT\n", i); SelectObject(hdc, prevfont); DeleteDC(hdc); @@ -7131,6 +7144,41 @@ static void test_static_messages(void) /****************** ComboBox message test *************************/ #define ID_COMBOBOX 0x000f +static const struct message SetCurSelComboSeq[] = +{ + { CB_SETCURSEL, sent|wparam|lparam, 0, 0 }, + { LB_SETCURSEL, sent|wparam|lparam, 0, 0 }, + { LB_SETTOPINDEX, sent|wparam|lparam, 0, 0 }, + { LB_GETCURSEL, sent|wparam|lparam, 0, 0 }, + { LB_GETTEXTLEN, sent|wparam|lparam, 0, 0 }, + { LB_GETTEXTLEN, sent|wparam|lparam|optional, 0, 0 }, /* TODO: it's sent on all Windows versions */ + { LB_GETTEXT, sent|wparam, 0 }, + { WM_CTLCOLOREDIT, sent|parent }, + { LB_GETITEMDATA, sent|wparam|lparam, 0, 0 }, + { WM_DRAWITEM, sent|wparam|lparam|parent, ID_COMBOBOX, 0x100010f3 }, + { 0 } +}; + +static const struct message SetCurSelComboSeq2[] = +{ + { CB_SETCURSEL, sent|wparam|lparam, 0, 0 }, + { LB_SETCURSEL, sent|wparam|lparam, 0, 0 }, + { LB_SETTOPINDEX, sent|wparam|lparam, 0, 0 }, + { LB_GETCURSEL, sent|wparam|lparam, 0, 0 }, + { LB_GETTEXTLEN, sent|wparam|lparam, 0, 0 }, + { LB_GETTEXTLEN, sent|wparam|lparam|optional, 0, 0 }, /* TODO: it's sent on all Windows versions */ + { LB_GETTEXT, sent|wparam, 0 }, + { 0 } +}; + +static const struct message SetCurSelComboSeq_edit[] = +{ + { CB_SETCURSEL, sent|wparam|lparam, 0, 0 }, + { WM_SETTEXT, sent|wparam, 0 }, + { EM_SETSEL, sent|wparam|lparam, 0, INT_MAX }, + { 0 } +}; + static const struct message WmKeyDownComboSeq[] = { { WM_KEYDOWN, sent|wparam|lparam, VK_DOWN, 0 }, @@ -7214,9 +7262,10 @@ static const struct message SetFocusButtonSeq2[] = { 0 } }; -static WNDPROC old_combobox_proc, edit_window_proc; +static WNDPROC old_combobox_proc, edit_window_proc, lbox_window_proc; -static LRESULT CALLBACK combobox_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK combobox_edit_subclass_proc(HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter = 0; LRESULT ret; @@ -7237,7 +7286,7 @@ static LRESULT CALLBACK combobox_subclass_proc(HWND hwnd, UINT message, WPARAM w if (defwndproc_counter) msg.flags |= defwinproc; msg.wParam = wParam; msg.lParam = lParam; - msg.descr = "combo"; + msg.descr = "combo edit"; add_message(&msg); } @@ -7248,6 +7297,38 @@ static LRESULT CALLBACK combobox_subclass_proc(HWND hwnd, UINT message, WPARAM w return ret; } +static LRESULT CALLBACK combobox_lbox_subclass_proc(HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam) +{ + static LONG defwndproc_counter = 0; + LRESULT ret; + struct recvd_message msg; + + /* do not log painting messages */ + if (message != WM_PAINT && + message != WM_NCPAINT && + message != WM_SYNCPAINT && + message != WM_ERASEBKGND && + message != WM_NCHITTEST && + !ignore_message( message )) + { + msg.hwnd = hwnd; + msg.message = message; + msg.flags = sent|wparam|lparam; + if (defwndproc_counter) msg.flags |= defwinproc; + msg.wParam = wParam; + msg.lParam = lParam; + msg.descr = "combo lbox"; + add_message(&msg); + } + + defwndproc_counter++; + ret = CallWindowProcA(lbox_window_proc, hwnd, message, wParam, lParam); + defwndproc_counter--; + + return ret; +} + static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter = 0; @@ -7297,9 +7378,8 @@ static void subclass_combobox(void) static void test_combobox_messages(void) { - HWND parent, combo, button, edit; + HWND parent, combo, button, edit, lbox; LRESULT ret; - BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO); COMBOBOXINFO cbInfo; BOOL res; @@ -7344,13 +7424,6 @@ static void test_combobox_messages(void) DestroyWindow(parent); /* Start again. Test combobox text selection when getting and losing focus */ - pGetComboBoxInfo = (void *)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo"); - if (!pGetComboBoxInfo) - { - win_skip("GetComboBoxInfo is not available\n"); - return; - } - parent = CreateWindowExA(0, "TestParentClass", "Parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 10, 10, 300, 300, NULL, NULL, NULL, NULL); ok(parent != 0, "Failed to create parent window\n"); @@ -7361,11 +7434,12 @@ static void test_combobox_messages(void) cbInfo.cbSize = sizeof(COMBOBOXINFO); SetLastError(0xdeadbeef); - res = pGetComboBoxInfo(combo, &cbInfo); + res = GetComboBoxInfo(combo, &cbInfo); ok(res, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError()); edit = cbInfo.hwndItem; - edit_window_proc = (WNDPROC)SetWindowLongPtrA(edit, GWLP_WNDPROC, (ULONG_PTR)combobox_subclass_proc); + edit_window_proc = (WNDPROC)SetWindowLongPtrA(edit, GWLP_WNDPROC, + (ULONG_PTR)combobox_edit_subclass_proc); button = CreateWindowExA(0, "Button", "OK", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 5, 50, 100, 20, parent, NULL, @@ -7398,7 +7472,46 @@ static void test_combobox_messages(void) log_all_parent_messages--; ok_sequence(SetFocusButtonSeq2, "SetFocus on a Button (2)", TRUE); + SetFocus(combo); + SendMessageA(combo, WM_SETREDRAW, FALSE, 0); + flush_sequence(); + log_all_parent_messages++; + SendMessageA(combo, CB_SETCURSEL, 0, 0); + log_all_parent_messages--; + ok_sequence(SetCurSelComboSeq_edit, "CB_SETCURSEL on a ComboBox with edit control", FALSE); + DestroyWindow(button); + DestroyWindow(combo); + + combo = CreateWindowExA(0, "my_combobox_class", "test", + WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | CBS_DROPDOWNLIST, + 5, 5, 100, 100, parent, (HMENU)ID_COMBOBOX, NULL, NULL); + ok(combo != 0, "Failed to create combobox window\n"); + + ret = SendMessageA(combo, CB_ADDSTRING, 0, (LPARAM)"item 0"); + ok(ret == 0, "expected 0, got %ld\n", ret); + + cbInfo.cbSize = sizeof(COMBOBOXINFO); + SetLastError(0xdeadbeef); + res = GetComboBoxInfo(combo, &cbInfo); + ok(res, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError()); + lbox = cbInfo.hwndList; + lbox_window_proc = (WNDPROC)SetWindowLongPtrA(lbox, GWLP_WNDPROC, + (ULONG_PTR)combobox_lbox_subclass_proc); + flush_sequence(); + + log_all_parent_messages++; + SendMessageA(combo, CB_SETCURSEL, 0, 0); + log_all_parent_messages--; + ok_sequence(SetCurSelComboSeq, "CB_SETCURSEL on a ComboBox", FALSE); + + ShowWindow(combo, SW_HIDE); + flush_sequence(); + log_all_parent_messages++; + SendMessageA(combo, CB_SETCURSEL, 0, 0); + log_all_parent_messages--; + ok_sequence(SetCurSelComboSeq2, "CB_SETCURSEL on a ComboBox", FALSE); + DestroyWindow(combo); DestroyWindow(parent); } @@ -9029,7 +9142,8 @@ static void test_accelerators(void) keybd_event(VK_MENU, 0, 0, 0); keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0); pump_msg_loop(hwnd, 0); - ok_sequence(WmAltPressRelease, "Alt press/release", FALSE); + /* this test doesn't pass in Wine for managed windows */ + ok_sequence(WmAltPressRelease, "Alt press/release", TRUE); trace("testing VK_F1 press/release\n"); keybd_event(VK_F1, 0, 0, 0); @@ -9049,7 +9163,7 @@ static void test_accelerators(void) keybd_event(VK_F10, 0, 0, 0); keybd_event(VK_F10, 0, KEYEVENTF_KEYUP, 0); pump_msg_loop(hwnd, 0); - ok_sequence(WmVkF10Seq, "VK_F10 press/release", FALSE); + ok_sequence(WmVkF10Seq, "VK_F10 press/release", TRUE); trace("testing SHIFT+F10 press/release\n"); keybd_event(VK_SHIFT, 0, 0, 0); @@ -14468,6 +14582,13 @@ static const struct message wm_lb_deletestring_reset[] = { 0 } }; static const struct message wm_lb_addstring[] = +{ + { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ef }, + { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed }, + { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ee }, + { 0 } +}; +static const struct message wm_lb_addstring_ownerdraw[] = { { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed }, { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf0f2, 0xf30604ed }, @@ -14477,7 +14598,7 @@ static const struct message wm_lb_addstring[] = { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf2f2, 0xf30604ef }, { 0 } }; -static const struct message wm_lb_addstring_sort[] = +static const struct message wm_lb_addstring_sort_ownerdraw[] = { { LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed }, { WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf0f2, 0xf30604ed }, @@ -14565,6 +14686,8 @@ static void test_listbox_messages(void) flush_sequence(); + log_all_parent_messages++; + ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0"); ok(ret == 0, "expected 0, got %ld\n", ret); ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1"); @@ -14572,13 +14695,11 @@ static void test_listbox_messages(void) ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2"); ok(ret == 2, "expected 2, got %ld\n", ret); - ok_sequence(wm_lb_addstring, "LB_ADDSTRING", FALSE); + ok_sequence(wm_lb_addstring_ownerdraw, "LB_ADDSTRING", FALSE); check_lb_state(listbox, 3, LB_ERR, 0, 0); flush_sequence(); - log_all_parent_messages++; - trace("selecting item 0\n"); ret = SendMessageA(listbox, LB_SETCURSEL, 0, 0); ok(ret == 0, "expected 0, got %ld\n", ret); @@ -14657,7 +14778,59 @@ static void test_listbox_messages(void) ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2"); ok(ret == 2, "expected 2, got %ld\n", ret); - ok_sequence(wm_lb_addstring_sort, "LB_ADDSTRING", FALSE); + ok_sequence(wm_lb_addstring_sort_ownerdraw, "LB_ADDSTRING", FALSE); + check_lb_state(listbox, 3, LB_ERR, 0, 0); + + log_all_parent_messages--; + + DestroyWindow(listbox); + + /* with LBS_HASSTRINGS */ + listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL, + WS_CHILD | LBS_NOTIFY | LBS_HASSTRINGS | WS_VISIBLE, + 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL); + listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc); + + check_lb_state(listbox, 0, LB_ERR, 0, 0); + + flush_sequence(); + + log_all_parent_messages++; + + ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2"); + ok(ret == 0, "expected 0, got %ld\n", ret); + ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0"); + ok(ret == 1, "expected 1, got %ld\n", ret); + ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1"); + ok(ret == 2, "expected 2, got %ld\n", ret); + + ok_sequence(wm_lb_addstring, "LB_ADDSTRING", FALSE); + check_lb_state(listbox, 3, LB_ERR, 0, 0); + + log_all_parent_messages--; + + DestroyWindow(listbox); + + /* with LBS_HASSTRINGS and LBS_SORT */ + listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL, + WS_CHILD | LBS_NOTIFY | LBS_HASSTRINGS | LBS_SORT | WS_VISIBLE, + 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL); + listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc); + + check_lb_state(listbox, 0, LB_ERR, 0, 0); + + flush_sequence(); + + log_all_parent_messages++; + + ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2"); + ok(ret == 0, "expected 0, got %ld\n", ret); + ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0"); + ok(ret == 0, "expected 0, got %ld\n", ret); + ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1"); + ok(ret == 1, "expected 1, got %ld\n", ret); + + ok_sequence(wm_lb_addstring, "LB_ADDSTRING", FALSE); check_lb_state(listbox, 3, LB_ERR, 0, 0); log_all_parent_messages--; @@ -16919,9 +17092,6 @@ static const struct message send_message_2[] = { }; static const struct message send_message_3[] = { { WM_USER+3, sent|wparam|lparam, 0, 0 }, - { 0 } -}; -static const struct message send_message_4[] = { { WM_USER+1, sent|wparam|lparam, 0, 0 }, { 0 } }; @@ -17027,16 +17197,11 @@ static void test_SendMessage_other_thread(int thread_n) ret = GetQueueStatus(QS_SENDMESSAGE|QS_POSTMESSAGE); ok(ret == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE), "wrong status %08x\n", ret); - trace("main: call PeekMessage\n"); - ok(PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "PeekMessage should not fail\n"); - ok(msg.message == WM_USER+1, "expected WM_USER+1, got %04x\n", msg.message); - ok_sequence(send_message_3, "SendMessage from other thread 3", thread_n == 2); - trace("main: call PeekMessage\n"); ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "PeekMessage should not fail\n"); ok(msg.message == WM_USER+1, "expected WM_USER+1, got %04x\n", msg.message); DispatchMessageA(&msg); - ok_sequence(send_message_4, "SendMessage from other thread 4", FALSE); + ok_sequence(send_message_3, "SendMessage from other thread 3", thread_n == 2); /* intentionally yield */ MsgWaitForMultipleObjects(0, NULL, FALSE, 100, qs_all_input); diff --git a/modules/rostests/winetests/user32/precomp.h b/modules/rostests/winetests/user32/precomp.h index 79309febc7..a379831662 100644 --- a/modules/rostests/winetests/user32/precomp.h +++ b/modules/rostests/winetests/user32/precomp.h @@ -1,16 +1,18 @@ -#ifndef _USER32_APITEST_PRECOMP_H_ -#define _USER32_APITEST_PRECOMP_H_ + +#ifndef _USER32_WINETEST_PRECOMP_H_ +#define _USER32_WINETEST_PRECOMP_H_ #include <assert.h> #include <stdarg.h> #include <stdio.h> #define STRICT -#define WIN32_LEAN_AND_MEAN #define WINE_NOWINSOCK #include <windows.h> #define WINE_NO_INLINE_RECT #include <wine/test.h> -#endif /* _USER32_APITEST_PRECOMP_H_ */ +#include <reactos/undocuser.h> + +#endif /* !_USER32_WINETEST_PRECOMP_H_ */ diff --git a/modules/rostests/winetests/user32/resource.c b/modules/rostests/winetests/user32/resource.c index 049f6653b8..2388adb64f 100755 --- a/modules/rostests/winetests/user32/resource.c +++ b/modules/rostests/winetests/user32/resource.c @@ -18,7 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <assert.h> +#include <windows.h> + +#include "wine/test.h" static UINT (WINAPI *pPrivateExtractIconsA)(LPCSTR, int, int, int, HICON *, UINT *, UINT, UINT) = NULL; diff --git a/modules/rostests/winetests/user32/scroll.c b/modules/rostests/winetests/user32/scroll.c index f95cbb700e..0bda5dd0f4 100644 --- a/modules/rostests/winetests/user32/scroll.c +++ b/modules/rostests/winetests/user32/scroll.c @@ -18,7 +18,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <assert.h> +#include <stdarg.h> +#include <stdio.h> +#include <windows.h> + +#include "wine/test.h" static HWND hScroll; static BOOL bThemeActive = FALSE; diff --git a/modules/rostests/winetests/user32/static.c b/modules/rostests/winetests/user32/static.c index 0a58b38fe7..8776c3a9e0 100644 --- a/modules/rostests/winetests/user32/static.c +++ b/modules/rostests/winetests/user32/static.c @@ -17,7 +17,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdarg.h> +#include <stdio.h> + +#define STRICT +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +#include "wine/test.h" #define TODO_COUNT 1 @@ -92,6 +99,7 @@ static void test_updates(int style, int flags) HDC hdc = GetDC( hStatic); COLORREF colour = GetPixel( hdc, 10, 10); ok ( colour != 0, "pixel should NOT be painted black!\n"); + ReleaseDC(hStatic, hdc); } if (style != SS_ETCHEDHORZ && style != SS_ETCHEDVERT) exp = 4; diff --git a/modules/rostests/winetests/user32/sysparams.c b/modules/rostests/winetests/user32/sysparams.c index e9a69e6703..9ed85a24d0 100755 --- a/modules/rostests/winetests/user32/sysparams.c +++ b/modules/rostests/winetests/user32/sysparams.c @@ -17,7 +17,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#ifndef __REACTOS__ +#define _WIN32_WINNT 0x0600 /* For SPI_GETMOUSEHOVERWIDTH and more */ +#define _WIN32_IE 0x0700 +#define WINVER 0x0600 /* For COLOR_MENUBAR, NONCLIENTMETRICS with padding */ +#endif + +#include <assert.h> +#include <stdlib.h> +#include <stdarg.h> +#include <stdio.h> + +#include "wine/test.h" +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winreg.h" +#include "winuser.h" +#include "winnls.h" #ifndef SPI_GETDESKWALLPAPER # define SPI_GETDESKWALLPAPER 0x0073 @@ -2682,6 +2699,14 @@ static BOOL is_font_enumerated(const char *name) return ret; } +static int get_cursor_size( int size ) +{ + /* only certain sizes are allowed for cursors */ + if (size >= 64) return 64; + if (size >= 48) return 48; + return 32; +} + static void test_GetSystemMetrics( void) { TEXTMETRICA tmMenuFont; @@ -2760,8 +2785,8 @@ static void test_GetSystemMetrics( void) /* These don't depend on the Shell Icon Size registry value */ ok_gsm( SM_CXICON, MulDiv( 32, dpi, USER_DEFAULT_SCREEN_DPI ) ); ok_gsm( SM_CYICON, MulDiv( 32, dpi, USER_DEFAULT_SCREEN_DPI ) ); - /* SM_CXCURSOR */ - /* SM_CYCURSOR */ + ok_gsm( SM_CXCURSOR, get_cursor_size( MulDiv( 32, dpi, USER_DEFAULT_SCREEN_DPI ))); + ok_gsm( SM_CYCURSOR, get_cursor_size( MulDiv( 32, dpi, USER_DEFAULT_SCREEN_DPI ))); ok_gsm( SM_CYMENU, ncm.iMenuHeight + 1); ok_gsm( SM_CXFULLSCREEN, GetSystemMetrics( SM_CXMAXIMIZED) - 2 * GetSystemMetrics( SM_CXFRAME)); @@ -2896,7 +2921,8 @@ static void test_GetSystemMetrics( void) trace( "Captionfontchar width %d MenuFont %d,%d CaptionWidth from registry: %d screen %d,%d\n", avcwCaption, tmMenuFont.tmHeight, tmMenuFont.tmExternalLeading, CaptionWidthfromreg, screen.cx, screen.cy); } - ReleaseDC( 0, hdc); + + DeleteDC(hdc); } static void test_EnumDisplaySettings(void) diff --git a/modules/rostests/winetests/user32/text.c b/modules/rostests/winetests/user32/text.c index ce60c64b56..3cc9571521 100755 --- a/modules/rostests/winetests/user32/text.c +++ b/modules/rostests/winetests/user32/text.c @@ -19,7 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <assert.h> + +#include "wine/test.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winerror.h" +#include "winnls.h" #define MODIFIED(rect) (rect.left == 10 && rect.right != 100 && rect.top == 10 && rect.bottom != 100) #define EMPTY(rect) (rect.left == rect.right && rect.bottom == rect.top) diff --git a/modules/rostests/winetests/user32/uitools.c b/modules/rostests/winetests/user32/uitools.c index 05bc45c78a..b52fe3a03a 100644 --- a/modules/rostests/winetests/user32/uitools.c +++ b/modules/rostests/winetests/user32/uitools.c @@ -17,7 +17,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#define WINE_NO_INLINE_RECT +#include "wine/test.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" static void test_FillRect(void) { diff --git a/modules/rostests/winetests/user32/winstation.c b/modules/rostests/winetests/user32/winstation.c index 3e0fe936b5..8522825a21 100755 --- a/modules/rostests/winetests/user32/winstation.c +++ b/modules/rostests/winetests/user32/winstation.c @@ -18,9 +18,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" - -#include <wine/winternl.h> +#include "wine/test.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winnls.h" +#include "wine/winternl.h" static NTSTATUS (WINAPI *pNtQueryObject)(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG); diff --git a/modules/rostests/winetests/user32/wsprintf.c b/modules/rostests/winetests/user32/wsprintf.c index 694814db5f..f0e80b2ad6 100755 --- a/modules/rostests/winetests/user32/wsprintf.c +++ b/modules/rostests/winetests/user32/wsprintf.c @@ -17,7 +17,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdarg.h> + +#include "wine/test.h" +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winnls.h" static const struct {
6 years, 8 months
1
0
0
0
01/01: [PSDK] Add some missing WDA_NONE and WDA_MONITOR. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=47e04dae506cf55caa3d5…
commit 47e04dae506cf55caa3d50f8705c9234ae42db1a Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:48:43 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:48:43 2018 +0100 [PSDK] Add some missing WDA_NONE and WDA_MONITOR. CORE-14434 --- sdk/include/psdk/winuser.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk/include/psdk/winuser.h b/sdk/include/psdk/winuser.h index ec52b1d5d7..60a92d6dfc 100644 --- a/sdk/include/psdk/winuser.h +++ b/sdk/include/psdk/winuser.h @@ -3341,6 +3341,9 @@ typedef struct tagMINIMIZEDMETRICS { int iArrange; } MINIMIZEDMETRICS, *PMINIMIZEDMETRICS,*LPMINIMIZEDMETRICS; +#define WDA_NONE 0x0 +#define WDA_MONITOR 0x1 + typedef struct tagMOUSEKEYS{ UINT cbSize; DWORD dwFlags;
6 years, 8 months
1
0
0
0
01/01: [SHELL32_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0be033fe1d60d71a68a15…
commit 0be033fe1d60d71a68a156f10df53ed926642ca3 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:47:46 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:47:46 2018 +0100 [SHELL32_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/shell32/CMakeLists.txt | 2 +- modules/rostests/winetests/shell32/appbar.c | 7 +- modules/rostests/winetests/shell32/assoc.c | 16 +- modules/rostests/winetests/shell32/autocomplete.c | 180 ++- modules/rostests/winetests/shell32/brsfolder.c | 9 +- modules/rostests/winetests/shell32/ebrowser.c | 27 +- modules/rostests/winetests/shell32/generated.c | 19 +- modules/rostests/winetests/shell32/msg.h | 17 +- modules/rostests/winetests/shell32/precomp.h | 11 +- modules/rostests/winetests/shell32/progman_dde.c | 815 +++++-------- modules/rostests/winetests/shell32/recyclebin.c | 7 +- modules/rostests/winetests/shell32/shelldispatch.c | 686 ++++++++--- modules/rostests/winetests/shell32/shelllink.c | 86 +- modules/rostests/winetests/shell32/shellole.c | 16 +- modules/rostests/winetests/shell32/shellpath.c | 42 +- .../rostests/winetests/shell32/shfldr_special.c | 16 +- modules/rostests/winetests/shell32/shlexec.c | 31 +- modules/rostests/winetests/shell32/shlfileop.c | 16 +- modules/rostests/winetests/shell32/shlfolder.c | 1258 +++++++++----------- modules/rostests/winetests/shell32/shlview.c | 77 +- modules/rostests/winetests/shell32/string.c | 13 +- modules/rostests/winetests/shell32/systray.c | 11 +- 22 files changed, 1870 insertions(+), 1492 deletions(-) diff --git a/modules/rostests/winetests/shell32/CMakeLists.txt b/modules/rostests/winetests/shell32/CMakeLists.txt index ded63d7065..e459d95360 100644 --- a/modules/rostests/winetests/shell32/CMakeLists.txt +++ b/modules/rostests/winetests/shell32/CMakeLists.txt @@ -32,7 +32,7 @@ add_executable(shell32_winetest target_link_libraries(shell32_winetest uuid) set_module_type(shell32_winetest win32cui) -add_importlibs(shell32_winetest shell32 ole32 oleaut32 user32 gdi32 advapi32 msvcrt kernel32) +add_importlibs(shell32_winetest shell32 shlwapi ole32 oleaut32 user32 gdi32 advapi32 msvcrt kernel32) if(MSVC) add_importlibs(shell32_winetest ntdll) diff --git a/modules/rostests/winetests/shell32/appbar.c b/modules/rostests/winetests/shell32/appbar.c index f25fed9159..1505a40aeb 100644 --- a/modules/rostests/winetests/shell32/appbar.c +++ b/modules/rostests/winetests/shell32/appbar.c @@ -17,7 +17,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdarg.h> + +#include <windows.h> +#include "shellapi.h" + +#include "wine/test.h" #define MSG_APPBAR WM_APP diff --git a/modules/rostests/winetests/shell32/assoc.c b/modules/rostests/winetests/shell32/assoc.c index ac6edef099..5e93750229 100644 --- a/modules/rostests/winetests/shell32/assoc.c +++ b/modules/rostests/winetests/shell32/assoc.c @@ -17,9 +17,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#define COBJMACROS + +#include <stdarg.h> + +#include "shlwapi.h" +#include "shlguid.h" +#include "shobjidl.h" + +#include "wine/heap.h" +#include "wine/test.h" -#include <shobjidl.h> static void test_IQueryAssociations_QueryInterface(void) { @@ -114,7 +122,7 @@ static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCW return; } - buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + buffer = heap_alloc(len * sizeof(WCHAR)); ok_(__FILE__, line)(buffer != NULL, "out of memory\n"); hr = IQueryAssociations_GetString(assoc, 0, str, NULL, buffer, &len); ok_(__FILE__, line)(hr == S_OK, "GetString returned 0x%x, expected S_OK\n", hr); @@ -126,7 +134,7 @@ static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCW } IQueryAssociations_Release(assoc); - HeapFree(GetProcessHeap(), 0, buffer); + heap_free(buffer); } static void test_IQueryAssociations_GetString(void) diff --git a/modules/rostests/winetests/shell32/autocomplete.c b/modules/rostests/winetests/shell32/autocomplete.c index c2c02e2ca9..859734ce59 100644 --- a/modules/rostests/winetests/shell32/autocomplete.c +++ b/modules/rostests/winetests/shell32/autocomplete.c @@ -18,7 +18,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#define COBJMACROS + +#include <stdarg.h> + +#include "windows.h" +#include "shobjidl.h" +#include "shlguid.h" +#include "initguid.h" +#include "shldisp.h" + +#include "wine/heap.h" +#include "wine/test.h" static HWND hMainWnd, hEdit; static HINSTANCE hinst; @@ -216,6 +227,171 @@ static void createMainWnd(void) CW_USEDEFAULT, CW_USEDEFAULT, 130, 105, NULL, NULL, GetModuleHandleA(NULL), 0); } +struct string_enumerator +{ + IEnumString IEnumString_iface; + LONG ref; + WCHAR **data; + int data_len; + int cur; +}; + +static struct string_enumerator *impl_from_IEnumString(IEnumString *iface) +{ + return CONTAINING_RECORD(iface, struct string_enumerator, IEnumString_iface); +} + +static HRESULT WINAPI string_enumerator_QueryInterface(IEnumString *iface, REFIID riid, void **ppv) +{ + if (IsEqualGUID(riid, &IID_IEnumString) || IsEqualGUID(riid, &IID_IUnknown)) + { + IUnknown_AddRef(iface); + *ppv = iface; + return S_OK; + } + + *ppv = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI string_enumerator_AddRef(IEnumString *iface) +{ + struct string_enumerator *this = impl_from_IEnumString(iface); + + ULONG ref = InterlockedIncrement(&this->ref); + + return ref; +} + +static ULONG WINAPI string_enumerator_Release(IEnumString *iface) +{ + struct string_enumerator *this = impl_from_IEnumString(iface); + + ULONG ref = InterlockedDecrement(&this->ref); + + if (!ref) + heap_free(this); + + return ref; +} + +static HRESULT WINAPI string_enumerator_Next(IEnumString *iface, ULONG num, LPOLESTR *strings, ULONG *num_returned) +{ + struct string_enumerator *this = impl_from_IEnumString(iface); + int i, len; + + *num_returned = 0; + for (i = 0; i < num; i++) + { + if (this->cur >= this->data_len) + return S_FALSE; + + len = lstrlenW(this->data[this->cur]) + 1; + + strings[i] = CoTaskMemAlloc(len * sizeof(WCHAR)); + memcpy(strings[i], this->data[this->cur], len * sizeof(WCHAR)); + + (*num_returned)++; + this->cur++; + } + + return S_OK; +} + +static HRESULT WINAPI string_enumerator_Reset(IEnumString *iface) +{ + struct string_enumerator *this = impl_from_IEnumString(iface); + + this->cur = 0; + + return S_OK; +} + +static HRESULT WINAPI string_enumerator_Skip(IEnumString *iface, ULONG num) +{ + struct string_enumerator *this = impl_from_IEnumString(iface); + + this->cur += num; + + return S_OK; +} + +static HRESULT WINAPI string_enumerator_Clone(IEnumString *iface, IEnumString **out) +{ + *out = NULL; + return E_NOTIMPL; +} + +static IEnumStringVtbl string_enumerator_vtlb = +{ + string_enumerator_QueryInterface, + string_enumerator_AddRef, + string_enumerator_Release, + string_enumerator_Next, + string_enumerator_Skip, + string_enumerator_Reset, + string_enumerator_Clone +}; + +static HRESULT string_enumerator_create(void **ppv, WCHAR **suggestions, int count) +{ + struct string_enumerator *object; + + object = heap_alloc_zero(sizeof(*object)); + object->IEnumString_iface.lpVtbl = &string_enumerator_vtlb; + object->ref = 1; + object->data = suggestions; + object->data_len = count; + object->cur = 0; + + *ppv = &object->IEnumString_iface; + + return S_OK; +} + +static void test_custom_source(void) +{ + static WCHAR str_alpha[] = {'t','e','s','t','1',0}; + static WCHAR str_alpha2[] = {'t','e','s','t','2',0}; + static WCHAR str_beta[] = {'a','u','t','o',' ','c','o','m','p','l','e','t','e',0}; + static WCHAR *suggestions[] = { str_alpha, str_alpha2, str_beta }; + IUnknown *enumerator; + IAutoComplete2 *autocomplete; + HWND hwnd_edit; + WCHAR buffer[20]; + HRESULT hr; + MSG msg; + + ShowWindow(hMainWnd, SW_SHOW); + + hwnd_edit = CreateWindowA("Edit", "", WS_OVERLAPPED | WS_VISIBLE | WS_CHILD | WS_BORDER, 50, 5, 200, 20, hMainWnd, 0, NULL, 0); + + hr = CoCreateInstance(&CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER, &IID_IAutoComplete2, (void**)&autocomplete); + ok(hr == S_OK, "CoCreateInstance failed: %x\n", hr); + + string_enumerator_create((void**)&enumerator, suggestions, sizeof(suggestions) / sizeof(*suggestions)); + + hr = IAutoComplete2_SetOptions(autocomplete, ACO_AUTOSUGGEST | ACO_AUTOAPPEND); + ok(hr == S_OK, "IAutoComplete2_SetOptions failed: %x\n", hr); + hr = IAutoComplete2_Init(autocomplete, hwnd_edit, enumerator, NULL, NULL); + ok(hr == S_OK, "IAutoComplete_Init failed: %x\n", hr); + + SendMessageW(hwnd_edit, WM_CHAR, 'a', 1); + /* Send a keyup message since wine doesn't handle WM_CHAR yet */ + SendMessageW(hwnd_edit, WM_KEYUP, 'u', 1); + Sleep(100); + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + SendMessageW(hwnd_edit, WM_GETTEXT, sizeof(buffer) / sizeof(*buffer), (LPARAM)buffer); + ok(lstrcmpW(str_beta, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str_beta), wine_dbgstr_w(buffer)); + + ShowWindow(hMainWnd, SW_HIDE); + DestroyWindow(hwnd_edit); +} + START_TEST(autocomplete) { HRESULT r; @@ -237,6 +413,8 @@ START_TEST(autocomplete) goto cleanup; test_killfocus(); + test_custom_source(); + PostQuitMessage(0); while(GetMessageA(&msg,0,0,0)) { TranslateMessage(&msg); diff --git a/modules/rostests/winetests/shell32/brsfolder.c b/modules/rostests/winetests/shell32/brsfolder.c index d564ed5e61..bf29d1169f 100644 --- a/modules/rostests/winetests/shell32/brsfolder.c +++ b/modules/rostests/winetests/shell32/brsfolder.c @@ -19,8 +19,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#define COBJMACROS +#include <windows.h> +#include <shlobj.h> +#include <shobjidl.h> +#include <string.h> +#include "shellapi.h" + +#include "wine/test.h" #define IDD_MAKENEWFOLDER 0x3746 /* From "../shresdef.h" */ #define TIMER_WAIT_MS 50 /* Should be long enough for slow systems */ diff --git a/modules/rostests/winetests/shell32/ebrowser.c b/modules/rostests/winetests/shell32/ebrowser.c index 27beff5ecc..3e89b90439 100644 --- a/modules/rostests/winetests/shell32/ebrowser.c +++ b/modules/rostests/winetests/shell32/ebrowser.c @@ -18,10 +18,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> -#include <initguid.h> -#include <mshtml.h> +#define COBJMACROS +#define CONST_VTABLE + +#include "shlobj.h" +#include "shlwapi.h" + +#include "wine/heap.h" +#include "wine/test.h" + +#include "initguid.h" +#include "mshtml.h" /********************************************************************** * Some IIDs for test_SetSite. @@ -231,7 +240,7 @@ static ULONG WINAPI IExplorerPaneVisibility_fnRelease(IExplorerPaneVisibility *i ULONG ref = InterlockedDecrement(&This->ref); if(!ref) - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); return ref; } @@ -277,7 +286,7 @@ static IExplorerPaneVisibilityImpl *create_explorerpanevisibility(void) { IExplorerPaneVisibilityImpl *epv; - epv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IExplorerPaneVisibilityImpl)); + epv = heap_alloc_zero(sizeof(*epv)); epv->IExplorerPaneVisibility_iface.lpVtbl = &epvvt; epv->ref = 1; @@ -320,7 +329,7 @@ static ULONG WINAPI ICommDlgBrowser3_fnRelease(ICommDlgBrowser3 *iface) ULONG ref = InterlockedDecrement(&This->ref); if(!ref) - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); return ref; } @@ -431,7 +440,7 @@ static ICommDlgBrowser3Impl *create_commdlgbrowser3(void) { ICommDlgBrowser3Impl *cdb; - cdb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ICommDlgBrowser3Impl)); + cdb = heap_alloc_zero(sizeof(*cdb)); cdb->ICommDlgBrowser3_iface.lpVtbl = &cdbvtbl; cdb->ref = 1; @@ -489,7 +498,7 @@ static ULONG WINAPI IServiceProvider_fnRelease(IServiceProvider *iface) LONG ref = InterlockedDecrement(&This->ref); if(!ref) - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); return ref; } @@ -540,7 +549,7 @@ static const IServiceProviderVtbl spvtbl = static IServiceProviderImpl *create_serviceprovider(void) { - IServiceProviderImpl *sp = HeapAlloc(GetProcessHeap(), 0, sizeof(IServiceProviderImpl)); + IServiceProviderImpl *sp = heap_alloc(sizeof(*sp)); sp->IServiceProvider_iface.lpVtbl = &spvtbl; sp->ref = 1; return sp; diff --git a/modules/rostests/winetests/shell32/generated.c b/modules/rostests/winetests/shell32/generated.c index b18fdec02c..d30857b9d2 100755 --- a/modules/rostests/winetests/shell32/generated.c +++ b/modules/rostests/winetests/shell32/generated.c @@ -5,7 +5,24 @@ * Unit tests for data structure packing */ -#include "precomp.h" +#ifndef __REACTOS__ +#define WINVER 0x0501 +#define _WIN32_IE 0x0501 +#define _WIN32_WINNT 0x0501 +#endif + +#define WINE_NOWINSOCK + +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wtypes.h" +#include "shellapi.h" +#include "winuser.h" +#include "wingdi.h" +#include "shlobj.h" + +#include "wine/test.h" /*********************************************************************** * Compatibility macros diff --git a/modules/rostests/winetests/shell32/msg.h b/modules/rostests/winetests/shell32/msg.h index 7afdc7af89..720e693ff5 100644 --- a/modules/rostests/winetests/shell32/msg.h +++ b/modules/rostests/winetests/shell32/msg.h @@ -20,6 +20,12 @@ #pragma once +#include <assert.h> +#include <windows.h> + +#include "wine/heap.h" +#include "wine/test.h" + /* undocumented SWP flags - from SDK 3.1 */ #define SWP_NOCLIENTSIZE 0x0800 #define SWP_NOCLIENTMOVE 0x1000 @@ -64,16 +70,13 @@ static void add_message(struct msg_sequence **seq, int sequence_index, if (!msg_seq->sequence) { msg_seq->size = 10; - msg_seq->sequence = HeapAlloc(GetProcessHeap(), 0, - msg_seq->size * sizeof (struct message)); + msg_seq->sequence = heap_alloc(msg_seq->size * sizeof (struct message)); } if (msg_seq->count == msg_seq->size) { msg_seq->size *= 2; - msg_seq->sequence = HeapReAlloc(GetProcessHeap(), 0, - msg_seq->sequence, - msg_seq->size * sizeof (struct message)); + msg_seq->sequence = heap_realloc(msg_seq->sequence, msg_seq->size * sizeof (struct message)); } assert(msg_seq->sequence); @@ -90,7 +93,7 @@ static void add_message(struct msg_sequence **seq, int sequence_index, static void flush_sequence(struct msg_sequence **seg, int sequence_index) { struct msg_sequence *msg_seq = seg[sequence_index]; - HeapFree(GetProcessHeap(), 0, msg_seq->sequence); + heap_free(msg_seq->sequence); msg_seq->sequence = NULL; msg_seq->count = msg_seq->size = 0; } @@ -288,5 +291,5 @@ static void init_msg_sequences(struct msg_sequence **seq, int n) int i; for (i = 0; i < n; i++) - seq[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct msg_sequence)); + seq[i] = heap_alloc_zero(sizeof(struct msg_sequence)); } diff --git a/modules/rostests/winetests/shell32/precomp.h b/modules/rostests/winetests/shell32/precomp.h index ffa1f861d5..f69af2a8d4 100644 --- a/modules/rostests/winetests/shell32/precomp.h +++ b/modules/rostests/winetests/shell32/precomp.h @@ -1,3 +1,4 @@ + #ifndef _SHELL32_WINETEST_PRECOMP_H_ #define _SHELL32_WINETEST_PRECOMP_H_ @@ -5,23 +6,19 @@ #include <stdio.h> #define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H #define COBJMACROS #define CONST_VTABLE +#include <windows.h> + +#include <wine/heap.h> #include <wine/test.h> -#include <winreg.h> -#include <winnls.h> -#include <winuser.h> -#include <wincon.h> #include <shellapi.h> #include <shlwapi.h> #include <shlguid.h> #include <shlobj.h> -#include <ddeml.h> #include <commoncontrols.h> #include <reactos/undocshell.h> diff --git a/modules/rostests/winetests/shell32/progman_dde.c b/modules/rostests/winetests/shell32/progman_dde.c index bb566ba125..62ed413ad0 100644 --- a/modules/rostests/winetests/shell32/progman_dde.c +++ b/modules/rostests/winetests/shell32/progman_dde.c @@ -26,30 +26,15 @@ * Tests for Invalid Characters in Names / Invalid Parameters */ -#include "precomp.h" - -/* Timeout on DdeClientTransaction Call */ -#define MS_TIMEOUT_VAL 1000 -/* # of times to poll for window creation */ -#define PDDE_POLL_NUM 150 -/* time to sleep between polls */ -#define PDDE_POLL_TIME 300 - -/* Call Info */ -#define DDE_TEST_MISC 0x00010000 -#define DDE_TEST_CREATEGROUP 0x00020000 -#define DDE_TEST_DELETEGROUP 0x00030000 -#define DDE_TEST_SHOWGROUP 0x00040000 -#define DDE_TEST_ADDITEM 0x00050000 -#define DDE_TEST_DELETEITEM 0x00060000 -#define DDE_TEST_COMPOUND 0x00070000 -#define DDE_TEST_CALLMASK 0x00ff0000 - -#define DDE_TEST_NUMMASK 0x0000ffff +#include <stdio.h> +#include <wine/test.h> +#include <winbase.h> +#include "dde.h" +#include "ddeml.h" +#include "winuser.h" +#include "shlobj.h" static HRESULT (WINAPI *pSHGetLocalizedName)(LPCWSTR, LPWSTR, UINT, int *); -static BOOL (WINAPI *pSHGetSpecialFolderPathA)(HWND, LPSTR, int, BOOL); -static BOOL (WINAPI *pReadCabinetState)(CABINETSTATE *, int); static void init_function_pointers(void) { @@ -57,10 +42,6 @@ static void init_function_pointers(void) hmod = GetModuleHandleA("shell32.dll"); pSHGetLocalizedName = (void*)GetProcAddress(hmod, "SHGetLocalizedName"); - pSHGetSpecialFolderPathA = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathA"); - pReadCabinetState = (void*)GetProcAddress(hmod, "ReadCabinetState"); - if (!pReadCabinetState) - pReadCabinetState = (void*)GetProcAddress(hmod, (LPSTR)651); } static BOOL use_common(void) @@ -101,63 +82,20 @@ static BOOL full_title(void) CABINETSTATE cs; memset(&cs, 0, sizeof(cs)); - if (pReadCabinetState) - { - pReadCabinetState(&cs, sizeof(cs)); - } - else - { - HKEY key; - DWORD size; - - win_skip("ReadCabinetState is not available, reading registry directly\n"); - RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState", &key); - size = sizeof(cs); - RegQueryValueExA(key, "Settings", NULL, NULL, (LPBYTE)&cs, &size); - RegCloseKey(key); - } + ReadCabinetState(&cs, sizeof(cs)); return (cs.fFullPathTitle == -1); } static char ProgramsDir[MAX_PATH]; -static char Group1Title[MAX_PATH] = "Group1"; -static char Group2Title[MAX_PATH] = "Group2"; -static char Group3Title[MAX_PATH] = "Group3"; -static char StartupTitle[MAX_PATH] = "Startup"; - static void init_strings(void) { - char startup[MAX_PATH]; char commonprograms[MAX_PATH]; char programs[MAX_PATH]; - if (pSHGetSpecialFolderPathA) - { - pSHGetSpecialFolderPathA(NULL, programs, CSIDL_PROGRAMS, FALSE); - pSHGetSpecialFolderPathA(NULL, commonprograms, CSIDL_COMMON_PROGRAMS, FALSE); - pSHGetSpecialFolderPathA(NULL, startup, CSIDL_STARTUP, FALSE); - } - else - { - HKEY key; - DWORD size; - - /* Older Win9x and NT4 */ - - RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &key); - size = sizeof(programs); - RegQueryValueExA(key, "Programs", NULL, NULL, (LPBYTE)&programs, &size); - size = sizeof(startup); - RegQueryValueExA(key, "Startup", NULL, NULL, (LPBYTE)&startup, &size); - RegCloseKey(key); - - RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &key); - size = sizeof(commonprograms); - RegQueryValueExA(key, "Common Programs", NULL, NULL, (LPBYTE)&commonprograms, &size); - RegCloseKey(key); - } + SHGetSpecialFolderPathA(NULL, programs, CSIDL_PROGRAMS, FALSE); + SHGetSpecialFolderPathA(NULL, commonprograms, CSIDL_COMMON_PROGRAMS, FALSE); /* ProgramsDir on Vista+ is always the users one (CSIDL_PROGRAMS). Before Vista * it depends on whether the user is an administrator (CSIDL_COMMON_PROGRAMS) or @@ -167,55 +105,6 @@ static void init_strings(void) lstrcpyA(ProgramsDir, commonprograms); else lstrcpyA(ProgramsDir, programs); - - if (full_title()) - { - lstrcpyA(Group1Title, ProgramsDir); - lstrcatA(Group1Title, "\\Group1"); - lstrcpyA(Group2Title, ProgramsDir); - lstrcatA(Group2Title, "\\Group2"); - lstrcpyA(Group3Title, ProgramsDir); - lstrcatA(Group3Title, "\\Group3"); - - lstrcpyA(StartupTitle, startup); - } - else - { - /* Vista has the nice habit of displaying the full path in English - * and the short one localized. CSIDL_STARTUP on Vista gives us the - * English version so we have to 'translate' this one. - * - * MSDN claims it should be used for files not folders but this one - * suits our purposes just fine. - */ - if (pSHGetLocalizedName) - { - WCHAR startupW[MAX_PATH]; - WCHAR module[MAX_PATH]; - WCHAR module_expanded[MAX_PATH]; - WCHAR localized[MAX_PATH]; - HRESULT hr; - int id; - - MultiByteToWideChar(CP_ACP, 0, startup, -1, startupW, sizeof(startupW)/sizeof(WCHAR)); - hr = pSHGetLocalizedName(startupW, module, MAX_PATH, &id); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); - /* check to be removed when SHGetLocalizedName is implemented */ - if (hr == S_OK) - { - ExpandEnvironmentStringsW(module, module_expanded, MAX_PATH); - LoadStringW(GetModuleHandleW(module_expanded), id, localized, MAX_PATH); - - WideCharToMultiByte(CP_ACP, 0, localized, -1, StartupTitle, sizeof(StartupTitle), NULL, NULL); - } - else - lstrcpyA(StartupTitle, (strrchr(startup, '\\') + 1)); - } - else - { - lstrcpyA(StartupTitle, (strrchr(startup, '\\') + 1)); - } - } } static HDDEDATA CALLBACK DdeCallback(UINT type, UINT format, HCONV hConv, HSZ hsz1, HSZ hsz2, @@ -225,472 +114,305 @@ static HDDEDATA CALLBACK DdeCallback(UINT type, UINT format, HCONV hConv, HSZ hs return NULL; } -/* - * Encoded String for Error Messages so that inner failures can determine - * what test is failing. Format is: [Code:TestNum] - */ -static const char * GetStringFromTestParams(int testParams) +static UINT dde_execute(DWORD instance, HCONV hconv, const char *command_str) { - int testNum; - static char testParamString[64]; - const char *callId; + HDDEDATA command, hdata; + DWORD result; + UINT ret; - testNum = testParams & DDE_TEST_NUMMASK; - switch (testParams & DDE_TEST_CALLMASK) - { - default: - case DDE_TEST_MISC: - callId = "MISC"; - break; - case DDE_TEST_CREATEGROUP: - callId = "C_G"; - break; - case DDE_TEST_DELETEGROUP: - callId = "D_G"; - break; - case DDE_TEST_SHOWGROUP: - callId = "S_G"; - break; - case DDE_TEST_ADDITEM: - callId = "A_I"; - break; - case DDE_TEST_DELETEITEM: - callId = "D_I"; - break; - case DDE_TEST_COMPOUND: - callId = "CPD"; - break; - } + command = DdeCreateDataHandle(instance, (BYTE *)command_str, strlen(command_str)+1, 0, 0, 0, 0); + ok(command != NULL, "DdeCreateDataHandle() failed: %u\n", DdeGetLastError(instance)); - sprintf(testParamString, " [%s:%i]", callId, testNum); - return testParamString; -} + hdata = DdeClientTransaction((BYTE *)command, -1, hconv, 0, 0, XTYP_EXECUTE, 2000, &result); + ret = DdeGetLastError(instance); + /* PROGMAN always returns 1 on success */ + ok((UINT_PTR)hdata == !ret, "expected %u, got %p\n", !ret, hdata); -/* Transfer DMLERR's into text readable strings for Error Messages */ -#define DMLERR_TO_STR(x) case x: return#x; -static const char * GetStringFromError(UINT err) -{ - switch (err) - { - DMLERR_TO_STR(DMLERR_NO_ERROR); - DMLERR_TO_STR(DMLERR_ADVACKTIMEOUT); - DMLERR_TO_STR(DMLERR_BUSY); - DMLERR_TO_STR(DMLERR_DATAACKTIMEOUT); - DMLERR_TO_STR(DMLERR_DLL_NOT_INITIALIZED); - DMLERR_TO_STR(DMLERR_DLL_USAGE); - DMLERR_TO_STR(DMLERR_EXECACKTIMEOUT); - DMLERR_TO_STR(DMLERR_INVALIDPARAMETER); - DMLERR_TO_STR(DMLERR_LOW_MEMORY); - DMLERR_TO_STR(DMLERR_MEMORY_ERROR); - DMLERR_TO_STR(DMLERR_NOTPROCESSED); - DMLERR_TO_STR(DMLERR_NO_CONV_ESTABLISHED); - DMLERR_TO_STR(DMLERR_POKEACKTIMEOUT); - DMLERR_TO_STR(DMLERR_POSTMSG_FAILED); - DMLERR_TO_STR(DMLERR_REENTRANCY); - DMLERR_TO_STR(DMLERR_SERVER_DIED); - DMLERR_TO_STR(DMLERR_SYS_ERROR); - DMLERR_TO_STR(DMLERR_UNADVACKTIMEOUT); - DMLERR_TO_STR(DMLERR_UNFOUND_QUEUE_ID); - default: - return "Unknown DML Error"; - } + return ret; } -/* Helper Function to Transfer DdeGetLastError into a String */ -static const char * GetDdeLastErrorStr(DWORD instance) +static char *dde_request(DWORD instance, HCONV hconv, const char *request_str) { - UINT err = DdeGetLastError(instance); + static char data[2000]; + HDDEDATA hdata; + HSZ item; + DWORD result; - return GetStringFromError(err); -} + item = DdeCreateStringHandleA(instance, request_str, CP_WINANSI); + ok(item != NULL, "DdeCreateStringHandle() failed: %u\n", DdeGetLastError(instance)); -/* Execute a Dde Command and return the error & result */ -/* Note: Progman DDE always returns a pointer to 0x00000001 on a successful result */ -static void DdeExecuteCommand(DWORD instance, HCONV hConv, const char *strCmd, HDDEDATA *hData, UINT *err, int testParams) -{ - HDDEDATA command; - - command = DdeCreateDataHandle(instance, (LPBYTE) strCmd, strlen(strCmd)+1, 0, 0L, 0, 0); - ok (command != NULL, "DdeCreateDataHandle Error %s.%s\n", - GetDdeLastErrorStr(instance), GetStringFromTestParams(testParams)); - *hData = DdeClientTransaction((void *) command, - -1, - hConv, - 0, - 0, - XTYP_EXECUTE, - MS_TIMEOUT_VAL, - NULL); - - /* hData is technically a pointer, but for Program Manager, - * it is NULL (error) or 1 (success) - * TODO: Check other versions of Windows to verify 1 is returned. - * While it is unlikely that anyone is actually testing that the result is 1 - * if all versions of windows return 1, Wine should also. - */ - if (*hData == NULL) - { - *err = DdeGetLastError(instance); - } - else - { - *err = DMLERR_NO_ERROR; - todo_wine - { - ok(*hData == (HDDEDATA) 1, "Expected HDDEDATA Handle == 1, actually %p.%s\n", - *hData, GetStringFromTestParams(testParams)); - } - } - DdeFreeDataHandle(command); + hdata = DdeClientTransaction(NULL, -1, hconv, item, CF_TEXT, XTYP_REQUEST, 2000, &result); + if (hdata == NULL) return NULL; + + DdeGetData(hdata, (BYTE *)data, 2000, 0); + + return data; } -/* - * Check if Window is onscreen with the appropriate name. - * - * Windows are not created synchronously. So we do not know - * when and if the window will be created/shown on screen. - * This function implements a polling mechanism to determine - * creation. - * A more complicated method would be to use SetWindowsHookEx. - * Since polling worked fine in my testing, no reason to implement - * the other. Comments about other methods of determining when - * window creation happened were not encouraging (not including - * SetWindowsHookEx). - */ -static HWND CheckWindowCreated(const char *winName, BOOL closeWindow, int testParams) +static BOOL check_window_exists(const char *name) { + char title[MAX_PATH]; HWND window = NULL; int i; - /* Poll for Window Creation */ - for (i = 0; window == NULL && i < PDDE_POLL_NUM; i++) + if (full_title()) { - Sleep(PDDE_POLL_TIME); - /* Specify the window class name to make sure what we find is really an - * Explorer window. Explorer used two different window classes so try - * both. - */ - window = FindWindowA("ExplorerWClass", winName); - if (!window) - window = FindWindowA("CabinetWClass", winName); + strcpy(title, ProgramsDir); + strcat(title, "\\"); + strcat(title, name); } - ok (window != NULL, "Window \"%s\" was not created in %i seconds - assumed failure.%s\n", - winName, PDDE_POLL_NUM*PDDE_POLL_TIME/1000, GetStringFromTestParams(testParams)); + else + strcpy(title, name); - /* Close Window as desired. */ - if (window != NULL && closeWindow) + for (i = 0; i < 20; i++) { - SendMessageA(window, WM_SYSCOMMAND, SC_CLOSE, 0); - window = NULL; + Sleep(100); + if ((window = FindWindowA("ExplorerWClass", title)) || + (window = FindWindowA("CabinetWClass", title))) + { + SendMessageA(window, WM_SYSCOMMAND, SC_CLOSE, 0); + break; + } } - return window; + + return (window != NULL); } -/* Check for Existence (or non-existence) of a file or group - * When testing for existence of a group, groupName is not needed - */ -static void CheckFileExistsInProgramGroups(const char *nameToCheck, BOOL shouldExist, BOOL isGroup, - const char *groupName, int testParams) +static BOOL check_exists(const char *name) { char path[MAX_PATH]; - DWORD attributes; - int len; - - lstrcpyA(path, ProgramsDir); - len = strlen(path) + strlen(nameToCheck)+1; - if (groupName != NULL) - { - len += strlen(groupName)+1; - } - ok (len <= MAX_PATH, "Path Too Long.%s\n", GetStringFromTestParams(testParams)); - if (len <= MAX_PATH) - { - if (groupName != NULL) - { - strcat(path, "\\"); - strcat(path, groupName); - } - strcat(path, "\\"); - strcat(path, nameToCheck); - attributes = GetFileAttributesA(path); - if (!shouldExist) - { - ok (attributes == INVALID_FILE_ATTRIBUTES , "File exists and shouldn't %s.%s\n", - path, GetStringFromTestParams(testParams)); - } else { - if (attributes == INVALID_FILE_ATTRIBUTES) - { - ok (FALSE, "Created File %s doesn't exist.%s\n", path, GetStringFromTestParams(testParams)); - } else if (isGroup) { - ok (attributes & FILE_ATTRIBUTE_DIRECTORY, "%s is not a folder (attr=%x).%s\n", - path, attributes, GetStringFromTestParams(testParams)); - } else { - ok (attributes & FILE_ATTRIBUTE_ARCHIVE, "Created File %s has wrong attributes (%x).%s\n", - path, attributes, GetStringFromTestParams(testParams)); - } - } - } + strcpy(path, ProgramsDir); + strcat(path, "\\"); + strcat(path, name); + return GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES; } -/* Create Group Test. - * command and expected_result. - * if expected_result is DMLERR_NO_ERROR, test - * 1. group was created - * 2. window is open - */ -static void CreateGroupTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, - const char *groupName, const char *windowTitle, int testParams) +static void test_parser(DWORD instance, HCONV hConv) { - HDDEDATA hData; UINT error; - /* Execute Command & Check Result */ - DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); - todo_wine - { - ok (expected_result == error, "CreateGroup %s: Expected Error %s, received %s.%s\n", - groupName, GetStringFromError(expected_result), GetStringFromError(error), - GetStringFromTestParams(testParams)); - } + /* Invalid Command */ + error = dde_execute(instance, hConv, "[InvalidCommand()]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); - /* No Error */ - if (error == DMLERR_NO_ERROR) - { + /* test parsing */ + error = dde_execute(instance, hConv, ""); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); - /* Check if Group Now Exists */ - CheckFileExistsInProgramGroups(groupName, TRUE, TRUE, NULL, testParams); - /* Check if Window is Open (polling) */ - CheckWindowCreated(windowTitle, TRUE, testParams); - } -} + error = dde_execute(instance, hConv, "CreateGroup"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); -/* Show Group Test. - * DDE command, expected_result, and the group name to check for existence - * if expected_result is DMLERR_NO_ERROR, test - * 1. window is open - */ -static HWND ShowGroupTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, - const char *groupName, const char *windowTitle, BOOL closeAfterShowing, int testParams) -{ - HDDEDATA hData; - UINT error; - HWND hwnd = 0; + error = dde_execute(instance, hConv, "[CreateGroup"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); - DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); -/* todo_wine... Is expected to fail, wine stubbed functions DO fail */ -/* TODO REMOVE THIS CODE!!! */ - todo_wine_if (expected_result != DMLERR_NOTPROCESSED) - ok (expected_result == error, "ShowGroup %s: Expected Error %s, received %s.%s\n", - groupName, GetStringFromError(expected_result), GetStringFromError(error), - GetStringFromTestParams(testParams)); + error = dde_execute(instance, hConv, "[CreateGroup]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); - if (error == DMLERR_NO_ERROR) - { - /* Check if Window is Open (polling) */ - hwnd = CheckWindowCreated(windowTitle, closeAfterShowing, testParams); - } - return hwnd; -} + error = dde_execute(instance, hConv, "[CreateGroup()]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); -/* Delete Group Test. - * DDE command, expected_result, and the group name to check for existence - * if expected_result is DMLERR_NO_ERROR, test - * 1. group does not exist - */ -static void DeleteGroupTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, - const char *groupName, int testParams) -{ - HDDEDATA hData; - UINT error; + error = dde_execute(instance, hConv, "[cREATEgROUP(test)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("test"), "directory not created\n"); + ok(check_window_exists("test"), "window not created\n"); - DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); - todo_wine - { - ok (expected_result == error, "DeleteGroup %s: Expected Error %s, received %s.%s\n", - groupName, GetStringFromError(expected_result), GetStringFromError(error), - GetStringFromTestParams(testParams)); - } + error = dde_execute(instance, hConv, "[AddItem(notepad,foobar)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("test/foobar.lnk"), "link not created\n"); - if (error == DMLERR_NO_ERROR) - { - /* Check that Group does not exist */ - CheckFileExistsInProgramGroups(groupName, FALSE, TRUE, NULL, testParams); - } -} + error = dde_execute(instance, hConv, "[AddItem(notepad,foo bar)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("test/foo bar.lnk"), "link not created\n"); -/* Add Item Test - * DDE command, expected result, and group and file name where it should exist. - * checks to make sure error code matches expected error code - * checks to make sure item exists if successful - */ -static void AddItemTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, - const char *fileName, const char *groupName, int testParams) -{ - HDDEDATA hData; - UINT error; + error = dde_execute(instance, hConv, "[AddItem(notepad,a[b,c]d)]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); - DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); - todo_wine - { - ok (expected_result == error, "AddItem %s: Expected Error %s, received %s.%s\n", - fileName, GetStringFromError(expected_result), GetStringFromError(error), - GetStringFromTestParams(testParams)); - } + error = dde_execute(instance, hConv, "[AddItem(notepad,\"a[b,c]d\")]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("test/a[b,c]d.lnk"), "link not created\n"); - if (error == DMLERR_NO_ERROR) - { - /* Check that File exists */ - CheckFileExistsInProgramGroups(fileName, TRUE, FALSE, groupName, testParams); - } -} + error = dde_execute(instance, hConv, " [ AddItem ( notepad , test ) ] "); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("test/test.lnk"), "link not created\n"); -/* Delete Item Test. - * DDE command, expected result, and group and file name where it should exist. - * checks to make sure error code matches expected error code - * checks to make sure item does not exist if successful - */ -static void DeleteItemTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, - const char *fileName, const char *groupName, int testParams) -{ - HDDEDATA hData; - UINT error; + error = dde_execute(instance, hConv, "[AddItem(notepad,one)][AddItem(notepad,two)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("test/one.lnk"), "link not created\n"); + ok(check_exists("test/two.lnk"), "link not created\n"); - DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); - todo_wine - { - ok (expected_result == error, "DeleteItem %s: Expected Error %s, received %s.%s\n", - fileName, GetStringFromError(expected_result), GetStringFromError(error), - GetStringFromTestParams(testParams)); - } + error = dde_execute(instance, hConv, "[FakeCommand(test)][DeleteGroup(test)]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); + ok(check_exists("test"), "directory should exist\n"); - if (error == DMLERR_NO_ERROR) - { - /* Check that File does not exist */ - CheckFileExistsInProgramGroups(fileName, FALSE, FALSE, groupName, testParams); - } + error = dde_execute(instance, hConv, "[DeleteGroup(test)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(!check_exists("test"), "directory should not exist\n"); + + error = dde_execute(instance, hConv, "[ExitProgman()]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + + error = dde_execute(instance, hConv, "[ExitProgman]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); } -/* Compound Command Test. - * not really generic, assumes command of the form: - * [CreateGroup ...][AddItem ...][AddItem ...] - * All samples I've seen using Compound were of this form (CreateGroup, - * AddItems) so this covers minimum expected functionality. - */ -static HWND CompoundCommandTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, - const char *groupName, const char *windowTitle, const char *fileName1, - const char *fileName2, int testParams) +/* 1st set of tests */ +static void test_progman_dde(DWORD instance, HCONV hConv) { - HDDEDATA hData; UINT error; - HWND hwnd = 0; - DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); - todo_wine - { - ok (expected_result == error, "Compound String %s: Expected Error %s, received %s.%s\n", - command, GetStringFromError(expected_result), GetStringFromError(error), - GetStringFromTestParams(testParams)); - } + /* test creating and deleting groups and items */ + error = dde_execute(instance, hConv, "[CreateGroup(Group1)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group1"), "directory not created\n"); + ok(check_window_exists("Group1"), "window not created\n"); - if (error == DMLERR_NO_ERROR) - { - /* Check that File exists */ - CheckFileExistsInProgramGroups(groupName, TRUE, TRUE, NULL, testParams); - hwnd = CheckWindowCreated(windowTitle, FALSE, testParams); - CheckFileExistsInProgramGroups(fileName1, TRUE, FALSE, groupName, testParams); - CheckFileExistsInProgramGroups(fileName2, TRUE, FALSE, groupName, testParams); - } - return hwnd; + error = dde_execute(instance, hConv, "[AddItem]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); + + error = dde_execute(instance, hConv, "[AddItem(test)]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); + + error = dde_execute(instance, hConv, "[AddItem(notepad.exe)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group1/notepad.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[DeleteItem(notepad.exe)]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); + + error = dde_execute(instance, hConv, "[DeleteItem(notepad)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(!check_exists("Group1/notepad.lnk"), "link should not exist\n"); + + error = dde_execute(instance, hConv, "[DeleteItem(notepad)]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); + + error = dde_execute(instance, hConv, "[AddItem(notepad)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group1/notepad.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[AddItem(notepad)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + + /* XP allows any valid path even if it does not exist; Vista+ requires that + * the path both exist and be a file (directories are invalid). */ + + error = dde_execute(instance, hConv, "[AddItem(C:\\windows\\system.ini)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group1/system.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[AddItem(notepad,test1)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group1/test1.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[DeleteItem(test1)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(!check_exists("Group1/test1.lnk"), "link should not exist\n"); + + error = dde_execute(instance, hConv, "[AddItem(notepad,test1)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group1/test1.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[ReplaceItem(test1)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(!check_exists("Group1/test1.lnk"), "link should not exist\n"); + + error = dde_execute(instance, hConv, "[AddItem(regedit)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group1/regedit.lnk"), "link not created\n"); + + /* test ShowGroup() and test which group an item gets added to */ + error = dde_execute(instance, hConv, "[ShowGroup(Group1)]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); + + error = dde_execute(instance, hConv, "[ShowGroup(Group1, 0)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_window_exists("Group1"), "window not created\n"); + + error = dde_execute(instance, hConv, "[CreateGroup(Group2)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group2"), "directory not created\n"); + ok(check_window_exists("Group2"), "window not created\n"); + + error = dde_execute(instance, hConv, "[AddItem(notepad,test2)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group2/test2.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[ShowGroup(Group1, 0)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_window_exists("Group1"), "window not created\n"); + + error = dde_execute(instance, hConv, "[AddItem(notepad,test3)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group1/test3.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[DeleteGroup(Group1)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(!check_exists("Group1"), "directory should not exist\n"); + + error = dde_execute(instance, hConv, "[DeleteGroup(Group1)]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); + + error = dde_execute(instance, hConv, "[ShowGroup(Group2, 0)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_window_exists("Group2"), "window not created\n"); + + error = dde_execute(instance, hConv, "[ExitProgman(1)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + + error = dde_execute(instance, hConv, "[AddItem(notepad,test4)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group2/test4.lnk"), "link not created\n"); } -static void CreateAddItemText(char *itemtext, const char *cmdline, const char *name) +/* 2nd set of tests - 2nd connection */ +static void test_progman_dde2(DWORD instance, HCONV hConv) { - lstrcpyA(itemtext, "[AddItem("); - lstrcatA(itemtext, cmdline); - lstrcatA(itemtext, ","); - lstrcatA(itemtext, name); - lstrcatA(itemtext, ")]"); + UINT error; + + /* last open group is retained across connections */ + error = dde_execute(instance, hConv, "[AddItem(notepad)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("Group2/notepad.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[DeleteGroup(Group2)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(!check_exists("Group2"), "directory should not exist\n"); } -/* 1st set of tests */ -static int DdeTestProgman(DWORD instance, HCONV hConv) +static BOOL check_in_programs_list(const char *list, const char *group) { - HDDEDATA hData; - UINT error; - int testnum; - char temppath[MAX_PATH]; - char f1g1[MAX_PATH], f2g1[MAX_PATH], f3g1[MAX_PATH], f1g3[MAX_PATH], f2g3[MAX_PATH]; - char itemtext[MAX_PATH + 20]; - char comptext[2 * (MAX_PATH + 20) + 21]; - HWND hwnd; - - testnum = 1; - /* Invalid Command */ - DdeExecuteCommand(instance, hConv, "[InvalidCommand()]", &hData, &error, DDE_TEST_MISC|testnum++); - ok (error == DMLERR_NOTPROCESSED, "InvalidCommand(), expected error %s, received %s.\n", - GetStringFromError(DMLERR_NOTPROCESSED), GetStringFromError(error)); - - /* On Vista+ the files have to exist when adding a link */ - GetTempPathA(MAX_PATH, temppath); - GetTempFileNameA(temppath, "dde", 0, f1g1); - GetTempFileNameA(temppath, "dde", 0, f2g1); - GetTempFileNameA(temppath, "dde", 0, f3g1); - GetTempFileNameA(temppath, "dde", 0, f1g3); - GetTempFileNameA(temppath, "dde", 0, f2g3); - - /* CreateGroup Tests (including AddItem, DeleteItem) */ - CreateGroupTest(instance, hConv, "[CreateGroup(Group1)]", DMLERR_NO_ERROR, "Group1", Group1Title, DDE_TEST_CREATEGROUP|testnum++); - CreateAddItemText(itemtext, f1g1, "f1g1Name"); - AddItemTest(instance, hConv, itemtext, DMLERR_NO_ERROR, "f1g1Name.lnk", "Group1", DDE_TEST_ADDITEM|testnum++); - CreateAddItemText(itemtext, f2g1, "f2g1Name"); - AddItemTest(instance, hConv, itemtext, DMLERR_NO_ERROR, "f2g1Name.lnk", "Group1", DDE_TEST_ADDITEM|testnum++); - DeleteItemTest(instance, hConv, "[DeleteItem(f2g1Name)]", DMLERR_NO_ERROR, "f2g1Name.lnk", "Group1", DDE_TEST_DELETEITEM|testnum++); - CreateAddItemText(itemtext, f3g1, "f3g1Name"); - AddItemTest(instance, hConv, itemtext, DMLERR_NO_ERROR, "f3g1Name.lnk", "Group1", DDE_TEST_ADDITEM|testnum++); - CreateGroupTest(instance, hConv, "[CreateGroup(Group2)]", DMLERR_NO_ERROR, "Group2", Group2Title, DDE_TEST_CREATEGROUP|testnum++); - /* Create Group that already exists - same instance */ - CreateGroupTest(instance, hConv, "[CreateGroup(Group1)]", DMLERR_NO_ERROR, "Group1", Group1Title, DDE_TEST_CREATEGROUP|testnum++); - - /* ShowGroup Tests */ - ShowGroupTest(instance, hConv, "[ShowGroup(Group1)]", DMLERR_NOTPROCESSED, "Group1", Group1Title, TRUE, DDE_TEST_SHOWGROUP|testnum++); - DeleteItemTest(instance, hConv, "[DeleteItem(f3g1Name)]", DMLERR_NO_ERROR, "f3g1Name.lnk", "Group1", DDE_TEST_DELETEITEM|testnum++); - ShowGroupTest(instance, hConv, "[ShowGroup(Startup,0)]", DMLERR_NO_ERROR, "Startup", StartupTitle, TRUE, DDE_TEST_SHOWGROUP|testnum++); - hwnd = ShowGroupTest(instance, hConv, "[ShowGroup(Group1,0)]", DMLERR_NO_ERROR, "Group1", Group1Title, FALSE, DDE_TEST_SHOWGROUP|testnum++); - - /* DeleteGroup Test - Note that Window is Open for this test */ - DeleteGroupTest(instance, hConv, "[DeleteGroup(Group1)]", DMLERR_NO_ERROR, "Group1", DDE_TEST_DELETEGROUP|testnum++); - if (hwnd) SendMessageA(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0); - - /* Compound Execute String Command */ - lstrcpyA(comptext, "[CreateGroup(Group3)]"); - CreateAddItemText(itemtext, f1g3, "f1g3Name"); - lstrcatA(comptext, itemtext); - CreateAddItemText(itemtext, f2g3, "f2g3Name"); - lstrcatA(comptext, itemtext); - hwnd = CompoundCommandTest(instance, hConv, comptext, DMLERR_NO_ERROR, "Group3", Group3Title, "f1g3Name.lnk", "f2g3Name.lnk", DDE_TEST_COMPOUND|testnum++); - - DeleteGroupTest(instance, hConv, "[DeleteGroup(Group3)]", DMLERR_NO_ERROR, "Group3", DDE_TEST_DELETEGROUP|testnum++); - if (hwnd) SendMessageA(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0); - - /* Full Parameters of Add Item */ - /* AddItem(CmdLine[,Name[,IconPath[,IconIndex[,xPos,yPos[,DefDir[,HotKey[,fMinimize[fSeparateSpace]]]]]]]) */ - - DeleteFileA(f1g1); - DeleteFileA(f2g1); - DeleteFileA(f3g1); - DeleteFileA(f1g3); - DeleteFileA(f2g3); - - return testnum; + while (1) + { + if (!strncmp(list, group, strlen(group)) && list[strlen(group)] == '\r') + return TRUE; + if (!(list = strchr(list, '\r'))) break; + list += 2; + } + return FALSE; } -/* 2nd set of tests - 2nd connection */ -static void DdeTestProgman2(DWORD instance, HCONV hConv, int testnum) +static void test_request_groups(DWORD instance, HCONV hconv) { - /* Create Group that already exists on a separate connection */ - CreateGroupTest(instance, hConv, "[CreateGroup(Group2)]", DMLERR_NO_ERROR, "Group2", Group2Title, DDE_TEST_CREATEGROUP|testnum++); - DeleteGroupTest(instance, hConv, "[DeleteGroup(Group2)]", DMLERR_NO_ERROR, "Group2", DDE_TEST_DELETEGROUP|testnum++); + char *list; + char programs[MAX_PATH]; + WIN32_FIND_DATAA finddata; + HANDLE hfind; + + list = dde_request(instance, hconv, "Groups"); + ok(list != NULL, "request failed: %u\n", DdeGetLastError(instance)); + strcpy(programs, ProgramsDir); + strcat(programs, "/*"); + hfind = FindFirstFileA(programs, &finddata); + do + { + if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && finddata.cFileName[0] != '.') + { + ok(check_in_programs_list(list, finddata.cFileName), + "directory '%s' missing from group list\n", finddata.cFileName); + } + } while (FindNextFileA(hfind, &finddata)); + FindClose(hfind); } START_TEST(progman_dde) @@ -699,20 +421,21 @@ START_TEST(progman_dde) UINT err; HSZ hszProgman; HCONV hConv; - int testnum; + BOOL ret; init_function_pointers(); init_strings(); /* Initialize DDE Instance */ err = DdeInitializeA(&instance, DdeCallback, APPCMD_CLIENTONLY, 0); - ok (err == DMLERR_NO_ERROR, "DdeInitialize Error %s\n", GetStringFromError(err)); + ok(err == DMLERR_NO_ERROR, "DdeInitialize() failed: %u\n", err); /* Create Connection */ hszProgman = DdeCreateStringHandleA(instance, "PROGMAN", CP_WINANSI); - ok (hszProgman != NULL, "DdeCreateStringHandle Error %s\n", GetDdeLastErrorStr(instance)); + ok(hszProgman != NULL, "DdeCreateStringHandle() failed: %u\n", DdeGetLastError(instance)); hConv = DdeConnect(instance, hszProgman, hszProgman, NULL); - ok (DdeFreeStringHandle(instance, hszProgman), "DdeFreeStringHandle failure\n"); + ret = DdeFreeStringHandle(instance, hszProgman); + ok(ret, "DdeFreeStringHandle() failed: %u\n", DdeGetLastError(instance)); /* Seeing failures on early versions of Windows Connecting to progman, exit if connection fails */ if (hConv == NULL) { @@ -720,30 +443,36 @@ START_TEST(progman_dde) return; } - /* Run Tests */ - testnum = DdeTestProgman(instance, hConv); + test_parser(instance, hConv); + test_progman_dde(instance, hConv); + test_request_groups(instance, hConv); /* Cleanup & Exit */ - ok (DdeDisconnect(hConv), "DdeDisonnect Error %s\n", GetDdeLastErrorStr(instance)); - ok (DdeUninitialize(instance), "DdeUninitialize failed\n"); + ret = DdeDisconnect(hConv); + ok(ret, "DdeDisonnect() failed: %u\n", DdeGetLastError(instance)); + ret = DdeUninitialize(instance); + ok(ret, "DdeUninitialize() failed: %u\n", DdeGetLastError(instance)); /* 2nd Instance (Followup Tests) */ /* Initialize DDE Instance */ instance = 0; err = DdeInitializeA(&instance, DdeCallback, APPCMD_CLIENTONLY, 0); - ok (err == DMLERR_NO_ERROR, "DdeInitialize Error %s\n", GetStringFromError(err)); + ok (err == DMLERR_NO_ERROR, "DdeInitialize() failed: %u\n", err); /* Create Connection */ hszProgman = DdeCreateStringHandleA(instance, "PROGMAN", CP_WINANSI); - ok (hszProgman != NULL, "DdeCreateStringHandle Error %s\n", GetDdeLastErrorStr(instance)); + ok(hszProgman != NULL, "DdeCreateStringHandle() failed: %u\n", DdeGetLastError(instance)); hConv = DdeConnect(instance, hszProgman, hszProgman, NULL); - ok (hConv != NULL, "DdeConnect Error %s\n", GetDdeLastErrorStr(instance)); - ok (DdeFreeStringHandle(instance, hszProgman), "DdeFreeStringHandle failure\n"); + ok(hConv != NULL, "DdeConnect() failed: %u\n", DdeGetLastError(instance)); + ret = DdeFreeStringHandle(instance, hszProgman); + ok(ret, "DdeFreeStringHandle() failed: %u\n", DdeGetLastError(instance)); /* Run Tests */ - DdeTestProgman2(instance, hConv, testnum); + test_progman_dde2(instance, hConv); /* Cleanup & Exit */ - ok (DdeDisconnect(hConv), "DdeDisonnect Error %s\n", GetDdeLastErrorStr(instance)); - ok (DdeUninitialize(instance), "DdeUninitialize failed\n"); + ret = DdeDisconnect(hConv); + ok(ret, "DdeDisonnect() failed: %u\n", DdeGetLastError(instance)); + ret = DdeUninitialize(instance); + ok(ret, "DdeUninitialize() failed: %u\n", DdeGetLastError(instance)); } diff --git a/modules/rostests/winetests/shell32/recyclebin.c b/modules/rostests/winetests/shell32/recyclebin.c index 7cb8f6e8ca..50e262e918 100644 --- a/modules/rostests/winetests/shell32/recyclebin.c +++ b/modules/rostests/winetests/shell32/recyclebin.c @@ -18,7 +18,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include "shellapi.h" + +#include <stdio.h> +#include "wine/test.h" static int (WINAPI *pSHQueryRecycleBinA)(LPCSTR,LPSHQUERYRBINFO); static int (WINAPI *pSHFileOperationA)(LPSHFILEOPSTRUCTA); diff --git a/modules/rostests/winetests/shell32/shelldispatch.c b/modules/rostests/winetests/shell32/shelldispatch.c index 30b3133547..cc00757840 100644 --- a/modules/rostests/winetests/shell32/shelldispatch.c +++ b/modules/rostests/winetests/shell32/shelldispatch.c @@ -18,35 +18,63 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#define COBJMACROS +#define NONAMELESSUNION +#define NONAMELESSSTRUCT -#include <winsvc.h> -#include <initguid.h> +#include "shldisp.h" +#include "shlobj.h" +#include "shlwapi.h" +#include "winsvc.h" + +#include "wine/heap.h" +#include "wine/test.h" + +#include "initguid.h" #define EXPECT_HR(hr,hr_exp) \ ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp) +#define EXPECT_REF(obj,ref) _expect_ref((IUnknown *)obj, ref, __LINE__) +static void _expect_ref(IUnknown *obj, ULONG ref, int line) +{ + ULONG rc; + IUnknown_AddRef(obj); + rc = IUnknown_Release(obj); + ok_(__FILE__,line)(rc == ref, "Unexpected refcount %d, expected %d\n", rc, ref); +} + static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0}; -static HRESULT (WINAPI *pSHGetFolderPathW)(HWND, int, HANDLE, DWORD, LPWSTR); static HRESULT (WINAPI *pSHGetNameFromIDList)(PCIDLIST_ABSOLUTE,SIGDN,PWSTR*); -static HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *); -static DWORD (WINAPI *pGetLongPathNameW)(LPCWSTR, LPWSTR, DWORD); /* Updated Windows 7 has a new IShellDispatch6 in its typelib */ DEFINE_GUID(IID_IWin7ShellDispatch6, 0x34936ba1, 0x67ad, 0x4c41, 0x99,0xb8, 0x8c,0x12,0xdf,0xf1,0xe9,0x74); +static BSTR a2bstr(const char *str) +{ + BSTR ret; + int len; + + len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + ret = SysAllocStringLen(NULL, len); + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + + return ret; +} + +static void variant_set_string(VARIANT *v, const char *s) +{ + V_VT(v) = VT_BSTR; + V_BSTR(v) = a2bstr(s); +} + static void init_function_pointers(void) { - HMODULE hshell32, hkernel32; + HMODULE hshell32; hshell32 = GetModuleHandleA("shell32.dll"); - hkernel32 = GetModuleHandleA("kernel32.dll"); - pSHGetFolderPathW = (void*)GetProcAddress(hshell32, "SHGetFolderPathW"); pSHGetNameFromIDList = (void*)GetProcAddress(hshell32, "SHGetNameFromIDList"); - pSHGetSpecialFolderLocation = (void*)GetProcAddress(hshell32, - "SHGetSpecialFolderLocation"); - pGetLongPathNameW = (void*)GetProcAddress(hkernel32, "GetLongPathNameW"); } static void test_namespace(void) @@ -108,18 +136,23 @@ static void test_namespace(void) FolderItem *item; VARIANT var; BSTR title, item_path; + IDispatch *disp; int len, i; - r = CoCreateInstance(&CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, - &IID_IShellDispatch, (LPVOID*)&sd); - if (r == REGDB_E_CLASSNOTREG) /* NT4 */ - { - win_skip("skipping IShellDispatch tests\n"); - return; - } - ok(SUCCEEDED(r), "CoCreateInstance failed: %08x\n", r); - if (FAILED(r)) - return; + r = CoCreateInstance(&CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, &IID_IShellDispatch, (void **)&sd); + ok(SUCCEEDED(r), "Failed to create ShellDispatch object: %#x.\n", r); + + disp = NULL; + r = IShellDispatch_get_Application(sd, &disp); + ok(r == S_OK, "Failed to get application pointer, hr %#x.\n", r); + ok(disp == (IDispatch *)sd, "Unexpected application pointer %p.\n", disp); + IDispatch_Release(disp); + + disp = NULL; + r = IShellDispatch_get_Parent(sd, &disp); + ok(r == S_OK, "Failed to get Shell object parent, hr %#x.\n", r); + ok(disp == (IDispatch *)sd, "Unexpected parent pointer %p.\n", disp); + IDispatch_Release(disp); VariantInit(&var); folder = (void*)0xdeadbeef; @@ -135,6 +168,7 @@ static void test_namespace(void) folder = (void*)0xdeadbeef; r = IShellDispatch_NameSpace(sd, var, &folder); if (special_folders[i] == ssfALTSTARTUP || special_folders[i] == ssfCOMMONALTSTARTUP) + todo_wine ok(r == S_OK || broken(r == S_FALSE) /* winxp */, "Failed to get folder for index %#x, got %08x\n", special_folders[i], r); else ok(r == S_OK, "Failed to get folder for index %#x, got %08x\n", special_folders[i], r); @@ -144,32 +178,23 @@ static void test_namespace(void) V_VT(&var) = VT_I4; V_I4(&var) = -1; - folder = (void*)0xdeadbeef; + folder = (void *)0xdeadbeef; r = IShellDispatch_NameSpace(sd, var, &folder); - todo_wine { - ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r); - ok(folder == NULL, "got %p\n", folder); - if (r == S_OK) - Folder_Release(folder); -} + ok(r == S_FALSE, "Unexpected hr %#x.\n", r); + ok(folder == NULL, "Unexpected folder instance %p\n", folder); + V_VT(&var) = VT_I4; V_I4(&var) = ssfPROGRAMFILES; r = IShellDispatch_NameSpace(sd, var, &folder); - ok(r == S_OK || - broken(r == S_FALSE), /* NT4 */ - "IShellDispatch::NameSpace failed: %08x\n", r); + ok(r == S_OK, "IShellDispatch::NameSpace failed: %08x\n", r); if (r == S_OK) { static WCHAR path[MAX_PATH]; - if (pSHGetFolderPathW) - { - r = pSHGetFolderPathW(NULL, CSIDL_PROGRAM_FILES, NULL, - SHGFP_TYPE_CURRENT, path); - ok(r == S_OK, "SHGetFolderPath failed: %08x\n", r); - } + r = SHGetFolderPathW(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, path); + ok(r == S_OK, "Failed to get folder path: %#x.\n", r); + r = Folder_get_Title(folder, &title); - todo_wine ok(r == S_OK, "Folder::get_Title failed: %08x\n", r); if (r == S_OK) { @@ -177,22 +202,20 @@ static void test_namespace(void) HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir. On newer Windows it seems constant and is not changed if the program files directory name is changed */ - if (pSHGetSpecialFolderLocation && pSHGetNameFromIDList) + if (pSHGetNameFromIDList) { LPITEMIDLIST pidl; PWSTR name; - r = pSHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidl); + r = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidl); ok(r == S_OK, "SHGetSpecialFolderLocation failed: %08x\n", r); r = pSHGetNameFromIDList(pidl, SIGDN_NORMALDISPLAY, &name); ok(r == S_OK, "SHGetNameFromIDList failed: %08x\n", r); - todo_wine - ok(!lstrcmpW(title, name), "expected %s, got %s\n", - wine_dbgstr_w(name), wine_dbgstr_w(title)); + ok(!lstrcmpW(title, name), "expected %s, got %s\n", wine_dbgstr_w(name), wine_dbgstr_w(title)); CoTaskMemFree(name); CoTaskMemFree(pidl); } - else if (pSHGetFolderPathW) + else { WCHAR *p; @@ -202,7 +225,6 @@ static void test_namespace(void) ok(!lstrcmpiW(title, p), "expected %s, got %s\n", wine_dbgstr_w(p), wine_dbgstr_w(title)); } - else skip("skipping Folder::get_Title test\n"); SysFreeString(title); } r = Folder_QueryInterface(folder, &IID_Folder2, (LPVOID*)&folder2); @@ -215,9 +237,7 @@ static void test_namespace(void) { r = FolderItem_get_Path(item, &item_path); ok(r == S_OK, "FolderItem::get_Path failed: %08x\n", r); - if (pSHGetFolderPathW) - ok(!lstrcmpiW(item_path, path), "expected %s, got %s\n", - wine_dbgstr_w(path), wine_dbgstr_w(item_path)); + ok(!lstrcmpiW(item_path, path), "expected %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(item_path)); SysFreeString(item_path); FolderItem_Release(item); } @@ -229,34 +249,21 @@ static void test_namespace(void) V_VT(&var) = VT_I4; V_I4(&var) = ssfBITBUCKET; r = IShellDispatch_NameSpace(sd, var, &folder); - ok(r == S_OK || - broken(r == S_FALSE), /* NT4 */ - "IShellDispatch::NameSpace failed: %08x\n", r); - if (r == S_OK) - { - r = Folder_QueryInterface(folder, &IID_Folder2, (LPVOID*)&folder2); - ok(r == S_OK || - broken(r == E_NOINTERFACE), /* NT4 */ - "Folder::QueryInterface failed: %08x\n", r); - if (r == S_OK) - { - r = Folder2_get_Self(folder2, &item); - ok(r == S_OK, "Folder::get_Self failed: %08x\n", r); - if (r == S_OK) - { - r = FolderItem_get_Path(item, &item_path); - todo_wine - ok(r == S_OK, "FolderItem::get_Path failed: %08x\n", r); - todo_wine - ok(!lstrcmpW(item_path, clsidW), "expected %s, got %s\n", - wine_dbgstr_w(clsidW), wine_dbgstr_w(item_path)); - SysFreeString(item_path); - FolderItem_Release(item); - } - Folder2_Release(folder2); - } - Folder_Release(folder); - } + ok(r == S_OK, "IShellDispatch::NameSpace failed: %08x\n", r); + + r = Folder_QueryInterface(folder, &IID_Folder2, (void **)&folder2); + ok(r == S_OK, "Failed to get Folder2 interface: %#x.\n", r); + r = Folder2_get_Self(folder2, &item); + ok(r == S_OK, "Folder::get_Self failed: %08x\n", r); + r = FolderItem_get_Path(item, &item_path); + ok(r == S_OK, "FolderItem::get_Path failed: %08x\n", r); + /* TODO: we return lowercase GUID here */ + ok(!lstrcmpiW(item_path, clsidW), "expected %s, got %s\n", wine_dbgstr_w(clsidW), wine_dbgstr_w(item_path)); + + SysFreeString(item_path); + FolderItem_Release(item); + Folder2_Release(folder2); + Folder_Release(folder); GetTempPathW(MAX_PATH, tempW); GetCurrentDirectoryW(MAX_PATH, curW); @@ -269,51 +276,39 @@ static void test_namespace(void) SysFreeString(V_BSTR(&var)); GetFullPathNameW(winetestW, MAX_PATH, tempW, NULL); - if (pGetLongPathNameW) - { - len = pGetLongPathNameW(tempW, NULL, 0); - long_pathW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (long_pathW) - pGetLongPathNameW(tempW, long_pathW, len); - } + + len = GetLongPathNameW(tempW, NULL, 0); + long_pathW = heap_alloc(len * sizeof(WCHAR)); + GetLongPathNameW(tempW, long_pathW, len); + V_VT(&var) = VT_BSTR; V_BSTR(&var) = SysAllocString(tempW); r = IShellDispatch_NameSpace(sd, var, &folder); ok(r == S_OK, "IShellDispatch::NameSpace failed: %08x\n", r); - if (r == S_OK) - { - r = Folder_get_Title(folder, &title); - ok(r == S_OK, "Folder::get_Title failed: %08x\n", r); - if (r == S_OK) - { - ok(!lstrcmpW(title, winetestW), "bad title: %s\n", - wine_dbgstr_w(title)); - SysFreeString(title); - } - r = Folder_QueryInterface(folder, &IID_Folder2, (LPVOID*)&folder2); - ok(r == S_OK || - broken(r == E_NOINTERFACE), /* NT4 */ - "Folder::QueryInterface failed: %08x\n", r); - if (r == S_OK) - { - r = Folder2_get_Self(folder2, &item); - ok(r == S_OK, "Folder::get_Self failed: %08x\n", r); - if (r == S_OK) - { - r = FolderItem_get_Path(item, &item_path); - ok(r == S_OK, "FolderItem::get_Path failed: %08x\n", r); - if (long_pathW) - ok(!lstrcmpW(item_path, long_pathW), - "expected %s, got %s\n", wine_dbgstr_w(long_pathW), - wine_dbgstr_w(item_path)); - SysFreeString(item_path); - FolderItem_Release(item); - } - Folder2_Release(folder2); - } - Folder_Release(folder); - } - SysFreeString(V_BSTR(&var)); + + disp = (void *)0xdeadbeef; + r = Folder_get_Parent(folder, &disp); + ok(r == E_NOTIMPL, "Unexpected hr %#x.\n", r); + ok(disp == NULL, "Unexpected parent pointer %p.\n", disp); + + r = Folder_get_Title(folder, &title); + ok(r == S_OK, "Failed to get folder title: %#x.\n", r); + ok(!lstrcmpW(title, winetestW), "Unexpected title: %s\n", wine_dbgstr_w(title)); + SysFreeString(title); + + r = Folder_QueryInterface(folder, &IID_Folder2, (void **)&folder2); + ok(r == S_OK, "Failed to get Folder2 interface: %#x.\n", r); + r = Folder2_get_Self(folder2, &item); + ok(r == S_OK, "Folder::get_Self failed: %08x\n", r); + r = FolderItem_get_Path(item, &item_path); + ok(r == S_OK, "Failed to get item path: %#x.\n", r); + ok(!lstrcmpW(item_path, long_pathW), "Unexpected path %s, got %s\n", wine_dbgstr_w(item_path), wine_dbgstr_w(long_pathW)); + SysFreeString(item_path); + FolderItem_Release(item); + Folder2_Release(folder2); + + Folder_Release(folder); + VariantClear(&var); len = lstrlenW(tempW); if (len < MAX_PATH - 1) @@ -334,9 +329,7 @@ static void test_namespace(void) SysFreeString(title); } r = Folder_QueryInterface(folder, &IID_Folder2, (LPVOID*)&folder2); - ok(r == S_OK || - broken(r == E_NOINTERFACE), /* NT4 */ - "Folder::QueryInterface failed: %08x\n", r); + ok(r == S_OK, "Failed to get Folder2 interface: %#x.\n", r); if (r == S_OK) { r = Folder2_get_Self(folder2, &item); @@ -345,10 +338,8 @@ static void test_namespace(void) { r = FolderItem_get_Path(item, &item_path); ok(r == S_OK, "FolderItem::get_Path failed: %08x\n", r); - if (long_pathW) - ok(!lstrcmpW(item_path, long_pathW), - "expected %s, got %s\n", wine_dbgstr_w(long_pathW), - wine_dbgstr_w(item_path)); + ok(!lstrcmpW(item_path, long_pathW), "Unexpected path %s, got %s\n", wine_dbgstr_w(item_path), + wine_dbgstr_w(long_pathW)); SysFreeString(item_path); FolderItem_Release(item); } @@ -359,7 +350,7 @@ static void test_namespace(void) SysFreeString(V_BSTR(&var)); } - HeapFree(GetProcessHeap(), 0, long_pathW); + heap_free(long_pathW); RemoveDirectoryW(winetestW); SetCurrentDirectoryW(curW); IShellDispatch_Release(sd); @@ -367,55 +358,110 @@ static void test_namespace(void) static void test_items(void) { - WCHAR wstr[MAX_PATH], orig_dir[MAX_PATH]; + static const struct + { + char name[32]; + enum + { + DIRECTORY, + EMPTY_FILE, + } + type; + } + file_defs[] = + { + { "00-Myfolder", DIRECTORY }, + { "01-empty.bin", EMPTY_FILE }, + }; + WCHAR path[MAX_PATH], cur_dir[MAX_PATH], orig_dir[MAX_PATH]; HRESULT r; IShellDispatch *sd = NULL; Folder *folder = NULL; - FolderItems *items = NULL; + FolderItems *items; FolderItems2 *items2 = NULL; FolderItems3 *items3 = NULL; - FolderItem *item = (FolderItem*)0xdeadbeef; - IDispatch *disp = NULL; - IUnknown *unk = NULL; + FolderItem *item = (FolderItem*)0xdeadbeef, *item2; FolderItemVerbs *verbs = (FolderItemVerbs*)0xdeadbeef; - VARIANT var; - LONG lcount = -1; + VARIANT var, int_index, str_index, str_index2; + IDispatch *disp, *disp2; + LONG count = -1; + IUnknown *unk; + HANDLE file; + BSTR bstr; + char cstr[64]; + BOOL ret; + int i; r = CoCreateInstance(&CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, &IID_IShellDispatch, (void**)&sd); ok(SUCCEEDED(r), "CoCreateInstance failed: %08x\n", r); ok(!!sd, "sd is null\n"); - GetTempPathW(MAX_PATH, wstr); + /* create and enter a temporary directory and a folder object for it */ + GetTempPathW(MAX_PATH, path); GetCurrentDirectoryW(MAX_PATH, orig_dir); - SetCurrentDirectoryW(wstr); - CreateDirectoryW(winetestW, NULL); - GetFullPathNameW(winetestW, MAX_PATH, wstr, NULL); + SetCurrentDirectoryW(path); + ret = CreateDirectoryW(winetestW, NULL); + ok(ret, "CreateDirectory failed: %08x\n", GetLastError()); + GetFullPathNameW(winetestW, MAX_PATH, path, NULL); V_VT(&var) = VT_BSTR; - V_BSTR(&var) = SysAllocString(wstr); + V_BSTR(&var) = SysAllocString(path); + + EXPECT_REF(sd, 1); r = IShellDispatch_NameSpace(sd, var, &folder); ok(r == S_OK, "IShellDispatch::NameSpace failed: %08x\n", r); ok(!!folder, "folder is null\n"); - SysFreeString(V_BSTR(&var)); - IShellDispatch_Release(sd); + EXPECT_REF(folder, 1); + EXPECT_REF(sd, 1); + + VariantClear(&var); SetCurrentDirectoryW(winetestW); + GetCurrentDirectoryW(MAX_PATH, path); + GetLongPathNameW(path, cur_dir, MAX_PATH); + /* FolderItems grabs its Folder reference */ + items = NULL; r = Folder_Items(folder, &items); ok(r == S_OK, "Folder::Items failed: %08x\n", r); ok(!!items, "items is null\n"); - r = FolderItems_QueryInterface(items, &IID_FolderItems2, (void**)&items2); - ok(r == S_OK || broken(r == E_NOINTERFACE) /* xp and later */, "FolderItems::QueryInterface failed: %08x\n", r); - ok(!!items2 || broken(!items2) /* xp and later */, "items2 is null\n"); - r = FolderItems_QueryInterface(items, &IID_FolderItems3, (void**)&items3); - ok(r == S_OK, "FolderItems::QueryInterface failed: %08x\n", r); - ok(!!items3, "items3 is null\n"); - Folder_Release(folder); + EXPECT_REF(folder, 2); + EXPECT_REF(items, 1); + + unk = NULL; + r = Folder_Items(folder, (FolderItems **)&unk); + ok(r == S_OK, "Folder::Items failed: %08x\n", r); + EXPECT_REF(folder, 3); + IUnknown_Release(unk); + EXPECT_REF(folder, 2); + + FolderItems_AddRef(items); + EXPECT_REF(folder, 2); + FolderItems_Release(items); + + /* Application property */ + disp = NULL; + EXPECT_REF(sd, 1); + r = Folder_get_Application(folder, &disp); + ok(r == S_OK, "Failed to get application %#x.\n", r); + ok(disp != (IDispatch *)sd, "Unexpected application pointer\n"); + EXPECT_REF(sd, 1); + + disp2 = NULL; + r = Folder_get_Application(folder, &disp2); + ok(r == S_OK, "Failed to get application %#x.\n", r); + ok(disp2 == disp, "Unexpected application pointer\n"); + IDispatch_Release(disp2); + + r = IDispatch_QueryInterface(disp, &IID_IShellDispatch, (void **)&disp2); + ok(r == S_OK, "Wrong instance, hr %#x.\n", r); + IDispatch_Release(disp2); + IDispatch_Release(disp); if (0) /* crashes on all versions of Windows */ r = FolderItems_get_Count(items, NULL); - r = FolderItems_get_Count(items, &lcount); + r = FolderItems_get_Count(items, &count); ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r); - ok(!lcount, "expected 0 files, got %d\n", lcount); + ok(!count, "expected 0 files, got %d\n", count); V_VT(&var) = VT_I4; V_I4(&var) = 0; @@ -424,7 +470,269 @@ static void test_items(void) r = FolderItems_Item(items, var, NULL); r = FolderItems_Item(items, var, &item); -todo_wine + ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r); + ok(!item, "item is not null\n"); + + /* create test files */ + for (i = 0; i < sizeof(file_defs)/sizeof(file_defs[0]); i++) + { + switch (file_defs[i].type) + { + case DIRECTORY: + r = CreateDirectoryA(file_defs[i].name, NULL); + ok(r, "CreateDirectory failed: %08x\n", GetLastError()); + PathCombineA(cstr, file_defs[i].name, "foo.txt"); + file = CreateFileA(cstr, 0, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %08x\n", GetLastError()); + CloseHandle(file); + break; + + case EMPTY_FILE: + file = CreateFileA(file_defs[i].name, 0, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %08x\n", GetLastError()); + CloseHandle(file); + break; + } + } + + /* test that get_Count is not aware of the newly created files */ + count = -1; + r = FolderItems_get_Count(items, &count); + ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r); + ok(!count, "expected 0 files, got %d\n", count); + + /* test that the newly created files CAN be retrieved by string index */ + variant_set_string(&var, file_defs[0].name); + item = NULL; + r = FolderItems_Item(items, var, &item); + ok(r == S_OK, "FolderItems::Item failed: %08x\n", r); + ok(!!item, "item is null\n"); + + disp = (void *)0xdeadbeef; + r = FolderItems_get_Parent(items, &disp); + ok(r == E_NOTIMPL, "Unexpected hr %#x.\n", r); + ok(disp == NULL, "Unexpected parent pointer %p.\n", disp); + + r = FolderItem_get_Parent(item, &disp); + ok(r == S_OK, "Failed to get parent pointer, hr %#x.\n", r); + ok(disp == (IDispatch *)folder, "Unexpected parent pointer %p.\n", disp); + IDispatch_Release(disp); + + if (item) FolderItem_Release(item); + VariantClear(&var); + + /* recreate the items object */ + FolderItems_Release(items); + items = NULL; + r = Folder_Items(folder, &items); + ok(r == S_OK, "Folder::Items failed: %08x\n", r); + ok(!!items, "items is null\n"); + r = FolderItems_QueryInterface(items, &IID_FolderItems2, (void**)&items2); + ok(r == S_OK || broken(r == E_NOINTERFACE) /* xp and later */, "FolderItems::QueryInterface failed: %08x\n", r); + if (r == S_OK) + { + ok(!!items2, "items2 is null\n"); + FolderItems2_Release(items2); + } + r = FolderItems_QueryInterface(items, &IID_FolderItems3, (void**)&items3); + ok(r == S_OK, "FolderItems::QueryInterface failed: %08x\n", r); + ok(!!items3, "items3 is null\n"); + + count = -1; + r = FolderItems_get_Count(items, &count); + ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r); + ok(count == sizeof(file_defs)/sizeof(file_defs[0]), + "expected %d files, got %d\n", (LONG)(sizeof(file_defs)/sizeof(file_defs[0])), count); + + V_VT(&var) = VT_EMPTY; + item = (FolderItem*)0xdeadbeef; + r = FolderItems_Item(items, var, &item); + ok(r == E_NOTIMPL, "expected E_NOTIMPL, got %08x\n", r); + ok(!item, "item is not null\n"); + + V_VT(&var) = VT_I2; + V_I2(&var) = 0; + + EXPECT_REF(folder, 2); + EXPECT_REF(items, 2); + item = NULL; + r = FolderItems_Item(items, var, &item); + ok(r == S_OK, "FolderItems::Item failed: %08x\n", r); + ok(!!item, "item is null\n"); + EXPECT_REF(folder, 3); + EXPECT_REF(items, 2); + + r = Folder_get_Application(folder, &disp); + ok(r == S_OK, "Failed to get application pointer %#x.\n", r); + r = FolderItem_get_Application(item, &disp2); + ok(r == S_OK, "Failed to get application pointer %#x.\n", r); + ok(disp == disp2, "Unexpected application pointer.\n"); + IDispatch_Release(disp2); + IDispatch_Release(disp); + + FolderItem_Release(item); + + V_VT(&var) = VT_I4; + V_I4(&var) = 0; + item = NULL; + r = FolderItems_Item(items, var, &item); + ok(r == S_OK, "FolderItems::Item failed: %08x\n", r); + ok(!!item, "item is null\n"); + if (item) FolderItem_Release(item); + + V_I4(&var) = -1; + item = (FolderItem*)0xdeadbeef; + r = FolderItems_Item(items, var, &item); + ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r); + ok(!item, "item is not null\n"); + + V_VT(&var) = VT_ERROR; + V_ERROR(&var) = 0; + item = NULL; + r = FolderItems_Item(items, var, &item); + ok(r == S_OK, "expected S_OK, got %08x\n", r); + ok(!!item, "item is null\n"); + if (item) + { + bstr = NULL; + r = FolderItem_get_Path(item, &bstr); + ok(r == S_OK, "FolderItem::get_Path failed: %08x\n", r); + ok(!lstrcmpW(bstr, cur_dir), + "expected %s, got %s\n", wine_dbgstr_w(cur_dir), wine_dbgstr_w(bstr)); + SysFreeString(bstr); + FolderItem_Release(item); + } + + V_VT(&int_index) = VT_I4; + + /* test the folder item corresponding to each file */ + for (i = 0; i < sizeof(file_defs)/sizeof(file_defs[0]); i++) + { + VARIANT_BOOL b; + BSTR name; + + V_I4(&int_index) = i; + variant_set_string(&str_index, file_defs[i].name); + + item = NULL; + r = FolderItems_Item(items, int_index, &item); + ok(r == S_OK, "file_defs[%d]: FolderItems::Item failed: %08x\n", i, r); + ok(!!item, "file_defs[%d]: item is null\n", i); + + item2 = NULL; + r = FolderItems_Item(items, int_index, &item2); + ok(r == S_OK, "file_defs[%d]: FolderItems::Item failed: %08x\n", i, r); + ok(item2 != item, "file_defs[%d]: item and item2 are the same\n", i); + FolderItem_Release(item2); + + bstr = NULL; + r = FolderItem_get_Path(item, &bstr); + ok(r == S_OK, "file_defs[%d]: FolderItem::get_Path failed: %08x\n", i, r); + PathCombineW(path, cur_dir, V_BSTR(&str_index)); + ok(!lstrcmpW(bstr, path), + "file_defs[%d]: expected %s, got %s\n", i, wine_dbgstr_w(path), wine_dbgstr_w(bstr)); + SysFreeString(bstr); + + bstr = a2bstr(file_defs[i].name); + r = FolderItem_get_Name(item, &name); + ok(r == S_OK, "Failed to get item name, hr %#x.\n", r); + /* Returned display name does not have to strictly match file name, e.g. extension could be omitted. */ + ok(lstrlenW(name) <= lstrlenW(bstr), "file_defs[%d]: unexpected name length.\n", i); + ok(!memcmp(bstr, name, lstrlenW(name) * sizeof(WCHAR)), "file_defs[%d]: unexpected name %s.\n", i, wine_dbgstr_w(name)); + SysFreeString(name); + SysFreeString(bstr); + + FolderItem_Release(item); + + item = NULL; + r = FolderItems_Item(items, str_index, &item); + ok(r == S_OK, "file_defs[%d]: FolderItems::Item failed: %08x\n", i, r); + ok(!!item, "file_defs[%d]: item is null\n", i); + + bstr = NULL; + r = FolderItem_get_Path(item, &bstr); + ok(r == S_OK, "file_defs[%d]: FolderItem::get_Path failed: %08x\n", i, r); + PathCombineW(path, cur_dir, V_BSTR(&str_index)); + ok(!lstrcmpW(bstr, path), + "file_defs[%d]: expected %s, got %s\n", i, wine_dbgstr_w(path), wine_dbgstr_w(bstr)); + SysFreeString(bstr); + + b = 0xdead; + r = FolderItem_get_IsFolder(item, &b); + ok(r == S_OK, "Failed to get IsFolder property, %#x.\n", r); + ok(file_defs[i].type == DIRECTORY ? b == VARIANT_TRUE : b == VARIANT_FALSE, "Unexpected prop value %#x.\n", b); + + FolderItem_Release(item); + + if (file_defs[i].type == DIRECTORY) + { + /* test that getting an item object for a file in a subdirectory succeeds */ + PathCombineA(cstr, file_defs[i].name, "foo.txt"); + variant_set_string(&str_index2, cstr); + item2 = NULL; + r = FolderItems_Item(items, str_index2, &item2); + ok(r == S_OK, "file_defs[%d]: FolderItems::Item failed: %08x\n", i, r); + ok(!!item2, "file_defs[%d]: item is null\n", i); + if (item2) FolderItem_Release(item2); + VariantClear(&str_index2); + + /* delete the file in the subdirectory */ + ret = DeleteFileA(cstr); + ok(ret, "file_defs[%d]: DeleteFile failed: %08x\n", i, GetLastError()); + + /* test that getting an item object via a relative path fails */ + strcpy(cstr, file_defs[i].name); + strcat(cstr, "\\..\\"); + strcat(cstr, file_defs[i].name); + variant_set_string(&str_index2, cstr); + item2 = (FolderItem*)0xdeadbeef; + r = FolderItems_Item(items, str_index2, &item2); + todo_wine { + ok(r == S_FALSE, "file_defs[%d]: expected S_FALSE, got %08x\n", i, r); + ok(!item2, "file_defs[%d]: item is not null\n", i); + } + if (item2) FolderItem_Release(item2); + VariantClear(&str_index2); + + /* remove the directory */ + ret = RemoveDirectoryA(file_defs[i].name); + ok(ret, "file_defs[%d]: RemoveDirectory failed: %08x\n", i, GetLastError()); + } + else + { + ret = DeleteFileA(file_defs[i].name); + ok(ret, "file_defs[%d]: DeleteFile failed: %08x\n", i, GetLastError()); + } + + /* test that the folder item is still accessible by integer index */ + item = NULL; + r = FolderItems_Item(items, int_index, &item); + ok(r == S_OK, "file_defs[%d]: FolderItems::Item failed: %08x\n", i, r); + ok(!!item, "file_defs[%d]: item is null\n", i); + + bstr = NULL; + r = FolderItem_get_Path(item, &bstr); + ok(r == S_OK, "file_defs[%d]: FolderItem::get_Path failed: %08x\n", i, r); + PathCombineW(path, cur_dir, V_BSTR(&str_index)); + ok(!lstrcmpW(bstr, path), + "file_defs[%d]: expected %s, got %s\n", i, wine_dbgstr_w(path), wine_dbgstr_w(bstr)); + SysFreeString(bstr); + + FolderItem_Release(item); + + /* test that the folder item is no longer accessible by string index */ + item = (FolderItem*)0xdeadbeef; + r = FolderItems_Item(items, str_index, &item); + ok(r == S_FALSE, "file_defs[%d]: expected S_FALSE, got %08x\n", i, r); + ok(!item, "file_defs[%d]: item is not null\n", i); + + VariantClear(&str_index); + } + + /* test that there are only as many folder items as there were files */ + V_I4(&int_index) = sizeof(file_defs)/sizeof(file_defs[0]); + item = (FolderItem*)0xdeadbeef; + r = FolderItems_Item(items, int_index, &item); ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r); ok(!item, "item is not null\n"); @@ -435,11 +743,13 @@ todo_wine } r = FolderItems_get_Application(items, &disp); -todo_wine ok(r == S_OK, "FolderItems::get_Application failed: %08x\n", r); -todo_wine - ok(!!disp, "disp is null\n"); - if (disp) IDispatch_Release(disp); + + r = Folder_get_Application(folder, &disp2); + ok(r == S_OK, "Failed to get application pointer, hr %#x.\n", r); + ok(disp == disp2, "Unexpected application pointer.\n"); + IDispatch_Release(disp2); + IDispatch_Release(disp); if (0) /* crashes on xp */ { @@ -483,14 +793,37 @@ todo_wine ok(!verbs, "verbs is not null\n"); } - GetTempPathW(MAX_PATH, wstr); - SetCurrentDirectoryW(wstr); - RemoveDirectoryW(winetestW); + /* remove the temporary directory and restore the original working directory */ + GetTempPathW(MAX_PATH, path); + SetCurrentDirectoryW(path); + ret = RemoveDirectoryW(winetestW); + ok(ret, "RemoveDirectory failed: %08x\n", GetLastError()); SetCurrentDirectoryW(orig_dir); + /* test that everything stops working after the directory has been removed */ + count = -1; + r = FolderItems_get_Count(items, &count); + ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r); + ok(!count, "expected 0 files, got %d\n", count); + + item = NULL; + V_I4(&int_index) = 0; + item = (FolderItem*)0xdeadbeef; + r = FolderItems_Item(items, int_index, &item); + ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r); + ok(!item, "item is not null\n"); + + variant_set_string(&str_index, file_defs[0].name); + item = (FolderItem*)0xdeadbeef; + r = FolderItems_Item(items, str_index, &item); + ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r); + ok(!item, "item is not null\n"); + VariantClear(&str_index); + FolderItems_Release(items); - if (items2) FolderItems2_Release(items2); + Folder_Release(folder); if (items3) FolderItems3_Release(items3); + IShellDispatch_Release(sd); } static void test_service(void) @@ -739,7 +1072,7 @@ todo_wine { ok(hr == S_OK || broken(hr == S_FALSE), "got 0x%08x\n", hr); if (hr == S_FALSE) /* winxp and earlier */ { win_skip("SWC_DESKTOP is not supported, some tests will be skipped.\n"); - /* older versions allowed to regiser SWC_DESKTOP and access it with FindWindowSW */ + /* older versions allowed to register SWC_DESKTOP and access it with FindWindowSW */ ok(disp == NULL, "got %p\n", disp); ok(ret == 0, "got %d\n", ret); } @@ -763,6 +1096,9 @@ todo_wine { IUnknown *unk; ok(disp != NULL, "got %p\n", disp); + + if (disp == NULL) goto skip_disp_tests; + ok(ret != HandleToUlong(hwnd), "got %d\n", ret); /* IDispatch-related tests */ @@ -840,6 +1176,7 @@ if (hr == S_OK) { IServiceProvider_Release(sp); IDispatch_Release(disp); } +skip_disp_tests: disp = (void*)0xdeadbeef; ret = 0xdead; @@ -934,12 +1271,13 @@ static void test_ParseName(void) static void test_Verbs(void) { - FolderItemVerbs *verbs; + FolderItemVerbs *verbs, *verbs2; WCHAR pathW[MAX_PATH]; FolderItemVerb *verb; IShellDispatch *sd; FolderItem *item; Folder2 *folder2; + IDispatch *disp; Folder *folder; HRESULT hr; LONG count, i; @@ -972,6 +1310,21 @@ if (0) { /* crashes on some systems */ hr = FolderItem_Verbs(item, &verbs); ok(hr == S_OK, "got 0x%08x\n", hr); + hr = FolderItem_Verbs(item, &verbs2); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(verbs2 != verbs, "Unexpected verbs pointer.\n"); + FolderItemVerbs_Release(verbs2); + + disp = (void *)0xdeadbeef; + hr = FolderItemVerbs_get_Application(verbs, &disp); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + ok(disp == NULL, "Unexpected application pointer.\n"); + + disp = (void *)0xdeadbeef; + hr = FolderItemVerbs_get_Parent(verbs, &disp); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + ok(disp == NULL, "Unexpected parent pointer %p.\n", disp); + if (0) { /* crashes on winxp/win2k3 */ hr = FolderItemVerbs_get_Count(verbs, NULL); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); @@ -998,7 +1351,17 @@ if (0) { /* crashes on winxp/win2k3 */ ok(hr == S_OK, "got 0x%08x\n", hr); ok(str != NULL, "%d: name %s\n", i, wine_dbgstr_w(str)); if (i == count) - ok(str[0] == 0, "%d: got teminating item %s\n", i, wine_dbgstr_w(str)); + ok(str[0] == 0, "%d: got terminating item %s\n", i, wine_dbgstr_w(str)); + + disp = (void *)0xdeadbeef; + hr = FolderItemVerb_get_Parent(verb, &disp); + ok(hr == E_NOTIMPL, "got %#x.\n", hr); + ok(disp == NULL, "Unexpected parent pointer %p.\n", disp); + + disp = (void *)0xdeadbeef; + hr = FolderItemVerb_get_Application(verb, &disp); + ok(hr == E_NOTIMPL, "got %#x.\n", hr); + ok(disp == NULL, "Unexpected parent pointer %p.\n", disp); SysFreeString(str); FolderItemVerb_Release(verb); @@ -1054,6 +1417,7 @@ static void test_ShellExecute(void) ok(hr == S_OK, "ShellExecute failed: %08x\n", hr); SysFreeString(name); + IShellDispatch2_Release(sd); } START_TEST(shelldispatch) diff --git a/modules/rostests/winetests/shell32/shelllink.c b/modules/rostests/winetests/shell32/shelllink.c index 5e995db54e..444fdcc417 100755 --- a/modules/rostests/winetests/shell32/shelllink.c +++ b/modules/rostests/winetests/shell32/shelllink.c @@ -19,7 +19,24 @@ * */ -#include "precomp.h" +#define COBJMACROS + +#include "initguid.h" +#include "windows.h" +#include "shlguid.h" +#include "shobjidl.h" +#include "shlobj.h" +#include "shellapi.h" +#include "commoncontrols.h" + +#include "wine/heap.h" +#include "wine/test.h" + +#include "shell32_test.h" + +#ifdef __REACTOS__ +#include <reactos/undocshell.h> +#endif #ifndef SLDF_HAS_LOGO3ID # define SLDF_HAS_LOGO3ID 0x00000800 /* not available in the Vista SDK */ @@ -28,6 +45,7 @@ static void (WINAPI *pILFree)(LPITEMIDLIST); static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST); static HRESULT (WINAPI *pSHILCreateFromPath)(LPCWSTR, LPITEMIDLIST *,DWORD*); +static HRESULT (WINAPI *pSHGetFolderLocation)(HWND,INT,HANDLE,DWORD,PIDLIST_ABSOLUTE*); static HRESULT (WINAPI *pSHDefExtractIconA)(LPCSTR, int, UINT, HICON*, HICON*, UINT); static HRESULT (WINAPI *pSHGetStockIconInfo)(SHSTOCKICONID, UINT, SHSTOCKICONINFO *); static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR, LPSTR, DWORD); @@ -71,12 +89,12 @@ static LPITEMIDLIST path_to_pidl(const char* path) int len; len=MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0); - pathW=HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + pathW = heap_alloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, len); r=pSHILCreateFromPath(pathW, &pidl, NULL); ok(r == S_OK, "SHILCreateFromPath failed (0x%08x)\n", r); - HeapFree(GetProcessHeap(), 0, pathW); + heap_free(pathW); } return pidl; } @@ -93,6 +111,7 @@ static void test_get_set(void) IShellLinkW *slW = NULL; char mypath[MAX_PATH]; char buffer[INFOTIPSIZE]; + WIN32_FIND_DATAA finddata; LPITEMIDLIST pidl, tmp_pidl; const char * str; int i; @@ -145,11 +164,20 @@ static void test_get_set(void) /* Test Getting / Setting the path */ strcpy(buffer,"garbage"); r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH); - todo_wine ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r); + ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r); + ok(*buffer=='\0', "GetPath returned '%s'\n", buffer); + + strcpy(buffer,"garbage"); + memset(&finddata, 0xaa, sizeof(finddata)); + r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH); + ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r); ok(*buffer=='\0', "GetPath returned '%s'\n", buffer); + ok(finddata.dwFileAttributes == 0, "unexpected attributes %x\n", finddata.dwFileAttributes); + ok(finddata.cFileName[0] == 0, "unexpected filename '%s'\n", finddata.cFileName); - CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, - &IID_IShellLinkW, (LPVOID*)&slW); + r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, + &IID_IShellLinkW, (LPVOID*)&slW); + ok(r == S_OK, "CoCreateInstance failed (0x%08x)\n", r); if (!slW /* Win9x */ || !pGetLongPathNameA /* NT4 */) skip("SetPath with NULL parameter crashes on Win9x and some NT4\n"); else @@ -166,7 +194,7 @@ static void test_get_set(void) strcpy(buffer,"garbage"); r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH); - todo_wine ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r); + ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r); ok(*buffer=='\0', "GetPath returned '%s'\n", buffer); /* Win98 returns S_FALSE, but WinXP returns S_OK */ @@ -179,6 +207,14 @@ static void test_get_set(void) ok(r == S_OK, "GetPath failed (0x%08x)\n", r); ok(lstrcmpiA(buffer,str)==0, "GetPath returned '%s'\n", buffer); + strcpy(buffer,"garbage"); + memset(&finddata, 0xaa, sizeof(finddata)); + r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH); + ok(r == S_OK, "GetPath failed (0x%08x)\n", r); + ok(lstrcmpiA(buffer,str)==0, "GetPath returned '%s'\n", buffer); + ok(finddata.dwFileAttributes == 0, "unexpected attributes %x\n", finddata.dwFileAttributes); + ok(lstrcmpiA(finddata.cFileName, "file") == 0, "unexpected filename '%s'\n", finddata.cFileName); + /* Get some real path to play with */ GetWindowsDirectoryA( mypath, sizeof(mypath)-12 ); strcat(mypath, "\\regedit.exe"); @@ -228,8 +264,41 @@ static void test_get_set(void) strcpy(buffer,"garbage"); r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH); ok(r == S_OK, "GetPath failed (0x%08x)\n", r); - todo_wine ok(lstrcmpiA(buffer, mypath)==0, "GetPath returned '%s'\n", buffer); + + strcpy(buffer,"garbage"); + memset(&finddata, 0xaa, sizeof(finddata)); + r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH); + ok(r == S_OK, "GetPath failed (0x%08x)\n", r); + ok(lstrcmpiA(buffer, mypath)==0, "GetPath returned '%s'\n", buffer); + ok(finddata.dwFileAttributes != 0, "unexpected attributes %x\n", finddata.dwFileAttributes); + ok(lstrcmpiA(finddata.cFileName, "regedit.exe") == 0, "unexpected filename '%s'\n", finddata.cFileName); + } + + if (pSHGetFolderLocation) + { + LPITEMIDLIST pidl_controls; + + r = pSHGetFolderLocation(NULL, CSIDL_CONTROLS, NULL, 0, &pidl_controls); + ok(r == S_OK, "SHGetFolderLocation failed (0x%08x)\n", r); + + r = IShellLinkA_SetIDList(sl, pidl_controls); + ok(r == S_OK, "SetIDList failed (0x%08x)\n", r); + + strcpy(buffer,"garbage"); + r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH); + ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r); + ok(buffer[0] == 0, "GetPath returned '%s'\n", buffer); + + strcpy(buffer,"garbage"); + memset(&finddata, 0xaa, sizeof(finddata)); + r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH); + ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r); + ok(buffer[0] == 0, "GetPath returned '%s'\n", buffer); + ok(finddata.dwFileAttributes == 0, "unexpected attributes %x\n", finddata.dwFileAttributes); + ok(finddata.cFileName[0] == 0, "unexpected filename '%s'\n", finddata.cFileName); + + pILFree(pidl_controls); } /* test path with quotes (IShellLinkA_SetPath returns S_FALSE on W2K and below and S_OK on XP and above */ @@ -1396,6 +1465,7 @@ START_TEST(shelllink) pILFree = (void *)GetProcAddress(hmod, (LPSTR)155); pILIsEqual = (void *)GetProcAddress(hmod, (LPSTR)21); pSHILCreateFromPath = (void *)GetProcAddress(hmod, (LPSTR)28); + pSHGetFolderLocation = (void *)GetProcAddress(hmod, "SHGetFolderLocation"); pSHDefExtractIconA = (void *)GetProcAddress(hmod, "SHDefExtractIconA"); pSHGetStockIconInfo = (void *)GetProcAddress(hmod, "SHGetStockIconInfo"); pGetLongPathNameA = (void *)GetProcAddress(hkernel32, "GetLongPathNameA"); diff --git a/modules/rostests/winetests/shell32/shellole.c b/modules/rostests/winetests/shell32/shellole.c index f2485928e4..e79d666699 100644 --- a/modules/rostests/winetests/shell32/shellole.c +++ b/modules/rostests/winetests/shell32/shellole.c @@ -16,9 +16,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" - -#include <initguid.h> +#define COBJMACROS +#define CONST_VTABLE +#ifndef __REACTOS__ +#define NONAMELESSUNION +#endif + +#include <stdio.h> +#include <wine/test.h> + +#include "winbase.h" +#include "shlobj.h" +#include "shellapi.h" +#include "initguid.h" DEFINE_GUID(FMTID_Test,0x12345678,0x1234,0x1234,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12); DEFINE_GUID(FMTID_NotExisting, 0x12345678,0x1234,0x1234,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x13); diff --git a/modules/rostests/winetests/shell32/shellpath.c b/modules/rostests/winetests/shell32/shellpath.c index 02eecb972a..f6674313f8 100644 --- a/modules/rostests/winetests/shell32/shellpath.c +++ b/modules/rostests/winetests/shell32/shellpath.c @@ -21,9 +21,20 @@ * namespace) path for a given folder (CSIDL value). */ -#include "precomp.h" +#define COBJMACROS -#include <initguid.h> +#include <stdarg.h> +#include <stdio.h> +#include "windef.h" +#include "winbase.h" +#include "shlguid.h" +#include "shlobj.h" +#include "shlwapi.h" +#include "knownfolders.h" +#include "shellapi.h" +#include "wine/test.h" + +#include "initguid.h" /* CSIDL_MYDOCUMENTS is now the same as CSIDL_PERSONAL, but what we want * here is its original value. @@ -1887,7 +1898,7 @@ static const struct knownFolderDef known_folders[] = { { 0 } }; #undef KNOWN_FOLDER -BOOL known_folder_found[sizeof(known_folders)/sizeof(known_folders[0])-1]; +BOOL known_folder_found[ARRAY_SIZE(known_folders)-1]; static BOOL is_in_strarray(const WCHAR *needle, const char *hay) { @@ -1903,7 +1914,7 @@ static BOOL is_in_strarray(const WCHAR *needle, const char *hay) if(strcmp(hay, "(null)") == 0 && !needle) return TRUE; - ret = MultiByteToWideChar(CP_ACP, 0, hay, -1, wstr, sizeof(wstr)/sizeof(wstr[0])); + ret = MultiByteToWideChar(CP_ACP, 0, hay, -1, wstr, ARRAY_SIZE(wstr)); if(ret == 0) { ok(0, "Failed to convert string\n"); @@ -1956,7 +1967,7 @@ static void check_known_folder(IKnownFolderManager *mgr, KNOWNFOLDERID *folderId ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot get known folder definition for %s\n", known_folder->sFolderId); if(SUCCEEDED(hr)) { - ret = MultiByteToWideChar(CP_ACP, 0, known_folder->sName, -1, sName, sizeof(sName)/sizeof(sName[0])); + ret = MultiByteToWideChar(CP_ACP, 0, known_folder->sName, -1, sName, ARRAY_SIZE(sName)); ok_(__FILE__, known_folder->line)(ret != 0, "cannot convert known folder name \"%s\" to wide characters\n", known_folder->sName); ok_(__FILE__, known_folder->line)(lstrcmpW(kfd.pszName, sName)==0, "invalid known folder name returned for %s: %s expected, but %s retrieved\n", known_folder->sFolderId, wine_dbgstr_w(sName), wine_dbgstr_w(kfd.pszName)); @@ -2052,10 +2063,10 @@ static void test_knownFolders(void) GetWindowsDirectoryW( sWinDir, MAX_PATH ); - GetTempPathW(sizeof(sExamplePath)/sizeof(sExamplePath[0]), sExamplePath); + GetTempPathW(ARRAY_SIZE(sExamplePath), sExamplePath); lstrcatW(sExamplePath, sExample); - GetTempPathW(sizeof(sExample2Path)/sizeof(sExample2Path[0]), sExample2Path); + GetTempPathW(ARRAY_SIZE(sExample2Path), sExample2Path); lstrcatW(sExample2Path, sExample2); lstrcpyW(sSubFolderPath, sExamplePath); @@ -2110,7 +2121,6 @@ static void test_knownFolders(void) CoTaskMemFree(folderPath); hr = IKnownFolder_GetRedirectionCapabilities(folder, &redirectionCapabilities); - todo_wine ok(hr == S_OK, "failed to get redirection capabilities: 0x%08x\n", hr); todo_wine ok(redirectionCapabilities==0, "invalid redirection capabilities returned: %d\n", redirectionCapabilities); @@ -2162,7 +2172,7 @@ static void test_knownFolders(void) ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr); ok(folder == NULL, "got %p\n", folder); - for(i=0; i<sizeof(known_folder_found)/sizeof(known_folder_found[0]); ++i) + for(i=0; i < ARRAY_SIZE(known_folder_found); ++i) known_folder_found[i] = FALSE; hr = IKnownFolderManager_GetFolderIds(mgr, &folders, &nCount); @@ -2170,7 +2180,7 @@ static void test_knownFolders(void) for(i=0;i<nCount;++i) check_known_folder(mgr, &folders[i]); - for(i=0; i<sizeof(known_folder_found)/sizeof(known_folder_found[0]); ++i) + for(i=0; i < ARRAY_SIZE(known_folder_found); ++i) if(!known_folder_found[i]) trace("Known folder %s not found on current platform\n", known_folders[i].sFolderId); @@ -2544,7 +2554,7 @@ static void test_DoEnvironmentSubst(void) memset(bufferA, '#', MAX_PATH - 1); bufferA[MAX_PATH - 1] = 0; lstrcpyA(bufferA, names[i]); - MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, sizeof(bufferW)/sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW)); res2 = ExpandEnvironmentStringsA(names[i], expectedA, MAX_PATH); res = DoEnvironmentSubstA(bufferA, MAX_PATH); @@ -2575,7 +2585,7 @@ static void test_DoEnvironmentSubst(void) memset(bufferA, '#', MAX_PATH - 1); bufferA[len + 2] = 0; lstrcpyA(bufferA, names[i]); - MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, sizeof(bufferW)/sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW)); res2 = ExpandEnvironmentStringsA(bufferA, expectedA, MAX_PATH); res = DoEnvironmentSubstA(bufferA, len + 1); @@ -2596,7 +2606,7 @@ static void test_DoEnvironmentSubst(void) memset(bufferA, '#', MAX_PATH - 1); bufferA[len + 2] = 0; lstrcpyA(bufferA, names[i]); - MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, sizeof(bufferW)/sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW)); /* ANSI version failed without an extra byte, as documented on msdn */ res = DoEnvironmentSubstA(bufferA, len); @@ -2619,7 +2629,7 @@ static void test_DoEnvironmentSubst(void) memset(bufferA, '#', MAX_PATH - 1); bufferA[len + 2] = 0; lstrcpyA(bufferA, names[i]); - MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, sizeof(bufferW)/sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW)); res = DoEnvironmentSubstA(bufferA, len - 1); ok(!HIWORD(res) && (LOWORD(res) == (len - 1)), @@ -2640,7 +2650,7 @@ static void test_DoEnvironmentSubst(void) memset(bufferA, '#', MAX_PATH - 1); bufferA[MAX_PATH - 1] = 0; lstrcpyA(bufferA, does_not_existA); - MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, sizeof(bufferW)/sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW)); res2 = lstrlenA(does_not_existA) + 1; res = DoEnvironmentSubstA(bufferA, MAX_PATH); @@ -2691,7 +2701,7 @@ if (0) ok(!ret, "got %d\n", ret); } - GetTempPathW(sizeof(pathW)/sizeof(WCHAR), pathW); + GetTempPathW(ARRAY_SIZE(pathW), pathW); /* Using short name only first */ nameW[0] = 0; diff --git a/modules/rostests/winetests/shell32/shfldr_special.c b/modules/rostests/winetests/shell32/shfldr_special.c index 08efed9720..09d82f088b 100644 --- a/modules/rostests/winetests/shell32/shfldr_special.c +++ b/modules/rostests/winetests/shell32/shfldr_special.c @@ -19,7 +19,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdarg.h> +#include <stdio.h> + +#define COBJMACROS +#ifndef __REACTOS__ +#define NONAMELESSUNION +#define NONAMELESSSTRUCT +#endif + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include "shellapi.h" +#include "shlobj.h" + +#include "wine/test.h" static inline BOOL SHELL_OsIsUnicode(void) { diff --git a/modules/rostests/winetests/shell32/shlexec.c b/modules/rostests/winetests/shell32/shlexec.c index 34f76e3e3b..a8aabac734 100755 --- a/modules/rostests/winetests/shell32/shlexec.c +++ b/modules/rostests/winetests/shell32/shlexec.c @@ -30,7 +30,28 @@ * we could check */ -#include "precomp.h" +/* Needed to get SEE_MASK_NOZONECHECKS with the PSDK */ +#ifndef __REACTOS__ +#define NTDDI_WINXPSP1 0x05010100 +#define NTDDI_VERSION NTDDI_WINXPSP1 +#define _WIN32_WINNT 0x0501 +#endif + +#include <stdio.h> +#include <assert.h> + +#include "wtypes.h" +#include "winbase.h" +#include "windef.h" +#include "shellapi.h" +#include "shlwapi.h" +#include "ddeml.h" + +#include "wine/heap.h" +#include "wine/test.h" + +#include "shell32_test.h" + static char argv0[MAX_PATH]; static int myARGC; @@ -742,7 +763,7 @@ static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey) if (dwMaxLen > sizeof(szNameBuf)/sizeof(CHAR)) { /* Name too big: alloc a buffer for it */ - if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(CHAR)))) + if (!(lpszName = heap_alloc(dwMaxLen*sizeof(CHAR)))) { ret = ERROR_NOT_ENOUGH_MEMORY; goto cleanup; @@ -777,7 +798,7 @@ static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey) cleanup: /* Free buffer if allocated */ if (lpszName != szNameBuf) - HeapFree( GetProcessHeap(), 0, lpszName); + heap_free(lpszName); if(lpszSubKey) RegCloseKey(hSubKey); return ret; @@ -837,11 +858,11 @@ static void create_test_verb_dde(const char* classname, const char* verb, } else { - cmd=HeapAlloc(GetProcessHeap(), 0, strlen(argv0)+10+strlen(child_file)+2+strlen(cmdtail)+1); + cmd = heap_alloc(strlen(argv0) + 10 + strlen(child_file) + 2 + strlen(cmdtail) + 1); sprintf(cmd,"%s shlexec \"%s\" %s", argv0, child_file, cmdtail); rc=RegSetValueExA(hkey_cmd, NULL, 0, REG_SZ, (LPBYTE)cmd, strlen(cmd)+1); ok(rc == ERROR_SUCCESS, "setting command failed with %d\n", rc); - HeapFree(GetProcessHeap(), 0, cmd); + heap_free(cmd); } if (ddeexec) diff --git a/modules/rostests/winetests/shell32/shlfileop.c b/modules/rostests/winetests/shell32/shlfileop.c index 4e898586e3..72ca1e7e36 100644 --- a/modules/rostests/winetests/shell32/shlfileop.c +++ b/modules/rostests/winetests/shell32/shlfileop.c @@ -18,7 +18,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdarg.h> +#include <stdio.h> + +#define COBJMACROS +#define WINE_NOWINSOCK +#include <windows.h> +#include "shellapi.h" +#include "shlobj.h" +#include "commoncontrols.h" + +#include "wine/test.h" + +#ifdef __REACTOS__ +#include <reactos/undocshell.h> +#endif #ifndef FOF_NORECURSION #define FOF_NORECURSION 0x1000 diff --git a/modules/rostests/winetests/shell32/shlfolder.c b/modules/rostests/winetests/shell32/shlfolder.c index 8d2481ffc4..2ee91ef7d6 100644 --- a/modules/rostests/winetests/shell32/shlfolder.c +++ b/modules/rostests/winetests/shell32/shlfolder.c @@ -18,7 +18,27 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdarg.h> +#include <stdio.h> + +#define COBJMACROS +#define CONST_VTABLE + +#include "windef.h" +#include "winbase.h" +#include "wtypes.h" +#include "shellapi.h" + + +#include "shlguid.h" +#include "shlobj.h" +#include "shobjidl.h" +#include "shlwapi.h" +#include "ocidl.h" +#include "oleauto.h" + +#include "wine/heap.h" +#include "wine/test.h" #include <initguid.h> DEFINE_GUID(IID_IParentAndItem, 0xB3A4B685, 0xB685, 0x4805, 0x99,0xD9, 0x5D,0xEA,0xD2,0x87,0x32,0x36); @@ -26,17 +46,6 @@ DEFINE_GUID(CLSID_ShellDocObjView, 0xe7e4bc40, 0xe76a, 0x11ce, 0xa9,0xbb, 0x00,0 static IMalloc *ppM; -static HRESULT (WINAPI *pSHBindToParent)(LPCITEMIDLIST, REFIID, LPVOID*, LPCITEMIDLIST*); -static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR); -static HRESULT (WINAPI *pSHGetFolderPathAndSubDirA)(HWND, int, HANDLE, DWORD, LPCSTR, LPSTR); -static BOOL (WINAPI *pSHGetPathFromIDListW)(LPCITEMIDLIST,LPWSTR); -static HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *); -static BOOL (WINAPI *pSHGetSpecialFolderPathA)(HWND, LPSTR, int, BOOL); -static BOOL (WINAPI *pSHGetSpecialFolderPathW)(HWND, LPWSTR, int, BOOL); -static HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT); -static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST); -static void (WINAPI *pILFree)(LPITEMIDLIST); -static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST); static HRESULT (WINAPI *pSHCreateItemFromIDList)(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv); static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR,IBindCtx*,REFIID,void**); static HRESULT (WINAPI *pSHCreateItemFromRelativeName)(IShellItem*,PCWSTR,IBindCtx*,REFIID,void**); @@ -46,18 +55,13 @@ static HRESULT (WINAPI *pSHCreateShellItemArray)(LPCITEMIDLIST,IShellFolder*,UIN static HRESULT (WINAPI *pSHCreateShellItemArrayFromIDLists)(UINT, PCIDLIST_ABSOLUTE*, IShellItemArray**); static HRESULT (WINAPI *pSHCreateShellItemArrayFromDataObject)(IDataObject*, REFIID, void **); static HRESULT (WINAPI *pSHCreateShellItemArrayFromShellItem)(IShellItem*, REFIID, void **); -static LPITEMIDLIST (WINAPI *pILCombine)(LPCITEMIDLIST,LPCITEMIDLIST); -static HRESULT (WINAPI *pSHParseDisplayName)(LPCWSTR,IBindCtx*,LPITEMIDLIST*,SFGAOF,SFGAOF*); -static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathAW)(LPCVOID); static HRESULT (WINAPI *pSHGetKnownFolderPath)(REFKNOWNFOLDERID,DWORD,HANDLE,PWSTR*); static HRESULT (WINAPI *pSHGetNameFromIDList)(PCIDLIST_ABSOLUTE,SIGDN,PWSTR*); static HRESULT (WINAPI *pSHGetItemFromDataObject)(IDataObject*,DATAOBJ_GET_ITEM_FLAGS,REFIID,void**); static HRESULT (WINAPI *pSHGetIDListFromObject)(IUnknown*, PIDLIST_ABSOLUTE*); static HRESULT (WINAPI *pSHGetItemFromObject)(IUnknown*,REFIID,void**); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); -static UINT (WINAPI *pGetSystemWow64DirectoryW)(LPWSTR, UINT); static HRESULT (WINAPI *pSHCreateDefaultContextMenu)(const DEFCONTEXTMENU*,REFIID,void**); -static HRESULT (WINAPI *pSHILCreateFromPath)(LPCWSTR, LPITEMIDLIST *,DWORD*); static BOOL (WINAPI *pSHGetPathFromIDListEx)(PCIDLIST_ABSOLUTE,WCHAR*,DWORD,GPFIDL_FLAGS); static WCHAR *make_wstr(const char *str) @@ -72,7 +76,7 @@ static WCHAR *make_wstr(const char *str) if(!len || len < 0) return NULL; - ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + ret = heap_alloc(len * sizeof(WCHAR)); if(!ret) return NULL; @@ -96,7 +100,6 @@ static void init_function_pointers(void) hmod = GetModuleHandleA("shell32.dll"); #define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f)) - MAKEFUNC(SHBindToParent); MAKEFUNC(SHCreateItemFromIDList); MAKEFUNC(SHCreateItemFromParsingName); MAKEFUNC(SHCreateItemFromRelativeName); @@ -106,13 +109,6 @@ static void init_function_pointers(void) MAKEFUNC(SHCreateShellItemArrayFromIDLists); MAKEFUNC(SHCreateShellItemArrayFromDataObject); MAKEFUNC(SHCreateShellItemArrayFromShellItem); - MAKEFUNC(SHGetFolderPathA); - MAKEFUNC(SHGetFolderPathAndSubDirA); - MAKEFUNC(SHGetPathFromIDListW); - MAKEFUNC(SHGetSpecialFolderPathA); - MAKEFUNC(SHGetSpecialFolderPathW); - MAKEFUNC(SHGetSpecialFolderLocation); - MAKEFUNC(SHParseDisplayName); MAKEFUNC(SHGetKnownFolderPath); MAKEFUNC(SHGetNameFromIDList); MAKEFUNC(SHGetItemFromDataObject); @@ -122,15 +118,6 @@ static void init_function_pointers(void) MAKEFUNC(SHGetPathFromIDListEx); #undef MAKEFUNC -#define MAKEFUNC_ORD(f, ord) (p##f = (void*)GetProcAddress(hmod, (LPSTR)(ord))) - MAKEFUNC_ORD(ILFindLastID, 16); - MAKEFUNC_ORD(ILIsEqual, 21); - MAKEFUNC_ORD(ILCombine, 25); - MAKEFUNC_ORD(SHILCreateFromPath, 28); - MAKEFUNC_ORD(ILFree, 155); - MAKEFUNC_ORD(SHSimpleIDListFromPathAW, 162); -#undef MAKEFUNC_ORD - /* test named exports */ ptr = GetProcAddress(hmod, "ILFree"); ok(broken(ptr == 0) || ptr != 0, "expected named export for ILFree\n"); @@ -158,12 +145,8 @@ static void init_function_pointers(void) #undef TESTNAMED } - hmod = GetModuleHandleA("shlwapi.dll"); - pStrRetToBufW = (void*)GetProcAddress(hmod, "StrRetToBufW"); - hmod = GetModuleHandleA("kernel32.dll"); pIsWow64Process = (void*)GetProcAddress(hmod, "IsWow64Process"); - pGetSystemWow64DirectoryW = (void*)GetProcAddress(hmod, "GetSystemWow64DirectoryW"); hr = SHGetMalloc(&ppM); ok(hr == S_OK, "SHGetMalloc failed %08x\n", hr); @@ -206,12 +189,11 @@ static void test_ParseDisplayName(void) ok(hr == S_OK, "Expected SHGetDesktopFolder to return S_OK, got 0x%08x\n", hr); if(hr != S_OK) return; - /* Tests crash on W2K and below (SHCreateShellItem available as of XP) */ if (pSHCreateShellItem) { if (0) { - /* null name and pidl, also crashes on Windows 8 */ + /* null name and pidl, crashes on Windows 8 */ hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, NULL, NULL, NULL, 0); ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr); @@ -225,29 +207,26 @@ static void test_ParseDisplayName(void) ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr); } else - win_skip("Tests would crash on W2K and below\n"); + win_skip("SHCreateShellItem requires XP SP1 or later\n"); MultiByteToWideChar(CP_ACP, 0, cInetTestA, -1, cTestDirW, MAX_PATH); - hr = IShellFolder_ParseDisplayName(IDesktopFolder, - NULL, NULL, cTestDirW, NULL, &newPIDL, 0); - todo_wine ok(hr == S_OK || broken(hr == E_FAIL) /* NT4 */, - "ParseDisplayName returned %08x, expected SUCCESS or E_FAIL\n", hr); + hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0); + todo_wine ok(hr == S_OK, "ParseDisplayName returned %08x, expected SUCCESS\n", hr); if (hr == S_OK) { - ok(pILFindLastID(newPIDL)->mkid.abID[0] == 0x61, "Last pidl should be of type " - "PT_IESPECIAL1, but is: %02x\n", pILFindLastID(newPIDL)->mkid.abID[0]); + ok(ILFindLastID(newPIDL)->mkid.abID[0] == 0x61, "Last pidl should be of type " + "PT_IESPECIAL1, but is: %02x\n", ILFindLastID(newPIDL)->mkid.abID[0]); IMalloc_Free(ppM, newPIDL); } MultiByteToWideChar(CP_ACP, 0, cInetTest2A, -1, cTestDirW, MAX_PATH); hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0); - todo_wine ok(hr == S_OK || broken(hr == E_FAIL) /* NT4 */, - "ParseDisplayName returned %08x, expected SUCCESS or E_FAIL\n", hr); + todo_wine ok(hr == S_OK, "ParseDisplayName returned %08x, expected SUCCESS\n", hr); if (hr == S_OK) { - ok(pILFindLastID(newPIDL)->mkid.abID[0] == 0x61, "Last pidl should be of type " - "PT_IESPECIAL1, but is: %02x\n", pILFindLastID(newPIDL)->mkid.abID[0]); + ok(ILFindLastID(newPIDL)->mkid.abID[0] == 0x61, "Last pidl should be of type " + "PT_IESPECIAL1, but is: %02x\n", ILFindLastID(newPIDL)->mkid.abID[0]); IMalloc_Free(ppM, newPIDL); } @@ -259,10 +238,10 @@ static void test_ParseDisplayName(void) } MultiByteToWideChar(CP_ACP, 0, cNonExistDir1A, -1, cTestDirW, MAX_PATH); - hr = IShellFolder_ParseDisplayName(IDesktopFolder, + hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0); - ok((hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) || (hr == E_FAIL), - "ParseDisplayName returned %08x, expected 80070002 or E_FAIL\n", hr); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), + "ParseDisplayName returned %08x, expected 0x80070002\n", hr); res = GetFileAttributesA(cNonExistDir2A); if(res != INVALID_FILE_ATTRIBUTES) @@ -272,21 +251,15 @@ static void test_ParseDisplayName(void) } MultiByteToWideChar(CP_ACP, 0, cNonExistDir2A, -1, cTestDirW, MAX_PATH); - hr = IShellFolder_ParseDisplayName(IDesktopFolder, + hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0); - ok((hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) || (hr == E_FAIL) || (hr == E_INVALIDARG), - "ParseDisplayName returned %08x, expected 80070002, E_FAIL or E_INVALIDARG\n", hr); + todo_wine ok(hr == E_INVALIDARG, "ParseDisplayName returned %08x, expected E_INVALIDARG\n", hr); /* I thought that perhaps the DesktopFolder's ParseDisplayName would recognize the * path corresponding to CSIDL_PERSONAL and return a CLSID_MyDocuments PIDL. Turns * out it doesn't. The magic seems to happen in the file dialogs, then. */ - if (!pSHGetSpecialFolderPathW || !pILFindLastID) - { - win_skip("SHGetSpecialFolderPathW and/or ILFindLastID are not available\n"); - goto finished; - } - bRes = pSHGetSpecialFolderPathW(NULL, cTestDirW, CSIDL_PERSONAL, FALSE); + bRes = SHGetSpecialFolderPathW(NULL, cTestDirW, CSIDL_PERSONAL, FALSE); ok(bRes, "SHGetSpecialFolderPath(CSIDL_PERSONAL) failed! %u\n", GetLastError()); if (!bRes) goto finished; @@ -294,12 +267,11 @@ static void test_ParseDisplayName(void) ok(hr == S_OK, "DesktopFolder->ParseDisplayName failed. hr = %08x.\n", hr); if (hr != S_OK) goto finished; - ok(pILFindLastID(newPIDL)->mkid.abID[0] == 0x31 || - pILFindLastID(newPIDL)->mkid.abID[0] == 0xb1, /* Win98 */ - "Last pidl should be of type PT_FOLDER or PT_IESPECIAL2, but is: %02x\n", - pILFindLastID(newPIDL)->mkid.abID[0]); + ok(ILFindLastID(newPIDL)->mkid.abID[0] == 0x31, + "Last pidl should be of type PT_FOLDER, but is: %02x\n", + ILFindLastID(newPIDL)->mkid.abID[0]); IMalloc_Free(ppM, newPIDL); - + finished: IShellFolder_Release(IDesktopFolder); } @@ -422,7 +394,6 @@ static void test_EnumObjects(IShellFolder *iFolder) flags &= SFGAO_testfor; ok(hr == S_OK, "GetAttributesOf returns %08x\n", hr); ok(flags == (attrs[i]) || - flags == (attrs[i] & ~SFGAO_FILESYSANCESTOR) || /* Win9x, NT4 */ flags == ((attrs[i] & ~SFGAO_CAPABILITYMASK) | SFGAO_VISTA), /* Vista and higher */ "GetAttributesOf[%i] got %08x, expected %08x\n", i, flags, attrs[i]); @@ -430,9 +401,7 @@ static void test_EnumObjects(IShellFolder *iFolder) hr = IShellFolder_GetAttributesOf(iFolder, 1, (LPCITEMIDLIST*)(idlArr + i), &flags); flags &= SFGAO_testfor; ok(hr == S_OK, "GetAttributesOf returns %08x\n", hr); - ok(flags == attrs[i] || - flags == (attrs[i] & ~SFGAO_FILESYSANCESTOR), /* Win9x, NT4 */ - "GetAttributesOf[%i] got %08x, expected %08x\n", i, flags, attrs[i]); + ok(flags == attrs[i], "GetAttributesOf[%i] got %08x, expected %08x\n", i, flags, attrs[i]); flags = ~0u; hr = IShellFolder_GetAttributesOf(iFolder, 1, (LPCITEMIDLIST*)(idlArr + i), &flags); @@ -493,12 +462,8 @@ static void test_BindToObject(void) hr = IShellFolder_BindToObject(psfMyComputer, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild); ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr); -if (0) -{ - /* this call segfaults on 98SE */ hr = IShellFolder_BindToObject(psfMyComputer, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild); ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr); -} cChars = GetSystemDirectoryA(szSystemDir, MAX_PATH); ok (cChars > 0 && cChars < MAX_PATH, "GetSystemDirectoryA failed! LastError: %u\n", GetLastError()); @@ -525,13 +490,9 @@ if (0) ok (hr == E_INVALIDARG, "FileSystem ShellFolder's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr); -if (0) -{ - /* this call segfaults on 98SE */ hr = IShellFolder_BindToObject(psfSystemDir, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild); ok (hr == E_INVALIDARG, "FileSystem ShellFolder's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr); -} IShellFolder_Release(psfSystemDir); @@ -567,23 +528,19 @@ if (0) { IPersist *pp; hr = IShellFolder_QueryInterface(psfChild, &IID_IPersist, (void**)&pp); - ok(hr == S_OK || - broken(hr == E_NOINTERFACE), /* Win9x, NT4, W2K */ - "Got 0x%08x\n", hr); + ok(hr == S_OK, "Got 0x%08x\n", hr); if(SUCCEEDED(hr)) { CLSID id; hr = IPersist_GetClassID(pp, &id); ok(hr == S_OK, "Got 0x%08x\n", hr); - /* CLSID_ShellFSFolder on some w2k systems */ - ok(IsEqualIID(&id, &CLSID_ShellDocObjView) || broken(IsEqualIID(&id, &CLSID_ShellFSFolder)), - "Unexpected classid %s\n", wine_dbgstr_guid(&id)); + ok(IsEqualIID(&id, &CLSID_ShellDocObjView), "Unexpected classid %s\n", wine_dbgstr_guid(&id)); IPersist_Release(pp); } IShellFolder_Release(psfChild); } - pILFree(pidl); + ILFree(pidl); } DeleteFileA(pathA); } @@ -604,12 +561,10 @@ if (0) { hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild); ok(hr == E_FAIL || /* Vista+ */ - hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || /* XP, W2K3 */ - hr == E_INVALIDARG || /* W2K item in top dir */ - broken(hr == S_OK), /* Win9x, NT4, W2K */ + hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */ "Got 0x%08x\n", hr); if(SUCCEEDED(hr)) IShellFolder_Release(psfChild); - pILFree(pidl); + ILFree(pidl); } DeleteFileA(pathA); } @@ -630,12 +585,10 @@ if (0) { hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild); ok(hr == E_FAIL || /* Vista+ */ - hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || /* XP, W2K3 */ - hr == E_INVALIDARG || /* W2K item in top dir */ - broken(hr == S_OK), /* Win9x, NT4, W2K */ + hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */ "Got 0x%08x\n", hr); if(SUCCEEDED(hr)) IShellFolder_Release(psfChild); - pILFree(pidl); + ILFree(pidl); } DeleteFileA(pathA); } @@ -643,59 +596,42 @@ if (0) win_skip("Failed to create .foo testfile.\n"); /* And on the desktop */ - if(pSHGetSpecialFolderPathA) - { - pSHGetSpecialFolderPathA(NULL, pathA, CSIDL_DESKTOP, FALSE); - lstrcatA(pathA, "\\"); - lstrcatA(pathA, filename_html); - hfile = CreateFileA(pathA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - if(hfile != INVALID_HANDLE_VALUE) - { - CloseHandle(hfile); - MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH); - hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL); - ok(hr == S_OK, "Got 0x%08x\n", hr); - if(SUCCEEDED(hr)) - { - hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild); - ok(hr == S_OK || - hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */ - "Got 0x%08x\n", hr); - if(SUCCEEDED(hr)) IShellFolder_Release(psfChild); - pILFree(pidl); - } - if(!DeleteFileA(pathA)) - trace("Failed to delete: %d\n", GetLastError()); + SHGetSpecialFolderPathA(NULL, pathA, CSIDL_DESKTOP, FALSE); + lstrcatA(pathA, "\\"); + lstrcatA(pathA, filename_html); + hfile = CreateFileA(pathA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - } - else - win_skip("Failed to create .html testfile.\n"); + CloseHandle(hfile); + MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH); + hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL); + ok(hr == S_OK, "Got 0x%08x\n", hr); - pSHGetSpecialFolderPathA(NULL, pathA, CSIDL_DESKTOP, FALSE); - lstrcatA(pathA, "\\"); - lstrcatA(pathA, filename_foo); - hfile = CreateFileA(pathA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); - if(hfile != INVALID_HANDLE_VALUE) - { - CloseHandle(hfile); - MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH); - hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL); - ok(hr == S_OK, "Got 0x%08x\n", hr); - if(SUCCEEDED(hr)) - { - hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild); - ok(hr == E_FAIL || /* Vista+ */ - hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || /* XP, W2K3 */ - broken(hr == S_OK), /* Win9x, NT4, W2K */ - "Got 0x%08x\n", hr); - if(SUCCEEDED(hr)) IShellFolder_Release(psfChild); - pILFree(pidl); - } - DeleteFileA(pathA); - } - else - win_skip("Failed to create .foo testfile.\n"); - } + hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void **)&psfChild); + ok(hr == S_OK || + hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */ + "Got 0x%08x\n", hr); + if(SUCCEEDED(hr)) IShellFolder_Release(psfChild); + ILFree(pidl); + if(!DeleteFileA(pathA)) + trace("Failed to delete: %d\n", GetLastError()); + + SHGetSpecialFolderPathA(NULL, pathA, CSIDL_DESKTOP, FALSE); + lstrcatA(pathA, "\\"); + lstrcatA(pathA, filename_foo); + hfile = CreateFileA(pathA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + + CloseHandle(hfile); + MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH); + hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL); + ok(hr == S_OK, "Got 0x%08x\n", hr); + + hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void **)&psfChild); + ok(hr == E_FAIL || /* Vista+ */ + hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */ + "Got 0x%08x\n", hr); + if(SUCCEEDED(hr)) IShellFolder_Release(psfChild); + ILFree(pidl); + DeleteFileA(pathA); IShellFolder_Release(psfDesktop); } @@ -718,6 +654,10 @@ static void test_GetDisplayName(void) static const WCHAR wszFileName[] = { 'w','i','n','e','t','e','s','t','.','f','o','o',0 }; static const WCHAR wszDirName[] = { 'w','i','n','e','t','e','s','t',0 }; + /* It's ok to use this fixed path. Call will fail anyway. */ + WCHAR wszAbsoluteFilename[] = { 'C',':','\\','w','i','n','e','t','e','s','t', 0 }; + LPITEMIDLIST pidlNew; + /* I'm trying to figure if there is a functional difference between calling * SHGetPathFromIDListW and calling GetDisplayNameOf(SHGDN_FORPARSING) after * binding to the shellfolder. One thing I thought of was that perhaps @@ -726,13 +666,8 @@ static void test_GetDisplayName(void) * no functional difference in this respect. */ - if(!pSHGetSpecialFolderPathA) { - win_skip("SHGetSpecialFolderPathA is not available\n"); - return; - } - /* First creating a directory in MyDocuments and a file in this directory. */ - result = pSHGetSpecialFolderPathA(NULL, szTestDir, CSIDL_PERSONAL, FALSE); + result = SHGetSpecialFolderPathA(NULL, szTestDir, CSIDL_PERSONAL, FALSE); ok(result, "SHGetSpecialFolderPathA failed! Last error: %u\n", GetLastError()); if (!result) return; @@ -768,11 +703,8 @@ static void test_GetDisplayName(void) return; } - pidlLast = pILFindLastID(pidlTestFile); - ok(pidlLast->mkid.cb >=76 || - broken(pidlLast->mkid.cb == 28) || /* W2K */ - broken(pidlLast->mkid.cb == 40), /* Win9x, WinME */ - "Expected pidl length of at least 76, got %d.\n", pidlLast->mkid.cb); + pidlLast = ILFindLastID(pidlTestFile); + ok(pidlLast->mkid.cb >= 76, "Expected pidl length of at least 76, got %d.\n", pidlLast->mkid.cb); if (pidlLast->mkid.cb >= 28) { ok(!lstrcmpA((CHAR*)&pidlLast->mkid.abID[12], szFileName), "Filename should be stored as ansi-string at this position!\n"); @@ -790,95 +722,70 @@ static void test_GetDisplayName(void) */ hr = IShellFolder_BindToObject(psfDesktop, pidlTestFile, NULL, &IID_IUnknown, (VOID**)&psfFile); ok (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || - hr == E_NOTIMPL || /* Vista */ - broken(hr == S_OK), /* Win9x, W2K */ + hr == E_NOTIMPL, /* Vista */ "hr = %08x\n", hr); if (hr == S_OK) { IUnknown_Release(psfFile); } - if (!pSHBindToParent) - { - win_skip("SHBindToParent is missing\n"); - DeleteFileA(szTestFile); - RemoveDirectoryA(szTestDir); - return; - } - /* Some tests for IShellFolder::SetNameOf */ - if (pSHGetFolderPathAndSubDirA) - { - hr = pSHBindToParent(pidlTestFile, &IID_IShellFolder, (VOID**)&psfPersonal, &pidlLast); - ok(hr == S_OK, "SHBindToParent failed! hr = %08x\n", hr); - if (hr == S_OK) { - /* It's ok to use this fixed path. Call will fail anyway. */ - WCHAR wszAbsoluteFilename[] = { 'C',':','\\','w','i','n','e','t','e','s','t', 0 }; - LPITEMIDLIST pidlNew; - - /* The pidl returned through the last parameter of SetNameOf is a simple one. */ - hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlLast, wszDirName, SHGDN_NORMAL, &pidlNew); - ok (hr == S_OK, "SetNameOf failed! hr = %08x\n", hr); - if (hr == S_OK) - { - ok (((LPITEMIDLIST)((LPBYTE)pidlNew+pidlNew->mkid.cb))->mkid.cb == 0, - "pidl returned from SetNameOf should be simple!\n"); + hr = SHBindToParent(pidlTestFile, &IID_IShellFolder, (void **)&psfPersonal, &pidlLast); + ok(hr == S_OK, "SHBindToParent failed! hr = %08x\n", hr); - /* Passing an absolute path to SetNameOf fails. The HRESULT code indicates that SetNameOf - * is implemented on top of SHFileOperation in WinXP. */ - hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszAbsoluteFilename, - SHGDN_FORPARSING, NULL); - ok (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED), "SetNameOf succeeded! hr = %08x\n", hr); + /* The pidl returned through the last parameter of SetNameOf is a simple one. */ + hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlLast, wszDirName, SHGDN_NORMAL, &pidlNew); + ok (hr == S_OK, "SetNameOf failed! hr = %08x\n", hr); - /* Rename the file back to its original name. SetNameOf ignores the fact, that the - * SHGDN flags specify an absolute path. */ - hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszFileName, SHGDN_FORPARSING, NULL); - ok (hr == S_OK, "SetNameOf failed! hr = %08x\n", hr); + ok (((ITEMIDLIST *)((BYTE *)pidlNew + pidlNew->mkid.cb))->mkid.cb == 0, + "pidl returned from SetNameOf should be simple!\n"); - pILFree(pidlNew); - } + /* Passing an absolute path to SetNameOf fails. The HRESULT code indicates that SetNameOf + * is implemented on top of SHFileOperation in WinXP. */ + hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszAbsoluteFilename, SHGDN_FORPARSING, NULL); + ok (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED), "SetNameOf succeeded! hr = %08x\n", hr); - IShellFolder_Release(psfPersonal); - } - } - else - win_skip("Avoid needs of interaction on Win2k\n"); + /* Rename the file back to its original name. SetNameOf ignores the fact, that the + * SHGDN flags specify an absolute path. */ + hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszFileName, SHGDN_FORPARSING, NULL); + ok (hr == S_OK, "SetNameOf failed! hr = %08x\n", hr); + + ILFree(pidlNew); + IShellFolder_Release(psfPersonal); /* Deleting the file and the directory */ DeleteFileA(szTestFile); RemoveDirectoryA(szTestDir); /* SHGetPathFromIDListW still works, although the file is not present anymore. */ - if (pSHGetPathFromIDListW) - { - result = pSHGetPathFromIDListW(pidlTestFile, wszTestFile2); - ok (result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError()); - ok (!lstrcmpiW(wszTestFile, wszTestFile2), "SHGetPathFromIDListW returns incorrect path!\n"); - } + result = SHGetPathFromIDListW(pidlTestFile, wszTestFile2); + ok (result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError()); + ok (!lstrcmpiW(wszTestFile, wszTestFile2), "SHGetPathFromIDListW returns incorrect path!\n"); /* SHBindToParent fails, if called with a NULL PIDL. */ - hr = pSHBindToParent(NULL, &IID_IShellFolder, (VOID**)&psfPersonal, &pidlLast); - ok (hr != S_OK, "SHBindToParent(NULL) should fail!\n"); + hr = SHBindToParent(NULL, &IID_IShellFolder, (void **)&psfPersonal, &pidlLast); + ok (hr == E_INVALIDARG || broken(hr == E_OUTOFMEMORY) /* XP */, + "SHBindToParent(NULL) should fail! hr = %08x\n", hr); /* But it succeeds with an empty PIDL. */ - hr = pSHBindToParent(pidlEmpty, &IID_IShellFolder, (VOID**)&psfPersonal, &pidlLast); + hr = SHBindToParent(pidlEmpty, &IID_IShellFolder, (void **)&psfPersonal, &pidlLast); ok (hr == S_OK, "SHBindToParent(empty PIDL) should succeed! hr = %08x\n", hr); ok (pidlLast == pidlEmpty, "The last element of an empty PIDL should be the PIDL itself!\n"); if (hr == S_OK) IShellFolder_Release(psfPersonal); - + /* Binding to the folder and querying the display name of the file also works. */ - hr = pSHBindToParent(pidlTestFile, &IID_IShellFolder, (VOID**)&psfPersonal, &pidlLast); + hr = SHBindToParent(pidlTestFile, &IID_IShellFolder, (void **)&psfPersonal, &pidlLast); ok (hr == S_OK, "SHBindToParent failed! hr = %08x\n", hr); if (hr != S_OK) { IShellFolder_Release(psfDesktop); return; } - /* This test shows that Windows doesn't allocate a new pidlLast, but returns a pointer into + /* This test shows that Windows doesn't allocate a new pidlLast, but returns a pointer into * pidlTestFile (In accordance with MSDN). */ - ok (pILFindLastID(pidlTestFile) == pidlLast, + ok (ILFindLastID(pidlTestFile) == pidlLast, "SHBindToParent doesn't return the last id of the pidl param!\n"); - + hr = IShellFolder_GetDisplayNameOf(psfPersonal, pidlLast, SHGDN_FORPARSING, &strret); ok (hr == S_OK, "Personal->GetDisplayNameOf failed! hr = %08x\n", hr); if (hr != S_OK) { @@ -887,13 +794,10 @@ static void test_GetDisplayName(void) return; } - if (pStrRetToBufW) - { - hr = pStrRetToBufW(&strret, pidlLast, wszTestFile2, MAX_PATH); - ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr); - ok (!lstrcmpiW(wszTestFile, wszTestFile2), "GetDisplayNameOf returns incorrect path!\n"); - } - + hr = StrRetToBufW(&strret, pidlLast, wszTestFile2, MAX_PATH); + ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr); + ok (!lstrcmpiW(wszTestFile, wszTestFile2), "GetDisplayNameOf returns incorrect path!\n"); + ILFree(pidlTestFile); IShellFolder_Release(psfDesktop); IShellFolder_Release(psfPersonal); @@ -931,11 +835,10 @@ static void test_CallForAttributes(void) hr = SHGetDesktopFolder(&psfDesktop); ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr); if (hr != S_OK) return; - - hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyDocuments, NULL, + + hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyDocuments, NULL, &pidlMyDocuments, NULL); - ok (hr == S_OK || - broken(hr == E_INVALIDARG), /* Win95, NT4 */ + ok (hr == S_OK, "Desktop's ParseDisplayName failed to parse MyDocuments's CLSID! hr = %08x\n", hr); if (hr != S_OK) { IShellFolder_Release(psfDesktop); @@ -1030,32 +933,11 @@ static void test_GetAttributesOf(void) LPCITEMIDLIST pidlEmpty = (LPCITEMIDLIST)&emptyitem; LPITEMIDLIST pidlMyComputer; DWORD dwFlags; - static const DWORD desktopFlags[] = { - /* WinXP */ - SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | SFGAO_FILESYSANCESTOR | - SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER, - /* Win2k */ - SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_STREAM | SFGAO_FILESYSANCESTOR | - SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER, - /* WinMe, Win9x, WinNT*/ - SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_FILESYSANCESTOR | - SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER - }; - static const DWORD myComputerFlags[] = { - /* WinXP */ - SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | - SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER, - /* Win2k */ - SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_STREAM | - SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER, - /* WinMe, Win9x, WinNT */ - SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR | - SFGAO_FOLDER | SFGAO_HASSUBFOLDER, - /* Win95, WinNT when queried directly */ - SFGAO_CANLINK | SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR | - SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER - }; - WCHAR wszMyComputer[] = { + static const DWORD desktopFlags = SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | + SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER; + static const DWORD myComputerFlags = SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET | + SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER; + WCHAR wszMyComputer[] = { ':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-', 'A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0 }; char cCurrDirA [MAX_PATH] = {0}; @@ -1063,8 +945,7 @@ static void test_GetAttributesOf(void) static WCHAR cTestDirW[] = {'t','e','s','t','d','i','r',0}; IShellFolder *IDesktopFolder, *testIShellFolder; ITEMIDLIST *newPIDL; - int len, i; - BOOL foundFlagsMatch; + int len; hr = SHGetDesktopFolder(&psfDesktop); ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr); @@ -1074,26 +955,14 @@ static void test_GetAttributesOf(void) dwFlags = 0xffffffff; hr = IShellFolder_GetAttributesOf(psfDesktop, 1, &pidlEmpty, &dwFlags); ok (hr == S_OK, "Desktop->GetAttributesOf(empty pidl) failed! hr = %08x\n", hr); - for (i = 0, foundFlagsMatch = FALSE; !foundFlagsMatch && - i < sizeof(desktopFlags) / sizeof(desktopFlags[0]); i++) - { - if (desktopFlags[i] == dwFlags) - foundFlagsMatch = TRUE; - } - ok (foundFlagsMatch, "Wrong Desktop attributes: %08x\n", dwFlags); + ok (dwFlags == desktopFlags, "Wrong Desktop attributes: %08x\n", dwFlags); /* .. or with no itemidlist at all. */ dwFlags = 0xffffffff; hr = IShellFolder_GetAttributesOf(psfDesktop, 0, NULL, &dwFlags); ok (hr == S_OK, "Desktop->GetAttributesOf(NULL) failed! hr = %08x\n", hr); - for (i = 0, foundFlagsMatch = FALSE; !foundFlagsMatch && - i < sizeof(desktopFlags) / sizeof(desktopFlags[0]); i++) - { - if (desktopFlags[i] == dwFlags) - foundFlagsMatch = TRUE; - } - ok (foundFlagsMatch, "Wrong Desktop attributes: %08x\n", dwFlags); - + ok (dwFlags == desktopFlags, "Wrong Desktop attributes: %08x\n", dwFlags); + /* Testing the attributes of the MyComputer shellfolder */ hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyComputer, NULL, &pidlMyComputer, NULL); ok (hr == S_OK, "Desktop's ParseDisplayName failed to parse MyComputer's CLSID! hr = %08x\n", hr); @@ -1108,14 +977,8 @@ static void test_GetAttributesOf(void) dwFlags = 0xffffffff; hr = IShellFolder_GetAttributesOf(psfDesktop, 1, (LPCITEMIDLIST*)&pidlMyComputer, &dwFlags); ok (hr == S_OK, "Desktop->GetAttributesOf(MyComputer) failed! hr = %08x\n", hr); - for (i = 0, foundFlagsMatch = FALSE; !foundFlagsMatch && - i < sizeof(myComputerFlags) / sizeof(myComputerFlags[0]); i++) - { - if ((myComputerFlags[i] | SFGAO_CANLINK) == dwFlags) - foundFlagsMatch = TRUE; - } todo_wine - ok (foundFlagsMatch, "Wrong MyComputer attributes: %08x\n", dwFlags); + ok (dwFlags == (myComputerFlags | SFGAO_CANLINK), "Wrong MyComputer attributes: %08x\n", dwFlags); hr = IShellFolder_BindToObject(psfDesktop, pidlMyComputer, NULL, &IID_IShellFolder, (LPVOID*)&psfMyComputer); ok (hr == S_OK, "Desktop failed to bind to MyComputer object! hr = %08x\n", hr); @@ -1125,21 +988,13 @@ static void test_GetAttributesOf(void) hr = IShellFolder_GetAttributesOf(psfMyComputer, 1, &pidlEmpty, &dwFlags); todo_wine - ok (hr == E_INVALIDARG || - broken(hr == S_OK), /* W2K and earlier */ - "MyComputer->GetAttributesOf(empty pidl) should fail! hr = %08x\n", hr); + ok (hr == E_INVALIDARG, "MyComputer->GetAttributesOf(empty pidl) should fail! hr = %08x\n", hr); dwFlags = 0xffffffff; hr = IShellFolder_GetAttributesOf(psfMyComputer, 0, NULL, &dwFlags); ok (hr == S_OK, "MyComputer->GetAttributesOf(NULL) failed! hr = %08x\n", hr); - for (i = 0, foundFlagsMatch = FALSE; !foundFlagsMatch && - i < sizeof(myComputerFlags) / sizeof(myComputerFlags[0]); i++) - { - if (myComputerFlags[i] == dwFlags) - foundFlagsMatch = TRUE; - } todo_wine - ok (foundFlagsMatch, "Wrong MyComputer attributes: %08x\n", dwFlags); + ok (dwFlags == myComputerFlags, "Wrong MyComputer attributes: %08x\n", dwFlags); IShellFolder_Release(psfMyComputer); @@ -1227,34 +1082,19 @@ static void test_SHGetPathFromIDList(void) 'w','i','n','e','t','e','s','t','.','f','o','o',0 }; LPITEMIDLIST pidlPrograms; - if(!pSHGetPathFromIDListW || !pSHGetSpecialFolderPathW) - { - win_skip("SHGetPathFromIDListW() or SHGetSpecialFolderPathW() is missing\n"); - return; - } - /* Calling SHGetPathFromIDListW with no pidl should return the empty string */ wszPath[0] = 'a'; wszPath[1] = '\0'; - result = pSHGetPathFromIDListW(NULL, wszPath); + result = SHGetPathFromIDListW(NULL, wszPath); ok(!result, "Expected failure\n"); ok(!wszPath[0], "Expected empty string\n"); /* Calling SHGetPathFromIDListW with an empty pidl should return the desktop folder's path. */ - result = pSHGetSpecialFolderPathW(NULL, wszDesktop, CSIDL_DESKTOP, FALSE); + result = SHGetSpecialFolderPathW(NULL, wszDesktop, CSIDL_DESKTOP, FALSE); ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOP) failed! Last error: %u\n", GetLastError()); if (!result) return; - /* Check if we are on Win9x */ - SetLastError(0xdeadbeef); - lstrcmpiW(wszDesktop, wszDesktop); - if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) - { - win_skip("Most W-calls are not implemented\n"); - return; - } - - result = pSHGetPathFromIDListW(pidlEmpty, wszPath); + result = SHGetPathFromIDListW(pidlEmpty, wszPath); ok(result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError()); if (!result) return; ok(!lstrcmpiW(wszDesktop, wszPath), "SHGetPathFromIDListW didn't return desktop path for empty pidl!\n"); @@ -1274,7 +1114,7 @@ static void test_SHGetPathFromIDList(void) SetLastError(0xdeadbeef); wszPath[0] = 'a'; wszPath[1] = '\0'; - result = pSHGetPathFromIDListW(pidlMyComputer, wszPath); + result = SHGetPathFromIDListW(pidlMyComputer, wszPath); ok (!result, "SHGetPathFromIDListW succeeded where it shouldn't!\n"); ok (GetLastError()==0xdeadbeef || GetLastError()==ERROR_SUCCESS, /* Vista and higher */ @@ -1287,7 +1127,7 @@ static void test_SHGetPathFromIDList(void) IMalloc_Free(ppM, pidlMyComputer); - result = pSHGetSpecialFolderPathW(NULL, wszFileName, CSIDL_DESKTOPDIRECTORY, FALSE); + result = SHGetSpecialFolderPathW(NULL, wszFileName, CSIDL_DESKTOPDIRECTORY, FALSE); ok(result, "SHGetSpecialFolderPathW failed! Last error: %u\n", GetLastError()); if (!result) { IShellFolder_Release(psfDesktop); @@ -1322,15 +1162,12 @@ static void test_SHGetPathFromIDList(void) IMalloc_Free(ppM, pidlTestFile); return; } - if (pStrRetToBufW) - { - pStrRetToBufW(&strret, pidlTestFile, wszPath, MAX_PATH); - ok(0 == lstrcmpW(wszFileName, wszPath), - "Desktop->GetDisplayNameOf(pidlTestFile, SHGDN_FORPARSING) " - "returned incorrect path for file placed on desktop\n"); - } + StrRetToBufW(&strret, pidlTestFile, wszPath, MAX_PATH); + ok(0 == lstrcmpW(wszFileName, wszPath), + "Desktop->GetDisplayNameOf(pidlTestFile, SHGDN_FORPARSING) " + "returned incorrect path for file placed on desktop\n"); - result = pSHGetPathFromIDListW(pidlTestFile, wszPath); + result = SHGetPathFromIDListW(pidlTestFile, wszPath); ok(result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError()); ok(0 == lstrcmpW(wszFileName, wszPath), "SHGetPathFromIDListW returned incorrect path for file placed on desktop\n"); @@ -1362,11 +1199,11 @@ static void test_SHGetPathFromIDList(void) IMalloc_Free(ppM, pidlTestFile); /* Test if we can get the path from the start menu "program files" PIDL. */ - hr = pSHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidlPrograms); + hr = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidlPrograms); ok(hr == S_OK, "SHGetFolderLocation failed: 0x%08x\n", hr); SetLastError(0xdeadbeef); - result = pSHGetPathFromIDListW(pidlPrograms, wszPath); + result = SHGetPathFromIDListW(pidlPrograms, wszPath); IMalloc_Free(ppM, pidlPrograms); ok(result, "SHGetPathFromIDListW failed\n"); } @@ -1459,11 +1296,9 @@ static HRESULT WINAPI InitPropertyBag_IPropertyBag_Read(IPropertyBag *iface, LPC 'T','a','r','g','e','t','K','n','o','w','n','F','o','l','d','e','r',0 }; static const WCHAR wszCLSID[] = { 'C','L','S','I','D',0 }; - + if (!lstrcmpW(pszPropName, wszTargetSpecialFolder)) { - ok(V_VT(pVar) == VT_I4 || - broken(V_VT(pVar) == VT_BSTR), /* Win2k */ - "Wrong variant type for 'TargetSpecialFolder' property!\n"); + ok(V_VT(pVar) == VT_I4, "Wrong variant type for 'TargetSpecialFolder' property!\n"); return E_INVALIDARG; } @@ -1476,13 +1311,11 @@ static HRESULT WINAPI InitPropertyBag_IPropertyBag_Read(IPropertyBag *iface, LPC if (!lstrcmpW(pszPropName, wszTarget)) { WCHAR wszPath[MAX_PATH]; BOOL result; - - ok(V_VT(pVar) == VT_BSTR || - broken(V_VT(pVar) == VT_EMPTY), /* Win2k */ - "Wrong variant type for 'Target' property!\n"); + + ok(V_VT(pVar) == VT_BSTR, "Wrong variant type for 'Target' property!\n"); if (V_VT(pVar) != VT_BSTR) return E_INVALIDARG; - result = pSHGetSpecialFolderPathW(NULL, wszPath, CSIDL_DESKTOPDIRECTORY, FALSE); + result = SHGetSpecialFolderPathW(NULL, wszPath, CSIDL_DESKTOPDIRECTORY, FALSE); ok(result, "SHGetSpecialFolderPathW(DESKTOPDIRECTORY) failed! %u\n", GetLastError()); if (!result) return E_INVALIDARG; @@ -1559,17 +1392,6 @@ static void test_FolderShortcut(void) { static const GUID CLSID_UnixDosFolder = {0x9d20aae8, 0x0625, 0x44b0, {0x9c, 0xa7, 0x71, 0x88, 0x9c, 0x22, 0x54, 0xd9}}; - if (!pSHGetSpecialFolderPathW || !pStrRetToBufW) { - win_skip("SHGetSpecialFolderPathW and/or StrRetToBufW are not available\n"); - return; - } - - if (!pSHGetFolderPathAndSubDirA) - { - win_skip("FolderShortcut test doesn't work on Win2k\n"); - return; - } - /* These tests basically show, that CLSID_FolderShortcuts are initialized * via their IPersistPropertyBag interface. And that the target folder * is taken from the IPropertyBag's 'Target' property. @@ -1604,11 +1426,11 @@ static void test_FolderShortcut(void) { return; } - result = pSHGetSpecialFolderPathW(NULL, wszDesktopPath, CSIDL_DESKTOPDIRECTORY, FALSE); + result = SHGetSpecialFolderPathW(NULL, wszDesktopPath, CSIDL_DESKTOPDIRECTORY, FALSE); ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOPDIRECTORY) failed! %u\n", GetLastError()); if (!result) return; - pStrRetToBufW(&strret, NULL, wszBuffer, MAX_PATH); + StrRetToBufW(&strret, NULL, wszBuffer, MAX_PATH); ok(!lstrcmpiW(wszDesktopPath, wszBuffer), "FolderShortcut returned incorrect folder!\n"); hr = IShellFolder_QueryInterface(pShellFolder, &IID_IPersistFolder3, (LPVOID*)&pPersistFolder3); @@ -1649,16 +1471,16 @@ static void test_FolderShortcut(void) { ok (hr == S_OK, "IPersistFolder3::Initialize failed! hr = %08x\n", hr); if (hr != S_OK) { IPersistFolder3_Release(pPersistFolder3); - pILFree(pidlWineTestFolder); + ILFree(pidlWineTestFolder); return; } hr = IPersistFolder3_GetCurFolder(pPersistFolder3, &pidlCurrentFolder); ok(hr == S_OK, "IPersistFolder3_GetCurFolder failed! hr=0x%08x\n", hr); - ok(pILIsEqual(pidlCurrentFolder, pidlWineTestFolder), + ok(ILIsEqual(pidlCurrentFolder, pidlWineTestFolder), "IPersistFolder3_GetCurFolder should return pidlWineTestFolder!\n"); - pILFree(pidlCurrentFolder); - pILFree(pidlWineTestFolder); + ILFree(pidlCurrentFolder); + ILFree(pidlWineTestFolder); hr = IPersistFolder3_QueryInterface(pPersistFolder3, &IID_IShellFolder, (LPVOID*)&pShellFolder); IPersistFolder3_Release(pPersistFolder3); @@ -1672,7 +1494,7 @@ static void test_FolderShortcut(void) { return; } - pStrRetToBufW(&strret, NULL, wszBuffer, MAX_PATH); + StrRetToBufW(&strret, NULL, wszBuffer, MAX_PATH); ok(!lstrcmpiW(wszDesktopPath, wszBuffer), "FolderShortcut returned incorrect folder!\n"); /* Next few lines are meant to show that children of FolderShortcuts are not FolderShortcuts, @@ -1696,7 +1518,7 @@ static void test_FolderShortcut(void) { hr = IShellFolder_BindToObject(pShellFolder, pidlSubFolder, NULL, &IID_IPersistFolder3, (LPVOID*)&pPersistFolder3); IShellFolder_Release(pShellFolder); - pILFree(pidlSubFolder); + ILFree(pidlSubFolder); ok (hr == S_OK, "IShellFolder::BindToObject failed! hr = %08x\n", hr); if (hr != S_OK) return; @@ -1748,9 +1570,7 @@ static void test_ITEMIDLIST_format(void) { { 'l','o','n','g','e','r','_','t','h','a','n','.','8','_','3',0 } }; int i; - if (!pSHGetSpecialFolderPathW) return; - - bResult = pSHGetSpecialFolderPathW(NULL, wszPersonal, CSIDL_PERSONAL, FALSE); + bResult = SHGetSpecialFolderPathW(NULL, wszPersonal, CSIDL_PERSONAL, FALSE); ok(bResult, "SHGetSpecialFolderPathW failed! Last error: %u\n", GetLastError()); if (!bResult) return; @@ -1777,7 +1597,7 @@ static void test_ITEMIDLIST_format(void) { hr = IShellFolder_BindToObject(psfDesktop, pidlPersonal, NULL, &IID_IShellFolder, (LPVOID*)&psfPersonal); IShellFolder_Release(psfDesktop); - pILFree(pidlPersonal); + ILFree(pidlPersonal); ok(hr == S_OK, "psfDesktop->BindToObject failed! hr = %08x\n", hr); if (hr != S_OK) return; @@ -1818,13 +1638,10 @@ static void test_ITEMIDLIST_format(void) { * current habit of storing the long filename here, which seems to work * just fine. */ todo_wine - ok(pidlFile->mkid.abID[18] == '~' || - broken(pidlFile->mkid.abID[34] == '~'), /* Win2k */ - "Should be derived 8.3 name!\n"); + ok(pidlFile->mkid.abID[18] == '~', "Should be derived 8.3 name!\n"); if (i == 0) /* First file name has an even number of chars. No need for alignment. */ - ok(pidlFile->mkid.abID[12 + strlen(szFile) + 1] != '\0' || - broken(pidlFile->mkid.cb == 2 + 12 + strlen(szFile) + 1 + 1), /* Win2k */ + ok(pidlFile->mkid.abID[12 + strlen(szFile) + 1] != '\0', "Alignment byte, where there shouldn't be!\n"); if (i == 1) /* Second file name has an uneven number of chars => alignment byte */ @@ -1834,9 +1651,7 @@ static void test_ITEMIDLIST_format(void) { /* The offset of the FileStructW member is stored as a WORD at the end of the pidl. */ cbOffset = *(WORD*)(((LPBYTE)pidlFile)+pidlFile->mkid.cb-sizeof(WORD)); ok ((cbOffset >= sizeof(struct FileStructA) && - cbOffset <= pidlFile->mkid.cb - sizeof(struct FileStructW)) || - broken(pidlFile->mkid.cb == 2 + 12 + strlen(szFile) + 1 + 1) || /* Win2k on short names */ - broken(pidlFile->mkid.cb == 2 + 12 + strlen(szFile) + 1 + 12 + 1), /* Win2k on long names */ + cbOffset <= pidlFile->mkid.cb - sizeof(struct FileStructW)), "Wrong offset value (%d) stored at the end of the PIDL\n", cbOffset); if (cbOffset >= sizeof(struct FileStructA) && @@ -1888,7 +1703,7 @@ static void test_ITEMIDLIST_format(void) { } } - pILFree(pidlFile); + ILFree(pidlFile); } IShellFolder_Release(psfPersonal); @@ -1904,16 +1719,11 @@ static void test_SHGetFolderPathA(void) HRESULT hr; HKEY key; - if (!pSHGetFolderPathA) - { - win_skip("SHGetFolderPathA not present\n"); - return; - } if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE; - hr = pSHGetFolderPathA( 0, CSIDL_PROGRAM_FILES, 0, SHGFP_TYPE_CURRENT, path ); + hr = SHGetFolderPathA( 0, CSIDL_PROGRAM_FILES, 0, SHGFP_TYPE_CURRENT, path ); ok( hr == S_OK, "SHGetFolderPathA failed %x\n", hr ); - hr = pSHGetFolderPathA( 0, CSIDL_PROGRAM_FILESX86, 0, SHGFP_TYPE_CURRENT, path_x86 ); + hr = SHGetFolderPathA( 0, CSIDL_PROGRAM_FILESX86, 0, SHGFP_TYPE_CURRENT, path_x86 ); if (hr == E_FAIL) { win_skip( "Program Files (x86) not supported\n" ); @@ -1946,9 +1756,9 @@ static void test_SHGetFolderPathA(void) RegCloseKey( key ); } - hr = pSHGetFolderPathA( 0, CSIDL_PROGRAM_FILES_COMMON, 0, SHGFP_TYPE_CURRENT, path ); + hr = SHGetFolderPathA( 0, CSIDL_PROGRAM_FILES_COMMON, 0, SHGFP_TYPE_CURRENT, path ); ok( hr == S_OK, "SHGetFolderPathA failed %x\n", hr ); - hr = pSHGetFolderPathA( 0, CSIDL_PROGRAM_FILES_COMMONX86, 0, SHGFP_TYPE_CURRENT, path_x86 ); + hr = SHGetFolderPathA( 0, CSIDL_PROGRAM_FILES_COMMONX86, 0, SHGFP_TYPE_CURRENT, path_x86 ); if (hr == E_FAIL) { win_skip( "Common Files (x86) not supported\n" ); @@ -1993,17 +1803,7 @@ static void test_SHGetFolderPathAndSubDirA(void) static char testpath[MAX_PATH]; static char toolongpath[MAX_PATH+1]; - if(!pSHGetFolderPathAndSubDirA) - { - win_skip("SHGetFolderPathAndSubDirA not present!\n"); - return; - } - - if(!pSHGetFolderPathA) { - win_skip("SHGetFolderPathA not present!\n"); - return; - } - if(FAILED(pSHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdata))) + if(FAILED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdata))) { win_skip("SHGetFolderPathA failed for CSIDL_LOCAL_APPDATA!\n"); return; @@ -2024,11 +1824,11 @@ static void test_SHGetFolderPathAndSubDirA(void) } /* test invalid second parameter */ - ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | 0xff, NULL, SHGFP_TYPE_CURRENT, wine, testpath); + ret = SHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | 0xff, NULL, SHGFP_TYPE_CURRENT, wine, testpath); ok(E_INVALIDARG == ret, "expected E_INVALIDARG, got %x\n", ret); /* test fourth parameter */ - ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, 2, winetemp, testpath); + ret = SHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, 2, winetemp, testpath); switch(ret) { case S_OK: /* winvista */ ok(!strncmp(appdata, testpath, strlen(appdata)), @@ -2044,40 +1844,40 @@ static void test_SHGetFolderPathAndSubDirA(void) /* test fifth parameter */ testpath[0] = '\0'; - ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, NULL, testpath); + ret = SHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, NULL, testpath); ok(S_OK == ret, "expected S_OK, got %x\n", ret); ok(!lstrcmpA(appdata, testpath), "expected %s, got %s\n", appdata, testpath); testpath[0] = '\0'; - ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, "", testpath); + ret = SHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, "", testpath); ok(S_OK == ret, "expected S_OK, got %x\n", ret); ok(!lstrcmpA(appdata, testpath), "expected %s, got %s\n", appdata, testpath); testpath[0] = '\0'; - ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, "\\", testpath); + ret = SHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, "\\", testpath); ok(S_OK == ret, "expected S_OK, got %x\n", ret); ok(!lstrcmpA(appdata, testpath), "expected %s, got %s\n", appdata, testpath); for(i=0; i< MAX_PATH; i++) toolongpath[i] = '0' + i % 10; toolongpath[MAX_PATH] = '\0'; - ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, toolongpath, testpath); + ret = SHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, toolongpath, testpath); ok(HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE) == ret, "expected %x, got %x\n", HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE), ret); testpath[0] = '\0'; - ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, wine, NULL); + ret = SHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, wine, NULL); ok((S_OK == ret) || (E_INVALIDARG == ret), "expected S_OK or E_INVALIDARG, got %x\n", ret); /* test a not existing path */ testpath[0] = '\0'; - ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, winetemp, testpath); + ret = SHGetFolderPathAndSubDirA(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, winetemp, testpath); ok(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == ret, "expected %x, got %x\n", HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), ret); /* create a directory inside a not existing directory */ testpath[0] = '\0'; - ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_CREATE | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, winetemp, testpath); + ret = SHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_CREATE | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, winetemp, testpath); ok(S_OK == ret, "expected S_OK, got %x\n", ret); ok(!strncmp(appdata, testpath, strlen(appdata)), "expected %s to start with %s\n", testpath, appdata); @@ -2162,40 +1962,27 @@ static void test_LocalizedNames(void) hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_INFOLDER, &strret); ok(hr == S_OK, "GetDisplayNameOf failed %08x\n", hr); - if (hr == S_OK && pStrRetToBufW) - { - hr = pStrRetToBufW(&strret, newPIDL, tempbufW, sizeof(tempbufW)/sizeof(WCHAR)); - ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr); - todo_wine - ok (!lstrcmpiW(tempbufW, folderdisplayW) || - broken(!lstrcmpiW(tempbufW, foldernameW)), /* W2K */ - "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW)); - } + hr = StrRetToBufW(&strret, newPIDL, tempbufW, sizeof(tempbufW)/sizeof(WCHAR)); + ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr); + todo_wine + ok (!lstrcmpiW(tempbufW, folderdisplayW), "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW)); /* editing name is also read from the resource */ hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_INFOLDER|SHGDN_FOREDITING, &strret); ok(hr == S_OK, "GetDisplayNameOf failed %08x\n", hr); - if (hr == S_OK && pStrRetToBufW) - { - hr = pStrRetToBufW(&strret, newPIDL, tempbufW, sizeof(tempbufW)/sizeof(WCHAR)); - ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr); - todo_wine - ok (!lstrcmpiW(tempbufW, folderdisplayW) || - broken(!lstrcmpiW(tempbufW, foldernameW)), /* W2K */ - "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW)); - } + hr = StrRetToBufW(&strret, newPIDL, tempbufW, sizeof(tempbufW)/sizeof(WCHAR)); + ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr); + todo_wine + ok (!lstrcmpiW(tempbufW, folderdisplayW), "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW)); /* parsing name is unchanged */ hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_INFOLDER|SHGDN_FORPARSING, &strret); ok(hr == S_OK, "GetDisplayNameOf failed %08x\n", hr); - if (hr == S_OK && pStrRetToBufW) - { - hr = pStrRetToBufW(&strret, newPIDL, tempbufW, sizeof(tempbufW)/sizeof(WCHAR)); - ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr); - ok (!lstrcmpiW(tempbufW, foldernameW), "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW)); - } + hr = StrRetToBufW(&strret, newPIDL, tempbufW, sizeof(tempbufW)/sizeof(WCHAR)); + ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr); + ok (!lstrcmpiW(tempbufW, foldernameW), "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW)); IShellFolder_Release(IDesktopFolder); IShellFolder_Release(testIShellFolder); @@ -2234,16 +2021,8 @@ static void test_SHCreateShellItem(void) return; } - if(pSHGetSpecialFolderLocation) - { - ret = pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop); - ok(ret == S_OK, "Got 0x%08x\n", ret); - } - else - { - win_skip("pSHGetSpecialFolderLocation missing.\n"); - pidl_desktop = NULL; - } + ret = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop); + ok(ret == S_OK, "Got 0x%08x\n", ret); MultiByteToWideChar(CP_ACP, 0, curdirA, -1, curdirW, MAX_PATH); @@ -2261,7 +2040,7 @@ static void test_SHCreateShellItem(void) ret = IShellFolder_ParseDisplayName(currentfolder, NULL, NULL, testfileW, NULL, &pidl_testfile, NULL); ok(SUCCEEDED(ret), "ParseDisplayName returned %x\n", ret); - pidl_abstestfile = pILCombine(pidl_cwd, pidl_testfile); + pidl_abstestfile = ILCombine(pidl_cwd, pidl_testfile); shellitem = (void*)0xdeadbeef; ret = pSHCreateShellItem(NULL, NULL, NULL, &shellitem); @@ -2289,7 +2068,7 @@ static void test_SHCreateShellItem(void) if (SUCCEEDED(ret)) { ok(ILIsEqual(pidl_cwd, pidl_test), "id lists are not equal\n"); - pILFree(pidl_test); + ILFree(pidl_test); } IPersistIDList_Release(persistidl); } @@ -2309,7 +2088,7 @@ static void test_SHCreateShellItem(void) if (SUCCEEDED(ret)) { ok(ILIsEqual(pidl_abstestfile, pidl_test), "id lists are not equal\n"); - pILFree(pidl_test); + ILFree(pidl_test); } IPersistIDList_Release(persistidl); } @@ -2327,7 +2106,7 @@ static void test_SHCreateShellItem(void) if (SUCCEEDED(ret)) { ok(ILIsEqual(pidl_cwd, pidl_test), "id lists are not equal\n"); - pILFree(pidl_test); + ILFree(pidl_test); } IPersistIDList_Release(persistidl); } @@ -2350,7 +2129,7 @@ static void test_SHCreateShellItem(void) if (SUCCEEDED(ret)) { ok(ILIsEqual(pidl_abstestfile, pidl_test), "id lists are not equal\n"); - pILFree(pidl_test); + ILFree(pidl_test); } IPersistIDList_Release(persistidl); } @@ -2371,7 +2150,7 @@ static void test_SHCreateShellItem(void) if (SUCCEEDED(ret)) { ok(ILIsEqual(pidl_abstestfile, pidl_test), "id lists are not equal\n"); - pILFree(pidl_test); + ILFree(pidl_test); } IPersistIDList_Release(persistidl); } @@ -2391,7 +2170,7 @@ static void test_SHCreateShellItem(void) if (SUCCEEDED(ret)) { ok(ILIsEqual(pidl_testfile, pidl_test), "id lists are not equal\n"); - pILFree(pidl_test); + ILFree(pidl_test); } IPersistIDList_Release(persistidl); } @@ -2476,7 +2255,7 @@ static void test_SHCreateShellItem(void) if (SUCCEEDED(ret)) { ok(ILIsEqual(pidl_cwd, pidl_test), "id lists are not equal\n"); - pILFree(pidl_test); + ILFree(pidl_test); } IPersistIDList_Release(persistidl); } @@ -2496,7 +2275,7 @@ static void test_SHCreateShellItem(void) if (SUCCEEDED(ret)) { ok(ILIsEqual(pidl_testfile, pidl_test), "id lists are not equal\n"); - pILFree(pidl_test); + ILFree(pidl_test); } IPersistIDList_Release(persistidl); } @@ -2573,7 +2352,7 @@ static void test_SHCreateShellItem(void) ret = IShellItem_Compare(shellitem, shellitem2, 0, &order); ok(ret == S_OK, "IShellItem_Compare fail: 0x%08x.\n", ret); ok(!order, "order got wrong value: %d.\n", order); - pILFree(pidl_desktop_testfile); + ILFree(pidl_desktop_testfile); IShellItem_Release(shellitem2); IShellItem_Release(shellitem); @@ -2664,7 +2443,7 @@ static void test_SHCreateShellItem(void) ret = IShellItem_Compare(shellitem, shellitem2, 0, &order); ok(ret == S_OK, "IShellItem_Compare failed: 0x%08x.\n", ret); ok(!order, "order got wrong value: %d.\n", order); - pILFree(pidl_desktop_testfile); + ILFree(pidl_desktop_testfile); IShellItem_Release(shellitem2); IShellItem_Release(shellitem); @@ -2696,10 +2475,10 @@ static void test_SHCreateShellItem(void) win_skip("No SHCreateItemInKnownFolder or SHGetKnownFolderPath\n"); DeleteFileA(".\\testfile"); - pILFree(pidl_abstestfile); - pILFree(pidl_testfile); - pILFree(pidl_desktop); - pILFree(pidl_cwd); + ILFree(pidl_abstestfile); + ILFree(pidl_testfile); + ILFree(pidl_desktop); + ILFree(pidl_cwd); IShellFolder_Release(currentfolder); IShellFolder_Release(desktopfolder); } @@ -2723,11 +2502,8 @@ static void test_SHGetNameFromIDList(void) return; } - /* These should be available on any platform that passed the above test. */ + /* This should be available on any platform that passed the above test. */ ok(pSHCreateShellItem != NULL, "SHCreateShellItem missing.\n"); - ok(pSHBindToParent != NULL, "SHBindToParent missing.\n"); - ok(pSHGetSpecialFolderLocation != NULL, "SHGetSpecialFolderLocation missing.\n"); - ok(pStrRetToBufW != NULL, "StrRetToBufW missing.\n"); if(0) { @@ -2739,7 +2515,7 @@ static void test_SHGetNameFromIDList(void) ok(hres == E_INVALIDARG, "Got 0x%08x\n", hres); /* Test the desktop */ - hres = pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl); + hres = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl); ok(hres == S_OK, "Got 0x%08x\n", hres); hres = pSHCreateShellItem(NULL, NULL, pidl, &shellitem); ok(hres == S_OK, "Got 0x%08x\n", hres); @@ -2767,7 +2543,7 @@ static void test_SHGetNameFromIDList(void) if(SUCCEEDED(hrSF)) { - pStrRetToBufW(&strret, NULL, buf, MAX_PATH); + StrRetToBufW(&strret, NULL, buf, MAX_PATH); if(SUCCEEDED(hrSI)) ok(!lstrcmpW(nameSI, buf), "Strings differ.\n"); if(SUCCEEDED(hrSF)) @@ -2778,16 +2554,13 @@ static void test_SHGetNameFromIDList(void) } IShellFolder_Release(psf); - if(pSHGetPathFromIDListW){ - hrSI = pSHGetNameFromIDList(pidl, SIGDN_FILESYSPATH, &nameSI); - ok(hrSI == S_OK, "Got 0x%08x\n", hrSI); - res = pSHGetPathFromIDListW(pidl, buf); - ok(res == TRUE, "Got %d\n", res); - if(SUCCEEDED(hrSI) && res) - ok(!lstrcmpW(nameSI, buf), "Strings differ.\n"); - if(SUCCEEDED(hrSI)) CoTaskMemFree(nameSI); - }else - win_skip("pSHGetPathFromIDListW not available\n"); + hrSI = pSHGetNameFromIDList(pidl, SIGDN_FILESYSPATH, &nameSI); + ok(hrSI == S_OK, "Got 0x%08x\n", hrSI); + res = SHGetPathFromIDListW(pidl, buf); + ok(res == TRUE, "Got %d\n", res); + if(SUCCEEDED(hrSI) && res) + ok(!lstrcmpW(nameSI, buf), "Strings differ.\n"); + if(SUCCEEDED(hrSI)) CoTaskMemFree(nameSI); hres = pSHGetNameFromIDList(pidl, SIGDN_URL, &name_string); todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres); @@ -2795,10 +2568,10 @@ static void test_SHGetNameFromIDList(void) IShellItem_Release(shellitem); } - pILFree(pidl); + ILFree(pidl); /* Test the control panel */ - hres = pSHGetSpecialFolderLocation(NULL, CSIDL_CONTROLS, &pidl); + hres = SHGetSpecialFolderLocation(NULL, CSIDL_CONTROLS, &pidl); ok(hres == S_OK, "Got 0x%08x\n", hres); hres = pSHCreateShellItem(NULL, NULL, pidl, &shellitem); ok(hres == S_OK, "Got 0x%08x\n", hres); @@ -2826,7 +2599,7 @@ static void test_SHGetNameFromIDList(void) if(SUCCEEDED(hrSF)) { - pStrRetToBufW(&strret, NULL, buf, MAX_PATH); + StrRetToBufW(&strret, NULL, buf, MAX_PATH); if(SUCCEEDED(hrSI)) ok(!lstrcmpW(nameSI, buf), "Strings differ.\n"); if(SUCCEEDED(hrSF)) @@ -2837,16 +2610,13 @@ static void test_SHGetNameFromIDList(void) } IShellFolder_Release(psf); - if(pSHGetPathFromIDListW){ - hrSI = pSHGetNameFromIDList(pidl, SIGDN_FILESYSPATH, &nameSI); - ok(hrSI == E_INVALIDARG, "Got 0x%08x\n", hrSI); - res = pSHGetPathFromIDListW(pidl, buf); - ok(res == FALSE, "Got %d\n", res); - if(SUCCEEDED(hrSI) && res) - ok(!lstrcmpW(nameSI, buf), "Strings differ.\n"); - if(SUCCEEDED(hrSI)) CoTaskMemFree(nameSI); - }else - win_skip("pSHGetPathFromIDListW not available\n"); + hrSI = pSHGetNameFromIDList(pidl, SIGDN_FILESYSPATH, &nameSI); + ok(hrSI == E_INVALIDARG, "Got 0x%08x\n", hrSI); + res = SHGetPathFromIDListW(pidl, buf); + ok(res == FALSE, "Got %d\n", res); + if(SUCCEEDED(hrSI) && res) + ok(!lstrcmpW(nameSI, buf), "Strings differ.\n"); + if(SUCCEEDED(hrSI)) CoTaskMemFree(nameSI); hres = pSHGetNameFromIDList(pidl, SIGDN_URL, &name_string); todo_wine ok(hres == E_NOTIMPL /* Win7 */ || hres == S_OK /* Vista */, @@ -2855,7 +2625,7 @@ static void test_SHGetNameFromIDList(void) IShellItem_Release(shellitem); } - pILFree(pidl); + ILFree(pidl); } static void test_SHGetItemFromDataObject(void) @@ -2960,7 +2730,7 @@ static void test_SHGetItemFromDataObject(void) skip("zero or one file found - skipping multi-file test.\n"); for(i = 0; i < count; i++) - pILFree(apidl[i]); + ILFree(apidl[i]); IEnumIDList_Release(peidl); } @@ -3035,7 +2805,7 @@ static void test_ShellItemCompare(void) { hr = pSHCreateShellItem(NULL, NULL, pidl_testfile, &psi[i]); ok(hr == S_OK, "Got 0x%08x\n", hr); - pILFree(pidl_testfile); + ILFree(pidl_testfile); } if(FAILED(hr)) failed = TRUE; } @@ -3270,8 +3040,6 @@ static void test_SHGetIDListFromObject(void) return; } - ok(pSHGetSpecialFolderLocation != NULL, "SHGetSpecialFolderLocation missing.\n"); - if(0) { /* Crashes native */ @@ -3282,7 +3050,7 @@ static void test_SHGetIDListFromObject(void) hres = pSHGetIDListFromObject(NULL, &pidl); ok(hres == E_NOINTERFACE, "Got %x\n", hres); - punkimpl = HeapAlloc(GetProcessHeap(), 0, sizeof(IUnknownImpl)); + punkimpl = heap_alloc(sizeof(*punkimpl)); punkimpl->IUnknown_iface.lpVtbl = &vt_IUnknown; punkimpl->ifaces = ifaces; punkimpl->unknown = 0; @@ -3299,10 +3067,10 @@ static void test_SHGetIDListFromObject(void) "interface not requested.\n"); ok(!punkimpl->unknown, "Got %d unknown.\n", punkimpl->unknown); - HeapFree(GetProcessHeap(), 0, punkimpl); + heap_free(punkimpl); pidl_desktop = NULL; - pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop); + SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop); ok(pidl_desktop != NULL, "Failed to get desktop pidl.\n"); SHGetDesktopFolder(&psfdesktop); @@ -3320,7 +3088,7 @@ static void test_SHGetIDListFromObject(void) if(SUCCEEDED(hres)) { ok(ILIsEqual(pidl_desktop, pidl), "pidl not equal.\n"); - pILFree(pidl); + ILFree(pidl); } IShellItem_Release(shellitem); } @@ -3334,7 +3102,7 @@ static void test_SHGetIDListFromObject(void) if(SUCCEEDED(hres)) { ok(ILIsEqual(pidl_desktop, pidl), "pidl not equal.\n"); - pILFree(pidl); + ILFree(pidl); } hres = IShellFolder_CreateViewObject(psfdesktop, NULL, &IID_IShellView, (void**)&psv); @@ -3351,7 +3119,7 @@ static void test_SHGetIDListFromObject(void) if(SUCCEEDED(hres)) { ok(ILIsEqual(pidl_desktop, pidl), "pidl not equal.\n"); - pILFree(pidl); + ILFree(pidl); } /* Test IDataObject */ @@ -3378,7 +3146,7 @@ static void test_SHGetIDListFromObject(void) ok(hres == S_OK, "got 0x%08x\n", hres); ok(pidl != NULL, "pidl is NULL.\n"); ok(ILIsEqual(pidl, apidl[0]), "pidl not equal.\n"); - pILFree(pidl); + ILFree(pidl); IDataObject_Release(pdo); } @@ -3406,7 +3174,7 @@ static void test_SHGetIDListFromObject(void) skip("zero or one file found - skipping multi-file test.\n"); for(i = 0; i < count; i++) - pILFree(apidl[i]); + ILFree(apidl[i]); IEnumIDList_Release(peidl); } @@ -3415,7 +3183,7 @@ static void test_SHGetIDListFromObject(void) } IShellFolder_Release(psfdesktop); - pILFree(pidl_desktop); + ILFree(pidl_desktop); } static void test_SHGetItemFromObject(void) @@ -3453,7 +3221,7 @@ static void test_SHGetItemFromObject(void) hres = pSHGetItemFromObject(NULL, &IID_IUnknown, (void**)&punk); ok(hres == E_NOINTERFACE, "Got 0x%08x\n", hres); - punkimpl = HeapAlloc(GetProcessHeap(), 0, sizeof(IUnknownImpl)); + punkimpl = heap_alloc(sizeof(*punkimpl)); punkimpl->IUnknown_iface.lpVtbl = &vt_IUnknown; punkimpl->ifaces = ifaces; punkimpl->unknown = 0; @@ -3471,7 +3239,7 @@ static void test_SHGetItemFromObject(void) "interface not requested.\n"); ok(!punkimpl->unknown, "Got %d unknown.\n", punkimpl->unknown); - HeapFree(GetProcessHeap(), 0, punkimpl); + heap_free(punkimpl); /* Test IShellItem */ hres = pSHGetItemFromObject((IUnknown*)psfdesktop, &IID_IShellItem, (void**)&psi); @@ -3508,8 +3276,6 @@ static void test_SHCreateShellItemArray(void) return; } - ok(pSHGetSpecialFolderLocation != NULL, "SHGetSpecialFolderLocation missing.\n"); - if(0) { /* Crashes under native */ @@ -3529,10 +3295,10 @@ static void test_SHCreateShellItemArray(void) hr = pSHCreateShellItemArray(NULL, pdesktopsf, 1, NULL, &psia); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); - pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl); + SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl); hr = pSHCreateShellItemArray(pidl, NULL, 0, NULL, &psia); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); - pILFree(pidl); + ILFree(pidl); GetCurrentDirectoryW(MAX_PATH, cTestDirW); myPathAddBackslashW(cTestDirW); @@ -3553,7 +3319,7 @@ static void test_SHCreateShellItemArray(void) if(FAILED(hr)) { skip("Failed to set up environment for SHCreateShellItemArray tests.\n"); - pILFree(pidl_testdir); + ILFree(pidl_testdir); Cleanup(); return; } @@ -3605,14 +3371,14 @@ static void test_SHCreateShellItemArray(void) if(SUCCEEDED(hr)) { ok(ILIsEqual(pidl_abs, pidl), "Pidl not equal.\n"); - pILFree(pidl); + ILFree(pidl); } IShellItem_Release(psi); } - pILFree(pidl_abs); + ILFree(pidl_abs); } for(i = 0; i < done; i++) - pILFree(apidl[i]); + ILFree(apidl[i]); IShellItemArray_Release(psia); } } @@ -3657,8 +3423,8 @@ static void test_SHCreateShellItemArray(void) ok(hr == S_OK, "Got 0x%08x\n", hr); ok(pidl2 != NULL, "pidl2 was null.\n"); ok(ILIsEqual(pidl1, pidl2), "pidls not equal.\n"); - pILFree(pidl1); - pILFree(pidl2); + ILFree(pidl1); + ILFree(pidl2); IShellItem_Release(psi2); } hr = IShellItemArray_GetItemAt(psia, 1, &psi2); @@ -3733,10 +3499,10 @@ static void test_SHCreateShellItemArray(void) ok(hr == S_OK, "Got 0x%08x\n", hr); ok(pidl != NULL, "pidl as NULL.\n"); ok(ILIsEqual(pidl, pidl_abs), "pidls differ.\n"); - pILFree(pidl); + ILFree(pidl); IShellItem_Release(psi); } - pILFree(pidl_abs); + ILFree(pidl_abs); } IShellItemArray_Release(psia); @@ -3745,7 +3511,7 @@ static void test_SHCreateShellItemArray(void) IDataObject_Release(pdo); } for(i = 0; i < count; i++) - pILFree(apidl[i]); + ILFree(apidl[i]); } else skip("No files found - skipping test.\n"); @@ -3824,7 +3590,7 @@ static void test_SHCreateShellItemArray(void) WCHAR desktoppath[MAX_PATH]; BOOL result; - result = pSHGetSpecialFolderPathW(NULL, desktoppath, CSIDL_DESKTOPDIRECTORY, FALSE); + result = SHGetSpecialFolderPathW(NULL, desktoppath, CSIDL_DESKTOPDIRECTORY, FALSE); ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOPDIRECTORY) failed! %u\n", GetLastError()); hr = IShellItem_GetDisplayName(psi, SIGDN_DESKTOPABSOLUTEPARSING, &path); @@ -3929,7 +3695,7 @@ static void test_SHCreateShellItemArray(void) IShellItemArray_Release(psia); } - pILFree(pidltest1); + ILFree(pidltest1); } IShellFolder_Release(pdesktopsf); @@ -3938,7 +3704,7 @@ static void test_SHCreateShellItemArray(void) skip("No SHCreateShellItemArrayFromIDLists.\n"); IShellFolder_Release(psf); - pILFree(pidl_testdir); + ILFree(pidl_testdir); Cleanup(); } @@ -3972,7 +3738,7 @@ static void test_ShellItemArrayEnumItems(void) hr = IShellFolder_BindToObject(pdesktopsf, pidl_testdir, NULL, (REFIID)&IID_IShellFolder, (void**)&psf); ok(hr == S_OK, "Got 0x%08x\n", hr); - pILFree(pidl_testdir); + ILFree(pidl_testdir); } IShellFolder_Release(pdesktopsf); if (FAILED(hr)) return; @@ -4091,7 +3857,7 @@ static void test_ShellItemArrayEnumItems(void) } for(i = 0; i < done; i++) - pILFree(apidl[i]); + ILFree(apidl[i]); } } @@ -4108,7 +3874,7 @@ static void test_ShellItemBindToHandler(void) return; } - hr = pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop); + hr = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop); ok(hr == S_OK, "Got 0x%08x\n", hr); if(SUCCEEDED(hr)) { @@ -4143,7 +3909,7 @@ static void test_ShellItemBindToHandler(void) if(SUCCEEDED(hr)) { ok(ILIsEqual(pidl_desktop, pidl_tmp), "Pidl not equal (%p, %p)\n", pidl_desktop, pidl_tmp); - pILFree(pidl_tmp); + ILFree(pidl_tmp); } IPersistFolder2_Release(ppf2); } @@ -4257,7 +4023,7 @@ static void test_ShellItemBindToHandler(void) else skip("Failed to create ShellItem.\n"); - pILFree(pidl_desktop); + ILFree(pidl_desktop); } static void test_ShellItemGetAttributes(void) @@ -4278,13 +4044,13 @@ static void test_ShellItemGetAttributes(void) return; } - hr = pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop); + hr = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop); ok(hr == S_OK, "Got 0x%08x\n", hr); if(SUCCEEDED(hr)) { hr = pSHCreateShellItem(NULL, NULL, pidl_desktop, &psi); ok(hr == S_OK, "Got 0x%08x\n", hr); - pILFree(pidl_desktop); + ILFree(pidl_desktop); } if(FAILED(hr)) { @@ -4319,7 +4085,7 @@ static void test_ShellItemGetAttributes(void) ok(hr == S_OK, "got 0x%08x\n", hr); hr = pSHCreateShellItem(NULL, NULL, pidl, &psi_folder1); ok(hr == S_OK, "Got 0x%08x\n", sfgao); - pILFree(pidl); + ILFree(pidl); lstrcpyW(buf, curdirW); lstrcatW(buf, testfile1W); @@ -4327,7 +4093,7 @@ static void test_ShellItemGetAttributes(void) ok(hr == S_OK, "got 0x%08x\n", hr); hr = pSHCreateShellItem(NULL, NULL, pidl, &psi_file1); ok(hr == S_OK, "Got 0x%08x\n", sfgao); - pILFree(pidl); + ILFree(pidl); IShellFolder_Release(pdesktopsf); @@ -4402,7 +4168,7 @@ static void test_ShellItemArrayGetAttributes(void) ok(hr == S_OK, "got 0x%08x\n", hr); for(i = 0; i < 5; i++) - pILFree((LPITEMIDLIST)pidl_array[i]); + ILFree((LPITEMIDLIST)pidl_array[i]); /* [testfolder/, testfolder/testfolder2] seems to break in Vista */ attr = 0xdeadbeef; @@ -4480,71 +4246,65 @@ static void test_SHParseDisplayName(void) HRESULT hr; BOOL ret, is_wow64; - if (!pSHParseDisplayName) - { - win_skip("SHParseDisplayName isn't available\n"); - return; - } - if (0) { /* crashes on native */ - pSHParseDisplayName(NULL, NULL, NULL, 0, NULL); + SHParseDisplayName(NULL, NULL, NULL, 0, NULL); nameW[0] = 0; - pSHParseDisplayName(nameW, NULL, NULL, 0, NULL); + SHParseDisplayName(nameW, NULL, NULL, 0, NULL); } pidl1 = (LPITEMIDLIST)0xdeadbeef; - hr = pSHParseDisplayName(NULL, NULL, &pidl1, 0, NULL); + hr = SHParseDisplayName(NULL, NULL, &pidl1, 0, NULL); ok(broken(hr == E_OUTOFMEMORY) /* < Vista */ || hr == E_INVALIDARG, "failed %08x\n", hr); ok(pidl1 == 0, "expected null ptr, got %p\n", pidl1); /* dummy name */ nameW[0] = 0; - hr = pSHParseDisplayName(nameW, NULL, &pidl1, 0, NULL); + hr = SHParseDisplayName(nameW, NULL, &pidl1, 0, NULL); ok(hr == S_OK, "failed %08x\n", hr); hr = SHGetDesktopFolder(&desktop); ok(hr == S_OK, "failed %08x\n", hr); hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, nameW, NULL, &pidl2, NULL); ok(hr == S_OK, "failed %08x\n", hr); - ret = pILIsEqual(pidl1, pidl2); + ret = ILIsEqual(pidl1, pidl2); ok(ret == TRUE, "expected equal idls\n"); - pILFree(pidl1); - pILFree(pidl2); + ILFree(pidl1); + ILFree(pidl2); /* with path */ GetWindowsDirectoryW( dirW, MAX_PATH ); - hr = pSHParseDisplayName(dirW, NULL, &pidl1, 0, NULL); + hr = SHParseDisplayName(dirW, NULL, &pidl1, 0, NULL); ok(hr == S_OK, "failed %08x\n", hr); hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, dirW, NULL, &pidl2, NULL); ok(hr == S_OK, "failed %08x\n", hr); - ret = pILIsEqual(pidl1, pidl2); + ret = ILIsEqual(pidl1, pidl2); ok(ret == TRUE, "expected equal idls\n"); - pILFree(pidl1); - pILFree(pidl2); + ILFree(pidl1); + ILFree(pidl2); /* system32 is not redirected to syswow64 on WOW64 */ if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE; - if (is_wow64 && pGetSystemWow64DirectoryW) + if (is_wow64) { UINT len; *dirW = 0; len = GetSystemDirectoryW(dirW, MAX_PATH); ok(len > 0, "GetSystemDirectoryW failed: %u\n", GetLastError()); - hr = pSHParseDisplayName(dirW, NULL, &pidl1, 0, NULL); + hr = SHParseDisplayName(dirW, NULL, &pidl1, 0, NULL); ok(hr == S_OK, "failed %08x\n", hr); *dirW = 0; - len = pGetSystemWow64DirectoryW(dirW, MAX_PATH); + len = GetSystemWow64DirectoryW(dirW, MAX_PATH); ok(len > 0, "GetSystemWow64DirectoryW failed: %u\n", GetLastError()); - hr = pSHParseDisplayName(dirW, NULL, &pidl2, 0, NULL); + hr = SHParseDisplayName(dirW, NULL, &pidl2, 0, NULL); ok(hr == S_OK, "failed %08x\n", hr); - ret = pILIsEqual(pidl1, pidl2); + ret = ILIsEqual(pidl1, pidl2); ok(ret == FALSE, "expected different idls\n"); - pILFree(pidl1); - pILFree(pidl2); + ILFree(pidl1); + ILFree(pidl2); } IShellFolder_Release(desktop); @@ -4554,9 +4314,9 @@ if (0) skip("No empty cdrom drive found, skipping test\n"); else { - hr = pSHParseDisplayName(cdrom, NULL, &pidl1, 0, NULL); + hr = SHParseDisplayName(cdrom, NULL, &pidl1, 0, NULL); ok(hr == S_OK, "failed %08x\n", hr); - if (SUCCEEDED(hr)) pILFree(pidl1); + if (SUCCEEDED(hr)) ILFree(pidl1); } } @@ -4572,7 +4332,7 @@ static void test_desktop_IPersist(void) ok(hr == S_OK, "failed %08x\n", hr); hr = IShellFolder_QueryInterface(desktop, &IID_IPersist, (void**)&persist); - ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* NT4, W9X */, "failed %08x\n", hr); + ok(hr == S_OK, "failed %08x\n", hr); if (hr == S_OK) { @@ -4608,7 +4368,7 @@ static void test_desktop_IPersist(void) hr = IPersistFolder2_GetCurFolder(ppf2, &pidl); ok(hr == S_OK, "got %08x\n", hr); ok(pidl != NULL, "pidl was NULL.\n"); - if(SUCCEEDED(hr)) pILFree(pidl); + if(SUCCEEDED(hr)) ILFree(pidl); IPersistFolder2_Release(ppf2); } @@ -4616,6 +4376,103 @@ static void test_desktop_IPersist(void) IShellFolder_Release(desktop); } +static void test_contextmenu_qi(IContextMenu *menu, BOOL todo) +{ + IUnknown *unk; + HRESULT hr; + + hr = IContextMenu_QueryInterface(menu, &IID_IShellExtInit, (void **)&unk); +todo_wine_if(todo) + ok(hr == S_OK, "Failed to get IShellExtInit, hr %#x.\n", hr); +if (hr == S_OK) + IUnknown_Release(unk); + + hr = IContextMenu_QueryInterface(menu, &IID_IObjectWithSite, (void **)&unk); +todo_wine_if(todo) + ok(hr == S_OK, "Failed to get IShellExtInit, hr %#x.\n", hr); +if (hr == S_OK) + IUnknown_Release(unk); +} + +static void test_contextmenu(IContextMenu *menu, BOOL background) +{ + HMENU hmenu = CreatePopupMenu(); + const int id_upper_limit = 32767; + const int baseItem = 0x40; + INT max_id, max_id_check; + UINT count, i; + HRESULT hr; + + test_contextmenu_qi(menu, FALSE); + + hr = IContextMenu_QueryContextMenu(menu, hmenu, 0, baseItem, id_upper_limit, CMF_NORMAL); + ok(SUCCEEDED(hr), "Failed to query the menu, hr %#x.\n", hr); + + max_id = HRESULT_CODE(hr) - 1; /* returns max_id + 1 */ + ok(max_id <= id_upper_limit, "Got %d\n", max_id); + count = GetMenuItemCount(hmenu); + ok(count, "Got %d\n", count); + + max_id_check = 0; + for (i = 0; i < count; i++) + { + MENUITEMINFOA mii; + INT res; + char buf[255], buf2[255]; + ZeroMemory(&mii, sizeof(MENUITEMINFOA)); + mii.cbSize = sizeof(MENUITEMINFOA); + mii.fMask = MIIM_ID | MIIM_FTYPE | MIIM_STRING; + mii.dwTypeData = buf2; + mii.cch = sizeof(buf2); + + res = GetMenuItemInfoA(hmenu, i, TRUE, &mii); + ok(res, "Failed to get menu item info, error %d.\n", GetLastError()); + + ok((mii.wID <= id_upper_limit) || (mii.fType & MFT_SEPARATOR), + "Got non-separator ID out of range: %d (type: %x)\n", mii.wID, mii.fType); + if (!(mii.fType & MFT_SEPARATOR)) + { + max_id_check = (mii.wID > max_id_check) ? mii.wID : max_id_check; + hr = IContextMenu_GetCommandString(menu, mii.wID - baseItem, GCS_VERBA, 0, buf, sizeof(buf)); + todo_wine_if(background) + ok(SUCCEEDED(hr) || hr == E_NOTIMPL, "for id 0x%x got 0x%08x (menustr: %s)\n", mii.wID - baseItem, hr, mii.dwTypeData); + if (SUCCEEDED(hr)) + trace("for id 0x%x got string %s (menu string: %s)\n", mii.wID - baseItem, buf, mii.dwTypeData); + else if (hr == E_NOTIMPL) + trace("for id 0x%x got E_NOTIMPL (menu string: %s)\n", mii.wID - baseItem, mii.dwTypeData); + } + } + max_id_check -= baseItem; + ok((max_id_check == max_id) || + (max_id_check == max_id-1) || /* Win 7 */ + (max_id_check == max_id-2) || /* Win 8 */ + (max_id_check == max_id-3), + "Not equal (or near equal), got %d and %d\n", max_id_check, max_id); + + if (count) + { + CMINVOKECOMMANDINFO cmi; + + memset(&cmi, 0, sizeof(CMINVOKECOMMANDINFO)); + cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); + + /* Attempt to execute a nonexistent command */ + cmi.lpVerb = MAKEINTRESOURCEA(9999); + hr = IContextMenu_InvokeCommand(menu, &cmi); + todo_wine_if(background) + ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr); + + cmi.lpVerb = "foobar_wine_test"; + hr = IContextMenu_InvokeCommand(menu, &cmi); + todo_wine_if(background) + ok((hr == E_INVALIDARG) || (hr == E_FAIL /* Win7 */) || + (hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Vista */), + "Unexpected hr %#x.\n", hr); + } + + DestroyMenu(hmenu); +} + static void test_GetUIObject(void) { IShellFolder *psf_desktop; @@ -4625,12 +4482,8 @@ static void test_GetUIObject(void) WCHAR path[MAX_PATH]; const WCHAR filename[] = {'\\','t','e','s','t','d','i','r','\\','t','e','s','t','1','.','t','x','t',0}; - - if(!pSHBindToParent) - { - win_skip("SHBindToParent missing.\n"); - return; - } + LPCITEMIDLIST pidl_child; + IShellFolder *psf; GetCurrentDirectoryW(MAX_PATH, path); if (!path[0]) @@ -4644,95 +4497,25 @@ static void test_GetUIObject(void) CreateFilesFolders(); hr = IShellFolder_ParseDisplayName(psf_desktop, NULL, NULL, path, NULL, &pidl, 0); - ok(hr == S_OK || broken(hr == E_FAIL) /* WinME */, "Got 0x%08x\n", hr); - if(SUCCEEDED(hr)) - { - IShellFolder *psf; - LPCITEMIDLIST pidl_child; - hr = pSHBindToParent(pidl, &IID_IShellFolder, (void**)&psf, &pidl_child); - ok(hr == S_OK, "Got 0x%08x\n", hr); - if(SUCCEEDED(hr)) - { - hr = IShellFolder_GetUIObjectOf(psf, NULL, 1, &pidl_child, &IID_IContextMenu, NULL, - (void**)&pcm); - ok(hr == S_OK, "Got 0x%08x\n", hr); - if(SUCCEEDED(hr)) - { - const int baseItem = 0x40; - HMENU hmenu = CreatePopupMenu(); - INT max_id, max_id_check; - UINT count, i; - const int id_upper_limit = 32767; - hr = IContextMenu_QueryContextMenu(pcm, hmenu, 0, baseItem, id_upper_limit, CMF_NORMAL); - ok(SUCCEEDED(hr), "Got 0x%08x\n", hr); - max_id = HRESULT_CODE(hr) - 1; /* returns max_id + 1 */ - ok(max_id <= id_upper_limit, "Got %d\n", max_id); - count = GetMenuItemCount(hmenu); - ok(count, "Got %d\n", count); - - max_id_check = 0; - for(i = 0; i < count; i++) - { - MENUITEMINFOA mii; - INT res; - char buf[255], buf2[255]; - ZeroMemory(&mii, sizeof(MENUITEMINFOA)); - mii.cbSize = sizeof(MENUITEMINFOA); - mii.fMask = MIIM_ID | MIIM_FTYPE | MIIM_STRING; - mii.dwTypeData = buf2; - mii.cch = sizeof(buf2); - - SetLastError(0); - res = GetMenuItemInfoA(hmenu, i, TRUE, &mii); - ok(res, "Failed (last error: %d).\n", GetLastError()); - - ok( (mii.wID <= id_upper_limit) || (mii.fType & MFT_SEPARATOR), - "Got non-separator ID out of range: %d (type: %x)\n", mii.wID, mii.fType); - if(!(mii.fType & MFT_SEPARATOR)) - { - max_id_check = (mii.wID>max_id_check)?mii.wID:max_id_check; - hr = IContextMenu_GetCommandString(pcm, mii.wID - baseItem, GCS_VERBA, 0, buf, sizeof(buf)); - ok(SUCCEEDED(hr) || hr == E_NOTIMPL, "for id 0x%x got 0x%08x (menustr: %s)\n", mii.wID - baseItem, hr, mii.dwTypeData); - if (SUCCEEDED(hr)) - trace("for id 0x%x got string %s (menu string: %s)\n", mii.wID - baseItem, buf, mii.dwTypeData); - else if (hr == E_NOTIMPL) - trace("for id 0x%x got E_NOTIMPL (menu string: %s)\n", mii.wID - baseItem, mii.dwTypeData); - } - } - max_id_check -= baseItem; - ok((max_id_check == max_id) || - (max_id_check == max_id-1) || /* Win 7 */ - (max_id_check == max_id-2), /* Win 8 */ - "Not equal (or near equal), got %d and %d\n", max_id_check, max_id); + ok(hr == S_OK, "Got 0x%08x\n", hr); -#define is_win2k() (pSHGetFolderPathA && !pSHGetFolderPathAndSubDirA) + hr = SHBindToParent(pidl, &IID_IShellFolder, (void **)&psf, &pidl_child); + ok(hr == S_OK, "Failed to bind to folder, hr %#x.\n", hr); - if(count && !is_win2k()) /* Test is interactive on w2k, so skip */ - { - CMINVOKECOMMANDINFO cmi; - ZeroMemory(&cmi, sizeof(CMINVOKECOMMANDINFO)); - cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); - - /* Attempt to execute a nonexistent command */ - cmi.lpVerb = MAKEINTRESOURCEA(9999); - hr = IContextMenu_InvokeCommand(pcm, &cmi); - ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr); - - cmi.lpVerb = "foobar_wine_test"; - hr = IContextMenu_InvokeCommand(pcm, &cmi); - ok( (hr == E_INVALIDARG) || (hr == E_FAIL /* Win7 */) || - (hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Vista */), - "Got 0x%08x\n", hr); - } -#undef is_win2k + /* Item menu */ + hr = IShellFolder_GetUIObjectOf(psf, NULL, 1, &pidl_child, &IID_IContextMenu, NULL, (void **)&pcm); + ok(hr == S_OK, "GetUIObjectOf() failed, hr %#x.\n", hr); + test_contextmenu(pcm, FALSE); + IContextMenu_Release(pcm); - DestroyMenu(hmenu); - IContextMenu_Release(pcm); - } - IShellFolder_Release(psf); - } - if(pILFree) pILFree(pidl); - } + /* Background menu */ + hr = IShellFolder_GetUIObjectOf(psf_desktop, NULL, 0, NULL, &IID_IContextMenu, NULL, (void **)&pcm); + ok(hr == S_OK, "GetUIObjectOf() failed, hr %#x.\n", hr); + test_contextmenu(pcm, TRUE); + IContextMenu_Release(pcm); + + IShellFolder_Release(psf); + ILFree(pidl); IShellFolder_Release(psf_desktop); Cleanup(); @@ -4746,22 +4529,13 @@ static void r_verify_pidl(unsigned l, LPCITEMIDLIST pidl, const WCHAR *path) STRRET filename; HRESULT hr; - if(!pSHBindToParent){ - win_skip("SHBindToParent is not available, not performing full PIDL verification\n"); - if(path) - ok_(__FILE__,l)(pidl != NULL, "Expected PIDL to be non-NULL\n"); - else - ok_(__FILE__,l)(pidl == NULL, "Expected PIDL to be NULL\n"); - return; - } - if(path){ if(!pidl){ ok_(__FILE__,l)(0, "didn't get expected path (%s), instead: NULL\n", wine_dbgstr_w(path)); return; } - hr = pSHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&parent, &child); + hr = SHBindToParent(pidl, &IID_IShellFolder, (void **)&parent, &child); ok_(__FILE__,l)(hr == S_OK, "SHBindToParent failed: 0x%08x\n", hr); if(FAILED(hr)) return; @@ -4799,30 +4573,25 @@ static void test_SHSimpleIDListFromPath(void) LPITEMIDLIST pidl = NULL; ... 619 lines suppressed ...
6 years, 8 months
1
0
0
0
01/01: [SETUPAPI_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cdd41ac6c4c84da5fc533…
commit cdd41ac6c4c84da5fc533c7e015b9d5bf971590a Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:47:12 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:47:12 2018 +0100 [SETUPAPI_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/setupapi/CMakeLists.txt | 2 +- modules/rostests/winetests/setupapi/devinst.c | 3 +- modules/rostests/winetests/setupapi/install.c | 182 +++++---------------- 3 files changed, 47 insertions(+), 140 deletions(-) diff --git a/modules/rostests/winetests/setupapi/CMakeLists.txt b/modules/rostests/winetests/setupapi/CMakeLists.txt index 0dafc11c19..341ffe85fa 100644 --- a/modules/rostests/winetests/setupapi/CMakeLists.txt +++ b/modules/rostests/winetests/setupapi/CMakeLists.txt @@ -13,5 +13,5 @@ list(APPEND SOURCE add_executable(setupapi_winetest ${SOURCE} setupapi.rc) set_module_type(setupapi_winetest win32cui) -add_importlibs(setupapi_winetest advapi32 setupapi user32 msvcrt kernel32 ntdll) +add_importlibs(setupapi_winetest advapi32 setupapi user32 shell32 msvcrt kernel32 ntdll) add_rostests_file(TARGET setupapi_winetest) diff --git a/modules/rostests/winetests/setupapi/devinst.c b/modules/rostests/winetests/setupapi/devinst.c index 91ca61319e..bdf664aadf 100644 --- a/modules/rostests/winetests/setupapi/devinst.c +++ b/modules/rostests/winetests/setupapi/devinst.c @@ -1417,8 +1417,6 @@ START_TEST(devinst) testRegisterAndGetDetail(); testDeviceRegistryPropertyA(); testDeviceRegistryPropertyW(); - testSetupDiGetClassDevsA(); - if (!winetest_interactive) { win_skip("testSetupDiGetINFClassA(), ROSTESTS-66.\n"); @@ -1427,4 +1425,5 @@ START_TEST(devinst) { testSetupDiGetINFClassA(); } + testSetupDiGetClassDevsA(); } diff --git a/modules/rostests/winetests/setupapi/install.c b/modules/rostests/winetests/setupapi/install.c index 3ca7f26acf..72d16a1020 100644 --- a/modules/rostests/winetests/setupapi/install.c +++ b/modules/rostests/winetests/setupapi/install.c @@ -39,23 +39,16 @@ static const WCHAR inffileW[] = {'t','e','s','t','.','i','n','f',0}; static char CURR_DIR[MAX_PATH]; /* Notes on InstallHinfSectionA/W: - * - InstallHinfSectionW on Win98 and InstallHinfSectionA on WinXP seem to be stubs - they do not do anything - * and simply return without displaying any error message or setting last error. We test whether - * InstallHinfSectionA sets last error, and if it doesn't we set it to NULL and use the W version if available. - * - These functions do not return a value and do not always set last error to ERROR_SUCCESS when installation still - * occurs (e.g., unquoted inf file with spaces, registry keys are written but last error is 6). Also, on Win98 last error - * is set to ERROR_SUCCESS even if install fails (e.g., quoted inf file with spaces, no registry keys set, MessageBox with - * "Installation Error" displayed). Thus, we must use functional tests (e.g., is registry key created) to determine whether - * or not installation occurred. - * - On installation problems, a MessageBox() is displayed and a Beep() is issued. The MessageBox() is disabled with a - * CBT hook. + * - InstallHinfSectionA on WinXP seems to be a stub - it does not do anything + * and simply returns without displaying any error message or setting last + * error. + * - These functions do not return a value and do not always set last error to + * ERROR_SUCCESS when installation still occurs (e.g., unquoted inf file with + * spaces, registry keys are written but last error is 6). + * - On installation problems, a MessageBox() is displayed and a Beep() is + * issued. The MessageBox() is disabled with a CBT hook. */ -static void (WINAPI *pInstallHinfSectionA)(HWND, HINSTANCE, LPCSTR, INT); -static void (WINAPI *pInstallHinfSectionW)(HWND, HINSTANCE, LPCWSTR, INT); -static BOOL (WINAPI *pSetupGetInfFileListA)(PCSTR, DWORD, PSTR, DWORD, PDWORD); -static BOOL (WINAPI *pSetupGetInfFileListW)(PCWSTR, DWORD, PWSTR, DWORD, PDWORD); - /* * Helpers */ @@ -93,15 +86,11 @@ static const char *cmdline_inf = "[Version]\n" static void run_cmdline(LPCSTR section, int mode, LPCSTR path) { CHAR cmdline[MAX_PATH * 2]; + WCHAR cmdlinew[MAX_PATH * 2]; sprintf(cmdline, "%s %d %s", section, mode, path); - if (pInstallHinfSectionA) pInstallHinfSectionA(NULL, NULL, cmdline, 0); - else - { - WCHAR cmdlinew[MAX_PATH * 2]; - MultiByteToWideChar(CP_ACP, 0, cmdline, -1, cmdlinew, MAX_PATH*2); - pInstallHinfSectionW(NULL, NULL, cmdlinew, 0); - } + MultiByteToWideChar(CP_ACP, 0, cmdline, -1, cmdlinew, MAX_PATH*2); + InstallHinfSectionW(NULL, NULL, cmdlinew, 0); } static void ok_registry(BOOL expectsuccess) @@ -193,17 +182,6 @@ static void test_install_svc_from(void) BOOL ret; SC_HANDLE scm_handle, svc_handle; - /* Bail out if we are on win98 */ - SetLastError(0xdeadbeef); - scm_handle = OpenSCManagerA(NULL, NULL, GENERIC_ALL); - - if (!scm_handle && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) - { - win_skip("OpenSCManagerA is not implemented, we are most likely on win9x\n"); - return; - } - CloseServiceHandle(scm_handle); - /* Basic inf file to satisfy SetupOpenInfFileA */ strcpy(inf, "[Version]\nSignature=\"$Chicago$\"\n"); create_inf_file(inffile, inf); @@ -365,16 +343,10 @@ static void test_driver_install(void) "[Winetest.DriverFiles]\n" "winetest.sys"; - /* Bail out if we are on win98 */ + /* Bail out if we don't have enough rights */ SetLastError(0xdeadbeef); scm_handle = OpenSCManagerA(NULL, NULL, GENERIC_ALL); - - if (!scm_handle && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) - { - win_skip("OpenSCManagerA is not implemented, we are most likely on win9x\n"); - return; - } - else if (!scm_handle && (GetLastError() == ERROR_ACCESS_DENIED)) + if (!scm_handle && (GetLastError() == ERROR_ACCESS_DENIED)) { skip("Not enough rights to install the service\n"); return; @@ -421,8 +393,6 @@ static void test_driver_install(void) static void test_profile_items(void) { char path[MAX_PATH], commonprogs[MAX_PATH]; - HMODULE hShell32; - BOOL (WINAPI *pSHGetFolderPathA)(HWND hwnd, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath); static const char *inf = "[Version]\n" @@ -440,15 +410,7 @@ static void test_profile_items(void) "Name=TestGroup,4\n" ; - hShell32 = LoadLibraryA("shell32"); - pSHGetFolderPathA = (void*)GetProcAddress(hShell32, "SHGetFolderPathA"); - if (!pSHGetFolderPathA) - { - win_skip("SHGetFolderPathA is not available\n"); - goto cleanup; - } - - if (S_OK != pSHGetFolderPathA(NULL, CSIDL_COMMON_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, commonprogs)) + if (S_OK != SHGetFolderPathA(NULL, CSIDL_COMMON_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, commonprogs)) { skip("No common program files directory exists\n"); goto cleanup; @@ -467,19 +429,12 @@ static void test_profile_items(void) run_cmdline("DefaultInstall", 128, path); snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs); - if (INVALID_FILE_ATTRIBUTES == GetFileAttributesA(path)) - { - win_skip("ProfileItems not implemented on this system\n"); - } - else - { - snprintf(path, MAX_PATH, "%s\\TestDir", commonprogs); - ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "directory not created\n"); - snprintf(path, MAX_PATH, "%s\\TestDir\\TestItem2.lnk", commonprogs); - ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "link not created\n"); - snprintf(path, MAX_PATH, "%s\\TestGroup", commonprogs); - ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "group not created\n"); - } + snprintf(path, MAX_PATH, "%s\\TestDir", commonprogs); + ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "directory not created\n"); + snprintf(path, MAX_PATH, "%s\\TestDir\\TestItem2.lnk", commonprogs); + ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "link not created\n"); + snprintf(path, MAX_PATH, "%s\\TestGroup", commonprogs); + ok(INVALID_FILE_ATTRIBUTES != GetFileAttributesA(path), "group not created\n"); snprintf(path, MAX_PATH, "%s\\TestItem.lnk", commonprogs); DeleteFileA(path); @@ -493,7 +448,6 @@ static void test_profile_items(void) RemoveDirectoryA(path); cleanup: - if (hShell32) FreeLibrary(hShell32); DeleteFileA(inffile); } @@ -509,12 +463,6 @@ static void test_inffilelistA(void) DWORD expected, outsize; BOOL ret; - if(!pSetupGetInfFileListA) - { - win_skip("SetupGetInfFileListA not present\n"); - return; - } - /* create a private directory, the temp directory may contain some * inf files left over from old installations */ @@ -541,8 +489,8 @@ static void test_inffilelistA(void) /* mixed style */ expected = 3 + strlen(inffile) + strlen(inffile2); - ret = pSetupGetInfFileListA(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer, - MAX_PATH, &outsize); + ret = SetupGetInfFileListA(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer, + MAX_PATH, &outsize); ok(ret, "expected SetupGetInfFileListA to succeed!\n"); ok(expected == outsize, "expected required buffersize to be %d, got %d\n", expected, outsize); @@ -579,30 +527,19 @@ static void test_inffilelist(void) DWORD expected, outsize; BOOL ret; - if(!pSetupGetInfFileListW) - { - win_skip("SetupGetInfFileListW not present\n"); - return; - } - /* NULL means %windir%\\inf * get the value as reference */ expected = 0; SetLastError(0xdeadbeef); - ret = pSetupGetInfFileListW(NULL, INF_STYLE_WIN4, NULL, 0, &expected); - if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) - { - win_skip("SetupGetInfFileListW not implemented\n"); - return; - } + ret = SetupGetInfFileListW(NULL, INF_STYLE_WIN4, NULL, 0, &expected); ok(ret, "expected SetupGetInfFileListW to succeed! Error: %d\n", GetLastError()); ok(expected > 0, "expected required buffersize to be at least 1\n"); /* check if an empty string doesn't behaves like NULL */ outsize = 0; SetLastError(0xdeadbeef); - ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); + ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); ok(!ret, "expected SetupGetInfFileListW to fail!\n"); /* create a private directory, the temp directory may contain some @@ -632,7 +569,7 @@ static void test_inffilelist(void) MultiByteToWideChar(CP_ACP, 0, "\\not_existent", -1, ptr, MAX_PATH - lstrlenW(dir)); outsize = 0xffffffff; SetLastError(0xdeadbeef); - ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); + ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(outsize == 1, "expected required buffersize to be 1, got %d\n", outsize); ok(ERROR_PATH_NOT_FOUND == GetLastError(), @@ -648,7 +585,7 @@ static void test_inffilelist(void) MultiByteToWideChar(CP_ACP, 0, invalid_inf, -1, ptr+1, MAX_PATH - lstrlenW(dir)); outsize = 0xffffffff; SetLastError(0xdeadbeef); - ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); + ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); ok(!ret, "expected SetupGetInfFileListW to fail!\n"); ok(ERROR_DIRECTORY == GetLastError(), "expected error ERROR_DIRECTORY, got %d\n", GetLastError()); @@ -658,7 +595,7 @@ static void test_inffilelist(void) dir[1 + lstrlenW(dir)] = 0; dir[lstrlenW(dir)] = '\\'; SetLastError(0xdeadbeef); - ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); + ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize); ok(!ret, "expected SetupGetInfFileListW to fail!\n"); ok(ERROR_DIRECTORY == GetLastError(), "expected error ERROR_DIRECTORY, got %d\n", GetLastError()); @@ -667,7 +604,7 @@ static void test_inffilelist(void) */ *ptr = 0; expected = 3 + strlen(inffile) + strlen(inffile2); - ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize); + ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize); ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(expected == outsize, "expected required buffersize to be %d, got %d\n", expected, outsize); @@ -678,7 +615,7 @@ static void test_inffilelist(void) /* upper case value */ create_inf_file(inffile2, inf2); - ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize); + ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize); ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(expected == outsize, "expected required buffersize to be %d, got %d\n", expected, outsize); @@ -690,7 +627,7 @@ static void test_inffilelist(void) */ create_inf_file(inffile2, infNT); expected = 3 + strlen(inffile) + strlen(inffile2); - ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize); + ret = SetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize); ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(expected == outsize, "expected required buffersize to be %d, got %d\n", expected, outsize); @@ -701,7 +638,7 @@ static void test_inffilelist(void) /* old style */ expected = 2 + strlen(invalid_inf); - ret = pSetupGetInfFileListW(dir, INF_STYLE_OLDNT, buffer, MAX_PATH, &outsize); + ret = SetupGetInfFileListW(dir, INF_STYLE_OLDNT, buffer, MAX_PATH, &outsize); ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(expected == outsize, "expected required buffersize to be %d, got %d\n", expected, outsize); @@ -711,8 +648,8 @@ static void test_inffilelist(void) /* mixed style */ expected = 4 + strlen(inffile) + strlen(inffile2) + strlen(invalid_inf); - ret = pSetupGetInfFileListW(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer, - MAX_PATH, &outsize); + ret = SetupGetInfFileListW(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer, + MAX_PATH, &outsize); ok(ret, "expected SetupGetInfFileListW to succeed!\n"); ok(expected == outsize, "expected required buffersize to be %d, got %d\n", expected, outsize); @@ -787,7 +724,6 @@ static void test_dirid(void) START_TEST(install) { - HMODULE hsetupapi = GetModuleHandleA("setupapi.dll"); char temp_path[MAX_PATH], prev_path[MAX_PATH]; DWORD len; @@ -800,49 +736,21 @@ START_TEST(install) if(len && (CURR_DIR[len - 1] == '\\')) CURR_DIR[len - 1] = 0; - pInstallHinfSectionA = (void *)GetProcAddress(hsetupapi, "InstallHinfSectionA"); - pInstallHinfSectionW = (void *)GetProcAddress(hsetupapi, "InstallHinfSectionW"); - pSetupGetInfFileListA = (void *)GetProcAddress(hsetupapi, "SetupGetInfFileListA"); - pSetupGetInfFileListW = (void *)GetProcAddress(hsetupapi, "SetupGetInfFileListW"); + /* Set CBT hook to disallow MessageBox creation in current thread */ + hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId()); + assert(hhook != 0); - if (pInstallHinfSectionA) - { - /* Check if pInstallHinfSectionA sets last error or is a stub (as on WinXP) */ - static const char *minimal_inf = "[Version]\nSignature=\"$Chicago$\"\n"; - char cmdline[MAX_PATH*2]; - BOOL ret; - create_inf_file(inffile, minimal_inf); - sprintf(cmdline, "DefaultInstall 128 %s\\%s", CURR_DIR, inffile); - SetLastError(0xdeadbeef); - pInstallHinfSectionA(NULL, NULL, cmdline, 0); - if (GetLastError() == 0xdeadbeef) - { - skip("InstallHinfSectionA is broken (stub)\n"); - pInstallHinfSectionA = NULL; - } - ret = DeleteFileA(inffile); - ok(ret, "Expected source inf to exist, last error was %d\n", GetLastError()); - } - if (!pInstallHinfSectionW && !pInstallHinfSectionA) - win_skip("InstallHinfSectionA and InstallHinfSectionW are not available\n"); - else - { - /* Set CBT hook to disallow MessageBox creation in current thread */ - hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId()); - assert(hhook != 0); + test_cmdline(); + test_registry(); + test_install_svc_from(); + test_driver_install(); + test_dirid(); - test_cmdline(); - test_registry(); - test_install_svc_from(); - test_driver_install(); - test_dirid(); + UnhookWindowsHookEx(hhook); - UnhookWindowsHookEx(hhook); - - /* We have to run this test after the CBT hook is disabled because - ProfileItems needs to create a window on Windows XP. */ - test_profile_items(); - } + /* We have to run this test after the CBT hook is disabled because + ProfileItems needs to create a window on Windows XP. */ + test_profile_items(); test_inffilelist(); test_inffilelistA();
6 years, 8 months
1
0
0
0
01/01: [SERVICES_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=340679bd1ab995106ab74…
commit 340679bd1ab995106ab7431a1cc856df717a427e Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:46:36 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:46:36 2018 +0100 [SERVICES_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/services/service.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/rostests/winetests/services/service.c b/modules/rostests/winetests/services/service.c index 98419497a5..728d515f85 100644 --- a/modules/rostests/winetests/services/service.c +++ b/modules/rostests/winetests/services/service.c @@ -561,6 +561,7 @@ static void test_runner(void (*p_run_test)(void)) WaitForSingleObject(thread, INFINITE); CloseHandle(event_handle); CloseHandle(pipe_handle); + CloseHandle(thread); } START_TEST(service)
6 years, 8 months
1
0
0
0
01/01: [SECUR32_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33b28635b42bdfe2a32d7…
commit 33b28635b42bdfe2a32d753e54a84b9f601fce23 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Tue Apr 3 13:45:57 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Tue Apr 3 13:45:57 2018 +0100 [SECUR32_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/secur32/negotiate.c | 3 - modules/rostests/winetests/secur32/ntlm.c | 2 - modules/rostests/winetests/secur32/schannel.c | 18 +++-- modules/rostests/winetests/secur32/secur32.c | 95 ++++++++++++++++++-------- 4 files changed, 80 insertions(+), 38 deletions(-) diff --git a/modules/rostests/winetests/secur32/negotiate.c b/modules/rostests/winetests/secur32/negotiate.c index 2f1228ced2..095aee6cb5 100644 --- a/modules/rostests/winetests/secur32/negotiate.c +++ b/modules/rostests/winetests/secur32/negotiate.c @@ -306,12 +306,9 @@ static void test_authentication(void) expected = sizeof(*pi) + lstrlenA(pi->Name) + 1 + lstrlenA(pi->Comment) + 1; got = HeapSize(GetProcessHeap(), 0, pi); -todo_wine ok( got == expected, "got %u, expected %u\n", got, expected ); eob = (char *)pi + expected; -todo_wine ok( pi->Name + lstrlenA(pi->Name) < eob, "Name doesn't fit into allocated block\n" ); -todo_wine ok( pi->Comment + lstrlenA(pi->Comment) < eob, "Comment doesn't fit into allocated block\n" ); status = FreeContextBuffer( pi ); diff --git a/modules/rostests/winetests/secur32/ntlm.c b/modules/rostests/winetests/secur32/ntlm.c index c060420a3f..b9fdf6f237 100644 --- a/modules/rostests/winetests/secur32/ntlm.c +++ b/modules/rostests/winetests/secur32/ntlm.c @@ -916,12 +916,10 @@ static void testAuth(ULONG data_rep, BOOL fake) memset(&info, 0, sizeof(info)); sec_status = QueryContextAttributesA(&client.ctxt, SECPKG_ATTR_NEGOTIATION_INFO, &info); -todo_wine ok(sec_status == SEC_E_OK, "QueryContextAttributesA returned %08x\n", sec_status); pi = info.PackageInfo; ok(info.NegotiationState == SECPKG_NEGOTIATION_COMPLETE, "got %u\n", info.NegotiationState); -todo_wine ok(pi != NULL, "expected non-NULL PackageInfo\n"); if (pi) { diff --git a/modules/rostests/winetests/secur32/schannel.c b/modules/rostests/winetests/secur32/schannel.c index 800edd3a7f..1a37c5226a 100644 --- a/modules/rostests/winetests/secur32/schannel.c +++ b/modules/rostests/winetests/secur32/schannel.c @@ -17,15 +17,15 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <stdio.h> + #include <stdarg.h> #include <windef.h> -#include <winbase.h> +#include <winsock2.h> +#include <ws2tcpip.h> +#include <stdio.h> #define SECURITY_WIN32 #include <security.h> #include <schannel.h> -#include <winsock2.h> -#include <ws2tcpip.h> #include "wine/test.h" @@ -772,7 +772,6 @@ todo_wine ISC_REQ_CONFIDENTIALITY|ISC_REQ_STREAM, 0, 0, &buffers[1], 0, NULL, &buffers[0], &attrs, NULL); ok(status == SEC_E_INVALID_TOKEN, "Expected SEC_E_INVALID_TOKEN, got %08x\n", status); -todo_wine ok(buffers[0].pBuffers[0].cbBuffer == 0, "Output buffer size was not set to 0.\n"); buffers[0].pBuffers[0].cbBuffer = 0; @@ -782,9 +781,15 @@ todo_wine todo_wine ok(status == SEC_E_INSUFFICIENT_MEMORY || status == SEC_E_INVALID_TOKEN, "Expected SEC_E_INSUFFICIENT_MEMORY or SEC_E_INVALID_TOKEN, got %08x\n", status); + ok(buffers[0].pBuffers[0].cbBuffer == 0, "Output buffer size was not set to 0.\n"); - buffers[0].pBuffers[0].cbBuffer = buf_size; + status = InitializeSecurityContextA(&cred_handle, NULL, (SEC_CHAR *)"localhost", + ISC_REQ_CONFIDENTIALITY|ISC_REQ_STREAM, + 0, 0, NULL, 0, &context, NULL, &attrs, NULL); +todo_wine + ok(status == SEC_E_INVALID_TOKEN, "Expected SEC_E_INVALID_TOKEN, got %08x\n", status); + buffers[0].pBuffers[0].cbBuffer = buf_size; status = InitializeSecurityContextA(&cred_handle, NULL, (SEC_CHAR *)"localhost", ISC_REQ_CONFIDENTIALITY|ISC_REQ_STREAM, 0, 0, NULL, 0, &context, &buffers[0], &attrs, NULL); @@ -859,6 +864,7 @@ todo_wine buffers[1].pBuffers[0].cbBuffer = buf_size; } + ok(buffers[0].pBuffers[0].cbBuffer == 0, "Output buffer size was not set to 0.\n"); ok(status == SEC_E_OK || broken(status == SEC_E_INVALID_TOKEN) /* WinNT */, "InitializeSecurityContext failed: %08x\n", status); if(status != SEC_E_OK) { diff --git a/modules/rostests/winetests/secur32/secur32.c b/modules/rostests/winetests/secur32/secur32.c index 96b8c5f4e0..40c272ada3 100644 --- a/modules/rostests/winetests/secur32/secur32.c +++ b/modules/rostests/winetests/secur32/secur32.c @@ -22,10 +22,13 @@ #include <windef.h> #include <winbase.h> #include <winnls.h> -#include <wincred.h> +#include <rpc.h> +#include <rpcdce.h> #define SECURITY_WIN32 #include <security.h> #include <schannel.h> +#include <wincred.h> +#include <winsock2.h> #include "wine/test.h" @@ -65,20 +68,40 @@ static void testGetComputerObjectNameA(void) UINT i; for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) { + size = 0; + SetLastError(0xdeadbeef); + rc = pGetComputerObjectNameA(formats[i], NULL, &size); + ok(!rc, "GetComputerObjectName(%u) should fail\n", formats[i]); + switch (formats[i]) + { + case NameUnknown: + ok(GetLastError() == ERROR_INVALID_PARAMETER, "%u: got %u\n", formats[i], GetLastError()); + break; + default: + ok(GetLastError() == ERROR_NONE_MAPPED || + GetLastError() == ERROR_NO_SUCH_USER || + GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO || + GetLastError() == ERROR_INSUFFICIENT_BUFFER, + "%u: got %u\n", formats[i], GetLastError()); + break; + } + + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) continue; + size = sizeof(name); - ZeroMemory(name, sizeof(name)); + SetLastError(0xdeadbeef); rc = pGetComputerObjectNameA(formats[i], name, &size); - ok(rc || ((formats[i] == NameUnknown) && - (GetLastError() == ERROR_INVALID_PARAMETER)) || - (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) || - (GetLastError() == ERROR_NO_SUCH_DOMAIN) || - (GetLastError() == ERROR_NO_SUCH_USER) || - (GetLastError() == ERROR_NONE_MAPPED) || - (GetLastError() == ERROR_ACCESS_DENIED), - "GetComputerObjectNameA(%d) failed: %d\n", - formats[i], GetLastError()); - if (rc) - trace("GetComputerObjectNameA() returned %s\n", name); + switch (formats[i]) + { + case NameUnknown: + ok(!rc, "GetComputerObjectName(%u) should fail\n", formats[i]); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "%u: got %u\n", formats[i], GetLastError()); + break; + default: + ok(rc, "GetComputerObjectName(%u) error %u\n", formats[i], GetLastError()); + trace("GetComputerObjectName(%u) returned %s\n", formats[i], name); + break; + } } } @@ -90,22 +113,40 @@ static void testGetComputerObjectNameW(void) UINT i; for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) { + size = 0; + SetLastError(0xdeadbeef); + rc = pGetComputerObjectNameW(formats[i], NULL, &size); + ok(!rc || broken(rc) /* win10 */, "GetComputerObjectName(%u) should fail\n", formats[i]); + switch (formats[i]) + { + case NameUnknown: + ok(GetLastError() == ERROR_INVALID_PARAMETER, "%u: got %u\n", formats[i], GetLastError()); + break; + default: + ok(GetLastError() == ERROR_NONE_MAPPED || + GetLastError() == ERROR_NO_SUCH_USER || + GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO || + GetLastError() == WSAHOST_NOT_FOUND || + GetLastError() == ERROR_INSUFFICIENT_BUFFER, + "%u: got %u\n", formats[i], GetLastError()); + break; + } + + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) continue; + size = sizeof(nameW)/sizeof(nameW[0]); - ZeroMemory(nameW, sizeof(nameW)); + SetLastError(0xdeadbeef); rc = pGetComputerObjectNameW(formats[i], nameW, &size); - ok(rc || ((formats[i] == NameUnknown) && - (GetLastError() == ERROR_INVALID_PARAMETER)) || - (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) || - (GetLastError() == ERROR_NO_SUCH_DOMAIN) || - (GetLastError() == ERROR_NO_SUCH_USER) || - (GetLastError() == ERROR_NONE_MAPPED) || - (GetLastError() == ERROR_ACCESS_DENIED), - "GetComputerObjectNameW(%d) failed: %d\n", - formats[i], GetLastError()); - if (rc) { - char name[256]; - WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, sizeof(name), NULL, NULL ); - trace("GetComputerObjectNameW() returned %s\n", name); + switch (formats[i]) + { + case NameUnknown: + ok(!rc, "GetComputerObjectName(%u) should fail\n", formats[i]); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "%u: got %u\n", formats[i], GetLastError()); + break; + default: + ok(rc, "GetComputerObjectName(%u) error %u\n", formats[i], GetLastError()); + trace("GetComputerObjectName(%u) returned %s\n", formats[i], wine_dbgstr_w(nameW)); + break; } } }
6 years, 8 months
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
...
25
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Results per page:
10
25
50
100
200