msacm32/tests: Beginnings of a custom driver test.

Signed-off-by: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Bruno Jesus 2016-11-29 04:10:37 -02:00 committed by Alexandre Julliard
parent 1289a860de
commit f3f49a29d5
3 changed files with 168 additions and 1 deletions

View File

@ -1,5 +1,5 @@
TESTDLL = msacm32.dll TESTDLL = msacm32.dll
IMPORTS = msacm32 IMPORTS = msacm32 winmm
C_SRCS = \ C_SRCS = \
msacm.c msacm.c

View File

@ -31,6 +31,7 @@
#define NOBITMAP #define NOBITMAP
#include "mmreg.h" #include "mmreg.h"
#include "msacm.h" #include "msacm.h"
#include "msacmdrv.h"
static BOOL CALLBACK FormatTagEnumProc(HACMDRIVERID hadid, static BOOL CALLBACK FormatTagEnumProc(HACMDRIVERID hadid,
PACMFORMATTAGDETAILSA paftd, PACMFORMATTAGDETAILSA paftd,
@ -829,9 +830,174 @@ todo_wine
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc); 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) START_TEST(msacm)
{ {
driver_tests(); driver_tests();
test_prepareheader(); test_prepareheader();
test_acmFormatSuggest(); test_acmFormatSuggest();
/* Test acmDriverAdd in the end as it may conflict
* with other tests due to codec lookup order */
test_acmDriverAdd();
} }

View File

@ -44,6 +44,7 @@
#define ACMDM_DRIVER_NOTIFY (ACMDM_BASE + 1) #define ACMDM_DRIVER_NOTIFY (ACMDM_BASE + 1)
#define ACMDM_DRIVER_DETAILS (ACMDM_BASE + 10) #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_INPUT (ACMDM_BASE + 20)
#define ACMDM_HARDWARE_WAVE_CAPS_OUTPUT (ACMDM_BASE + 21) #define ACMDM_HARDWARE_WAVE_CAPS_OUTPUT (ACMDM_BASE + 21)