[PATCH v2 resend 2/3] dxgi/tests: Add more IDXGISwapChain_Present tests.
Józef Kucia
joseph.kucia at gmail.com
Tue Jun 11 08:09:34 CDT 2019
On Mon, Jun 10, 2019 at 3:05 PM Zhiyi Zhang <zzhang at codeweavers.com> wrote:
>
> Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
> ---
> dlls/dxgi/tests/dxgi.c | 167 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 167 insertions(+)
>
> diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
> index 765b174af6..216f03eed8 100644
> --- a/dlls/dxgi/tests/dxgi.c
> +++ b/dlls/dxgi/tests/dxgi.c
> @@ -3992,9 +3992,13 @@ static void test_swapchain_parameters(void)
>
> static void test_swapchain_present(IUnknown *device, BOOL is_d3d12)
> {
> + static const DWORD flags[] = {0, DXGI_PRESENT_TEST};
> + static const DWORD timeout = 2000;
> DXGI_SWAP_CHAIN_DESC swapchain_desc;
> IDXGISwapChain *swapchain;
> IDXGIFactory *factory;
> + IDXGIOutput *output;
> + BOOL fullscreen;
> unsigned int i;
> ULONG refcount;
> HRESULT hr;
> @@ -4029,6 +4033,169 @@ static void test_swapchain_present(IUnknown *device, BOOL is_d3d12)
> hr = IDXGISwapChain_Present(swapchain, 0, 0);
> ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
>
> + for (i = 0; i < ARRAY_SIZE(flags); ++i)
> + {
> + HWND occluding_hwnd = CreateWindowA("static", "occluding_window", WS_POPUP | WS_VISIBLE, 0, 0, 400, 200, 0, 0, 0, 0);
> +
> + /* Another window covers the swapchain window, doesn't report as occluded */
> + hr = IDXGISwapChain_Present(swapchain, 0, flags[i]);
> + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> +
> + /* Minimized window */
> + ShowWindow(swapchain_desc.OutputWindow, SW_MINIMIZE);
> + hr = IDXGISwapChain_Present(swapchain, 0, flags[i]);
> + todo_wine_if(!is_d3d12) ok(hr == (is_d3d12 ? S_OK : DXGI_STATUS_OCCLUDED), "Got unexpected hr %#x.\n", hr);
> + ShowWindow(swapchain_desc.OutputWindow, SW_NORMAL);
> +
> + /* Hidden window */
> + ShowWindow(swapchain_desc.OutputWindow, SW_HIDE);
> + hr = IDXGISwapChain_Present(swapchain, 0, flags[i]);
> + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> + ShowWindow(swapchain_desc.OutputWindow, SW_SHOW);
> + DestroyWindow(occluding_hwnd);
> +
> + /* Test IDXGIOutput_ReleaseOwnership makes the swapchain exit fullscreen */
> + hr = IDXGISwapChain_SetFullscreenState(swapchain, TRUE, NULL);
> + /* DXGI_ERROR_NOT_CURRENTLY_AVAILABLE on some machines. DXGI_ERROR_UNSUPPORTED on Win 7 testbot. */
> + if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE || broken(hr == DXGI_ERROR_UNSUPPORTED))
> + {
> + skip("Could not change fullscreen state.\n");
> + continue;
> + }
> + todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> + IDXGISwapChain_ResizeBuffers(swapchain, 0, 0, 0, DXGI_FORMAT_UNKNOWN, 0);
> + hr = IDXGISwapChain_Present(swapchain, 0, flags[i]);
> + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> + output = NULL;
> + fullscreen = FALSE;
> + hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, &output);
> + todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> + todo_wine_if(is_d3d12) ok(fullscreen, "Unexpected fullscreen status.\n");
> + todo_wine_if(is_d3d12) ok(output != NULL, "Expect output not null.\n");
> +
> + if (output) IDXGIOutput_ReleaseOwnership(output);
> + /* Still in fullscreen */
> + fullscreen = FALSE;
> + hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, NULL);
> + todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> + todo_wine_if(is_d3d12) ok(fullscreen, "Unexpected fullscreen status.\n");
> + /* Now calling IDXGISwapChain_Present will exit the fullscreen */
> + hr = IDXGISwapChain_Present(swapchain, 0, flags[i]);
> + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> + fullscreen = TRUE;
> + hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, NULL);
> + todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> + /* Now fullscreen mode is exited */
> + if (flags[i] == 0 && !is_d3d12)
> + {
> + /* Still on fullscreen on vista and 2008 */
> + todo_wine ok(!fullscreen || broken(fullscreen), "Unexpected fullscreen status.\n");
> + }
> + else
> + ok(fullscreen, "Unexpected fullscreen status.\n");
Coding style: please add { } for the else block.
> + if (output) IDXGIOutput_Release(output);
Coding style: please put IDXGIOutput_Release(output); on the new line.
> +
> +
> + /* Test creating a window when swapchain is in fullscreen.
> + * The window should break the swapchain out of fullscreen mode on d3d10/11.
> + * d3d12 is different, new occluding window doesn't break swapchain out of fullscreen because d3d12 swapchain
> + * fullscreen mode doesn't take exclusive ownership over output, nor does it disable compositing.
> + * d3d12 fullscreen mode acts just like borderless fullscreen window mode */
2 empty lines before the comment.
> + occluding_hwnd = CreateWindowA("static", "occluding_window", WS_POPUP, 0, 0, 400, 200, 0, 0, 0, 0);
> + /* Invisible window doesn't cause fullscreen mode to exit */
> + IDXGISwapChain_ResizeBuffers(swapchain, 0, 0, 0, DXGI_FORMAT_UNKNOWN, 0);
> + hr = IDXGISwapChain_Present(swapchain, 0, flags[i]);
> + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> + fullscreen = FALSE;
> + hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, NULL);
> + todo_wine_if(is_d3d12) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
> + todo_wine_if(is_d3d12) ok(fullscreen, "Unexpected fullscreen status.\n");
> + /* Visible but with bottom z-order window still cause fullscreen mode to exit */
> + SetWindowPos(occluding_hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
> + ShowWindow(occluding_hwnd, SW_SHOW);
> + /* Fullscreen mode takes a while to exit */
> + Sleep(timeout);
Can we poll for the fullscreen state change instead of always waiting
for 2 seconds? See get_query_data_() from dlls/d3d11/tests.
More information about the wine-devel
mailing list