atl80: Added AtlComModuleRegisterServer implementation (based on AtlModuleRegisterSer...
[wine] / dlls / msvfw32 / tests / msvfw.c
1 /*
2  * Unit tests for video playback
3  *
4  * Copyright 2008,2010 Jörg Höhle
5  * Copyright 2008 Austin English
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #define WIN32_LEAN_AND_MEAN
23 #include <windows.h>
24 #include <vfw.h>
25
26 #include "wine/test.h"
27
28 static void test_OpenCase(void)
29 {
30     HIC h;
31     /* Open a compressor with combinations of lowercase
32      * and uppercase compressortype and handler.
33      */
34     h = ICOpen(mmioFOURCC('v','i','d','c'),mmioFOURCC('m','s','v','c'),ICMODE_DECOMPRESS);
35     ok(0!=h,"ICOpen(vidc.msvc) failed\n");
36     if (h) {
37         ok(ICClose(h)==ICERR_OK,"ICClose failed\n");
38     }
39     h = ICOpen(mmioFOURCC('v','i','d','c'),mmioFOURCC('M','S','V','C'),ICMODE_DECOMPRESS);
40     ok(0!=h,"ICOpen(vidc.MSVC) failed\n");
41     if (h) {
42         ok(ICClose(h)==ICERR_OK,"ICClose failed\n");
43     }
44     h = ICOpen(mmioFOURCC('V','I','D','C'),mmioFOURCC('m','s','v','c'),ICMODE_DECOMPRESS);
45     ok(0!=h,"ICOpen(VIDC.msvc) failed\n");
46     if (h) {
47         ok(ICClose(h)==ICERR_OK,"ICClose failed\n");
48     }
49     h = ICOpen(mmioFOURCC('V','I','D','C'),mmioFOURCC('M','S','V','C'),ICMODE_DECOMPRESS);
50     ok(0!=h,"ICOpen(VIDC.MSVC) failed\n");
51     if (h) {
52         ok(ICClose(h)==ICERR_OK,"ICClose failed\n");
53     }
54     h = ICOpen(mmioFOURCC('v','i','d','c'),mmioFOURCC('m','S','v','C'),ICMODE_DECOMPRESS);
55     ok(0!=h,"ICOpen(vidc.mSvC) failed\n");
56     if (h) {
57         ok(ICClose(h)==ICERR_OK,"ICClose failed\n");
58     }
59     h = ICOpen(mmioFOURCC('v','I','d','C'),mmioFOURCC('m','s','v','c'),ICMODE_DECOMPRESS);
60     ok(0!=h,"ICOpen(vIdC.msvc) failed\n");
61     if (h) {
62         ok(ICClose(h)==ICERR_OK,"ICClose failed\n");
63     }
64 }
65
66 static void test_Locate(void)
67 {
68     static BITMAPINFOHEADER bi = {sizeof(BITMAPINFOHEADER),32,8, 1,8, BI_RLE8, 0,100000,100000, 0,0};
69     static BITMAPINFOHEADER bo = {sizeof(BITMAPINFOHEADER),32,8, 1,8, BI_RGB, 0,100000,100000, 0,0};
70     HIC h;
71     DWORD err;
72
73     /* Oddly, MSDN documents that ICLocate takes BITMAPINFOHEADER
74      * pointers, while ICDecompressQuery takes the larger
75      * BITMAPINFO.  Probably it's all the same as long as the
76      * variable length color quads are present when they are
77      * needed. */
78
79     h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
80     ok(h != 0, "RLE8->RGB failed\n");
81     if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
82
83     bo.biHeight = - bo.biHeight;
84     h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
85     ok(h == 0, "RLE8->RGB height<0 succeeded\n");
86     if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
87     bo.biHeight = - bo.biHeight;
88
89     bi.biCompression = mmioFOURCC('c','v','i','d'); /* Cinepak */
90     h = ICOpen(ICTYPE_VIDEO, mmioFOURCC('c','v','i','d'), ICMODE_DECOMPRESS);
91     if (h == 0) win_skip("Cinepak/ICCVID codec not found\n");
92     else {
93         bo.biBitCount = bi.biBitCount = 32;
94         err = ICDecompressQuery(h, &bi, &bo);
95         ok(err == ICERR_OK, "Query cvid->RGB32: %d\n", err);
96
97         err = ICDecompressQuery(h, &bi, NULL);
98         ok(err == ICERR_OK, "Query cvid 32: %d\n", err);
99
100         bo.biHeight = -bo.biHeight;
101         err = ICDecompressQuery(h, &bi, &bo);
102         todo_wine ok(err == ICERR_OK, "Query cvid->RGB32 height<0: %d\n", err);
103         bo.biHeight = -bo.biHeight;
104
105         ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
106
107         bo.biBitCount = bi.biBitCount = 8;
108         h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
109         todo_wine ok(h != 0, "cvid->RGB8 failed\n");
110         if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
111         bo.biHeight = - bo.biHeight;
112         h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
113         todo_wine ok(h != 0, "cvid->RGB8 height<0 failed\n");
114         if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
115         bo.biHeight = - bo.biHeight;
116
117         bo.biBitCount = bi.biBitCount = 16;
118         h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
119         ok(h != 0, "cvid->RGB16 failed\n");
120         if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
121         bo.biHeight = - bo.biHeight;
122         h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
123         todo_wine ok(h != 0, "cvid->RGB16 height<0 failed\n");
124         if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
125         bo.biHeight = - bo.biHeight;
126
127         bo.biBitCount = bi.biBitCount = 32;
128         h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
129         ok(h != 0, "cvid->RGB32 failed\n");
130         if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
131         bo.biHeight = - bo.biHeight;
132         h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
133         todo_wine ok(h != 0, "cvid->RGB32 height<0 failed\n");
134         if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
135         bo.biHeight = - bo.biHeight;
136
137         bi.biCompression = mmioFOURCC('C','V','I','D');
138         /* Unlike ICOpen, upper case fails with ICLocate. */
139         h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
140         ok(h == 0, "CVID->RGB32 upper case succeeded\n");
141         if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
142     }
143
144     bi.biCompression = mmioFOURCC('M','S','V','C'); /* MS Video 1 */
145
146     bo.biBitCount = bi.biBitCount = 16;
147     h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
148     ok(h != 0, "MSVC->RGB16 failed\n");
149     if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
150
151     bo.biHeight = - bo.biHeight;
152     h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
153     todo_wine ok(h != 0, "MSVC->RGB16 height<0 failed\n");
154     if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
155     bo.biHeight = - bo.biHeight;
156
157     bo.biHeight--;
158     h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
159     ok(h == 0, "MSVC->RGB16 height too small succeeded\n");
160     if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
161     bo.biHeight++;
162
163     /* ICLocate wants upper case MSVC */
164     bi.biCompression = mmioFOURCC('m','s','v','c');
165     h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
166     ok(h == 0, "msvc->RGB16 succeeded\n");
167     if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
168
169     bi.biCompression = mmioFOURCC('M','S','V','C');
170     h = ICOpen(ICTYPE_VIDEO, mmioFOURCC('M','S','V','C'), ICMODE_DECOMPRESS);
171     ok(h != 0, "No MSVC codec installed!?\n");
172     if (h != 0) {
173         err = ICDecompressQuery(h, &bi, &bo);
174         ok(err == ICERR_OK, "Query MSVC->RGB16: %d\n", err);
175
176         err = ICDecompressQuery(h, &bi, NULL);
177         ok(err == ICERR_OK, "Query MSVC 16: %d\n", err);
178
179         bo.biHeight = -bo.biHeight;
180         err = ICDecompressQuery(h, &bi, &bo);
181         todo_wine ok(err == ICERR_OK, "Query MSVC->RGB16 height<0: %d\n", err);
182         bo.biHeight = -bo.biHeight;
183
184         bi.biCompression = mmioFOURCC('m','s','v','c');
185         err = ICDecompressQuery(h, &bi, &bo);
186         ok(err == ICERR_BADFORMAT, "Query msvc->RGB16: %d\n", err);
187
188         ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
189     }
190
191     bi.biCompression = BI_RGB;
192     bo.biBitCount = bi.biBitCount = 8;
193     h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
194     todo_wine ok(h != 0, "RGB8->RGB identity failed\n");
195     if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
196
197     bi.biCompression = BI_RLE8;
198     h = ICLocate(ICTYPE_VIDEO, 0, &bi, &bo, ICMODE_DECOMPRESS);
199     ok(h != 0, "RLE8->RGB again failed\n");
200     if (h) ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
201 }
202
203 START_TEST(msvfw)
204 {
205     test_OpenCase();
206     test_Locate();
207 }