amstream/tests: Improve render file test. Move OpenFile specific test into a separate test function.

This commit is contained in:
Christian Costa 2009-04-19 22:35:41 +02:00 committed by Alexandre Julliard
parent eab59e84ac
commit c0f6808db6
2 changed files with 109 additions and 5 deletions

View File

@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = amstream.dll
IMPORTS = quartz oleaut32 ole32 kernel32
IMPORTS = quartz ddraw oleaut32 ole32 user32 kernel32
CTESTS = \
amstream.c

View File

@ -30,6 +30,8 @@
static const char fileA[FILE_LEN] = "test.avi";
IAMMultiMediaStream* pams;
IDirectDraw7* pdd7 = NULL;
IDirectDrawSurface7* pdds7 = NULL;
static int create_ammultimediastream(void)
{
@ -42,30 +44,131 @@ static void release_ammultimediastream(void)
IAMMultiMediaStream_Release(pams);
}
static void renderfile(const char * fileA)
static int create_directdraw(void)
{
HRESULT hr;
IDirectDraw* pdd = NULL;
DDSURFACEDESC2 ddsd;
hr = DirectDrawCreate(NULL, &pdd, NULL);
ok(hr==DD_OK, "DirectDrawCreate returned: %x\n", hr);
hr = IDirectDraw_QueryInterface(pdd, &IID_IDirectDraw7, (LPVOID*)&pdd7);
ok(hr==DD_OK, "QueryInterface returned: %x\n", hr);
if (hr != DD_OK) goto error;
hr = IDirectDraw7_SetCooperativeLevel(pdd7, GetDesktopWindow(), DDSCL_NORMAL);
ok(hr==DD_OK, "SetCooperativeLevel returned: %x\n", hr);
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = IDirectDraw7_CreateSurface(pdd7, &ddsd, &pdds7, NULL);
ok(hr==DD_OK, "CreateSurface returned: %x\n", hr);
return TRUE;
error:
if (pdds7)
IDirectDrawSurface7_Release(pdds7);
if (pdd7)
IDirectDraw7_Release(pdd7);
if (pdd)
IDirectDraw_Release(pdd);
return FALSE;
}
static void release_directdraw(void)
{
IDirectDrawSurface7_Release(pdds7);
IDirectDraw7_Release(pdd7);
}
static void test_openfile(void)
{
HANDLE h;
HRESULT hr;
WCHAR fileW[FILE_LEN];
IGraphBuilder* pgraph;
if (!create_ammultimediastream())
return;
h = CreateFileA(fileA, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
if (h == INVALID_HANDLE_VALUE) {
release_ammultimediastream();
return;
}
MultiByteToWideChar(CP_ACP, 0, fileA, -1, fileW, FILE_LEN);
hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
ok(hr==S_OK, "GetFilterGraph returned: %x\n", hr);
ok(hr==S_OK, "IAMMultiMediaStream_GetFilterGraph returned: %x\n", hr);
ok(pgraph==NULL, "Filtergraph should not be created yet\n");
if (pgraph)
IGraphBuilder_Release(pgraph);
hr = IAMMultiMediaStream_OpenFile(pams, fileW, 0);
ok(hr==S_OK, "OpenFile returned: %x\n", hr);
ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr);
hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
ok(hr==S_OK, "GetFilterGraph returned: %x\n", hr);
ok(hr==S_OK, "IAMMultiMediaStream_GetFilterGraph returned: %x\n", hr);
ok(pgraph!=NULL, "Filtergraph should be created\n");
if (pgraph)
IGraphBuilder_Release(pgraph);
release_ammultimediastream();
}
static void renderfile(const char * fileA)
{
HRESULT hr;
WCHAR fileW[FILE_LEN];
IMediaStream *pvidstream = NULL;
IDirectDrawMediaStream *pddstream = NULL;
IDirectDrawStreamSample *pddsample = NULL;
if (!create_directdraw())
return;
MultiByteToWideChar(CP_ACP, 0, fileA, -1, fileW, FILE_LEN);
hr = IAMMultiMediaStream_Initialize(pams, STREAMTYPE_READ, 0, NULL);
ok(hr==S_OK, "IAMMultiMediaStream_Initialize returned: %x\n", hr);
hr = IAMMultiMediaStream_AddMediaStream(pams, (IUnknown*)pdd7, &MSPID_PrimaryVideo, 0, NULL);
ok(hr==S_OK, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr);
hr = IAMMultiMediaStream_AddMediaStream(pams, NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL);
ok(hr==S_OK, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr);
hr = IAMMultiMediaStream_OpenFile(pams, fileW, 0);
ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr);
hr = IAMMultiMediaStream_GetMediaStream(pams, &MSPID_PrimaryVideo, &pvidstream);
ok(hr==S_OK, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr);
if (FAILED(hr)) goto error;
hr = IMediaStream_QueryInterface(pvidstream, &IID_IDirectDrawMediaStream, (LPVOID*)&pddstream);
ok(hr==S_OK, "IMediaStream_QueryInterface returned: %x\n", hr);
if (FAILED(hr)) goto error;
hr = IDirectDrawMediaStream_CreateSample(pddstream, NULL, NULL, 0, &pddsample);
todo_wine ok(hr==S_OK, "IDirectDrawMediaStream_CreateSample returned: %x\n", hr);
error:
if (pddsample)
IDirectDrawMediaSample_Release(pddsample);
if (pddstream)
IDirectDrawMediaStream_Release(pddstream);
if (pvidstream)
IMediaStream_Release(pvidstream);
release_directdraw();
}
static void test_render(void)
@ -87,6 +190,7 @@ static void test_render(void)
START_TEST(amstream)
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
test_openfile();
test_render();
CoUninitialize();
}