ReactOS  0.4.15-dev-985-gd905dd5
mciwnd.c
Go to the documentation of this file.
1 /*
2  * Unit tests for MCIWnd
3  *
4  * Copyright 2019 Sven Baars
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #define WIN32_LEAN_AND_MEAN
22 
23 #include <windows.h>
24 #include <vfw.h>
25 
26 #include "wine/heap.h"
27 #include "wine/test.h"
28 
29 static const DWORD file_header[] = /* file_header */
30 {
31  FOURCC_RIFF, 0x8c0 /* file size */,
33  FOURCC_LIST, 0xc0 /* list length */,
35 };
36 
38 {
39  0x0001046b, /* dwMicroSecPerFrame */
40  0x00000000, /* dwMaxBytesPerSec */
41  0x00000000, /* dwPaddingGranularity */
42  0x00000810, /* dwFlags */
43  2, /* dwTotalFrames */
44  0, /* dwInitialFrames */
45  1, /* dwStreams */
46  0x48, /* dwSuggestedBufferSize*/
47  5, /* dwWidth */
48  5, /* dwHeight */
49  { 0, 0, 0, 0 } /* dwReserved[4] */
50 };
51 
52 static const DWORD stream_list[] =
53 {
54  FOURCC_LIST, 0x74 /* length */,
55  listtypeSTREAMHEADER, ckidSTREAMHEADER, 0x38 /* length */,
56 };
57 
59 {
60  streamtypeVIDEO, /* fccType */
61  0, /* fccHandler */
62  0, /* dwFlags */
63  0, /* wPriority */
64  0, /* wLanguage */
65  0, /* dwInitialFrames */
66  1, /* dwScale */
67  0xf, /* dwRate */
68  0, /* dwStart */
69  2, /* dwLength */
70  0x48, /* dwSuggestedBufferSize*/
71  0, /* dwQuality */
72  0, /* dwSampleSize */
73  { 0, 0, 0, 0 } /* short left right top bottom */
74 };
75 
76 static const DWORD video_stream_format[] =
77 {
79  0x28 /* length */,
80  0x28 /* length */,
81  5 /* width */,
82  5 /* height */,
83  0x00180001 ,
84  mmioFOURCC('c', 'v', 'i', 'd'),
85  0x245a,
86  0, 0, 0, 0,
87 };
88 
89 static const DWORD padding[] =
90 {
91  ckidAVIPADDING, 0x718 /* length */,
92 };
93 
94 static const DWORD data[] =
95 {
96  FOURCC_LIST, 0xa4 /* length */, listtypeAVIMOVIE,
97  mmioFOURCC('0', '0', 'd', 'b'), 0x48, 0x48000000, 0x08000800,
98  0x00100100, 0x00003e00, 0x08000000, 0x00200800,
99  0x00001600, 0x00000000, 0x00003a00, 0x22e306f9,
100  0xfc120000, 0x0a000022, 0x00000000, 0x00300000,
101  0x00c01200, 0x00000000, 0x02010000, 0x00000000,
102  mmioFOURCC('0', '0', 'd', 'b'), 0x48, 0x48000000, 0x08000800,
103  0x00100100, 0x00003e00, 0x08000000, 0x00200800,
104  0x00001600, 0x00000000, 0x00003a00, 0x22e306f9,
105  0xfc120000, 0x0a000022, 0x00000000, 0x00300000,
106  0x00c01200, 0x00000000, 0x02010000, 0x00000000,
107  mmioFOURCC('i', 'd', 'x', '1'), 0x20, mmioFOURCC('0', '0', 'd', 'b'), 0x10,
108  0x04, 0x48, mmioFOURCC('0', '0', 'd', 'b'), 0x10,
109  0x54, 0x48,
110 };
111 
112 static BOOL create_avi_file(char *fname)
113 {
114  HANDLE hFile;
115  DWORD written;
116  char temp_path[MAX_PATH];
117  BOOL ret;
118  BYTE *buffer;
119  ULONG buffer_length;
120 
121  ret = GetTempPathA(sizeof(temp_path), temp_path);
122  ok(ret, "Failed to get a temp path, err %d\n", GetLastError());
123  if (!ret)
124  return FALSE;
125 
126  ret = GetTempFileNameA(temp_path, "mci", 0, fname);
127  ok(ret, "Failed to get a temp name, err %d\n", GetLastError());
128  if (!ret)
129  return FALSE;
130  DeleteFileA(fname);
131 
132  lstrcatA(fname, ".avi");
133 
135  ok(hFile != INVALID_HANDLE_VALUE, "Failed to create a file, err %d\n", GetLastError());
136  if (hFile == INVALID_HANDLE_VALUE) return FALSE;
137 
138  buffer_length = padding[1];
139  buffer = heap_alloc_zero(buffer_length);
140 
141  WriteFile(hFile, file_header, sizeof(file_header), &written, NULL);
142  WriteFile(hFile, &main_avi_header, sizeof(MainAVIHeader), &written, NULL);
143  WriteFile(hFile, stream_list, sizeof(stream_list), &written, NULL);
144  WriteFile(hFile, &avi_stream_header, sizeof(AVIStreamHeader), &written, NULL);
146  WriteFile(hFile, padding, sizeof(padding), &written, NULL);
147  WriteFile(hFile, buffer, buffer_length, &written, NULL);
148  WriteFile(hFile, data, sizeof(data), &written, NULL);
149 
150  heap_free(buffer);
151 
153  return ret;
154 }
155 
156 static void test_MCIWndCreate(void)
157 {
158  HWND parent, window;
160  char fname[MAX_PATH];
161  char invalid_fname[] = "invalid.avi";
162  char error[200];
163  LRESULT ret;
164 
165  create_avi_file(fname);
166 
168  ok(window != NULL, "Failed to create an MCIWnd window without parent\n");
169 
171  ok(!ret || broken(ret == ERROR_INVALID_HANDLE) /* w2003std, w2008s64 */,
172  "Unexpected error %ld\n", ret);
173 
175 
176  parent = CreateWindowExA(0, "static", "msvfw32 test",
177  WS_POPUP, 0, 0, 100, 100,
178  0, 0, 0, NULL);
179  ok(parent != NULL, "Failed to create a window\n");
181  ok(window != NULL, "Failed to create an MCIWnd window\n");
182 
184  ok(!ret || broken(ret == ERROR_INVALID_HANDLE) /* w2003std, w2008s64 */,
185  "Unexpected error %ld\n", ret);
186 
188 
189  window = MCIWndCreateA(NULL, hinst, MCIWNDF_NOERRORDLG, invalid_fname);
190  ok(window != NULL, "Failed to create an MCIWnd window\n");
191 
193  todo_wine ok(ret == MCIERR_FILE_NOT_FOUND, "Unexpected error %ld\n", ret);
194 
196 
197  DeleteFileA(fname);
198 }
199 
200 START_TEST(mciwnd)
201 {
203 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define MCIWNDF_NOERRORDLG
Definition: vfw.h:1807
#define CloseHandle
Definition: compat.h:487
#define ckidSTREAMFORMAT
Definition: aviriff.h:125
#define listtypeSTREAMHEADER
Definition: vfw.h:892
#define error(str)
Definition: mkdosfs.c:1605
#define ckidAVIPADDING
Definition: vfw.h:916
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define listtypeAVIHEADER
Definition: vfw.h:890
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
static const DWORD video_stream_format[]
Definition: mciwnd.c:76
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define ckidSTREAMHEADER
Definition: aviriff.h:88
static const DWORD stream_list[]
Definition: mciwnd.c:52
BOOL WINAPI DestroyWindow(_In_ HWND)
static const DWORD file_header[]
Definition: mciwnd.c:29
#define MCIWNDM_GETERRORA
Definition: vfw.h:1964
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
static void test_MCIWndCreate(void)
Definition: mciwnd.c:156
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static const MainAVIHeader main_avi_header
Definition: mciwnd.c:37
START_TEST(mciwnd)
Definition: mciwnd.c:200
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
struct _MainAVIHeader MainAVIHeader
#define FOURCC_LIST
Definition: mmsystem.h:565
r parent
Definition: btrfs.c:2944
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HWND VFWAPIV MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance, DWORD dwStyle, LPCSTR szFile)
Definition: mciwnd.c:126
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define todo_wine
Definition: test.h:162
#define FOURCC_RIFF
Definition: mmsystem.h:564
#define mmioFOURCC(c0, c1, c2, c3)
Definition: mmsystem.h:38
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static BOOL create_avi_file(char *fname)
Definition: mciwnd.c:112
static IHTMLWindow2 * window
Definition: events.c:77
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned char BYTE
Definition: xxhash.c:193
#define broken(x)
Definition: _sntprintf.h:21
#define streamtypeVIDEO
Definition: aviriff.h:92
#define CREATE_ALWAYS
Definition: disk.h:72
#define MCIERR_FILE_NOT_FOUND
Definition: mmsystem.h:585
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define formtypeAVI
Definition: vfw.h:889
#define ok(value,...)
Definition: atltest.h:57
#define listtypeAVIMOVIE
Definition: vfw.h:898
static const DWORD padding[]
Definition: mciwnd.c:89
#define WS_POPUP
Definition: pedump.c:616
static const AVIStreamHeader avi_stream_header
Definition: mciwnd.c:58
#define ckidAVIMAINHDR
Definition: vfw.h:891
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
unsigned int ULONG
Definition: retypes.h:1
static HINSTANCE hinst
Definition: edit.c:551
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:488
LONG_PTR LRESULT
Definition: windef.h:209
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
char temp_path[MAX_PATH]
Definition: mspatcha.c:123