Commit 2e44a3b2 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

dsound: Fix tests for old versions of windows.

parent 670cf778
......@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = dsound.dll
IMPORTS = dsound ole32 version user32 kernel32
IMPORTS = ole32 version user32 kernel32
EXTRALIBS = -ldxguid -luuid -ldxerr8
CTESTS = \
......
......@@ -710,20 +710,27 @@ START_TEST(capture)
CoInitialize(NULL);
hDsound = GetModuleHandleA("dsound.dll");
ok(hDsound != NULL, "dsound.dll not loaded!\n");
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,"DirectSoundCaptureCreate");
pDirectSoundCaptureEnumerateA=(void*)GetProcAddress(hDsound,"DirectSoundCaptureEnumerateA");
if (!pDirectSoundCaptureCreate || !pDirectSoundCaptureEnumerateA)
hDsound = LoadLibrary("dsound.dll");
if (hDsound)
{
trace("capture test skipped\n");
return;
}
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,
"DirectSoundCaptureCreate");
pDirectSoundCaptureEnumerateA=(void*)GetProcAddress(hDsound,
"DirectSoundCaptureEnumerateA");
if (pDirectSoundCaptureCreate && pDirectSoundCaptureEnumerateA)
{
IDirectSoundCapture_tests();
capture_tests();
}
else
skip("capture test skipped\n");
IDirectSoundCapture_tests();
capture_tests();
FreeLibrary(hDsound);
}
else
skip("dsound.dll not found!\n");
CoUninitialize();
}
......@@ -34,6 +34,12 @@
#include "dsound_test.h"
#define PI 3.14159265358979323846
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
LPUNKNOWN)=NULL;
char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
{
int i;
......@@ -686,7 +692,7 @@ static HRESULT test_secondary(LPGUID lpGuid, int play,
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -954,7 +960,7 @@ static HRESULT test_for_driver(LPGUID lpGuid)
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -978,7 +984,7 @@ static HRESULT test_primary(LPGUID lpGuid)
int ref, i;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -1065,7 +1071,7 @@ static HRESULT test_primary_3d(LPGUID lpGuid)
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -1139,7 +1145,7 @@ static HRESULT test_primary_3d_with_listener(LPGUID lpGuid)
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",
DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -1280,17 +1286,32 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
static void ds3d_tests(void)
{
HRESULT rc;
rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
}
START_TEST(ds3d)
{
HMODULE hDsound;
CoInitialize(NULL);
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
hDsound = LoadLibrary("dsound.dll");
if (hDsound)
{
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
ds3d_tests();
pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
"DirectSoundEnumerateA");
pDirectSoundCreate = (void*)GetProcAddress(hDsound,
"DirectSoundCreate");
ds3d_tests();
FreeLibrary(hDsound);
}
else
skip("dsound.dll not found!\n");
CoUninitialize();
}
......@@ -33,6 +33,7 @@
#include "dsound_test.h"
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,LPUNKNOWN)=NULL;
typedef struct {
......@@ -635,9 +636,18 @@ static HRESULT test_secondary8(LPGUID lpGuid, int play,
&listener_param);
ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
"failed: %s\n",DXGetErrorString8(rc));
} else {
ok(listener==NULL, "IDirectSoundBuffer_QueryInterface() "
"failed but returned a listener anyway\n");
ok(rc!=DS_OK, "IDirectSoundBuffer_QueryInterface() succeeded "
"but returned a NULL listener\n");
if (listener) {
ref=IDirectSound3DListener_Release(listener);
ok(ref==0,"IDirectSound3dListener_Release() listener has "
"%d references, should have 0\n",ref);
}
goto EXIT2;
}
else
goto EXIT;
}
init_format(&wfx,WAVE_FORMAT_PCM,22050,16,2);
......@@ -795,18 +805,28 @@ static HRESULT test_secondary8(LPGUID lpGuid, int play,
ref);
}
}
}
EXIT1:
if (has_listener) {
ref=IDirectSound3DListener_Release(listener);
ok(ref==0,"IDirectSound3dListener_Release() listener has %d "
"references, should have 0\n",ref);
if (has_listener) {
ref=IDirectSound3DListener_Release(listener);
ok(ref==0,"IDirectSound3dListener_Release() listener has %d "
"references, should have 0\n",ref);
} else {
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0\n",ref);
}
} else {
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0\n",ref);
ok(primary==NULL,"IDirectSound8_CreateSoundBuffer(primary) failed "
"but primary created anyway\n");
ok(rc!=DS_OK,"IDirectSound8_CreateSoundBuffer(primary) succeeded "
"but primary not created\n");
if (primary) {
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0\n",ref);
}
}
EXIT2:
/* Set the CooperativeLevel back to normal */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
......@@ -1152,7 +1172,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
static void ds3d8_tests(void)
{
HRESULT rc;
rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
}
......@@ -1162,17 +1182,24 @@ START_TEST(ds3d8)
CoInitialize(NULL);
hDsound = GetModuleHandleA("dsound.dll");
ok(hDsound != NULL, "dsound.dll not loaded!\n");
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
hDsound = LoadLibrary("dsound.dll");
if (hDsound)
{
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
"DirectSoundEnumerateA");
pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
"DirectSoundCreate8");
if (pDirectSoundCreate8)
ds3d8_tests();
else
skip("ds3d8 test skipped\n");
pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
if (!pDirectSoundCreate8) {
trace("ds3d8 test skipped\n");
return;
FreeLibrary(hDsound);
}
ds3d8_tests();
else
skip("dsound.dll not found!\n");
CoUninitialize();
}
......@@ -34,6 +34,10 @@
#include "dsound_test.h"
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
LPUNKNOWN)=NULL;
static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized,
LPCGUID lpGuid)
{
......@@ -227,14 +231,14 @@ static void IDirectSound_tests(void)
"should have failed: %s\n",DXGetErrorString8(rc));
/* try with no device specified */
rc=DirectSoundCreate(NULL,&dso,NULL);
rc=pDirectSoundCreate(NULL,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate(NULL) failed: %s\n",DXGetErrorString8(rc));
if (rc==S_OK && dso)
IDirectSound_test(dso, TRUE, NULL);
/* try with default playback device specified */
rc=DirectSoundCreate(&DSDEVID_DefaultPlayback,&dso,NULL);
rc=pDirectSoundCreate(&DSDEVID_DefaultPlayback,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate(DSDEVID_DefaultPlayback) failed: %s\n",
DXGetErrorString8(rc));
......@@ -242,7 +246,7 @@ static void IDirectSound_tests(void)
IDirectSound_test(dso, TRUE, NULL);
/* try with default voice playback device specified */
rc=DirectSoundCreate(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
rc=pDirectSoundCreate(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate(DSDEVID_DefaultVoicePlayback) failed: %s\n",
DXGetErrorString8(rc));
......@@ -250,7 +254,7 @@ static void IDirectSound_tests(void)
IDirectSound_test(dso, TRUE, NULL);
/* try with a bad device specified */
rc=DirectSoundCreate(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
rc=pDirectSoundCreate(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
ok(rc==DSERR_NODRIVER,"DirectSoundCreate(DSDEVID_DefaultVoiceCapture) "
"should have failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && dso)
......@@ -264,12 +268,12 @@ static HRESULT test_dsound(LPGUID lpGuid)
int ref;
/* DSOUND: Error: Invalid interface buffer */
rc=DirectSoundCreate(lpGuid,0,NULL);
rc=pDirectSoundCreate(lpGuid,0,NULL);
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate() should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -287,13 +291,13 @@ static HRESULT test_dsound(LPGUID lpGuid)
IDirectSound_test(dso, FALSE, lpGuid);
/* Create a DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
LPDIRECTSOUND dso1=NULL;
/* Create a second DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso1,NULL);
rc=pDirectSoundCreate(lpGuid,&dso1,NULL);
ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
/* Release the second DirectSound object */
......@@ -313,7 +317,7 @@ static HRESULT test_dsound(LPGUID lpGuid)
return rc;
/* Create a DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK) {
LPDIRECTSOUNDBUFFER secondary;
......@@ -369,7 +373,7 @@ static HRESULT test_primary(LPGUID lpGuid)
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -513,7 +517,7 @@ static HRESULT test_primary_secondary(LPGUID lpGuid)
int f,ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -651,7 +655,7 @@ static HRESULT test_secondary(LPGUID lpGuid)
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -763,7 +767,7 @@ static HRESULT test_block_align(LPGUID lpGuid)
int ref;
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -823,7 +827,7 @@ static HRESULT test_frequency(LPGUID lpGuid)
48000, 96000 };
/* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL);
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
......@@ -939,18 +943,33 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
static void dsound_tests(void)
{
HRESULT rc;
rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
}
START_TEST(dsound)
{
HMODULE hDsound;
CoInitialize(NULL);
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
hDsound = LoadLibrary("dsound.dll");
if (hDsound)
{
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
"DirectSoundEnumerateA");
pDirectSoundCreate = (void*)GetProcAddress(hDsound,
"DirectSoundCreate");
IDirectSound_tests();
dsound_tests();
IDirectSound_tests();
dsound_tests();
FreeLibrary(hDsound);
}
else
skip("dsound.dll not found!\n");
CoUninitialize();
}
......@@ -35,6 +35,7 @@
#include "dsound_test.h"
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,LPUNKNOWN)=NULL;
int align(int length, int align)
......@@ -808,7 +809,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
static void dsound8_tests(void)
{
HRESULT rc;
rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
}
......@@ -852,18 +853,27 @@ START_TEST(dsound8)
CoInitialize(NULL);
hDsound = GetModuleHandleA("dsound.dll");
ok(hDsound != NULL, "dsound.dll not loaded!\n");
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
hDsound = LoadLibrary("dsound.dll");
if (hDsound)
{
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
"DirectSoundEnumerateA");
pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
"DirectSoundCreate8");
if (pDirectSoundCreate8)
{
IDirectSound8_tests();
dsound8_tests();
}
else
skip("dsound8 test skipped\n");
pDirectSoundCreate8 = (void*)GetProcAddress(hDsound, "DirectSoundCreate8");
if (!pDirectSoundCreate8) {
trace("dsound8 test skipped\n");
return;
FreeLibrary(hDsound);
}
IDirectSound8_tests();
dsound8_tests();
else
skip("dsound.dll not found!\n");
CoUninitialize();
}
......@@ -237,19 +237,22 @@ START_TEST(duplex)
CoInitialize(NULL);
hDsound = GetModuleHandleA("dsound.dll");
ok(hDsound != NULL, "dsound.dll not loaded!\n");
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,"DirectSoundFullDuplexCreate");
if (!pDirectSoundFullDuplexCreate)
hDsound = LoadLibrary("dsound.dll");
if (hDsound)
{
trace("duplex test skipped\n");
goto done;
}
trace("DLL Version: %s\n", get_file_version("dsound.dll"));
IDirectSoundFullDuplex_tests();
pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,
"DirectSoundFullDuplexCreate");
if (pDirectSoundFullDuplexCreate)
IDirectSoundFullDuplex_tests();
else
skip("duplex test skipped\n");
FreeLibrary(hDsound);
}
else
skip("dsound.dll not found!\n");
done:
CoUninitialize();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment