[MSVFW32_WINETEST] Sync with Wine Staging 4.18. CORE-16441

This commit is contained in:
Amine Khaldi 2019-11-10 14:07:31 +01:00
parent 80bb48e789
commit ac43fd2b92
6 changed files with 389 additions and 6 deletions

View file

@ -1,6 +1,6 @@
add_definitions(-DUSE_WINE_TODOS)
add_executable(msvfw32_winetest drawdib.c msvfw.c testlist.c)
add_executable(msvfw32_winetest drawdib.c mciwnd.c msvfw.c testlist.c msvfw32.rc)
set_module_type(msvfw32_winetest win32cui)
add_importlibs(msvfw32_winetest gdi32 advapi32 msvfw32 msvcrt kernel32)
add_importlibs(msvfw32_winetest user32 gdi32 advapi32 msvfw32 msvcrt kernel32)
add_rostests_file(TARGET msvfw32_winetest)

View file

@ -0,0 +1,203 @@
/*
* Unit tests for MCIWnd
*
* Copyright 2019 Sven Baars
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <vfw.h>
#include "wine/heap.h"
#include "wine/test.h"
static const DWORD file_header[] = /* file_header */
{
FOURCC_RIFF, 0x8c0 /* file size */,
formtypeAVI,
FOURCC_LIST, 0xc0 /* list length */,
listtypeAVIHEADER, ckidAVIMAINHDR, sizeof(MainAVIHeader),
};
static const MainAVIHeader main_avi_header =
{
0x0001046b, /* dwMicroSecPerFrame */
0x00000000, /* dwMaxBytesPerSec */
0x00000000, /* dwPaddingGranularity */
0x00000810, /* dwFlags */
2, /* dwTotalFrames */
0, /* dwInitialFrames */
1, /* dwStreams */
0x48, /* dwSuggestedBufferSize*/
5, /* dwWidth */
5, /* dwHeight */
{ 0, 0, 0, 0 } /* dwReserved[4] */
};
static const DWORD stream_list[] =
{
FOURCC_LIST, 0x74 /* length */,
listtypeSTREAMHEADER, ckidSTREAMHEADER, 0x38 /* length */,
};
static const AVIStreamHeader avi_stream_header =
{
streamtypeVIDEO, /* fccType */
0, /* fccHandler */
0, /* dwFlags */
0, /* wPriority */
0, /* wLanguage */
0, /* dwInitialFrames */
1, /* dwScale */
0xf, /* dwRate */
0, /* dwStart */
2, /* dwLength */
0x48, /* dwSuggestedBufferSize*/
0, /* dwQuality */
0, /* dwSampleSize */
{ 0, 0, 0, 0 } /* short left right top bottom */
};
static const DWORD video_stream_format[] =
{
ckidSTREAMFORMAT,
0x28 /* length */,
0x28 /* length */,
5 /* width */,
5 /* height */,
0x00180001 ,
mmioFOURCC('c', 'v', 'i', 'd'),
0x245a,
0, 0, 0, 0,
};
static const DWORD padding[] =
{
ckidAVIPADDING, 0x718 /* length */,
};
static const DWORD data[] =
{
FOURCC_LIST, 0xa4 /* length */, listtypeAVIMOVIE,
mmioFOURCC('0', '0', 'd', 'b'), 0x48, 0x48000000, 0x08000800,
0x00100100, 0x00003e00, 0x08000000, 0x00200800,
0x00001600, 0x00000000, 0x00003a00, 0x22e306f9,
0xfc120000, 0x0a000022, 0x00000000, 0x00300000,
0x00c01200, 0x00000000, 0x02010000, 0x00000000,
mmioFOURCC('0', '0', 'd', 'b'), 0x48, 0x48000000, 0x08000800,
0x00100100, 0x00003e00, 0x08000000, 0x00200800,
0x00001600, 0x00000000, 0x00003a00, 0x22e306f9,
0xfc120000, 0x0a000022, 0x00000000, 0x00300000,
0x00c01200, 0x00000000, 0x02010000, 0x00000000,
mmioFOURCC('i', 'd', 'x', '1'), 0x20, mmioFOURCC('0', '0', 'd', 'b'), 0x10,
0x04, 0x48, mmioFOURCC('0', '0', 'd', 'b'), 0x10,
0x54, 0x48,
};
static BOOL create_avi_file(char *fname)
{
HANDLE hFile;
DWORD written;
char temp_path[MAX_PATH];
BOOL ret;
BYTE *buffer;
ULONG buffer_length;
ret = GetTempPathA(sizeof(temp_path), temp_path);
ok(ret, "Failed to get a temp path, err %d\n", GetLastError());
if (!ret)
return FALSE;
ret = GetTempFileNameA(temp_path, "mci", 0, fname);
ok(ret, "Failed to get a temp name, err %d\n", GetLastError());
if (!ret)
return FALSE;
DeleteFileA(fname);
lstrcatA(fname, ".avi");
hFile = CreateFileA(fname, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
ok(hFile != INVALID_HANDLE_VALUE, "Failed to create a file, err %d\n", GetLastError());
if (hFile == INVALID_HANDLE_VALUE) return FALSE;
buffer_length = padding[1];
buffer = heap_alloc_zero(buffer_length);
WriteFile(hFile, file_header, sizeof(file_header), &written, NULL);
WriteFile(hFile, &main_avi_header, sizeof(MainAVIHeader), &written, NULL);
WriteFile(hFile, stream_list, sizeof(stream_list), &written, NULL);
WriteFile(hFile, &avi_stream_header, sizeof(AVIStreamHeader), &written, NULL);
WriteFile(hFile, video_stream_format, sizeof(video_stream_format), &written, NULL);
WriteFile(hFile, padding, sizeof(padding), &written, NULL);
WriteFile(hFile, buffer, buffer_length, &written, NULL);
WriteFile(hFile, data, sizeof(data), &written, NULL);
heap_free(buffer);
CloseHandle(hFile);
return ret;
}
static void test_MCIWndCreate(void)
{
HWND parent, window;
HMODULE hinst = GetModuleHandleA(NULL);
char fname[MAX_PATH];
char invalid_fname[] = "invalid.avi";
char error[200];
LRESULT ret;
create_avi_file(fname);
window = MCIWndCreateA(NULL, hinst, MCIWNDF_NOERRORDLG, fname);
ok(window != NULL, "Failed to create an MCIWnd window without parent\n");
ret = SendMessageA(window, MCIWNDM_GETERRORA, sizeof(error), (LPARAM)error);
ok(!ret || broken(ret == ERROR_INVALID_HANDLE) /* w2003std, w2008s64 */,
"Unexpected error %ld\n", ret);
DestroyWindow(window);
parent = CreateWindowExA(0, "static", "msvfw32 test",
WS_POPUP, 0, 0, 100, 100,
0, 0, 0, NULL);
ok(parent != NULL, "Failed to create a window\n");
window = MCIWndCreateA(parent, hinst, MCIWNDF_NOERRORDLG, fname);
ok(window != NULL, "Failed to create an MCIWnd window\n");
ret = SendMessageA(window, MCIWNDM_GETERRORA, sizeof(error), (LPARAM)error);
ok(!ret || broken(ret == ERROR_INVALID_HANDLE) /* w2003std, w2008s64 */,
"Unexpected error %ld\n", ret);
DestroyWindow(parent);
window = MCIWndCreateA(NULL, hinst, MCIWNDF_NOERRORDLG, invalid_fname);
ok(window != NULL, "Failed to create an MCIWnd window\n");
ret = SendMessageA(window, MCIWNDM_GETERRORA, sizeof(error), (LPARAM)error);
todo_wine ok(ret == MCIERR_FILE_NOT_FOUND, "Unexpected error %ld\n", ret);
DestroyWindow(window);
DeleteFileA(fname);
}
START_TEST(mciwnd)
{
test_MCIWndCreate();
}

View file

@ -374,16 +374,59 @@ static void test_ICSeqCompress(void)
ok(err == ICERR_BADHANDLE, "Expected -8, got %d\n", err);
}
static ICINFO enum_info;
static LRESULT CALLBACK enum_driver_proc(DWORD_PTR id, HDRVR driver, UINT msg,
LPARAM lparam1, LPARAM lparam2)
{
ICINFO *info = (ICINFO *)lparam1;
ok(!id, "Got unexpected id %#lx.\n", id);
ok(msg == ICM_GETINFO, "Got unexpected message %#x.\n", msg);
ok(info == &enum_info, "Expected lparam1 %p, got %p.\n", &enum_info, info);
ok(lparam2 == sizeof(ICINFO), "Got lparam2 %ld.\n", lparam2);
ok(!info->fccType, "Got unexpected type %#x.\n", info->fccType);
ok(!info->fccHandler, "Got unexpected handler %#x.\n", info->fccHandler);
ok(!info->dwFlags, "Got unexpected flags %#x.\n", info->dwFlags);
ok(!info->dwVersion, "Got unexpected version %#x.\n", info->dwVersion);
ok(info->dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info->dwVersionICM);
ok(!info->szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info->szName));
ok(!info->szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info->szDescription));
ok(!info->szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(info->szDriver));
info->dwVersion = 0xdeadbeef;
return sizeof(ICINFO);
}
static void test_ICInfo(void)
{
static const WCHAR bogusW[] = {'b','o','g','u','s',0};
static const DWORD test_type = mmioFOURCC('w','i','n','e');
static const DWORD test_handler = mmioFOURCC('t','e','s','t');
DWORD i = 0, found = 0;
char buffer[MAX_PATH];
ICINFO info, info2;
DWORD i, found;
unsigned char *fcc;
DWORD size;
BOOL ret;
HKEY key;
LONG res;
for (i = found = 0; ICInfo(0, i, &info); i++)
for (;;)
{
memset(&info, 0x55, sizeof(info));
info.dwSize = sizeof(info);
if (!ICInfo(0, i++, &info))
break;
trace("Codec name: %s, fccHandler: 0x%08x\n", wine_dbgstr_w(info.szName), info.fccHandler);
ok(info.fccType, "expected nonzero fccType\n");
ok(info.fccType, "Expected nonzero type.\n");
ok(info.fccHandler, "Expected nonzero handler.\n");
ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags);
ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion);
ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM);
ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName));
ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription));
ok(ICInfo(info.fccType, info.fccHandler, &info2),
"ICInfo failed on fcc 0x%08x\n", info.fccHandler);
@ -399,10 +442,107 @@ static void test_ICInfo(void)
}
ok(found != 0, "expected at least one codec\n");
memset(&info, 0, sizeof(info));
memset(&info, 0x55, sizeof(info));
info.dwSize = sizeof(info);
ok(!ICInfo(ICTYPE_VIDEO, mmioFOURCC('f','a','k','e'), &info), "expected failure\n");
ok(info.fccType == ICTYPE_VIDEO, "got 0x%08x\n", info.fccType);
ok(info.fccHandler == mmioFOURCC('f','a','k','e'), "got 0x%08x\n", info.fccHandler);
ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags);
ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion);
ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM);
ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName));
ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription));
ok(!info.szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(info.szDriver));
if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT"
"\\CurrentVersion\\Drivers32", 0, KEY_ALL_ACCESS, &key))
{
ret = ICInstall(test_type, test_handler, (LPARAM)"bogus", NULL, ICINSTALL_DRIVER);
ok(ret, "Failed to install driver.\n");
size = sizeof(buffer);
res = RegQueryValueExA(key, "wine.test", NULL, NULL, (BYTE *)buffer, &size);
ok(!res, "Failed to query value, error %d.\n", res);
ok(!strcmp(buffer, "bogus"), "Got unexpected value \"%s\".\n", buffer);
memset(&info, 0x55, sizeof(info));
info.dwSize = sizeof(info);
ok(ICInfo(test_type, test_handler, &info), "Expected success.\n");
ok(info.fccType == test_type, "Got unexpected type %#x.\n", info.fccType);
ok(info.fccHandler == test_handler, "Got unexpected handler %#x.\n", info.fccHandler);
ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags);
ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion);
ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM);
ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName));
ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription));
ok(!lstrcmpW(info.szDriver, bogusW), "Got unexpected driver %s.\n", wine_dbgstr_w(info.szDriver));
/* Drivers installed after msvfw32 is loaded are not enumerated. */
todo_wine
ok(!ICInfo(test_type, 0, &info), "Expected failure.\n");
ret = ICRemove(test_type, test_handler, 0);
ok(ret, "Failed to remove driver.\n");
res = RegDeleteValueA(key, "wine.test");
ok(res == ERROR_FILE_NOT_FOUND, "Got error %u.\n", res);
RegCloseKey(key);
}
else
win_skip("Not enough permissions to register codec drivers.\n");
if (WritePrivateProfileStringA("drivers32", "wine.test", "bogus", "system.ini"))
{
memset(&info, 0x55, sizeof(info));
info.dwSize = sizeof(info);
ok(ICInfo(test_type, test_handler, &info), "Expected success.\n");
ok(info.fccType == test_type, "Got unexpected type %#x.\n", info.fccType);
ok(info.fccHandler == test_handler, "Got unexpected handler %#x.\n", info.fccHandler);
ok(!info.dwFlags, "Got unexpected flags %#x.\n", info.dwFlags);
ok(!info.dwVersion, "Got unexpected version %#x.\n", info.dwVersion);
ok(info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", info.dwVersionICM);
ok(!info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szName));
ok(!info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(info.szDescription));
ok(!lstrcmpW(info.szDriver, bogusW), "Got unexpected driver %s.\n", wine_dbgstr_w(info.szDriver));
/* Drivers installed after msvfw32 is loaded are not enumerated. */
todo_wine
ok(!ICInfo(test_type, 0, &info), "Expected failure.\n");
ret = WritePrivateProfileStringA("drivers32", "wine.test", NULL, "system.ini");
ok(ret, "Failed to remove INI entry.\n");
}
ret = ICInstall(test_type, test_handler, (LPARAM)enum_driver_proc, NULL, ICINSTALL_FUNCTION);
ok(ret, "Failed to install driver.\n");
memset(&enum_info, 0x55, sizeof(enum_info));
enum_info.dwSize = sizeof(enum_info);
ok(ICInfo(test_type, test_handler, &enum_info), "Expected success.\n");
ok(!enum_info.fccType, "Got unexpected type %#x.\n", enum_info.fccType);
ok(!enum_info.fccHandler, "Got unexpected handler %#x.\n", enum_info.fccHandler);
ok(!enum_info.dwFlags, "Got unexpected flags %#x.\n", enum_info.dwFlags);
ok(enum_info.dwVersion == 0xdeadbeef, "Got unexpected version %#x.\n", enum_info.dwVersion);
ok(enum_info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", enum_info.dwVersionICM);
ok(!enum_info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szName));
ok(!enum_info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szDescription));
ok(!enum_info.szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(enum_info.szDriver));
/* Functions installed after msvfw32 is loaded are enumerated. */
memset(&enum_info, 0x55, sizeof(enum_info));
enum_info.dwSize = sizeof(enum_info);
ok(ICInfo(test_type, 0, &enum_info), "Expected success.\n");
ok(!enum_info.fccType, "Got unexpected type %#x.\n", enum_info.fccType);
ok(!enum_info.fccHandler, "Got unexpected handler %#x.\n", enum_info.fccHandler);
ok(!enum_info.dwFlags, "Got unexpected flags %#x.\n", enum_info.dwFlags);
ok(enum_info.dwVersion == 0xdeadbeef, "Got unexpected version %#x.\n", enum_info.dwVersion);
ok(enum_info.dwVersionICM == ICVERSION, "Got unexpected ICM version %#x.\n", enum_info.dwVersionICM);
ok(!enum_info.szName[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szName));
ok(!enum_info.szDescription[0], "Got unexpected name %s.\n", wine_dbgstr_w(enum_info.szDescription));
ok(!enum_info.szDriver[0], "Got unexpected driver %s.\n", wine_dbgstr_w(enum_info.szDriver));
ret = ICRemove(test_type, test_handler, 0);
ok(ret, "Failed to remove driver.\n");
}
static int get_display_format_test;

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="Wine.msvfw32.Test"
version="1.0.0.0"
processorArchitecture="*"
/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View file

@ -0,0 +1,22 @@
/*
* Copyright 2019 Zebediah Figura
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "winuser.h"
/* @makedep: msvfw32.manifest */
1 RT_MANIFEST msvfw32.manifest

View file

@ -4,11 +4,13 @@
#include <wine/test.h>
extern void func_drawdib(void);
extern void func_mciwnd(void);
extern void func_msvfw(void);
const struct test winetest_testlist[] =
{
{ "drawdib", func_drawdib },
{ "mciwnd", func_mciwnd },
{ "msvfw", func_msvfw },
{ 0, 0 }
};