gdi32/tests: Add D3DKMTOpenAdapterFromHdc tests.
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
012d9bbc23
commit
b6072314e5
dlls/gdi32/tests
|
@ -35,6 +35,7 @@ static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y'
|
|||
|
||||
static NTSTATUS (WINAPI *pD3DKMTCloseAdapter)(const D3DKMT_CLOSEADAPTER *);
|
||||
static NTSTATUS (WINAPI *pD3DKMTOpenAdapterFromGdiDisplayName)(D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME *);
|
||||
static NTSTATUS (WINAPI *pD3DKMTOpenAdapterFromHdc)(D3DKMT_OPENADAPTERFROMHDC *);
|
||||
|
||||
static void test_D3DKMTOpenAdapterFromGdiDisplayName(void)
|
||||
{
|
||||
|
@ -90,12 +91,82 @@ static void test_D3DKMTOpenAdapterFromGdiDisplayName(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void test_D3DKMTOpenAdapterFromHdc(void)
|
||||
{
|
||||
DISPLAY_DEVICEW display_device = {sizeof(display_device)};
|
||||
D3DKMT_OPENADAPTERFROMHDC open_adapter_hdc_desc;
|
||||
D3DKMT_CLOSEADAPTER close_adapter_desc;
|
||||
INT adapter_count = 0;
|
||||
NTSTATUS status;
|
||||
HDC hdc;
|
||||
DWORD i;
|
||||
|
||||
if (!pD3DKMTOpenAdapterFromHdc || pD3DKMTOpenAdapterFromHdc(NULL) == STATUS_PROCEDURE_NOT_FOUND)
|
||||
{
|
||||
skip("D3DKMTOpenAdapterFromHdc() is unavailable.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Invalid parameters */
|
||||
status = pD3DKMTOpenAdapterFromHdc(NULL);
|
||||
todo_wine ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
|
||||
|
||||
memset(&open_adapter_hdc_desc, 0, sizeof(open_adapter_hdc_desc));
|
||||
status = pD3DKMTOpenAdapterFromHdc(&open_adapter_hdc_desc);
|
||||
todo_wine ok(status == STATUS_INVALID_PARAMETER, "Got unexpected return code %#x.\n", status);
|
||||
|
||||
/* Open adapter */
|
||||
for (i = 0; EnumDisplayDevicesW(NULL, i, &display_device, 0); ++i)
|
||||
{
|
||||
if (!(display_device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP))
|
||||
continue;
|
||||
|
||||
adapter_count++;
|
||||
|
||||
hdc = CreateDCW(0, display_device.DeviceName, 0, NULL);
|
||||
open_adapter_hdc_desc.hDc = hdc;
|
||||
status = pD3DKMTOpenAdapterFromHdc(&open_adapter_hdc_desc);
|
||||
todo_wine ok(status == STATUS_SUCCESS, "Got unexpected return code %#x.\n", status);
|
||||
todo_wine ok(open_adapter_hdc_desc.hAdapter, "Expect not null.\n");
|
||||
if (display_device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
|
||||
ok(open_adapter_hdc_desc.VidPnSourceId == 0, "Got unexpected value %#x.\n",
|
||||
open_adapter_hdc_desc.VidPnSourceId);
|
||||
else
|
||||
todo_wine ok(open_adapter_hdc_desc.VidPnSourceId, "Got unexpected value %#x.\n",
|
||||
open_adapter_hdc_desc.VidPnSourceId);
|
||||
DeleteDC(hdc);
|
||||
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
close_adapter_desc.hAdapter = open_adapter_hdc_desc.hAdapter;
|
||||
status = pD3DKMTCloseAdapter(&close_adapter_desc);
|
||||
ok(status == STATUS_SUCCESS, "Got unexpected return code %#x.\n", status);
|
||||
}
|
||||
}
|
||||
|
||||
/* HDC covering more than two adapters is invalid for D3DKMTOpenAdapterFromHdc */
|
||||
hdc = GetDC(0);
|
||||
open_adapter_hdc_desc.hDc = hdc;
|
||||
status = pD3DKMTOpenAdapterFromHdc(&open_adapter_hdc_desc);
|
||||
ReleaseDC(0, hdc);
|
||||
todo_wine ok(status == (adapter_count > 1 ? STATUS_INVALID_PARAMETER : STATUS_SUCCESS),
|
||||
"Got unexpected return code %#x.\n", status);
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
close_adapter_desc.hAdapter = open_adapter_hdc_desc.hAdapter;
|
||||
status = pD3DKMTCloseAdapter(&close_adapter_desc);
|
||||
ok(status == STATUS_SUCCESS, "Got unexpected return code %#x.\n", status);
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(driver)
|
||||
{
|
||||
HMODULE gdi32 = GetModuleHandleA("gdi32.dll");
|
||||
|
||||
pD3DKMTCloseAdapter = (void *)GetProcAddress(gdi32, "D3DKMTCloseAdapter");
|
||||
pD3DKMTOpenAdapterFromGdiDisplayName = (void *)GetProcAddress(gdi32, "D3DKMTOpenAdapterFromGdiDisplayName");
|
||||
pD3DKMTOpenAdapterFromHdc = (void *)GetProcAddress(gdi32, "D3DKMTOpenAdapterFromHdc");
|
||||
|
||||
test_D3DKMTOpenAdapterFromGdiDisplayName();
|
||||
test_D3DKMTOpenAdapterFromHdc();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue