[PATCH] msacm32/tests: Beginnings of a custom driver test

Bruno Jesus 00cpxxx at gmail.com
Tue Nov 29 00:10:37 CST 2016


In order to exercise more bug 24723 and bug 41290 I need to check what messages are delivered in specific circumstances, an example is to check if acmPrepareHeader filters out some bad parameters or delegates to the driver using the appropriate message. As the subject suggests, this is just the tip of the iceberg.

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
---
 dlls/msacm32/tests/Makefile.in |   2 +-
 dlls/msacm32/tests/msacm.c     | 166 +++++++++++++++++++++++++++++++++++++++++
 include/msacmdrv.h             |   1 +
 3 files changed, 168 insertions(+), 1 deletion(-)

diff --git a/dlls/msacm32/tests/Makefile.in b/dlls/msacm32/tests/Makefile.in
index 1b8a2f2..dba7cfe 100644
--- a/dlls/msacm32/tests/Makefile.in
+++ b/dlls/msacm32/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL   = msacm32.dll
-IMPORTS   = msacm32
+IMPORTS   = msacm32 winmm
 
 C_SRCS = \
 	msacm.c
diff --git a/dlls/msacm32/tests/msacm.c b/dlls/msacm32/tests/msacm.c
index 5ec4717..0816cb0 100644
--- a/dlls/msacm32/tests/msacm.c
+++ b/dlls/msacm32/tests/msacm.c
@@ -31,6 +31,7 @@
 #define NOBITMAP
 #include "mmreg.h"
 #include "msacm.h"
+#include "msacmdrv.h"
 
 static BOOL CALLBACK FormatTagEnumProc(HACMDRIVERID hadid,
                                        PACMFORMATTAGDETAILSA paftd,
@@ -829,9 +830,174 @@ todo_wine
     ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
 }
 
