test_wndproc() makes a series of ChangeDisplaySettings() calls that could make the current display mode no longer match the registry display mode. Restore display modes at the end of test_wndproc() so that other tests are not affected.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/d3d8/tests/device.c | 72 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 4c567a47603..f48a51cee85 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -114,6 +114,69 @@ static BOOL adapter_is_warp(const D3DADAPTER_IDENTIFIER8 *identifier) return !strcmp(identifier->Driver, "d3d10warp.dll"); }
+/* Free original_modes after finished using it */ +static BOOL save_display_modes(DEVMODEW **original_modes, unsigned int *display_count) +{ + unsigned int number, size = 2, count = 0, index = 0; + DISPLAY_DEVICEW display_device; + DEVMODEW *modes, *tmp; + + if (!(modes = heap_alloc(size * sizeof(*modes)))) + return FALSE; + + display_device.cb = sizeof(display_device); + while (EnumDisplayDevicesW(NULL, index++, &display_device, 0)) + { + /* Skip software devices */ + if (swscanf(display_device.DeviceName, L"\\.\DISPLAY%u", &number) != 1) + continue; + + if (!(display_device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) + continue; + + if (count >= size) + { + size *= 2; + if (!(tmp = heap_realloc(modes, size * sizeof(*modes)))) + { + heap_free(modes); + return FALSE; + } + modes = tmp; + } + + memset(&modes[count], 0, sizeof(modes[count])); + modes[count].dmSize = sizeof(modes[count]); + if (!EnumDisplaySettingsW(display_device.DeviceName, ENUM_CURRENT_SETTINGS, &modes[count])) + { + heap_free(modes); + return FALSE; + } + + lstrcpyW(modes[count++].dmDeviceName, display_device.DeviceName); + } + + *original_modes = modes; + *display_count = count; + return TRUE; +} + +static BOOL restore_display_modes(DEVMODEW *modes, unsigned int count) +{ + unsigned int index; + LONG ret; + + for (index = 0; index < count; ++index) + { + ret = ChangeDisplaySettingsExW(modes[index].dmDeviceName, &modes[index], NULL, + CDS_UPDATEREGISTRY | CDS_NORESET, NULL); + if (ret != DISP_CHANGE_SUCCESSFUL) + return FALSE; + } + ret = ChangeDisplaySettingsExW(NULL, NULL, NULL, 0, NULL); + return ret == DISP_CHANGE_SUCCESSFUL; +} + static IDirect3DDevice8 *create_device(IDirect3D8 *d3d8, HWND focus_window, const struct device_desc *desc) { D3DPRESENT_PARAMETERS present_parameters = {0}; @@ -2763,6 +2826,8 @@ static DWORD WINAPI wndproc_thread(void *param) static void test_wndproc(void) { struct wndproc_thread_param thread_params; + DEVMODEW devmode, *original_modes = NULL; + unsigned int display_count = 0; struct device_desc device_desc; static WINDOWPOS windowpos; IDirect3DDevice8 *device; @@ -2777,7 +2842,6 @@ static void test_wndproc(void) HRESULT hr; D3DDISPLAYMODE d3ddm; DWORD d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0; - DEVMODEW devmode; LONG change_ret, device_style; BOOL ret;
@@ -2959,6 +3023,9 @@ static void test_wndproc(void) return; }
+ ret = save_display_modes(&original_modes, &display_count); + ok(ret, "Failed to save original display modes.\n"); + filter_messages = NULL; expect_messages = NULL;
@@ -3361,6 +3428,9 @@ done: DestroyWindow(device_window); DestroyWindow(focus_window); UnregisterClassA("d3d8_test_wndproc_wc", GetModuleHandleA(NULL)); + ret = restore_display_modes(original_modes, display_count); + ok(ret, "Failed to restore display modes.\n"); + heap_free(original_modes); }
static void test_wndproc_windowed(void)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=81094
Your paranoid android.
=== debiant (32 bit French report) ===
d3d8: device.c:10384: Test failed: Adapter 0: Expect window rect (0,0)-(1024,768), got (0,-9)-(1024,759).