push e4fb87785f42653a03d84664d7db014c69dd1260
[wine/hacks.git] / dlls / amstream / tests / amstream.c
blob15b8a7b29160ec41d33ec03fbf31d0a9313fc3ab
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 "amstream.h"
28 #define FILE_LEN 9
29 static const char fileA[FILE_LEN] = "test.avi";
31 IAMMultiMediaStream* pams;
33 static int create_ammultimediastream(void)
35 return S_OK == CoCreateInstance(
36 &CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMultiMediaStream, (LPVOID*)&pams);
39 static void release_ammultimediastream(void)
41 IAMMultiMediaStream_Release(pams);
44 static void renderfile(const char * fileA)
46 HRESULT hr;
47 WCHAR fileW[FILE_LEN];
48 IGraphBuilder* pgraph;
50 MultiByteToWideChar(CP_ACP, 0, fileA, -1, fileW, FILE_LEN);
52 hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
53 ok(hr==S_OK, "GetFilterGraph returned: %x\n", hr);
54 ok(pgraph==NULL, "Filtergraph should not be created yet\n");
56 if (pgraph)
57 IGraphBuilder_Release(pgraph);
59 hr = IAMMultiMediaStream_OpenFile(pams, fileW, 0);
60 ok(hr==S_OK, "OpenFile returned: %x\n", hr);
62 hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
63 ok(hr==S_OK, "GetFilterGraph returned: %x\n", hr);
64 ok(pgraph!=NULL, "Filtergraph should be created\n");
66 if (pgraph)
67 IGraphBuilder_Release(pgraph);
70 static void test_render(void)
72 HANDLE h;
74 if (!create_ammultimediastream())
75 return;
77 h = CreateFileA(fileA, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
78 if (h != INVALID_HANDLE_VALUE) {
79 CloseHandle(h);
80 renderfile(fileA);
83 release_ammultimediastream();
86 START_TEST(amstream)
88 CoInitializeEx(NULL, COINIT_MULTITHREADED);
89 test_render();
90 CoUninitialize();