msacm32/tests: Add tests for acmFormatSuggest().

This commit is contained in:
Bruno Jesus 2015-09-09 12:10:39 +08:00 committed by Alexandre Julliard
parent d08197f92a
commit af8760e6e5
2 changed files with 109 additions and 0 deletions

View File

@ -594,8 +594,116 @@ static void test_prepareheader(void)
ok(mr == MMSYSERR_NOERROR, "close failed: 0x%x\n", mr);
}
static void test_acmFormatSuggest(void)
{
WAVEFORMATEX src, dst;
DWORD suggest;
MMRESULT rc;
/* Test a valid PCM format */
src.wFormatTag = WAVE_FORMAT_PCM;
src.nChannels = 1;
src.nSamplesPerSec = 8000;
src.nAvgBytesPerSec = 16000;
src.nBlockAlign = 2;
src.wBitsPerSample = 16;
src.cbSize = 0;
suggest = 0;
memset(&dst, 0, sizeof(dst));
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
ok(rc == MMSYSERR_NOERROR, "failed with error 0x%x\n", rc);
todo_wine
ok(src.wFormatTag == dst.wFormatTag, "expected %d, got %d\n", src.wFormatTag, dst.wFormatTag);
ok(src.nChannels == dst.nChannels, "expected %d, got %d\n", src.nChannels, dst.nChannels);
ok(src.nSamplesPerSec == dst.nSamplesPerSec, "expected %d, got %d\n", src.nSamplesPerSec, dst.nSamplesPerSec);
todo_wine
ok(src.nAvgBytesPerSec == dst.nAvgBytesPerSec, "expected %d, got %d\n", src.nAvgBytesPerSec, dst.nAvgBytesPerSec);
todo_wine
ok(src.nBlockAlign == dst.nBlockAlign, "expected %d, got %d\n", src.nBlockAlign, dst.nBlockAlign);
todo_wine
ok(src.wBitsPerSample == dst.wBitsPerSample, "expected %d, got %d\n", src.wBitsPerSample, dst.wBitsPerSample);
/* All parameters from destination are valid */
suggest = ACM_FORMATSUGGESTF_NCHANNELS
| ACM_FORMATSUGGESTF_NSAMPLESPERSEC
| ACM_FORMATSUGGESTF_WBITSPERSAMPLE
| ACM_FORMATSUGGESTF_WFORMATTAG;
dst = src;
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
ok(rc == MMSYSERR_NOERROR, "failed with error 0x%x\n", rc);
ok(src.wFormatTag == dst.wFormatTag, "expected %d, got %d\n", src.wFormatTag, dst.wFormatTag);
ok(src.nChannels == dst.nChannels, "expected %d, got %d\n", src.nChannels, dst.nChannels);
ok(src.nSamplesPerSec == dst.nSamplesPerSec, "expected %d, got %d\n", src.nSamplesPerSec, dst.nSamplesPerSec);
ok(src.nAvgBytesPerSec == dst.nAvgBytesPerSec, "expected %d, got %d\n", src.nAvgBytesPerSec, dst.nAvgBytesPerSec);
ok(src.nBlockAlign == dst.nBlockAlign, "expected %d, got %d\n", src.nBlockAlign, dst.nBlockAlign);
ok(src.wBitsPerSample == dst.wBitsPerSample, "expected %d, got %d\n", src.wBitsPerSample, dst.wBitsPerSample);
/* Test for WAVE_FORMAT_MSRT24 used in Monster Truck Madness 2 */
src.wFormatTag = WAVE_FORMAT_MSRT24;
src.nChannels = 1;
src.nSamplesPerSec = 8000;
src.nAvgBytesPerSec = 16000;
src.nBlockAlign = 2;
src.wBitsPerSample = 16;
src.cbSize = 0;
dst = src;
suggest = ACM_FORMATSUGGESTF_NCHANNELS
| ACM_FORMATSUGGESTF_NSAMPLESPERSEC
| ACM_FORMATSUGGESTF_WBITSPERSAMPLE
| ACM_FORMATSUGGESTF_WFORMATTAG;
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
todo_wine
ok(rc == ACMERR_NOTPOSSIBLE, "failed with error 0x%x\n", rc);
memset(&dst, 0, sizeof(dst));
suggest = 0;
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
todo_wine
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
/* Invalid struct size */
src.wFormatTag = WAVE_FORMAT_PCM;
rc = acmFormatSuggest(NULL, &src, &dst, 0, suggest);
todo_wine
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) / 2, suggest);
todo_wine
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
/* cbSize is the last parameter and not required for PCM */
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - 1, suggest);
ok(rc == MMSYSERR_NOERROR, "failed with error 0x%x\n", rc);
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - sizeof(dst.cbSize), suggest);
ok(rc == MMSYSERR_NOERROR, "failed with error 0x%x\n", rc);
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - sizeof(dst.cbSize) - 1, suggest);
todo_wine
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
/* cbSize is required for others */
src.wFormatTag = WAVE_FORMAT_ADPCM;
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - sizeof(dst.cbSize), suggest);
todo_wine
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - 1, suggest);
todo_wine
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
/* Invalid suggest flags */
src.wFormatTag = WAVE_FORMAT_PCM;
suggest = 0xFFFFFFFF;
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
ok(rc == MMSYSERR_INVALFLAG, "failed with error 0x%x\n", rc);
/* Invalid source and destination */
suggest = 0;
rc = acmFormatSuggest(NULL, NULL, &dst, sizeof(dst), suggest);
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
rc = acmFormatSuggest(NULL, &src, NULL, sizeof(dst), suggest);
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
rc = acmFormatSuggest(NULL, NULL, NULL, sizeof(dst), suggest);
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
}
START_TEST(msacm)
{
driver_tests();
test_prepareheader();
test_acmFormatSuggest();
}

View File

@ -107,6 +107,7 @@ typedef struct _WAVEFORMATEX {
#define WAVE_FORMAT_G721_ADPCM 0x0040 /* Antex Electronics Corporation */
#define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */
#define WAVE_FORMAT_MPEGLAYER3 0x0055
#define WAVE_FORMAT_MSRT24 0x0082 /* Microsoft Corporation */
#define WAVE_FORMAT_CREATIVE_ADPCM 0x0200 /* Creative Labs, Inc */
#define WAVE_FORMAT_CREATIVE_FASTSPEECH8 0x0202 /* Creative Labs, Inc */
#define WAVE_FORMAT_CREATIVE_FASTSPEECH10 0x0203 /* Creative Labs, Inc */