From 5a752f732ca69918ee524cf69df19c9a517f5bf8 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 4 Dec 2007 18:58:37 -0800 Subject: [PATCH] winmm: add driver unload test --- dlls/winmm/tests/Makefile.in | 3 + dlls/winmm/tests/driver.c | 153 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+), 1 deletions(-) diff --git a/dlls/winmm/tests/Makefile.in b/dlls/winmm/tests/Makefile.in index bf63dc3..7c690f8 100644 --- a/dlls/winmm/tests/Makefile.in +++ b/dlls/winmm/tests/Makefile.in @@ -3,10 +3,11 @@ TOPOBJDIR = ../../.. SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = winmm.dll -IMPORTS = winmm user32 kernel32 +IMPORTS = winmm user32 kernel32 msvfw32 avifil32 CTESTS = \ capture.c \ + driver.c \ mci.c \ mixer.c \ mmio.c \ diff --git a/dlls/winmm/tests/driver.c b/dlls/winmm/tests/driver.c new file mode 100644 index 0000000..4450013 --- /dev/null +++ b/dlls/winmm/tests/driver.c @@ -0,0 +1,153 @@ +/* + * Test winmm drivers + * + * Copyright (c) 2007 Google (Lei Zhang) + * + * 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 + +#include "wine/test.h" +#include "winbase.h" +#include "wingdi.h" +#include "vfw.h" + +#define WIDTH 320 +#define HEIGHT 240 +#define SIZE (WIDTH * HEIGHT * 3) + +static void driver_unload_test(void) +{ + AVICOMPRESSOPTIONS aco; + AVISTREAMINFO si; + BITMAPINFO bmi; + BITMAPINFOHEADER bh; + COMPVARS cv; + DWORD dwFormatSize; + HMODULE handle; + HRESULT hr; + LPBITMAPINFOHEADER lpbiOut; + PAVIFILE pfile = NULL; + PAVISTREAM ps = NULL, psc = NULL; + RECT rc; + + handle = LoadLibrary("xvidvfw.dll"); + if (!handle) + { + skip("xvidvfw.dll not available\n"); + return; + } + + memset(&cv, 0, sizeof(COMPVARS)); + memset(&bmi, 0, sizeof(BITMAPINFO)); + memset(&bh, 0, sizeof(BITMAPINFOHEADER)); + memset(&aco, 0, sizeof(aco)); + memset(&si, 0, sizeof(si)); + + rc.top = 0; + rc.bottom = HEIGHT; + rc.left = 0; + rc.right = WIDTH; + + bh.biSize = sizeof(BITMAPINFOHEADER); + bh.biWidth = WIDTH; + bh.biHeight = HEIGHT; + bh.biPlanes = 1; + bh.biBitCount = 24; + bh.biCompression = BI_RGB; + bh.biSizeImage = SIZE; + + cv.cbSize = sizeof(COMPVARS); + cv.dwFlags = ICMF_COMPVARS_VALID; + cv.fccType = ICTYPE_VIDEO; + cv.fccHandler = mmioFOURCC('x','v','i','d'); + cv.lKey = 30; + cv.lQ = ICQUALITY_DEFAULT; + + cv.hic = ICOpen(ICTYPE_VIDEO, cv.fccHandler, ICMODE_COMPRESS); + ok(cv.hic != NULL, "ICOpen returned NULL\n"); + if (!cv.hic) + { + skip("ICOpen failed\n"); + return; + } + + dwFormatSize = ICCompressGetFormatSize(cv.hic, &bh); + lpbiOut = HeapAlloc(GetProcessHeap(), 0, dwFormatSize); + if (!lpbiOut) + { + skip("HeapAlloc failed\n"); + goto driver_unload_test_exit2; + } + ICCompressGetFormat(cv.hic, &bh, lpbiOut); + + bmi.bmiHeader = bh; + cv.lpbiOut = (LPBITMAPINFO) lpbiOut; + cv.lpbiIn = &bmi; + + aco.lpFormat = &bmi; + aco.cbFormat = sizeof(BITMAPINFOHEADER); + + si.fccType = aco.fccType = streamtypeVIDEO; + si.fccHandler = aco.fccHandler = cv.fccHandler; + si.dwQuality = aco.dwQuality = cv.lQ; + si.dwScale = 1; + si.dwRate = 30; + si.dwSuggestedBufferSize = SIZE; + si.rcFrame = rc; + + AVIFileInit(); + hr = AVIFileOpen(&pfile, "test.avi", OF_WRITE|OF_CREATE, NULL); + ok(hr == 0, "AVIFileOpen returned %d\n", hr); + if (hr) + { + skip("AVIFileOpen failed\n"); + goto driver_unload_test_exit1; + } + ok(pfile != NULL, "AVIFileOpen did not set pfile\n"); + + hr = AVIFileCreateStream(pfile, &ps, &si); + ok(hr == 0, "AVIFileCreateStream returned %d\n", hr); + if (hr) + { + skip("AVIFileCreateStream failed\n"); + goto driver_unload_test_exit1; + } + + if (!strcmp(winetest_platform, "wine")) + { + skip("Skipping test on Wine (leads to a crash)\n"); + goto driver_unload_test_exit1; + } + + hr = AVIMakeCompressedStream(&psc, ps, &aco, NULL); + ok(hr == AVIERR_OK, "AVIERR_OK returned %d\n", hr); + +driver_unload_test_exit1: + if (psc) AVIStreamRelease(psc); + if (ps) AVIStreamRelease(ps); + if (pfile) AVIFileRelease(pfile); + + AVIFileExit(); +driver_unload_test_exit2: + ICCompressorFree(&cv); + DeleteFile("test.avi"); +} + +START_TEST(driver) +{ + driver_unload_test(); +} -- 1.4.1