[WINMM_WINETEST] Sync with Wine Staging 1.7.55. CORE-10536

svn path=/trunk/; revision=70141
This commit is contained in:
Amine Khaldi 2015-11-26 23:39:16 +00:00
parent d25d1c5a58
commit 740589c097
4 changed files with 283 additions and 2 deletions

View file

@ -156,7 +156,7 @@ static void test_api(void)
par = 0xdead;
ret = joyGetThreshold(joyid, &par);
ok(ret == JOYERR_NOERROR, "Test [%d]: Expected %d, got %d\n", i, JOYERR_NOERROR, ret);
if (!win98 || (win98 && i < 8))
if (!win98 || i < 8)
{
if ((1 << i) & threshold_error)
ok(par == period[8], "Test [%d]: Expected %d, got %d\n", i, period[8], par);
@ -195,6 +195,35 @@ static void test_api(void)
ret = joyGetPosEx(joyid, &infoex.ex);
ok(ret == JOYERR_NOERROR, "Expected %d, got %d\n", JOYERR_NOERROR, ret);
}
/* the interactive tests spans for 15 seconds, a 500ms polling is used to get
* changes in the joystick. */
if (winetest_interactive)
{
#define MAX_TIME 15000
DWORD tick = GetTickCount(), spent;
infoex.ex.dwSize = sizeof(infoex.ex);
infoex.ex.dwFlags = JOY_RETURNALL;
do
{
spent = GetTickCount() - tick;
ret = joyGetPosEx(joyid, &infoex.ex);
if (ret == JOYERR_NOERROR)
{
trace("X: %5d, Y: %5d, Z: %5d, POV: %5d\n",
infoex.ex.dwXpos, infoex.ex.dwYpos, infoex.ex.dwZpos, infoex.ex.dwPOV);
trace("R: %5d, U: %5d, V: %5d\n",
infoex.ex.dwRpos, infoex.ex.dwUpos, infoex.ex.dwVpos);
trace("BUTTONS: 0x%04X, BUTTON_COUNT: %2d, REMAINING: %d ms\n\n",
infoex.ex.dwButtons, infoex.ex.dwButtonNumber, MAX_TIME - spent);
}
Sleep(500);
}
while (spent < MAX_TIME);
#undef MAX_TIME
}
else
skip("Skipping interactive tests for the joystick\n");
}
START_TEST(joystick)

View file

@ -1329,10 +1329,72 @@ static void test_playWaveTypeMpegvideo(void)
ok(status_parm.dwReturn == MCI_MODE_PLAY,
"mciCommand status mode: %u\n", (DWORD)status_parm.dwReturn);
err = mciSendStringA("setaudio mysound volume to 1000", NULL, 0, NULL);
ok(!err,"mci setaudio volume to 1000 returned %s\n", dbg_mcierr(err));
err = mciSendStringA("status mysound mode", buf, sizeof(buf), NULL);
ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
ok(!strcmp(buf,"playing"), "mci status mode: %s\n", buf);
err = mciSendStringA("setaudio mysound volume to 1001", NULL, 0, NULL);
ok(err==MCIERR_OUTOFRANGE,"mci setaudio volume to 1001 returned %s\n", dbg_mcierr(err));
err = mciSendStringA("status mysound mode", buf, sizeof(buf), NULL);
ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
ok(!strcmp(buf,"playing"), "mci status mode: %s\n", buf);
err = mciSendStringA("close mysound", NULL, 0, NULL);
ok(!err,"mci close returned %s\n", dbg_mcierr(err));
}
static void test_asyncWaveTypeMpegvideo(HWND hwnd)
{
MCIDEVICEID wDeviceID;
int err;
char buf[1024];
memset(buf, 0, sizeof(buf));
err = mciSendStringA("open tempfile.wav alias mysound notify type mpegvideo", buf, sizeof(buf), hwnd);
ok(err==ok_saved,"mci open tempfile.wav returned %s\n", dbg_mcierr(err));
if(err) {
skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err));
return;
}
ok(!strcmp(buf,"1"), "mci open deviceId: %s, expected 1\n", buf);
wDeviceID = atoi(buf);
ok(wDeviceID,"mci open DeviceID: %d\n", wDeviceID);
test_notification(hwnd,"open alias notify",MCI_NOTIFY_SUCCESSFUL);
err = mciSendStringA("play mysound notify", NULL, 0, hwnd);
ok(!err,"mci play returned %s\n", dbg_mcierr(err));
Sleep(500); /* milliseconds */
err = mciSendStringA("pause mysound wait", NULL, 0, hwnd);
ok(!err,"mci pause wait returned %s\n", dbg_mcierr(err));
err = mciSendStringA("status mysound mode notify", buf, sizeof(buf), hwnd);
ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
if(!err) ok(!strcmp(buf,"paused"), "mci status mode: %s\n", buf);
test_notification(hwnd,"play (superseded)",MCI_NOTIFY_SUPERSEDED);
test_notification(hwnd,"status",MCI_NOTIFY_SUCCESSFUL);
err = mciSendStringA("seek mysound to start wait", NULL, 0, NULL);
ok(!err,"mci seek to start wait returned %s\n", dbg_mcierr(err));
err = mciSendStringA("set mysound time format milliseconds", NULL, 0, NULL);
ok(!err,"mci time format milliseconds returned %s\n", dbg_mcierr(err));
err = mciSendStringA("play mysound to 1500 notify", NULL, 0, hwnd);
ok(!err,"mci play returned %s\n", dbg_mcierr(err));
Sleep(200);
test_notification(hwnd,"play",0);
err = mciSendStringA("close mysound wait", NULL, 0, NULL);
ok(!err,"mci close wait returned %s\n", dbg_mcierr(err));
test_notification(hwnd,"play (aborted by close)",MCI_NOTIFY_ABORTED);
}
START_TEST(mci)
{
char curdir[MAX_PATH], tmpdir[MAX_PATH];
@ -1353,6 +1415,7 @@ START_TEST(mci)
test_asyncWAVE(hwnd);
test_AutoOpenWAVE(hwnd);
test_playWaveTypeMpegvideo();
test_asyncWaveTypeMpegvideo(hwnd);
}else
skip("No output devices available, skipping all output tests\n");
/* Win9X hangs when exiting with something still open. */

