Commit 34a1917f authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

amstream/tests: Make test.avi filename an unicode string and test the file presence once for all.

parent 91cc9ad5
/* /*
* Unit tests for MultiMedia Stream functions * Unit tests for MultiMedia Stream functions
* *
* Copyright (C) 2009 Christian Costa * Copyright (C) 2009, 2012 Christian Costa
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -24,8 +24,7 @@ ...@@ -24,8 +24,7 @@
#include "initguid.h" #include "initguid.h"
#include "amstream.h" #include "amstream.h"
#define FILE_LEN 9 static const WCHAR filenameW[] = {'t','e','s','t','.','a','v','i',0};
static const char fileA[FILE_LEN] = "test.avi";
static IAMMultiMediaStream* pams; static IAMMultiMediaStream* pams;
static IDirectDraw7* pdd7; static IDirectDraw7* pdd7;
...@@ -88,22 +87,12 @@ static void release_directdraw(void) ...@@ -88,22 +87,12 @@ static void release_directdraw(void)
static void test_openfile(void) static void test_openfile(void)
{ {
HANDLE h;
HRESULT hr; HRESULT hr;
WCHAR fileW[FILE_LEN];
IGraphBuilder* pgraph; IGraphBuilder* pgraph;
if (!create_ammultimediastream()) if (!create_ammultimediastream())
return; 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); hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
ok(hr==S_OK, "IAMMultiMediaStream_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"); ok(pgraph==NULL, "Filtergraph should not be created yet\n");
...@@ -111,7 +100,7 @@ static void test_openfile(void) ...@@ -111,7 +100,7 @@ static void test_openfile(void)
if (pgraph) if (pgraph)
IGraphBuilder_Release(pgraph); IGraphBuilder_Release(pgraph);
hr = IAMMultiMediaStream_OpenFile(pams, fileW, 0); hr = IAMMultiMediaStream_OpenFile(pams, filenameW, 0);
ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr); ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr);
hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph); hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
...@@ -124,18 +113,20 @@ static void test_openfile(void) ...@@ -124,18 +113,20 @@ static void test_openfile(void)
release_ammultimediastream(); release_ammultimediastream();
} }
static void renderfile(const char * fileA) static void test_renderfile(void)
{ {
HRESULT hr; HRESULT hr;
WCHAR fileW[FILE_LEN];
IMediaStream *pvidstream = NULL; IMediaStream *pvidstream = NULL;
IDirectDrawMediaStream *pddstream = NULL; IDirectDrawMediaStream *pddstream = NULL;
IDirectDrawStreamSample *pddsample = NULL; IDirectDrawStreamSample *pddsample = NULL;
if (!create_ammultimediastream())
return;
if (!create_directdraw()) if (!create_directdraw())
{
release_ammultimediastream();
return; return;
}
MultiByteToWideChar(CP_ACP, 0, fileA, -1, fileW, FILE_LEN);
hr = IAMMultiMediaStream_Initialize(pams, STREAMTYPE_READ, 0, NULL); hr = IAMMultiMediaStream_Initialize(pams, STREAMTYPE_READ, 0, NULL);
ok(hr==S_OK, "IAMMultiMediaStream_Initialize returned: %x\n", hr); ok(hr==S_OK, "IAMMultiMediaStream_Initialize returned: %x\n", hr);
...@@ -146,7 +137,7 @@ static void renderfile(const char * fileA) ...@@ -146,7 +137,7 @@ static void renderfile(const char * fileA)
hr = IAMMultiMediaStream_AddMediaStream(pams, NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL); hr = IAMMultiMediaStream_AddMediaStream(pams, NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL);
ok(hr==S_OK, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr); ok(hr==S_OK, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr);
hr = IAMMultiMediaStream_OpenFile(pams, fileW, 0); hr = IAMMultiMediaStream_OpenFile(pams, filenameW, 0);
ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr); ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr);
hr = IAMMultiMediaStream_GetMediaStream(pams, &MSPID_PrimaryVideo, &pvidstream); hr = IAMMultiMediaStream_GetMediaStream(pams, &MSPID_PrimaryVideo, &pvidstream);
...@@ -169,28 +160,23 @@ error: ...@@ -169,28 +160,23 @@ error:
IMediaStream_Release(pvidstream); IMediaStream_Release(pvidstream);
release_directdraw(); release_directdraw();
release_ammultimediastream();
} }
static void test_render(void) START_TEST(amstream)
{ {
HANDLE h; HANDLE file;
if (!create_ammultimediastream()) CoInitializeEx(NULL, COINIT_MULTITHREADED);
return;
h = CreateFileA(fileA, 0, 0, NULL, OPEN_EXISTING, 0, NULL); file = CreateFileW(filenameW, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
if (h != INVALID_HANDLE_VALUE) { if (file != INVALID_HANDLE_VALUE)
CloseHandle(h); {
renderfile(fileA); CloseHandle(file);
}
release_ammultimediastream(); test_openfile();
} test_renderfile();
}
START_TEST(amstream)
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
test_openfile();
test_render();
CoUninitialize(); 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