[2/2] quartz/tests: Add tests for IVMRMonitorConfig and IVMRMonitorConfig9 interface

Sebastian Lackner sebastian at fds-team.de
Mon Nov 18 22:01:44 CST 2013


---
 dlls/quartz/tests/Makefile.in     |    1 +
 dlls/quartz/tests/monitorconfig.c |  258
+++++++++++++++++++++++++++++++++++++
 2 files changed, 259 insertions(+)
 create mode 100644 dlls/quartz/tests/monitorconfig.c

-------------- next part --------------
From 3e2e76138e7e8de1ebe35c82828c3f907626d20c Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian at fds-team.de>
Date: Tue, 12 Nov 2013 21:30:33 +0100
Subject: quartz/tests: Add tests for IVMRMonitorConfig and IVMRMonitorConfig9
 interface

---
 dlls/quartz/tests/Makefile.in     |    1 +
 dlls/quartz/tests/monitorconfig.c |  258 +++++++++++++++++++++++++++++++++++++
 2 files changed, 259 insertions(+)
 create mode 100644 dlls/quartz/tests/monitorconfig.c

diff --git a/dlls/quartz/tests/Makefile.in b/dlls/quartz/tests/Makefile.in
index ae5fbac..94b2f44 100644
--- a/dlls/quartz/tests/Makefile.in
+++ b/dlls/quartz/tests/Makefile.in
@@ -8,6 +8,7 @@ C_SRCS = \
 	filtermapper.c \
 	memallocator.c \
 	misc.c \
+	monitorconfig.c \
 	referenceclock.c \
 	videorenderer.c
 
