Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/qedit/tests/mediadet.c | 92 +++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
diff --git a/dlls/qedit/tests/mediadet.c b/dlls/qedit/tests/mediadet.c index e00226a..951bf04 100644 --- a/dlls/qedit/tests/mediadet.c +++ b/dlls/qedit/tests/mediadet.c @@ -811,6 +811,45 @@ static void check_bitmap_(unsigned line, void *buffer, LONG width, LONG height, free(img); }
+#define check_bitmap_file(filename, buffer, width, height, seek_time) check_bitmap_file_(__LINE__, filename, buffer, width, height, seek_time) +static void check_bitmap_file_(unsigned line, const WCHAR *filename, void *buffer, LONG width, LONG height, double seek_time) +{ + DWORD size_high, read, expected; + BITMAPFILEHEADER *hdr; + DWORD64 size; + HANDLE file; + + /* WriteBitmapBits rounds the width up to a multiple of 4 */ + width = (width + 3) & ~3; + expected = sizeof(BITMAPINFOHEADER) + width * 3 * height; + + file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + ok_(__FILE__,line)(file != INVALID_HANDLE_VALUE, "CreateFile failed, error: 0x%08x.\n", GetLastError()); + if (file == INVALID_HANDLE_VALUE) return; + + size = GetFileSize(file, &size_high); + size |= (DWORD64)size_high << 32; + ok_(__FILE__,line)(GetLastError() == NO_ERROR, "GetFileSize failed, error: 0x%08x.\n", GetLastError()); + ok_(__FILE__,line)(size == expected + sizeof(BITMAPFILEHEADER), "Wrong size 0x%s (expected 0x%x).\n", + wine_dbgstr_longlong(size), expected); + + ok_(__FILE__,line)(ReadFile(file, buffer, sizeof(BITMAPFILEHEADER), &read, NULL), + "ReadFile failed, error: 0x%08x.\n", GetLastError()); + ok_(__FILE__,line)(read == sizeof(BITMAPFILEHEADER), "ReadFile read %u bytes (expected %u).\n", + read, sizeof(BITMAPFILEHEADER)); + hdr = (BITMAPFILEHEADER*)buffer; + ok_(__FILE__,line)(hdr->bfType == 0x4d42, "Got bfType %04x.\n", hdr->bfType); + ok_(__FILE__,line)(hdr->bfSize == expected + sizeof(BITMAPFILEHEADER), "Got bfSize %u.\n", hdr->bfSize); + ok_(__FILE__,line)(hdr->bfOffBits == sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER), + "Got bfOffBits %u.\n", hdr->bfOffBits); + + ok_(__FILE__,line)(ReadFile(file, buffer, expected, &read, NULL), "ReadFile failed, error: 0x%08x.\n", GetLastError()); + ok_(__FILE__,line)(read == expected, "ReadFile read %u bytes (expected %u).\n", read, expected); + + CloseHandle(file); + check_bitmap_(line, buffer, width, height, seek_time); +} + static BOOL init_tests(void) { return unpack_avi_file(TEST_AVI_RES, test_avi_filename) @@ -1503,6 +1542,7 @@ static void test_bitmap_grab_mode(void) &TIME_FORMAT_MEDIA_TIME }; char *buf = malloc(sizeof(BITMAPINFOHEADER) + 960 * 720 * 3); + WCHAR temp_path[MAX_PATH], filename[MAX_PATH]; struct testfilter testfilter; FILTER_INFO filter_info; IReferenceClock *clock; @@ -1523,6 +1563,10 @@ static void test_bitmap_grab_mode(void) GUID guid; BSTR str;
+ ok(GetTempPathW(MAX_PATH, temp_path), "GetTempPath failed, error: 0x%08x.\n", GetLastError()); + ok(GetTempFileNameW(temp_path, L"DES", 0, filename), "GetTempFileName failed, error: 0x%08x.\n", GetLastError()); + DeleteFileW(filename); + hr = CoCreateInstance(&CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER, &IID_IMediaDet, (void **)&detector); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1532,6 +1576,8 @@ static void test_bitmap_grab_mode(void) size = sizeof(BITMAPINFOHEADER) + 640 * 480 * 3; hr = IMediaDet_GetBitmapBits(detector, 0.0, &size, buf, 640, 480); ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IMediaDet_WriteBitmapBits(detector, 0.0, 640, 480, filename); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); hr = IMediaDet_GetSampleGrabber(detector, &sg); ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
@@ -1728,6 +1774,24 @@ static void test_bitmap_grab_mode(void) ok(hr == S_OK, "Got hr %#x.\n", hr); check_bitmap(buf, 960, 720, 3.25);
+ hr = IMediaDet_WriteBitmapBits(detector, 0.0, 640, 480, NULL); + todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "Got hr %#x.\n", hr); + hr = IMediaDet_WriteBitmapBits(detector, 1.6, 640, 480, filename); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine check_bitmap_file(filename, buf, 640, 480, 1.6); + hr = IMediaDet_WriteBitmapBits(detector, 3.08, 487, 337, filename); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine check_bitmap_file(filename, buf, 487, 337, 3.08); + hr = IMediaDet_WriteBitmapBits(detector, 2.68, 11, 250, filename); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine check_bitmap_file(filename, buf, 11, 250, 2.68); + hr = IMediaDet_WriteBitmapBits(detector, 0.44, 441, 363, filename); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine check_bitmap_file(filename, buf, 441, 363, 0.44); + hr = IMediaDet_WriteBitmapBits(detector, 4.04, 809, 701, filename); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine check_bitmap_file(filename, buf, 809, 701, 4.04); + /* Changing filter resets bitmap grab mode */ testfilter.bitmap_grab_mode = FALSE; hr = IMediaDet_put_Filter(detector, &testfilter.filter.IUnknown_inner); @@ -1756,6 +1820,34 @@ static void test_bitmap_grab_mode(void) hr = IMediaDet_get_OutputStreams(detector, &count); ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
+ testfilter.bitmap_grab_mode = FALSE; + hr = IMediaDet_put_Filter(detector, &testfilter.filter.IUnknown_inner); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaDet_GetSampleGrabber(detector, &sg); + ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr); + hr = IMediaDet_get_OutputStreams(detector, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got %d streams.\n", count); + + /* As does WriteBitmapBits */ + testfilter.bitmap_grab_mode = TRUE; + hr = IMediaDet_WriteBitmapBits(detector, 1.75, 640, 480, NULL); + todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "Got hr %#x.\n", hr); + hr = IMediaDet_GetSampleGrabber(detector, &sg); + ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr); + hr = IMediaDet_get_OutputStreams(detector, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got %d streams.\n", count); + + hr = IMediaDet_WriteBitmapBits(detector, 1.75, 640, 480, filename); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaDet_GetSampleGrabber(detector, &sg); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (SUCCEEDED(hr)) ISampleGrabber_Release(sg); + hr = IMediaDet_get_OutputStreams(detector, &count); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + DeleteFileW(filename); ref = IMediaDet_Release(detector); ok(!ref, "Got outstanding refcount %d.\n", ref); ref = IBaseFilter_Release(&testfilter.filter.IBaseFilter_iface);