user32/tests: Import functions if possible.
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5cf64084fb
commit
4fc651db92
|
@ -27,15 +27,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static HMODULE hdll;
|
||||
static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID);
|
||||
static LONG (WINAPI *pChangeDisplaySettingsExW)(LPCWSTR, LPDEVMODEW, HWND, DWORD, LPVOID);
|
||||
static BOOL (WINAPI *pEnumDisplayDevicesA)(LPCSTR,DWORD,LPDISPLAY_DEVICEA,DWORD);
|
||||
static BOOL (WINAPI *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
|
||||
static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
|
||||
static BOOL (WINAPI *pGetMonitorInfoW)(HMONITOR,LPMONITORINFO);
|
||||
static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
|
||||
static HMONITOR (WINAPI *pMonitorFromRect)(LPCRECT,DWORD);
|
||||
static HMONITOR (WINAPI *pMonitorFromWindow)(HWND,DWORD);
|
||||
static LONG (WINAPI *pGetDisplayConfigBufferSizes)(UINT32,UINT32*,UINT32*);
|
||||
|
||||
static void init_function_pointers(void)
|
||||
|
@ -47,16 +38,7 @@ static void init_function_pointers(void)
|
|||
if(!p ## func) \
|
||||
trace("GetProcAddress(%s) failed\n", #func);
|
||||
|
||||
GET_PROC(ChangeDisplaySettingsExA)
|
||||
GET_PROC(ChangeDisplaySettingsExW)
|
||||
GET_PROC(EnumDisplayDevicesA)
|
||||
GET_PROC(EnumDisplayMonitors)
|
||||
GET_PROC(GetDisplayConfigBufferSizes)
|
||||
GET_PROC(GetMonitorInfoA)
|
||||
GET_PROC(GetMonitorInfoW)
|
||||
GET_PROC(MonitorFromPoint)
|
||||
GET_PROC(MonitorFromRect)
|
||||
GET_PROC(MonitorFromWindow)
|
||||
|
||||
#undef GET_PROC
|
||||
}
|
||||
|
@ -69,7 +51,7 @@ static BOOL CALLBACK monitor_enum_proc(HMONITOR hmon, HDC hdc, LPRECT lprc,
|
|||
|
||||
mi.cbSize = sizeof(mi);
|
||||
|
||||
ok(pGetMonitorInfoA(hmon, (MONITORINFO*)&mi), "GetMonitorInfo failed\n");
|
||||
ok(GetMonitorInfoA(hmon, (MONITORINFO*)&mi), "GetMonitorInfo failed\n");
|
||||
if (mi.dwFlags & MONITORINFOF_PRIMARY)
|
||||
strcpy(primary, mi.szDevice);
|
||||
|
||||
|
@ -203,20 +185,14 @@ static void test_enumdisplaydevices(void)
|
|||
int monitor_index;
|
||||
BOOL ret;
|
||||
|
||||
if (!pEnumDisplayDevicesA)
|
||||
{
|
||||
win_skip("EnumDisplayDevicesA is not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Doesn't accept \\.\DISPLAY */
|
||||
dd.cb = sizeof(dd);
|
||||
ret = pEnumDisplayDevicesA("\\\\.\\DISPLAY", 0, &dd, 0);
|
||||
ret = EnumDisplayDevicesA("\\\\.\\DISPLAY", 0, &dd, 0);
|
||||
ok(!ret, "Expect failure\n");
|
||||
|
||||
/* Enumeration */
|
||||
for (flag_index = 0; flag_index < ARRAY_SIZE(flags); flag_index++)
|
||||
for (adapter_index = 0; pEnumDisplayDevicesA(NULL, adapter_index, &dd, flags[flag_index]); adapter_index++)
|
||||
for (adapter_index = 0; EnumDisplayDevicesA(NULL, adapter_index, &dd, flags[flag_index]); adapter_index++)
|
||||
{
|
||||
lstrcpyA(adapter_name, dd.DeviceName);
|
||||
|
||||
|
@ -228,7 +204,7 @@ static void test_enumdisplaydevices(void)
|
|||
|
||||
test_enumdisplaydevices_adapter(adapter_index, &dd, flags[flag_index]);
|
||||
|
||||
for (monitor_index = 0; pEnumDisplayDevicesA(adapter_name, monitor_index, &dd, flags[flag_index]);
|
||||
for (monitor_index = 0; EnumDisplayDevicesA(adapter_name, monitor_index, &dd, flags[flag_index]);
|
||||
monitor_index++)
|
||||
test_enumdisplaydevices_monitor(adapter_index, monitor_index, adapter_name, &dd, flags[flag_index]);
|
||||
}
|
||||
|
@ -237,18 +213,12 @@ static void test_enumdisplaydevices(void)
|
|||
/* XP on Testbot doesn't report a monitor, whereas XP on real machine does */
|
||||
ok(broken(monitor_count == 0) || monitor_count > 0, "Expect at least one monitor found\n");
|
||||
|
||||
if (!pEnumDisplayMonitors || !pGetMonitorInfoA)
|
||||
{
|
||||
win_skip("EnumDisplayMonitors or GetMonitorInfoA are not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pEnumDisplayDevicesA(NULL, 0, &dd, 0);
|
||||
ret = EnumDisplayDevicesA(NULL, 0, &dd, 0);
|
||||
ok(ret, "Expect success\n");
|
||||
lstrcpyA(primary_device_name, dd.DeviceName);
|
||||
|
||||
primary_monitor_device_name[0] = 0;
|
||||
ret = pEnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name);
|
||||
ret = EnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name);
|
||||
ok(ret, "EnumDisplayMonitors failed\n");
|
||||
ok(!strcmp(primary_monitor_device_name, primary_device_name),
|
||||
"monitor device name %s, device name %s\n", primary_monitor_device_name,
|
||||
|
@ -290,12 +260,6 @@ static void test_ChangeDisplaySettingsEx(void)
|
|||
LONG res;
|
||||
int i;
|
||||
|
||||
if (!pChangeDisplaySettingsExA)
|
||||
{
|
||||
win_skip("ChangeDisplaySettingsExA is not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
res = EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dm);
|
||||
ok(res, "EnumDisplaySettings error %u\n", GetLastError());
|
||||
|
@ -311,7 +275,7 @@ static void test_ChangeDisplaySettingsEx(void)
|
|||
|
||||
/* crashes under XP SP3 for large dmDriverExtra values */
|
||||
dm.dmDriverExtra = 1;
|
||||
res = pChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_TEST, NULL);
|
||||
res = ChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_TEST, NULL);
|
||||
ok(res == DISP_CHANGE_SUCCESSFUL,
|
||||
"ChangeDisplaySettingsExW returned %d, expected DISP_CHANGE_SUCCESSFUL\n", res);
|
||||
ok(dm.dmDriverExtra == 1, "ChangeDisplaySettingsExA shouldn't reset dmDriverExtra to 0\n");
|
||||
|
@ -333,7 +297,7 @@ static void test_ChangeDisplaySettingsEx(void)
|
|||
|
||||
/* Apparently XP treats dmDriverExtra being != 0 as an error */
|
||||
dmW.dmDriverExtra = 1;
|
||||
res = pChangeDisplaySettingsExW(NULL, &dmW, NULL, CDS_TEST, NULL);
|
||||
res = ChangeDisplaySettingsExW(NULL, &dmW, NULL, CDS_TEST, NULL);
|
||||
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
ok(res == DISP_CHANGE_SUCCESSFUL,
|
||||
|
@ -347,7 +311,7 @@ static void test_ChangeDisplaySettingsEx(void)
|
|||
memset(&dm, 0, sizeof(dm));
|
||||
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
dm.dmPelsWidth = width;
|
||||
res = pChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_TEST, NULL);
|
||||
res = ChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_TEST, NULL);
|
||||
ok(res == DISP_CHANGE_SUCCESSFUL ||
|
||||
res == DISP_CHANGE_BADMODE || /* Win98, WinMe */
|
||||
res == DISP_CHANGE_FAILED, /* NT4 */
|
||||
|
@ -357,7 +321,7 @@ static void test_ChangeDisplaySettingsEx(void)
|
|||
dmW.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
dmW.dmPelsWidth = width;
|
||||
SetLastError(0xdeadbeef);
|
||||
res = pChangeDisplaySettingsExW(NULL, &dmW, NULL, CDS_TEST, NULL);
|
||||
res = ChangeDisplaySettingsExW(NULL, &dmW, NULL, CDS_TEST, NULL);
|
||||
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
||||
ok(res == DISP_CHANGE_FAILED ||
|
||||
res == DISP_CHANGE_BADPARAM || /* NT4 */
|
||||
|
@ -374,7 +338,7 @@ static void test_ChangeDisplaySettingsEx(void)
|
|||
dm.dmBitsPerPel = vid_modes_test[i].bpp;
|
||||
dm.dmDisplayFrequency = vid_modes_test[i].freq;
|
||||
dm.dmFields = vid_modes_test[i].fields;
|
||||
res = pChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_TEST, NULL);
|
||||
res = ChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_TEST, NULL);
|
||||
ok(vid_modes_test[i].must_succeed ?
|
||||
(res == DISP_CHANGE_SUCCESSFUL || res == DISP_CHANGE_RESTART) :
|
||||
(res == DISP_CHANGE_SUCCESSFUL || res == DISP_CHANGE_RESTART ||
|
||||
|
@ -420,7 +384,7 @@ static void test_ChangeDisplaySettingsEx(void)
|
|||
ClipCursor(&virt);
|
||||
}
|
||||
}
|
||||
res = pChangeDisplaySettingsExA(NULL, NULL, NULL, CDS_RESET, NULL);
|
||||
res = ChangeDisplaySettingsExA(NULL, NULL, NULL, CDS_RESET, NULL);
|
||||
ok(res == DISP_CHANGE_SUCCESSFUL, "Failed to reset default resolution: %d\n", res);
|
||||
}
|
||||
|
||||
|
@ -464,76 +428,64 @@ static void test_monitors(void)
|
|||
{0xdeadbeef, FALSE},
|
||||
};
|
||||
|
||||
if (!pMonitorFromPoint || !pMonitorFromWindow || !pMonitorFromRect)
|
||||
{
|
||||
win_skip("MonitorFromPoint, MonitorFromWindow, or MonitorFromRect is not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pt.x = pt.y = 0;
|
||||
primary = pMonitorFromPoint( pt, MONITOR_DEFAULTTOPRIMARY );
|
||||
primary = MonitorFromPoint( pt, MONITOR_DEFAULTTOPRIMARY );
|
||||
ok( primary != 0, "couldn't get primary monitor\n" );
|
||||
|
||||
monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTONULL );
|
||||
monitor = MonitorFromWindow( 0, MONITOR_DEFAULTTONULL );
|
||||
ok( !monitor, "got %p, should not get a monitor for an invalid window\n", monitor );
|
||||
monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY );
|
||||
monitor = MonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY );
|
||||
ok( monitor == primary, "got %p, should get primary %p for MONITOR_DEFAULTTOPRIMARY\n", monitor, primary );
|
||||
monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTONEAREST );
|
||||
monitor = MonitorFromWindow( 0, MONITOR_DEFAULTTONEAREST );
|
||||
ok( monitor == primary, "got %p, should get primary %p for MONITOR_DEFAULTTONEAREST\n", monitor, primary );
|
||||
|
||||
SetRect( &rc, 0, 0, 1, 1 );
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
|
||||
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTOPRIMARY );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTOPRIMARY );
|
||||
ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
|
||||
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONEAREST );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTONEAREST );
|
||||
ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
|
||||
|
||||
/* Empty rect at 0,0 is considered inside the primary monitor */
|
||||
SetRect( &rc, 0, 0, -1, -1 );
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
|
||||
|
||||
/* Even if there is a monitor left of the primary, the primary will have the most overlapping area */
|
||||
SetRect( &rc, -1, 0, 2, 1 );
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
|
||||
|
||||
/* But the width of the rect doesn't matter if it's empty. */
|
||||
SetRect( &rc, -1, 0, 2, -1 );
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
ok( monitor != primary, "got primary %p\n", monitor );
|
||||
|
||||
if (!pGetMonitorInfoA)
|
||||
{
|
||||
win_skip("GetMonitorInfoA is not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Search for a monitor that has no others equally near to (left, top-1) */
|
||||
SetRect( &rc, -1, -2, 2, 0 );
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
nearest = primary;
|
||||
while (monitor != NULL)
|
||||
{
|
||||
ok( monitor != primary, "got primary %p\n", monitor );
|
||||
nearest = monitor;
|
||||
mi.cbSize = sizeof(mi);
|
||||
ret = pGetMonitorInfoA( monitor, &mi );
|
||||
ret = GetMonitorInfoA( monitor, &mi );
|
||||
ok( ret, "GetMonitorInfo failed\n" );
|
||||
SetRect( &rc, mi.rcMonitor.left-1, mi.rcMonitor.top-2, mi.rcMonitor.left+2, mi.rcMonitor.top );
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
}
|
||||
|
||||
/* tests for cbSize in MONITORINFO */
|
||||
monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY );
|
||||
monitor = MonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY );
|
||||
for (i = 0; i < ARRAY_SIZE(testdatami); i++)
|
||||
{
|
||||
memset( &mi, 0, sizeof(mi) );
|
||||
mi.cbSize = testdatami[i].cbSize;
|
||||
ret = pGetMonitorInfoA( monitor, &mi );
|
||||
ret = GetMonitorInfoA( monitor, &mi );
|
||||
ok( ret == testdatami[i].ret, "GetMonitorInfo returned wrong value\n" );
|
||||
if (ret)
|
||||
ok( (mi.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" );
|
||||
|
@ -542,7 +494,7 @@ static void test_monitors(void)
|
|||
|
||||
memset( &miexw, 0, sizeof(miexw) );
|
||||
miexw.cbSize = testdatamiexw[i].cbSize;
|
||||
ret = pGetMonitorInfoW( monitor, (LPMONITORINFO)&miexw );
|
||||
ret = GetMonitorInfoW( monitor, (LPMONITORINFO)&miexw );
|
||||
ok( ret == testdatamiexw[i].ret, "GetMonitorInfo returned wrong value\n" );
|
||||
if (ret)
|
||||
ok( (miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" );
|
||||
|
@ -555,7 +507,7 @@ static void test_monitors(void)
|
|||
{
|
||||
memset( &miexa, 0, sizeof(miexa) );
|
||||
miexa.cbSize = testdatamiexa[i].cbSize;
|
||||
ret = pGetMonitorInfoA( monitor, (LPMONITORINFO)&miexa );
|
||||
ret = GetMonitorInfoA( monitor, (LPMONITORINFO)&miexa );
|
||||
ok( ret == testdatamiexa[i].ret, "GetMonitorInfo returned wrong value\n" );
|
||||
if (ret)
|
||||
ok( (miexa.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" );
|
||||
|
@ -568,7 +520,7 @@ static void test_monitors(void)
|
|||
{
|
||||
memset( &miexw, 0, sizeof(miexw) );
|
||||
miexw.cbSize = testdatamiexw[i].cbSize;
|
||||
ret = pGetMonitorInfoW( monitor, (LPMONITORINFO)&miexw );
|
||||
ret = GetMonitorInfoW( monitor, (LPMONITORINFO)&miexw );
|
||||
ok( ret == testdatamiexw[i].ret, "GetMonitorInfo returned wrong value\n" );
|
||||
if (ret)
|
||||
ok( (miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" );
|
||||
|
@ -578,13 +530,13 @@ static void test_monitors(void)
|
|||
|
||||
SetRect( &rc, rc.left+1, rc.top+1, rc.left+2, rc.top+2 );
|
||||
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
|
||||
ok( monitor == NULL, "got %p\n", monitor );
|
||||
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTOPRIMARY );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTOPRIMARY );
|
||||
ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
|
||||
|
||||
monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONEAREST );
|
||||
monitor = MonitorFromRect( &rc, MONITOR_DEFAULTTONEAREST );
|
||||
ok( monitor == nearest, "got %p, should get nearest %p\n", monitor, nearest );
|
||||
}
|
||||
|
||||
|
@ -594,7 +546,7 @@ static BOOL CALLBACK find_primary_mon(HMONITOR hmon, HDC hdc, LPRECT rc, LPARAM
|
|||
BOOL ret;
|
||||
|
||||
mi.cbSize = sizeof(mi);
|
||||
ret = pGetMonitorInfoA(hmon, &mi);
|
||||
ret = GetMonitorInfoA(hmon, &mi);
|
||||
ok(ret, "GetMonitorInfo failed\n");
|
||||
if (mi.dwFlags & MONITORINFOF_PRIMARY)
|
||||
{
|
||||
|
@ -613,19 +565,13 @@ static void test_work_area(void)
|
|||
WINDOWPLACEMENT wp;
|
||||
BOOL ret;
|
||||
|
||||
if (!pEnumDisplayMonitors || !pGetMonitorInfoA)
|
||||
{
|
||||
win_skip("EnumDisplayMonitors or GetMonitorInfoA are not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
hmon = 0;
|
||||
ret = pEnumDisplayMonitors(NULL, NULL, find_primary_mon, (LPARAM)&hmon);
|
||||
ret = EnumDisplayMonitors(NULL, NULL, find_primary_mon, (LPARAM)&hmon);
|
||||
ok(!ret && hmon != 0, "Failed to find primary monitor\n");
|
||||
|
||||
mi.cbSize = sizeof(mi);
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pGetMonitorInfoA(hmon, &mi);
|
||||
ret = GetMonitorInfoA(hmon, &mi);
|
||||
ok(ret, "GetMonitorInfo error %u\n", GetLastError());
|
||||
ok(mi.dwFlags & MONITORINFOF_PRIMARY, "not a primary monitor\n");
|
||||
trace("primary monitor %s\n", wine_dbgstr_rect(&mi.rcMonitor));
|
||||
|
|
Loading…
Reference in New Issue