diff --git a/dlls/quartz/tests/monitorconfig.c b/dlls/quartz/tests/monitorconfig.c
new file mode 100644
index 0000000..07b13e9
--- /dev/null
+++ b/dlls/quartz/tests/monitorconfig.c
@@ -0,0 +1,258 @@
+/*
+ * MonitorConfig unit tests for Quartz
+ *
+ * Copyright (C) 2013 Sebastian Lackner
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+#include <dshow.h>
+#include <initguid.h>
+#include <d3d9.h>
+#include <vmr9.h>
+
+#include "wine/test.h"
+
+static void test_monitorconfig7_setmonitor(void)
+{
+    HRESULT hr;
+    IUnknown *pVMR = NULL;
+    IVMRMonitorConfig *pMonitorConfig = NULL;
+    VMRGUID guid;
+
+    hr = CoCreateInstance(&CLSID_VideoMixingRenderer, NULL, CLSCTX_INPROC_SERVER,
+                          &IID_IUnknown, (LPVOID*)&pVMR);
+    ok(hr == S_OK, "CoCreateInstance failed with %x.\n", hr);
+    ok(pVMR != NULL, "pVMR is NULL.\n");
+    if (!pVMR) goto out;
+
+    hr = IUnknown_QueryInterface(pVMR, &IID_IVMRMonitorConfig, (LPVOID*)&pMonitorConfig);
+    ok(hr == S_OK, "IUnknown_QueryInterface returned %x.\n", hr);
+    ok(pMonitorConfig != NULL, "pMonitorConfig is NULL.\n");
+    if (!pMonitorConfig) goto out;
+
+    hr = IVMRMonitorConfig_SetMonitor(pMonitorConfig, NULL);
+    ok(hr == E_POINTER, "SetMonitor returned %x, expected E_POINTER.\n", hr);
+
+    hr = IVMRMonitorConfig_GetMonitor(pMonitorConfig, NULL);
+    ok(hr == E_POINTER, "GetMonitor returned %x, expected E_POINTER.\n", hr);
+
+    hr = IVMRMonitorConfig_SetDefaultMonitor(pMonitorConfig, NULL);
+    ok(hr == E_POINTER, "SetDefaultMonitor returned %x, expected E_POINTER.\n", hr);
+
+    hr = IVMRMonitorConfig_GetDefaultMonitor(pMonitorConfig, NULL);
+    ok(hr == E_POINTER, "GetDefaultMonitor returned %x, expected E_POINTER.\n", hr);
+
+    memset(&guid, 0, sizeof(guid));
+    guid.pGUID = NULL; /* default DirectDraw device */
+    hr = IVMRMonitorConfig_SetMonitor(pMonitorConfig, &guid);
+    ok(hr == S_OK, "SetMonitor failed with %x.\n", hr);
+
+    memset(&guid, 255, sizeof(guid));
+    hr = IVMRMonitorConfig_GetMonitor(pMonitorConfig, &guid);
+    ok(hr == S_OK, "GetMonitor failed with %x.\n", hr);
+    ok(guid.pGUID == NULL, "GetMonitor returned guid.pGUID = %p, expected NULL.\n", guid.pGUID);
+
+    memset(&guid, 0, sizeof(guid));
+    guid.pGUID = NULL; /* default DirectDraw device */
+    hr = IVMRMonitorConfig_SetDefaultMonitor(pMonitorConfig, &guid);
+    ok(hr == S_OK, "SetDefaultMonitor failed with %x.\n", hr);
+
+    memset(&guid, 255, sizeof(guid));
+    hr = IVMRMonitorConfig_GetDefaultMonitor(pMonitorConfig, &guid);
+    ok(hr == S_OK, "GetDefaultMonitor failed with %x.\n", hr);
+    ok(guid.pGUID == NULL, "GetDefaultMonitor returned guid.pGUID = %p, expected NULL.\n", guid.pGUID);
+
+out:
+    if (pMonitorConfig) IVMRMonitorConfig_Release(pMonitorConfig);
+    if (pVMR) IUnknown_Release(pVMR);
+}
+
+static void test_monitorconfig9_setmonitor(void)
+{
+    HRESULT hr;
+    IUnknown *pVMR = NULL;
+    IVMRMonitorConfig9 *pMonitorConfig = NULL;
+    UINT uDev;
+
+    hr = CoCreateInstance(&CLSID_VideoMixingRenderer9, NULL, CLSCTX_INPROC_SERVER,
+                          &IID_IUnknown, (LPVOID*)&pVMR);
+    if (hr == VFW_E_DDRAW_CAPS_NOT_SUITABLE)
+    {
+        skip("VideoMixingRenderer9 is not available, skipping SetMonitor test.\n");
+        return;
+    }
+    ok(hr == S_OK, "CoCreateInstance failed with %x.\n", hr);
+    ok(pVMR != NULL, "pVMR is NULL.\n");
+    if (!pVMR) goto out;
+
+    hr = IUnknown_QueryInterface(pVMR, &IID_IVMRMonitorConfig9, (LPVOID*)&pMonitorConfig);
+    ok(hr == S_OK, "IUnknown_QueryInterface returned %x.\n", hr);
+    ok(pMonitorConfig != NULL, "pMonitorConfig is NULL.\n");
+    if (!pMonitorConfig) goto out;
+
+    hr = IVMRMonitorConfig9_GetMonitor(pMonitorConfig, NULL);
+    ok(hr == E_POINTER, "GetMonitor returned %x, expected E_POINTER.\n", hr);
+
+    hr = IVMRMonitorConfig9_GetDefaultMonitor(pMonitorConfig, NULL);
+    ok(hr == E_POINTER, "GetDefaultMonitor returned %x, expected E_POINTER.\n", hr);
+
+    hr = IVMRMonitorConfig9_SetMonitor(pMonitorConfig, 0);
+    ok(hr == S_OK, "SetMonitor failed with %x.\n", hr);
+
+    uDev = 0xdeadbeef;
+    hr = IVMRMonitorConfig9_GetMonitor(pMonitorConfig, &uDev);
+    ok(hr == S_OK, "GetMonitor failed with %x.\n", hr);
+    ok(uDev == 0, "GetMonitor returned uDev = %d, expected 0.\n", uDev);
+
+    hr = IVMRMonitorConfig9_SetDefaultMonitor(pMonitorConfig, 0);
+    ok(hr == S_OK, "SetDefaultMonitor failed with %x.\n", hr);
+
+    uDev = 0xdeadbeef;
+    hr = IVMRMonitorConfig9_GetDefaultMonitor(pMonitorConfig, &uDev);
+    ok(hr == S_OK, "GetDefaultMonitor failed with %x.\n", hr);
+    ok(uDev == 0, "GetDefaultMonitor returned uDev = %d, expected 0.\n", uDev);
+
+out:
+    if (pMonitorConfig) IVMRMonitorConfig9_Release(pMonitorConfig);
+    if (pVMR) IUnknown_Release(pVMR);
+}
+
+static void test_monitorconfig7_getavailablemonitors(void)
+{
+    HRESULT hr;
+    IUnknown *pVMR = NULL;
+    IVMRMonitorConfig *pMonitorConfig = NULL;
+    VMRMONITORINFO info[8];
+    DWORD numdev_total, numdev;
+
+    hr = CoCreateInstance(&CLSID_VideoMixingRenderer, NULL, CLSCTX_INPROC_SERVER,
+                          &IID_IUnknown, (LPVOID*)&pVMR);
+    ok(hr == S_OK, "CoCreateInstance failed with %x.\n", hr);
+    ok(pVMR != NULL, "pVMR is NULL.\n");
+    if (!pVMR) goto out;
+
+    hr = IUnknown_QueryInterface(pVMR, &IID_IVMRMonitorConfig, (LPVOID*)&pMonitorConfig);
+    ok(hr == S_OK, "IUnknown_QueryInterface returned %x.\n", hr);
+    ok(pMonitorConfig != NULL, "pMonitorConfig is NULL.\n");
+    if (!pMonitorConfig) goto out;
+
+    /* call without any arguments */
+    hr = IVMRMonitorConfig_GetAvailableMonitors(pMonitorConfig, NULL, 0, NULL);
+    ok(hr == E_POINTER, "GetAvailableMonitors returned %x, expected E_POINTER.\n", hr);
+
+    hr = IVMRMonitorConfig_GetAvailableMonitors(pMonitorConfig, info, 0, &numdev_total);
+    ok(hr == E_INVALIDARG, "GetAvailableMonitors returned %x, expected E_INVALIDARG.\n", hr);
+
+    numdev_total = 0;
+    hr = IVMRMonitorConfig_GetAvailableMonitors(pMonitorConfig, NULL, 0, &numdev_total);
+    ok(hr == S_OK, "GetAvailableMonitors failed with %x.\n", hr);
+    ok(numdev_total > 0, "GetAvailableMonitors returned numdev_total = %d, expected > 0.\n", numdev_total);
+
+    if (numdev_total > 1)
+    {
+        /* check if its possible to provide a buffer which is too small for all entries */
+        hr = IVMRMonitorConfig_GetAvailableMonitors(pMonitorConfig, info, 1, &numdev);
+        ok(hr == S_OK, "GetAvailableMonitors failed with %x.\n", hr);
+        ok(numdev == 1, "GetAvailableMonitors returned numdev = %d, expected 1.\n", numdev);
+    }
+
+    /* don't request information for more monitors than memory available */
+    if (numdev_total > sizeof(info)/sizeof(info[0]))
+        numdev_total = sizeof(info)/sizeof(info[0]);
+
+    hr = IVMRMonitorConfig_GetAvailableMonitors(pMonitorConfig, info, numdev_total, &numdev);
+    ok(hr == S_OK, "GetAvailableMonitors failed with %x.\n", hr);
+    ok(numdev == numdev_total, "GetAvailableMonitors returned numdev = %d, expected %d.\n", numdev, numdev_total);
+
+    /* TODO: Add test for content of info */
+
+out:
+    if (pMonitorConfig) IVMRMonitorConfig_Release(pMonitorConfig);
+    if (pVMR) IUnknown_Release(pVMR);
+}
+
+static void test_monitorconfig9_getavailablemonitors(void)
+{
+    HRESULT hr;
+    IUnknown *pVMR = NULL;
+    IVMRMonitorConfig9 *pMonitorConfig = NULL;
+    VMR9MonitorInfo info[8];
+    DWORD numdev_total, numdev;
+
+    hr = CoCreateInstance(&CLSID_VideoMixingRenderer9, NULL, CLSCTX_INPROC_SERVER,
+                          &IID_IUnknown, (LPVOID*)&pVMR);
+    if (hr == VFW_E_DDRAW_CAPS_NOT_SUITABLE)
+    {
+        skip("VideoMixingRenderer9 is not available, skipping GetAvailableMonitors test.\n");
+        return;
+    }
+    ok(hr == S_OK, "CoCreateInstance failed with %x.\n", hr);
+    ok(pVMR != NULL, "pVMR is NULL.\n");
+    if (!pVMR) goto out;
+
+    hr = IUnknown_QueryInterface(pVMR, &IID_IVMRMonitorConfig9, (LPVOID*)&pMonitorConfig);
+    ok(hr == S_OK, "IUnknown_QueryInterface returned %x.\n", hr);
+    ok(pMonitorConfig != NULL, "pMonitorConfig is NULL.\n");
+    if (!pMonitorConfig) goto out;
+
+    /* call without any arguments */
+    hr = IVMRMonitorConfig9_GetAvailableMonitors(pMonitorConfig, NULL, 0, NULL);
+    ok(hr == E_POINTER, "GetAvailableMonitors returned %x, expected E_POINTER.\n", hr);
+
+    hr = IVMRMonitorConfig9_GetAvailableMonitors(pMonitorConfig, info, 0, &numdev_total);
+    ok(hr == E_INVALIDARG, "GetAvailableMonitors returned %x, expected E_INVALIDARG.\n", hr);
+
+    numdev_total = 0;
+    hr = IVMRMonitorConfig9_GetAvailableMonitors(pMonitorConfig, NULL, 0, &numdev_total);
+    ok(hr == S_OK, "GetAvailableMonitors failed with %x.\n", hr);
+    ok(numdev_total > 0, "GetAvailableMonitors returned numdev_total = %d, expected > 0.\n", numdev_total);
+
+    if (numdev_total > 1)
+    {
+        /* check if its possible to provide a buffer which is too small for all entries */
+        hr = IVMRMonitorConfig9_GetAvailableMonitors(pMonitorConfig, info, 1, &numdev);
+        ok(hr == S_OK, "GetAvailableMonitors failed with %x.\n", hr);
+        ok(numdev == 1, "GetAvailableMonitors returned numdev = %d, expected 1.\n", numdev);
+    }
+
+    /* don't request information for more monitors than memory available */
+    if (numdev_total > sizeof(info)/sizeof(info[0]))
+        numdev_total = sizeof(info)/sizeof(info[0]);
+
+    hr = IVMRMonitorConfig9_GetAvailableMonitors(pMonitorConfig, info, numdev_total, &numdev);
+    ok(hr == S_OK, "GetAvailableMonitors failed with %x.\n", hr);
+    ok(numdev == numdev_total, "GetAvailableMonitors returned numdev = %d, expected %d.\n", numdev, numdev_total);
+
+    /* TODO: Add test for content of info */
+
+out:
+    if (pMonitorConfig) IVMRMonitorConfig9_Release(pMonitorConfig);
+    if (pVMR) IUnknown_Release(pVMR);
+}
+
+START_TEST(monitorconfig)
+{
+    CoInitialize(NULL);
+
+    test_monitorconfig7_setmonitor();
+    test_monitorconfig7_getavailablemonitors();
+
+    test_monitorconfig9_setmonitor();
+    test_monitorconfig9_getavailablemonitors();
+
+    CoUninitialize();
+}
-- 
1.7.9.5



More information about the wine-patches mailing list