From 88e7f19d0ae49fca34d50fbe9c73e8fd0425e964 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 14 Jan 2020 13:42:48 +1100
Subject: [PATCH] xaudio2_7: Initial IXACT3Engine tests

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
 dlls/xaudio2_7/tests/Makefile.in |  1 +
 dlls/xaudio2_7/tests/xact.c      | 88 ++++++++++++++++++++++++++++++++
 dlls/xaudio2_7/tests/xaudio2.c   |  2 +-
 3 files changed, 90 insertions(+), 1 deletion(-)
 create mode 100644 dlls/xaudio2_7/tests/xact.c

diff --git a/dlls/xaudio2_7/tests/Makefile.in b/dlls/xaudio2_7/tests/Makefile.in
index ba56d94a1f..ecd728d659 100644
--- a/dlls/xaudio2_7/tests/Makefile.in
+++ b/dlls/xaudio2_7/tests/Makefile.in
@@ -2,4 +2,5 @@ TESTDLL = xaudio2_7.dll
 IMPORTS = ole32
 
 C_SRCS = \
+	xact.c \
 	xaudio2.c
diff --git a/dlls/xaudio2_7/tests/xact.c b/dlls/xaudio2_7/tests/xact.c
new file mode 100644
index 0000000000..afe8e4d83a
--- /dev/null
+++ b/dlls/xaudio2_7/tests/xact.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2020 Alistair Leslie-Hughes
+ *
+ * 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
+ */
+
+#include <windows.h>
+#include <math.h>
+
+#define COBJMACROS
+#include "wine/test.h"
+
+#include "xact3.h"
+
+#include "initguid.h"
+DEFINE_GUID(IID_IXACT3Engine301, 0xe72c1b9a, 0xd717, 0x41c0, 0x81, 0xa6, 0x50, 0xeb, 0x56, 0xe8, 0x06, 0x49);
+
+struct xact_interfaces
+{
+    REFGUID clsid;
+    REFIID iid;
+    HRESULT expected;
+    BOOL todo;
+} xact_interfaces[] =
+{
+    {&CLSID_XACTEngine30, &IID_IXACT3Engine301, E_NOINTERFACE, TRUE },
+    {&CLSID_XACTEngine30, &IID_IXACT3Engine,    E_NOINTERFACE, TRUE },
+
+    /* Version 3.1 to 3.4 use the same inteface */
+    {&CLSID_XACTEngine31, &IID_IXACT3Engine301, S_OK },
+    {&CLSID_XACTEngine32, &IID_IXACT3Engine301, S_OK },
+    {&CLSID_XACTEngine33, &IID_IXACT3Engine301, S_OK },
+    {&CLSID_XACTEngine34, &IID_IXACT3Engine301, S_OK },
+
+    /* Version 3.5 to 3.7 use the same inteface */
+    {&CLSID_XACTEngine35, &IID_IXACT3Engine301, E_NOINTERFACE },
+    {&CLSID_XACTEngine35, &IID_IXACT3Engine,    S_OK },
+
+    {&CLSID_XACTEngine36, &IID_IXACT3Engine301, E_NOINTERFACE },
+    {&CLSID_XACTEngine36, &IID_IXACT3Engine,    S_OK },
+
+    {&CLSID_XACTEngine37, &IID_IXACT3Engine301, E_NOINTERFACE },
+    {&CLSID_XACTEngine37, &IID_IXACT3Engine,    S_OK },
+    {&CLSID_XACTEngine37, &IID_IUnknown,        S_OK },
+};
+
+static void test_interfaces(void)
+{
+    IUnknown *unk;
+    HRESULT hr;
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(xact_interfaces); i++)
+    {
+        hr = CoCreateInstance(xact_interfaces[i].clsid, NULL, CLSCTX_INPROC_SERVER,
+                    xact_interfaces[i].iid, (void**)&unk);
+        if (hr == REGDB_E_CLASSNOTREG || (hr != xact_interfaces[i].expected &&
+                                            xact_interfaces[i].todo))
+        {
+            trace("%d not registered. Skipping\n", wine_dbgstr_guid(xact_interfaces[i].clsid) );
+            continue;
+        }
+        ok(hr == xact_interfaces[i].expected, "%d, Unexpected value 0x%08x\n", i, hr);
+        if (hr == S_OK)
+            IUnknown_Release(unk);
+    }
+}
+
+START_TEST(xact)
+{
+    CoInitialize(NULL);
+
+    test_interfaces();
+
+    CoUninitialize();
+}
diff --git a/dlls/xaudio2_7/tests/xaudio2.c b/dlls/xaudio2_7/tests/xaudio2.c
index f2bffdf29f..05b1dc3aba 100644
--- a/dlls/xaudio2_7/tests/xaudio2.c
+++ b/dlls/xaudio2_7/tests/xaudio2.c
@@ -22,7 +22,7 @@
 #define COBJMACROS
 #include "wine/test.h"
 #include "initguid.h"
-#include "xaudio2.h"
+#include "xact3.h"
 #include "xaudio2fx.h"
 #include "xapo.h"
 #include "xapofx.h"
-- 
2.25.1

