push d0760662e4c9af92a52cfc83b053a1228de45087
[wine/hacks.git] / dlls / amstream / tests / amstream.c
blobc376e8e16fb2d599b2f310d08aaa2fe81e44101f
1 /*
2 * Unit tests for MultiMedia Stream functions
4 * Copyright (C) 2009 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <assert.h>
23 #define COBJMACROS
25 #include "wine/test.h"
26 #include "initguid.h"
27 #include "amstream.h"
29 #define FILE_LEN 9
30 static const char fileA[FILE_LEN] = "test.avi";
32 IAMMultiMediaStream* pams;
34 static int create_ammultimediastream(void)
36 return S_OK == CoCreateInstance(
37 &CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMultiMediaStream, (LPVOID*)&pams);
40 static void release_ammultimediastream(void)
42 IAMMultiMediaStream_Release(pams);
45 static void renderfile(const char * fileA)
47 HRESULT hr;
48 WCHAR fileW[FILE_LEN];
49 IGraphBuilder* pgraph;
51 MultiByteToWideChar(CP_ACP, 0, fileA, -1, fileW, FILE_LEN);
53 hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
54 ok(hr==S_OK, "GetFilterGraph returned: %x\n", hr);
55 ok(pgraph==NULL, "Filtergraph should not be created yet\n");
57 if (pgraph)
58 IGraphBuilder_Release(pgraph);
60 hr = IAMMultiMediaStream_OpenFile(pams, fileW, 0);
61 ok(hr==S_OK, "OpenFile returned: %x\n", hr);
63 hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
64 ok(hr==S_OK, "GetFilterGraph returned: %x\n", hr);
65 ok(pgraph!=NULL, "Filtergraph should be created\n");
67 if (pgraph)
68 IGraphBuilder_Release(pgraph);
71 static void test_render(void)
73 HANDLE h;
75 if (!create_ammultimediastream())
76 return;
78 h = CreateFileA(fileA, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
79 if (h != INVALID_HANDLE_VALUE) {
80 CloseHandle(h);
81 renderfile(fileA);
84 release_ammultimediastream();
87 START_TEST(amstream)
89 CoInitializeEx(NULL, COINIT_MULTITHREADED);
90 test_render();
91 CoUninitialize();