View file

@ -599,12 +599,15 @@ static void test_mmioSetBuffer(char *fname)
static LRESULT CALLBACK mmio_test_IOProc(LPSTR lpMMIOInfo, UINT uMessage, LPARAM lParam1, LPARAM lParam2)
{
LPMMIOINFO lpInfo = (LPMMIOINFO) lpMMIOInfo;
int i;
switch (uMessage)
{
case MMIOM_OPEN:
if (lpInfo->fccIOProc == FOURCC_DOS)
lpInfo->fccIOProc = mmioFOURCC('F', 'A', 'I', 'L');
for (i = 0; i < sizeof(lpInfo->adwInfo) / sizeof(*lpInfo->adwInfo); i++)
ok(lpInfo->adwInfo[i] == 0, "[%d] Expected 0, got %u\n", i, lpInfo->adwInfo[i]);
return MMSYSERR_NOERROR;
case MMIOM_CLOSE:
return MMSYSERR_NOERROR;
@ -642,6 +645,18 @@ static void test_mmioOpen_fourcc(void)
mmio.lDiskOffset);
mmioClose(hmmio, 0);
/* Same test with NULL info */
memset(&mmio, 0, sizeof(mmio));
hmmio = mmioOpenA(fname, NULL, MMIO_READ);
mmioGetInfo(hmmio, &mmio, 0);
ok(hmmio && mmio.fccIOProc == FOURCC_XYZ, "mmioOpenA error %u, got %4.4s\n",
mmio.wErrorRet, (LPCSTR)&mmio.fccIOProc);
ok(mmio.adwInfo[1] == 0, "mmioOpenA sent MMIOM_SEEK, got %d\n",
mmio.adwInfo[1]);
ok(mmio.lDiskOffset == 0, "mmioOpenA updated lDiskOffset, got %d\n",
mmio.lDiskOffset);
mmioClose(hmmio, 0);
mmioInstallIOProcA(FOURCC_XYZ, NULL, MMIO_REMOVEPROC);
memset(&mmio, 0, sizeof(mmio));
@ -870,7 +885,8 @@ static void test_mmio_buffer_pointer(void)
ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
/* fill the buffer */
size = mmioAdvance(hmmio, &mmio, MMIO_READ);
res = mmioAdvance(hmmio, &mmio, MMIO_READ);
ok(res == MMSYSERR_NOERROR, "mmioAdvance failed %x\n", res);
ok(mmio.pchEndRead-mmio.pchBuffer == sizeof(buffer), "got %d\n", (int)(mmio.pchEndRead-mmio.pchBuffer));
/* seeking to the same buffer chunk, the buffer is kept */
@ -906,6 +922,88 @@ static void test_mmio_buffer_pointer(void)
DeleteFileA(test_file);
}
static void test_riff_write(void)
{
static const DWORD test_write_data[] =
{
FOURCC_RIFF, 0x28, mmioFOURCC('W','A','V','E'), mmioFOURCC('d','a','t','a'),
0x1b, 0xdededede, 0xdededede, 0xefefefef,
0xefefefef, 0xbabababa, 0xbabababa, 0xefefef
};
char name[] = "test_write.wav";
char buf[256];
MMCKINFO chunk_info[2];
MMIOINFO info;
HMMIO mmio;
MMRESULT ret;
LONG written;
DWORD read;
HANDLE h;
memset(chunk_info, 0, sizeof(chunk_info));
mmio = mmioOpenA(name, NULL, MMIO_ALLOCBUF|MMIO_CREATE|MMIO_READWRITE);
ok(mmio != NULL, "mmioOpen failed\n");
chunk_info[0].fccType = mmioFOURCC('W','A','V','E');
ret = mmioCreateChunk(mmio, chunk_info, MMIO_CREATERIFF);
ok(ret == MMSYSERR_NOERROR, "mmioCreateChunk failed %x\n", ret);
ok(chunk_info[0].ckid == FOURCC_RIFF, "chunk_info[0].ckid = %x\n", chunk_info[0].ckid);
ok(chunk_info[0].cksize == 0, "chunk_info[0].cksize = %d\n", chunk_info[0].cksize);
ok(chunk_info[0].dwDataOffset == 8, "chunk_info[0].dwDataOffset = %d\n", chunk_info[0].dwDataOffset);
ok(chunk_info[0].dwFlags == MMIO_DIRTY, "chunk_info[0].dwFlags = %x\n", chunk_info[0].dwFlags);
chunk_info[1].ckid = mmioFOURCC('d','a','t','a');
ret = mmioCreateChunk(mmio, chunk_info+1, 0);
ok(ret == MMSYSERR_NOERROR, "mmioCreateChunk failed %x\n", ret);
ok(chunk_info[1].ckid == mmioFOURCC('d','a','t','a'), "chunk_info[1].ckid = %x\n", chunk_info[1].ckid);
ok(chunk_info[1].cksize == 0, "chunk_info[1].cksize = %d\n", chunk_info[1].cksize);
ok(chunk_info[1].dwDataOffset == 20, "chunk_info[1].dwDataOffset = %d\n", chunk_info[1].dwDataOffset);
ok(chunk_info[1].dwFlags == MMIO_DIRTY, "chunk_info[1].dwFlags = %x\n", chunk_info[1].dwFlags);
memset(buf, 0xde, sizeof(buf));
written = mmioWrite(mmio, buf, 8);
ok(written == 8, "mmioWrite failed %x\n", ret);
ret = mmioGetInfo(mmio, &info, 0);
ok(ret == MMSYSERR_NOERROR, "mmioGetInfo failed %x\n", ret);
memset(info.pchNext, 0xef, 8);
info.pchNext += 8;
ret = mmioAdvance(mmio, &info, 1);
ok(ret == MMSYSERR_NOERROR, "mmioAdvance failed %x\n", ret);
ok(info.lBufOffset == 36, "info.lBufOffset = %d\n", info.lBufOffset);
info.dwFlags |= MMIO_DIRTY;
memset(info.pchNext, 0xba, 8);
info.pchNext += 8;
ret = mmioAdvance(mmio, &info, 1);
ok(ret == MMSYSERR_NOERROR, "mmioAdvance failed %x\n", ret);
ok(info.lBufOffset == 44, "info.lBufOffset = %d\n", info.lBufOffset);
info.dwFlags |= MMIO_DIRTY;
memset(info.pchNext, 0xef, 3);
info.pchNext += 3;
ret = mmioSetInfo(mmio, &info, 0);
ok(ret == MMSYSERR_NOERROR, "mmioSetInfo failed %x\n", ret);
ret = mmioAscend(mmio, chunk_info+1, 0);
ok(ret == MMSYSERR_NOERROR, "mmioAscend failed %x\n", ret);
ret = mmioAscend(mmio, chunk_info, 0);
ok(ret == MMSYSERR_NOERROR, "mmioAscend failed %x\n", ret);
ret = mmioClose(mmio, 0);
ok(ret == MMSYSERR_NOERROR, "mmioClose failed %x\n", ret);
h = CreateFileA("test_write.wav", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
ok(h != INVALID_HANDLE_VALUE, "CreateFile failed\n");
ok(ReadFile(h, buf, sizeof(buf), &read, NULL), "ReadFile failed\n");
CloseHandle(h);
ok(!memcmp(buf, test_write_data, sizeof(test_write_data)), "created file is incorrect\n");
DeleteFileA("test_write.wav");
}
START_TEST(mmio)
{
/* Make it possible to run the tests against a specific AVI file in
@ -924,4 +1022,5 @@ START_TEST(mmio)
test_mmioSeek();
test_mmio_end_of_file();
test_mmio_buffer_pointer();
test_riff_write();
}

View file

@ -1603,10 +1603,100 @@ static void test_fragmentsize(void)
CloseHandle(hevent);
}
static void create_wav_file(char *temp_file)
{
WAVEFORMATEX format;
HMMIO h;
MMCKINFO riff_chunk, chunk;
MMRESULT rc;
LONG written;
DWORD length;
char *buffer;
format.wFormatTag=WAVE_FORMAT_PCM;
format.cbSize = 0;
format.nChannels=1;
format.wBitsPerSample=8;
format.nSamplesPerSec=8000;
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
h = mmioOpenA(temp_file, NULL, MMIO_ALLOCBUF | MMIO_WRITE | MMIO_CREATE);
ok(h != NULL, "Can't open temp_file\n");
riff_chunk.fccType = mmioFOURCC('W','A','V','E');
riff_chunk.cksize = 0;
rc = mmioCreateChunk(h, &riff_chunk, MMIO_CREATERIFF);
ok(rc == MMSYSERR_NOERROR, "mmioCreateChunk failed, got %u\n", rc);
chunk.ckid = mmioFOURCC('f','m','t',' ');
chunk.cksize = 0;
rc = mmioCreateChunk(h, &chunk, 0);
ok(rc == MMSYSERR_NOERROR, "mmioCreateChunk failed, got %u\n", rc);
written = mmioWrite(h, (char*)&format, sizeof(format));
ok(written == sizeof(format), "mmioWrite failed, got %d\n", written);
rc = mmioAscend(h, &chunk, 0);
ok(rc == MMSYSERR_NOERROR, "mmioAscend failed, got %d\n", rc);
chunk.ckid = mmioFOURCC('d','a','t','a');
rc = mmioCreateChunk(h, &chunk, 0);
ok(rc == MMSYSERR_NOERROR, "mmioCreateChunk failed, got %u\n", rc);
buffer = wave_generate_silence(&format, .1, &length);
written = mmioWrite(h, buffer, length);
ok(written == length, "mmioWrite failed, got %d\n", written);
rc = mmioAscend(h, &chunk, 0);
ok(rc == MMSYSERR_NOERROR, "mmioAscend failed, got %d\n", rc);
HeapFree(GetProcessHeap(), 0, buffer);
rc = mmioAscend(h, &riff_chunk, 0);
ok(rc == MMSYSERR_NOERROR, "mmioAscend failed, got %d\n", rc);
rc = mmioClose(h, 0);
ok(rc == MMSYSERR_NOERROR, "mmioClose failed, got %u\n", rc);
}
static void test_PlaySound(void)
{
BOOL br;
char test_file[MAX_PATH], temp[MAX_PATH], *exts;
if(waveOutGetNumDevs() == 0) {
skip("No output devices available\n");
return;
}
GetTempPathA(sizeof(test_file), test_file);
strcat(test_file, "mysound.wav");
create_wav_file(test_file);
br = PlaySoundA(test_file, NULL, SND_FILENAME | SND_NODEFAULT);
ok(br, "PlaySound failed, got %d\n", br);
/* SND_ALIAS fallbacks to SND_FILENAME */
br = PlaySoundA(test_file, NULL, SND_ALIAS | SND_NODEFAULT);
ok(br, "PlaySound failed, got %d\n", br);
strcpy(temp, test_file);
exts = strrchr(temp, '.');
/* no extensions */
*exts = '\0';
br = PlaySoundA(temp, NULL, SND_FILENAME | SND_NODEFAULT);
ok(br, "PlaySound failed, got %d\n", br);
/* ends with a dot */
strcpy(exts, ".");
br = PlaySoundA(temp, NULL, SND_FILENAME | SND_NODEFAULT);
ok(!br || broken(br), "PlaySound succeeded, got %d\n", br);
DeleteFileA(test_file);
}
START_TEST(wave)
{
test_multiple_waveopens();
wave_out_tests();
test_sndPlaySound();
test_fragmentsize();
test_PlaySound();
}