+static struct
+{
+    struct
+    {
+        int load, free, open, close, enable, disable, install,
+            remove, details, notify, querycfg, about;
+    } driver;
+    struct
+    {
+        int tag_details, details, suggest;
+    } format;
+    struct
+    {
+        int open, close, size, convert, prepare, unprepare, reset;
+    } stream;
+    int other;
+} driver_calls;
+
+LRESULT CALLBACK acm_driver_func(DWORD_PTR id, HDRVR handle, UINT msg, LPARAM param1, LPARAM param2)
+{
+    switch (msg)
+    {
+        /* Driver messages */
+        case DRV_LOAD:
+            driver_calls.driver.load++;
+            return 1;
+        case DRV_FREE:
+            driver_calls.driver.free++;
+            return 1;
+        case DRV_OPEN:
+            driver_calls.driver.open++;
+            return 1;
+        case DRV_CLOSE:
+            driver_calls.driver.close++;
+            return 1;
+        case DRV_ENABLE:
+            driver_calls.driver.enable++;
+            return 1;
+        case DRV_DISABLE:
+            driver_calls.driver.disable++;
+            return 1;
+        case DRV_QUERYCONFIGURE:
+            driver_calls.driver.querycfg++;
+            return 1;
+        case DRV_INSTALL:
+            driver_calls.driver.install++;
+            return DRVCNF_RESTART;
+        case DRV_REMOVE:
+            driver_calls.driver.remove++;
+            return DRVCNF_RESTART;
+        case ACMDM_DRIVER_ABOUT:
+            driver_calls.driver.about++;
+            return MMSYSERR_NOTSUPPORTED;
+        case ACMDM_DRIVER_DETAILS:
+        {
+            ACMDRIVERDETAILSA *ptr = (ACMDRIVERDETAILSA *)param1;
+
+            /* copied from pcmconverter.c */
+            ptr->fccType = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC;
+            ptr->fccComp = ACMDRIVERDETAILS_FCCCOMP_UNDEFINED;
+            ptr->wMid = MM_MICROSOFT;
+            ptr->wPid = MM_MSFT_ACM_PCM;
+            ptr->vdwACM = 0x01000000;
+            ptr->vdwDriver = 0x01000000;
+            ptr->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CONVERTER;
+            ptr->cFormatTags = 1;
+            ptr->cFilterTags = 0;
+            ptr->hicon = NULL;
+            strcpy(ptr->szShortName, "TEST-CODEC");
+            strcpy(ptr->szLongName, "Wine Test Codec");
+            strcpy(ptr->szCopyright, "Brought to you by the Wine team...");
+            strcpy(ptr->szLicensing, "Refer to LICENSE file");
+            ptr->szFeatures[0] = 0;
+
+            driver_calls.driver.details++;
+            break;
+        }
+        case ACMDM_DRIVER_NOTIFY:
+            driver_calls.driver.notify++;
+            return MMSYSERR_NOTSUPPORTED;
+
+        /* Format messages */
+        case ACMDM_FORMATTAG_DETAILS:
+            driver_calls.format.tag_details++;
+            break;
+        case ACMDM_FORMAT_DETAILS:
+            driver_calls.format.details++;
+            break;
+        case ACMDM_FORMAT_SUGGEST:
+            driver_calls.format.suggest++;
+            break;
+
+        /* Stream messages */
+        case ACMDM_STREAM_OPEN:
+            driver_calls.stream.open++;
+            break;
+        case ACMDM_STREAM_CLOSE:
+            driver_calls.stream.close++;
+            break;
+        case ACMDM_STREAM_SIZE:
+            driver_calls.stream.size++;
+            break;
+        case ACMDM_STREAM_CONVERT:
+            driver_calls.stream.convert++;
+            break;
+        case ACMDM_STREAM_RESET:
+            driver_calls.stream.reset++;
+            return MMSYSERR_NOTSUPPORTED;
+        case ACMDM_STREAM_PREPARE:
+            driver_calls.stream.prepare++;
+            break;
+        case ACMDM_STREAM_UNPREPARE:
+            driver_calls.stream.unprepare++;
+            break;
+
+        default:
+            driver_calls.other++;
+            return DefDriverProc(id, handle, msg, param1, param2);
+    }
+    return MMSYSERR_NOERROR;
+}
+
+static void test_acmDriverAdd(void)
+{
+    MMRESULT res;
+    HACMDRIVERID drvid;
+    union
+    {
+      ACMDRIVERDETAILSA drv_details;
+    } acm;
+
+    /* Driver load steps:
+     * - acmDriverAdd checks the passed parameters
+     * - DRV_LOAD message is sent - required
+     * - DRV_ENABLE message is sent - required
+     * - DRV_OPEN message is sent - required
+     * - DRV_DETAILS message is sent - required
+     * - ACMDM_FORMATTAG_DETAILS message is sent - optional
+     * - DRV_QUERYCONFIGURE message is sent - optional
+     * - ACMDM_DRIVER_ABOUT message is sent - optional
+     */
+
+    res = acmDriverAddA(&drvid, GetModuleHandleA(NULL), (LPARAM)acm_driver_func, 0, ACM_DRIVERADDF_FUNCTION);
+    ok(res == MMSYSERR_NOERROR, "Expected 0, got %d\n", res);
+todo_wine
+    ok(driver_calls.driver.open == 1, "Expected 1, got %d\n", driver_calls.driver.open);
+    ok(driver_calls.driver.details == 1, "Expected 1, got %d\n", driver_calls.driver.details);
+
+    memset(&acm, 0, sizeof(acm));
+    res = acmDriverDetailsA(drvid, &acm.drv_details, 0);
+    ok(res == MMSYSERR_INVALPARAM, "Expected 11, got %d\n", res);
+
+    acm.drv_details.cbStruct = sizeof(acm.drv_details);
+    res = acmDriverDetailsA(drvid, &acm.drv_details, 0);
+    ok(res == MMSYSERR_NOERROR, "Expected 0, got %d\n", res);
+todo_wine
+    ok(driver_calls.driver.open == 1, "Expected 1, got %d\n", driver_calls.driver.open);
+    ok(driver_calls.driver.details == 2, "Expected 2, got %d\n", driver_calls.driver.details);
+todo_wine
+    ok(driver_calls.driver.close == 0, "Expected 0, got %d\n", driver_calls.driver.close);
+}
+
 START_TEST(msacm)
 {
     driver_tests();
     test_prepareheader();
     test_acmFormatSuggest();
+    /* Test acmDriverAdd in the end as it may conflict
+     * with other tests due to codec lookup order */
+    test_acmDriverAdd();
 }
diff --git a/include/msacmdrv.h b/include/msacmdrv.h
index 3933ea1..09249fc 100644
--- a/include/msacmdrv.h
+++ b/include/msacmdrv.h
@@ -44,6 +44,7 @@
 
 #define ACMDM_DRIVER_NOTIFY             (ACMDM_BASE + 1)
 #define ACMDM_DRIVER_DETAILS            (ACMDM_BASE + 10)
+#define ACMDM_DRIVER_ABOUT              (ACMDM_BASE + 11)
 
 #define ACMDM_HARDWARE_WAVE_CAPS_INPUT  (ACMDM_BASE + 20)
 #define ACMDM_HARDWARE_WAVE_CAPS_OUTPUT (ACMDM_BASE + 21)
-- 
2.9.3




More information about the wine-patches mailing list