ReactOS 0.4.15-dev-8348-gc1b9bb5
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
29static 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
52static 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
76static 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
89static const DWORD padding[] =
90{
91 ckidAVIPADDING, 0x718 /* length */,
92};
93
94static 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
112static BOOL create_avi_file(char *fname)
113{
115 DWORD written;
116 char temp_path[MAX_PATH];
117 BOOL ret;
118 BYTE *buffer;
119 ULONG buffer_length;
120
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);
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
151
153 return ret;
154}
155
156static void test_MCIWndCreate(void)
157{
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
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
201{
203}
#define broken(x)
Definition: _sntprintf.h:21
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define streamtypeVIDEO
Definition: aviriff.h:92
#define ckidSTREAMHEADER
Definition: aviriff.h:88
#define ckidSTREAMFORMAT
Definition: aviriff.h:125
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
HWND VFWAPIV MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance, DWORD dwStyle, LPCSTR szFile)
Definition: mciwnd.c:126
r parent
Definition: btrfs.c:3010
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define error(str)
Definition: mkdosfs.c:1605
#define FOURCC_RIFF
Definition: mmsystem.h:564
#define MCIERR_FILE_NOT_FOUND
Definition: mmsystem.h:585
#define FOURCC_LIST
Definition: mmsystem.h:565
#define mmioFOURCC(c0, c1, c2, c3)
Definition: mmsystem.h:38
#define CREATE_ALWAYS
Definition: disk.h:72
static HINSTANCE hinst
Definition: edit.c:551
static IHTMLWindow2 * window
Definition: events.c:77
#define todo_wine
Definition: custom.c:79
static const DWORD stream_list[]
Definition: mciwnd.c:52
static void test_MCIWndCreate(void)
Definition: mciwnd.c:156
static const DWORD video_stream_format[]
Definition: mciwnd.c:76
static const DWORD padding[]
Definition: mciwnd.c:89
static const AVIStreamHeader avi_stream_header
Definition: mciwnd.c:58
static BOOL create_avi_file(char *fname)
Definition: mciwnd.c:112
static const MainAVIHeader main_avi_header
Definition: mciwnd.c:37
static const DWORD file_header[]
Definition: mciwnd.c:29
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90
#define WS_POPUP
Definition: pedump.c:616
uint32_t ULONG
Definition: typedefs.h:59
struct _MainAVIHeader MainAVIHeader
#define listtypeAVIMOVIE
Definition: vfw.h:898
#define MCIWNDM_GETERRORA
Definition: vfw.h:1964
#define listtypeSTREAMHEADER
Definition: vfw.h:892
#define listtypeAVIHEADER
Definition: vfw.h:890
#define MCIWNDF_NOERRORDLG
Definition: vfw.h:1807
#define ckidAVIPADDING
Definition: vfw.h:916
#define ckidAVIMAINHDR
Definition: vfw.h:891
#define formtypeAVI
Definition: vfw.h:889
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
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)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DestroyWindow(_In_ HWND)
unsigned char BYTE
Definition: xxhash.c:193