Commit e1c2a870 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

user32/tests: Drop broadcast test workarounds for Windows <= 2000.

parent 29e0230a
...@@ -33,10 +33,6 @@ ...@@ -33,10 +33,6 @@
typedef LONG (WINAPI *PBROADCAST)( DWORD,LPDWORD,UINT,WPARAM,LPARAM ); typedef LONG (WINAPI *PBROADCAST)( DWORD,LPDWORD,UINT,WPARAM,LPARAM );
typedef LONG (WINAPI *PBROADCASTEX)( DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO ); 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 HANDLE hevent;
static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
...@@ -59,20 +55,6 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR ...@@ -59,20 +55,6 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR
static BOOL init_procs(void) static BOOL init_procs(void)
{ {
WNDCLASSA cls; 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"); hevent = CreateEventA(NULL, TRUE, FALSE, "Asynchronous checking event");
...@@ -264,12 +246,8 @@ if (0) /* TODO: Check the hang flags */ ...@@ -264,12 +246,8 @@ if (0) /* TODO: Check the hang flags */
PulseEvent(hevent); 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) static void test_noprivileges(void)
{ {
HANDLE advapi32 = GetModuleHandleA("advapi32");
HANDLE token; HANDLE token;
DWORD recips; DWORD recips;
BOOL ret; BOOL ret;
...@@ -277,14 +255,12 @@ static void test_noprivileges(void) ...@@ -277,14 +255,12 @@ static void test_noprivileges(void)
static const DWORD BSM_ALL_RECIPS = BSM_VXDS | BSM_NETDRIVER | static const DWORD BSM_ALL_RECIPS = BSM_VXDS | BSM_NETDRIVER |
BSM_INSTALLABLEDRIVERS | BSM_APPLICATIONS; BSM_INSTALLABLEDRIVERS | BSM_APPLICATIONS;
pOpenProcessToken = (void *)GetProcAddress(advapi32, "OpenProcessToken"); if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
pAdjustTokenPrivileges = (void *)GetProcAddress(advapi32, "AdjustTokenPrivileges");
if (!pOpenProcessToken || !pAdjustTokenPrivileges || !pOpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
{ {
skip("Can't open security token for process\n"); skip("Can't open security token for process\n");
return; 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"); skip("Can't adjust security token for process\n");
return; return;
...@@ -294,7 +270,7 @@ static void test_noprivileges(void) ...@@ -294,7 +270,7 @@ static void test_noprivileges(void)
SetLastError(0xcafebabe); SetLastError(0xcafebabe);
recips = BSM_ALLDESKTOPS; recips = BSM_ALLDESKTOPS;
ResetEvent(hevent); 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(ret==1, "Returned: %d error %u\n", ret, GetLastError());
ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n");
ok(recips == BSM_ALLDESKTOPS || ok(recips == BSM_ALLDESKTOPS ||
...@@ -305,7 +281,7 @@ static void test_noprivileges(void) ...@@ -305,7 +281,7 @@ static void test_noprivileges(void)
SetLastError(0xcafebabe); SetLastError(0xcafebabe);
recips = BSM_ALLCOMPONENTS; recips = BSM_ALLCOMPONENTS;
ResetEvent(hevent); 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(ret==1, "Returned: %d error %u\n", ret, GetLastError());
ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n");
ok(recips == BSM_ALLCOMPONENTS || ok(recips == BSM_ALLCOMPONENTS ||
...@@ -316,7 +292,7 @@ static void test_noprivileges(void) ...@@ -316,7 +292,7 @@ static void test_noprivileges(void)
SetLastError(0xcafebabe); SetLastError(0xcafebabe);
recips = BSM_ALLDESKTOPS|BSM_APPLICATIONS; recips = BSM_ALLDESKTOPS|BSM_APPLICATIONS;
ResetEvent(hevent); 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(ret==1, "Returned: %d error %u\n", ret, GetLastError());
ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n");
ok(recips == (BSM_ALLDESKTOPS|BSM_APPLICATIONS) || ok(recips == (BSM_ALLDESKTOPS|BSM_APPLICATIONS) ||
...@@ -327,7 +303,7 @@ static void test_noprivileges(void) ...@@ -327,7 +303,7 @@ static void test_noprivileges(void)
SetLastError(0xcafebabe); SetLastError(0xcafebabe);
recips = BSM_ALLDESKTOPS|BSM_APPLICATIONS; recips = BSM_ALLDESKTOPS|BSM_APPLICATIONS;
ResetEvent(hevent); 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(!ret, "Returned: %d\n", ret);
ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n"); ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n");
ok(recips == (BSM_ALLDESKTOPS|BSM_APPLICATIONS) || ok(recips == (BSM_ALLDESKTOPS|BSM_APPLICATIONS) ||
...@@ -342,28 +318,17 @@ START_TEST(broadcast) ...@@ -342,28 +318,17 @@ START_TEST(broadcast)
return; return;
trace("Running BroadcastSystemMessageA tests\n"); trace("Running BroadcastSystemMessageA tests\n");
test_parameters(pBroadcastA, "BroadcastSystemMessageA"); test_parameters(BroadcastSystemMessageA, "BroadcastSystemMessageA");
if (pBroadcastW)
{ trace("Running BroadcastSystemMessageW tests\n");
trace("Running BroadcastSystemMessageW tests\n"); test_parameters(BroadcastSystemMessageW, "BroadcastSystemMessageW");
test_parameters(pBroadcastW, "BroadcastSystemMessageW");
} trace("Running BroadcastSystemMessageExA tests\n");
else test_parametersEx(BroadcastSystemMessageExA);
win_skip("No BroadcastSystemMessageW, skipping\n");
if (pBroadcastExA) trace("Running BroadcastSystemMessageExW tests\n");
{ test_parametersEx(BroadcastSystemMessageExW);
trace("Running BroadcastSystemMessageExA tests\n");
test_parametersEx(pBroadcastExA); trace("Attempting privileges checking tests\n");
} test_noprivileges();
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");
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment