static void ok_path(GpPath* path, const path_test_t *expected, INT expected_size, BOOL todo_size) { BYTE * types; INT size, idx = 0, eidx = 0, numskip; GpPointF * points; char ename[POINT_TYPE_MAX_LEN], name[POINT_TYPE_MAX_LEN]; if(GdipGetPointCount(path, &size) != Ok){ skip("Cannot perform path comparisons due to failure to retrieve path.\n"); return; } todo_wine_if (todo_size) ok(size == expected_size, "Path size %d does not match expected size %d\n", size, expected_size); points = HeapAlloc(GetProcessHeap(), 0, size * sizeof(GpPointF)); types = HeapAlloc(GetProcessHeap(), 0, size); if(GdipGetPathPoints(path, points, size) != Ok || GdipGetPathTypes(path, types, size) != Ok){ skip("Cannot perform path comparisons due to failure to retrieve path.\n"); goto end; } numskip = expected_size ? expected[eidx].wine_only_entries_preceding : 0; while (idx < size && eidx < expected_size){ /* We allow a few pixels fudge in matching X and Y coordinates to account for imprecision in * floating point to integer conversion */ BOOL match = (types[idx] == expected[eidx].type) && fabs(points[idx].X - expected[eidx].X) <= 2.0 && fabs(points[idx].Y - expected[eidx].Y) <= 2.0; stringify_point_type(expected[eidx].type, ename); stringify_point_type(types[idx], name); todo_wine_if (expected[eidx].todo || numskip) ok(match, "Expected #%d: %s (%.1f,%.1f) but got %s (%.1f,%.1f)\n", eidx, ename, expected[eidx].X, expected[eidx].Y, name, points[idx].X, points[idx].Y); if (match || expected[eidx].todo != 2) idx++; if (match || !numskip--) numskip = expected[++eidx].wine_only_entries_preceding; } end: HeapFree(GetProcessHeap(), 0, types); HeapFree(GetProcessHeap(), 0, points); }
static void verify_reg_(unsigned line, HKEY hkey, const char* value, DWORD exp_type, const void *exp_data, DWORD exp_size, DWORD todo) { DWORD type, size; BYTE data[256]; LONG err; size = sizeof(data); memset(data, 0xdd, size); err = RegQueryValueExA(hkey, value, NULL, &type, data, &size); lok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err); if (err != ERROR_SUCCESS) return; todo_wine_if (todo & TODO_REG_TYPE) lok(type == exp_type, "got wrong type %d, expected %d\n", type, exp_type); todo_wine_if (todo & TODO_REG_SIZE) lok(size == exp_size, "got wrong size %d, expected %d\n", size, exp_size); todo_wine_if (todo & TODO_REG_DATA) lok(memcmp(data, exp_data, size) == 0, "got wrong data\n"); }
static HRESULT check_expect_(enum method func, DWORD expect_param, DWORD *set_param, const char *file, int line ) { HRESULT hr; do { todo_wine_if(call_ptr->called_todo) ok_( file, line )( func == call_ptr->method, "unexpected call %s instead of %s\n", method_names[func], method_names[call_ptr->method] ); if (call_ptr->method == func) break; } while ((++call_ptr)->method != end_seq); ok_( file, line )( expect_param == call_ptr->expect_param, "%s: unexpected param %08x expected %08x\n", method_names[func], expect_param, call_ptr->expect_param ); if (set_param) *set_param = call_ptr->set_param; hr = call_ptr->set_ret; if (call_ptr->method != end_seq) call_ptr++; return hr; }
/* Show Group Test. * DDE command, expected_result, and the group name to check for existence * if expected_result is DMLERR_NO_ERROR, test * 1. window is open */ static HWND ShowGroupTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, const char *groupName, const char *windowTitle, BOOL closeAfterShowing, int testParams) { HDDEDATA hData; UINT error; HWND hwnd = 0; DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); /* todo_wine... Is expected to fail, wine stubbed functions DO fail */ /* TODO REMOVE THIS CODE!!! */ todo_wine_if (expected_result != DMLERR_NOTPROCESSED) ok (expected_result == error, "ShowGroup %s: Expected Error %s, received %s.%s\n", groupName, GetStringFromError(expected_result), GetStringFromError(error), GetStringFromTestParams(testParams)); if (error == DMLERR_NO_ERROR) { /* Check if Window is Open (polling) */ hwnd = CheckWindowCreated(windowTitle, closeAfterShowing, testParams); } return hwnd; }
/* Match one found file against testfiles[], increment count if found */ static void tally_test_file(FILE_BOTH_DIRECTORY_INFORMATION *dir_info) { int i; DWORD attribmask = (FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_REPARSE_POINT); DWORD attrib = dir_info->FileAttributes & attribmask; WCHAR *nameW = dir_info->FileName; int namelen = dir_info->FileNameLength / sizeof(WCHAR); for (i=0; testfiles[i].name; i++) { int len = strlen(testfiles[i].name); if (namelen != len || memcmp(nameW, testfiles[i].nameW, len*sizeof(WCHAR))) continue; if (!testfiles[i].attr_done) { todo_wine_if (testfiles[i].todo) ok (attrib == (testfiles[i].attr & attribmask), "file %s: expected %s (%x), got %x (is your linux new enough?)\n", testfiles[i].name, testfiles[i].description, testfiles[i].attr, attrib); testfiles[i].attr_done = TRUE; } testfiles[i].nfound++; break; } ok(testfiles[i].name != NULL, "unexpected file found\n"); }
static void test_async_xhr(IHTMLDocument2 *doc, const char *xml_url, const char *expect_text) { VARIANT vbool, vempty, var; BSTR method, url; BSTR text; LONG val; HRESULT hres; static const struct HEADER_TYPE expect_headers[] = { {"Content-Length", "51"}, {"Content-Type", "application/xml"} }; create_xmlhttprequest(doc); if(!xhr) return; V_VT(&var) = VT_DISPATCH; V_DISPATCH(&var) = (IDispatch*)&xmlhttprequest_onreadystatechange_obj; hres = IHTMLXMLHttpRequest_put_onreadystatechange(xhr, var); ok(hres == S_OK, "put_onreadystatechange failed: %08x\n", hres); V_VT(&var) = VT_EMPTY; hres = IHTMLXMLHttpRequest_get_onreadystatechange(xhr, &var); ok(hres == S_OK, "get_onreadystatechange failed: %08x\n", hres); ok(V_VT(&var) == VT_DISPATCH, "V_VT(onreadystatechange) = %d\n", V_VT(&var)); ok(V_DISPATCH(&var) == (IDispatch*)&xmlhttprequest_onreadystatechange_obj, "unexpected onreadystatechange value\n"); hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, NULL, &text); ok(hres == E_INVALIDARG, "Expect E_INVALIDARG, got %08x\n", hres); hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, NULL); ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres); hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, NULL, NULL); ok(hres == E_POINTER || broken(hres == E_INVALIDARG), /* Vista and before */ "Expect E_POINTER, got %08x\n", hres); text = (BSTR)0xdeadbeef; hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text); ok(hres == E_FAIL, "got %08x\n", hres); ok(text == NULL, "text = %p\n", text); hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, NULL); ok(hres == E_POINTER, "Expect E_POINTER, got %08x\n", hres); text = (BSTR)0xdeadbeef; hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text); ok(hres == E_FAIL, "got %08x\n", hres); ok(text == NULL, "text = %p\n", text); val = 0xdeadbeef; hres = IHTMLXMLHttpRequest_get_status(xhr, &val); ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres); ok(val == 0, "Expect 0, got %d\n", val); text = (BSTR)0xdeadbeef; hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text); ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres); ok(text == NULL, "Expect NULL, got %p\n", text); val = 0xdeadbeef; hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val); ok(hres == S_OK, "get_readyState failed: %08x\n", hres); ok(val == 0, "Expect UNSENT, got %d\n", val); method = a2bstr("GET"); url = a2bstr(xml_url); V_VT(&vbool) = VT_BOOL; V_BOOL(&vbool) = VARIANT_TRUE; V_VT(&vempty) = VT_EMPTY; SET_EXPECT(xmlhttprequest_onreadystatechange_opened); hres = IHTMLXMLHttpRequest_open(xhr, method, url, vbool, vempty, vempty); ok(hres == S_OK, "open failed: %08x\n", hres); CHECK_CALLED(xmlhttprequest_onreadystatechange_opened); SysFreeString(method); SysFreeString(url); if(FAILED(hres)) { IHTMLXMLHttpRequest_Release(xhr); xhr = NULL; return; } text = (BSTR)0xdeadbeef; hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text); ok(hres == E_FAIL, "got %08x\n", hres); ok(text == NULL, "text = %p\n", text); text = (BSTR)0xdeadbeef; hres = IHTMLXMLHttpRequest_getResponseHeader(xhr, content_type, &text); ok(hres == E_FAIL, "got %08x\n", hres); ok(text == NULL, "text = %p\n", text); val = 0xdeadbeef; hres = IHTMLXMLHttpRequest_get_status(xhr, &val); ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres); ok(val == 0, "Expect 0, got %d\n", val); hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text); ok(hres == E_FAIL, "Expect E_FAIL, got: %08x\n", hres); ok(text == NULL, "Expect NULL, got %p\n", text); val = 0xdeadbeef; hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val); ok(hres == S_OK, "get_readyState failed: %08x\n", hres); ok(val == 1, "Expect OPENED, got %d\n", val); SET_EXPECT(xmlhttprequest_onreadystatechange_opened); SET_EXPECT(xmlhttprequest_onreadystatechange_headers_received); SET_EXPECT(xmlhttprequest_onreadystatechange_loading); SET_EXPECT(xmlhttprequest_onreadystatechange_done); loading_cnt = 0; hres = IHTMLXMLHttpRequest_send(xhr, vempty); ok(hres == S_OK, "send failed: %08x\n", hres); if(SUCCEEDED(hres)) pump_msgs(&called_xmlhttprequest_onreadystatechange_done); todo_wine CHECK_CALLED(xmlhttprequest_onreadystatechange_opened); CHECK_CALLED(xmlhttprequest_onreadystatechange_headers_received); CHECK_CALLED(xmlhttprequest_onreadystatechange_loading); CHECK_CALLED(xmlhttprequest_onreadystatechange_done); /* Workaround for loading large files */ todo_wine_if(!expect_text) ok(loading_cnt == 1, "loading_cnt = %d\n", loading_cnt); if(FAILED(hres)) { IHTMLXMLHttpRequest_Release(xhr); xhr = NULL; return; } text = NULL; hres = IHTMLXMLHttpRequest_getAllResponseHeaders(xhr, &text); ok(hres == S_OK, "getAllResponseHeader failed, got %08x\n", hres); ok(text != NULL, "text == NULL\n"); SysFreeString(text); if(expect_text) test_header(expect_headers, sizeof(expect_headers)/sizeof(expect_headers[0])); val = 0xdeadbeef; hres = IHTMLXMLHttpRequest_get_status(xhr, &val); ok(hres == S_OK, "get_status failed: %08x\n", hres); ok(val == 200, "Expect 200, got %d\n", val); text = NULL; hres = IHTMLXMLHttpRequest_get_statusText(xhr, &text); ok(hres == S_OK, "get_statusText failed: %08x\n", hres); ok(text != NULL, "text == NULL\n"); ok(!strcmp_wa(text, "OK"), "Expected \"OK\", got %s\n", wine_dbgstr_w(text)); SysFreeString(text); val = 0xdeadbeef; hres = IHTMLXMLHttpRequest_get_readyState(xhr, &val); ok(hres == S_OK, "get_readyState failed: %08x\n", hres); ok(val == 4, "Expect DONE, got %d\n", val); text = NULL; hres = IHTMLXMLHttpRequest_get_responseText(xhr, &text); ok(hres == S_OK, "get_responseText failed: %08x\n", hres); ok(text != NULL, "test == NULL\n"); if(expect_text) ok(!strcmp_wa(text, expect_text), "expect %s, got %s\n", expect_text, wine_dbgstr_w(text)); SysFreeString(text); test_responseXML(expect_text); IHTMLXMLHttpRequest_Release(xhr); xhr = NULL; }
static void test_CreateBitmapFromHBITMAP(void) { /* 8 bpp data must be aligned to a DWORD boundary for a DIB */ static const BYTE data_8bpp_pal_dib[12] = { 0,1,2,0, 1,2,0,0, 2,1,0,0 }; static const BYTE data_8bpp_rgb_dib[12] = { 0xf0,0x0f,0xff,0, 0x0f,0xff,0xf0,0, 0xf0,0x0f,0xff,0 }; static const BYTE data_8bpp_pal_wic[12] = { 0xd,0xe,0x10,0, 0xe,0x10,0xd,0, 0x10,0xe,0xd,0 }; static const PALETTEENTRY pal_data[3] = { {0xff,0,0,0}, {0,0xff,0,0}, {0,0,0xff,0} }; char pal_buf[sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * 255]; LOGPALETTE *pal = (LOGPALETTE *)pal_buf; HBITMAP hbmp; HPALETTE hpal; BYTE data[12]; HRESULT hr; IWICBitmap *bitmap; UINT width, height, i, count; WICPixelFormatGUID format; IWICPalette *palette; WICBitmapPaletteType type; /* 8 bpp without palette */ hbmp = create_dib(3, 3, 8, NULL, data_8bpp_rgb_dib); ok(hbmp != 0, "failed to create bitmap\n"); hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, 0, 0, WICBitmapIgnoreAlpha, &bitmap); ok(hr == WINCODEC_ERR_WIN32ERROR || hr == 0x88980003 /*XP*/, "expected WINCODEC_ERR_WIN32ERROR, got %#x\n", hr); hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, 0, WICBitmapIgnoreAlpha, NULL); ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr); hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, 0, WICBitmapIgnoreAlpha, &bitmap); ok(hr == S_OK, "CreateBitmapFromHBITMAP error %#x\n", hr); IWICBitmap_GetPixelFormat(bitmap, &format); ok(IsEqualGUID(&format, &GUID_WICPixelFormat8bppIndexed), "unexpected pixel format %s\n", wine_dbgstr_guid(&format)); hr = IWICBitmap_GetSize(bitmap, &width, &height); ok(hr == S_OK, "IWICBitmap_GetSize error %#x\n", hr); ok(width == 3, "expected 3, got %u\n", width); ok(height == 3, "expected 3, got %u\n", height); memset(data, 0, sizeof(data)); hr = IWICBitmap_CopyPixels(bitmap, NULL, 4, sizeof(data), data); ok(hr == S_OK, "IWICBitmap_CopyPixels error %#x\n", hr); for (i = 0; i < sizeof(data); i++) ok(data[i] == data_8bpp_rgb_dib[i], "%u: expected %#x, got %#x\n", i, data_8bpp_rgb_dib[i], data[i]); IWICBitmap_Release(bitmap); DeleteObject(hbmp); /* 8 bpp with a 3 entries palette */ memset(pal_buf, 0, sizeof(pal_buf)); pal->palVersion = 0x300; pal->palNumEntries = 3; memcpy(pal->palPalEntry, pal_data, sizeof(pal_data)); hpal = CreatePalette(pal); ok(hpal != 0, "CreatePalette failed\n"); hbmp = create_dib(3, 3, 8, pal, data_8bpp_pal_dib); hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, hpal, WICBitmapIgnoreAlpha, &bitmap); ok(hr == S_OK, "CreateBitmapFromHBITMAP error %#x\n", hr); IWICBitmap_GetPixelFormat(bitmap, &format); todo_wine ok(IsEqualGUID(&format, &GUID_WICPixelFormat4bppIndexed), "unexpected pixel format %s\n", wine_dbgstr_guid(&format)); hr = IWICBitmap_GetSize(bitmap, &width, &height); ok(hr == S_OK, "IWICBitmap_GetSize error %#x\n", hr); ok(width == 3, "expected 3, got %u\n", width); ok(height == 3, "expected 3, got %u\n", height); hr = IWICImagingFactory_CreatePalette(factory, &palette); ok(hr == S_OK, "CreatePalette error %#x\n", hr); hr = IWICBitmap_CopyPalette(bitmap, palette); ok(hr == S_OK, "CopyPalette error %#x\n", hr); hr = IWICPalette_GetType(palette, &type); ok(hr == S_OK, "%u: GetType error %#x\n", i, hr); ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %#x\n", type); hr = IWICPalette_GetColorCount(palette, &count); ok(hr == S_OK, "GetColorCount error %#x\n", hr); todo_wine ok(count == 16, "expected 16, got %u\n", count); IWICPalette_Release(palette); IWICBitmap_Release(bitmap); DeleteObject(hbmp); DeleteObject(hpal); /* 8 bpp with a 256 entries palette */ memset(pal_buf, 0, sizeof(pal_buf)); pal->palVersion = 0x300; pal->palNumEntries = 256; memcpy(pal->palPalEntry, pal_data, sizeof(pal_data)); hpal = CreatePalette(pal); ok(hpal != 0, "CreatePalette failed\n"); hbmp = create_dib(3, 3, 8, pal, data_8bpp_pal_dib); hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, hpal, WICBitmapIgnoreAlpha, &bitmap); ok(hr == S_OK, "CreateBitmapFromHBITMAP error %#x\n", hr); IWICBitmap_GetPixelFormat(bitmap, &format); ok(IsEqualGUID(&format, &GUID_WICPixelFormat8bppIndexed), "unexpected pixel format %s\n", wine_dbgstr_guid(&format)); hr = IWICBitmap_GetSize(bitmap, &width, &height); ok(hr == S_OK, "IWICBitmap_GetSize error %#x\n", hr); ok(width == 3, "expected 3, got %u\n", width); ok(height == 3, "expected 3, got %u\n", height); hr = IWICImagingFactory_CreatePalette(factory, &palette); ok(hr == S_OK, "CreatePalette error %#x\n", hr); hr = IWICBitmap_CopyPalette(bitmap, palette); ok(hr == S_OK, "CopyPalette error %#x\n", hr); hr = IWICPalette_GetType(palette, &type); ok(hr == S_OK, "%u: GetType error %#x\n", i, hr); ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %#x\n", type); hr = IWICPalette_GetColorCount(palette, &count); ok(hr == S_OK, "GetColorCount error %#x\n", hr); ok(count == 256, "expected 256, got %u\n", count); IWICPalette_Release(palette); memset(data, 0, sizeof(data)); hr = IWICBitmap_CopyPixels(bitmap, NULL, 4, sizeof(data), data); ok(hr == S_OK, "IWICBitmap_CopyPixels error %#x\n", hr); for (i = 0; i < sizeof(data); i++) todo_wine_if (data[i] != data_8bpp_pal_wic[i]) ok(data[i] == data_8bpp_pal_wic[i], "%u: expected %#x, got %#x\n", i, data_8bpp_pal_wic[i], data[i]); IWICBitmap_Release(bitmap); DeleteObject(hbmp); DeleteObject(hpal); /* 32bpp alpha */ hbmp = create_dib(2, 2, 32, NULL, NULL); hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, NULL, WICBitmapUseAlpha, &bitmap); ok(hr == S_OK, "CreateBitmapFromHBITMAP error %#x\n", hr); hr = IWICBitmap_GetPixelFormat(bitmap, &format); ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppBGRA), "unexpected pixel format %s\n", wine_dbgstr_guid(&format)); IWICBitmap_Release(bitmap); /* 32bpp pre-multiplied alpha */ hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, NULL, WICBitmapUsePremultipliedAlpha, &bitmap); ok(hr == S_OK, "CreateBitmapFromHBITMAP error %#x\n", hr); hr = IWICBitmap_GetPixelFormat(bitmap, &format); ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppPBGRA), "unexpected pixel format %s\n", wine_dbgstr_guid(&format)); IWICBitmap_Release(bitmap); /* 32bpp no alpha */ hr = IWICImagingFactory_CreateBitmapFromHBITMAP(factory, hbmp, NULL, WICBitmapIgnoreAlpha, &bitmap); ok(hr == S_OK, "CreateBitmapFromHBITMAP error %#x\n", hr); hr = IWICBitmap_GetPixelFormat(bitmap, &format); ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppBGR), "unexpected pixel format %s\n", wine_dbgstr_guid(&format)); IWICBitmap_Release(bitmap); DeleteObject(hbmp); }
static void test_preinitialization(void) { static const struct { REFGUID rguid; BOOL pdev; HRESULT expected_hr; } create_device_tests[] = { {NULL, FALSE, E_POINTER}, {NULL, TRUE, E_POINTER}, {&GUID_Unknown, FALSE, E_POINTER}, {&GUID_Unknown, TRUE, DIERR_NOTINITIALIZED}, {&GUID_SysMouse, FALSE, E_POINTER}, {&GUID_SysMouse, TRUE, DIERR_NOTINITIALIZED}, }; static const struct { DWORD dwDevType; LPDIENUMDEVICESCALLBACKA lpCallback; DWORD dwFlags; HRESULT expected_hr; int todo; } enum_devices_tests[] = { {0, NULL, 0, DIERR_INVALIDPARAM}, {0, NULL, ~0u, DIERR_INVALIDPARAM}, {0, dummy_callback, 0, DIERR_NOTINITIALIZED}, {0, dummy_callback, ~0u, DIERR_INVALIDPARAM}, {0xdeadbeef, NULL, 0, DIERR_INVALIDPARAM}, {0xdeadbeef, NULL, ~0u, DIERR_INVALIDPARAM}, {0xdeadbeef, dummy_callback, 0, DIERR_INVALIDPARAM}, {0xdeadbeef, dummy_callback, ~0u, DIERR_INVALIDPARAM}, }; IDirectInput8A *pDI; HRESULT hr; int i; IDirectInputDevice8A *pDID; hr = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput8A, (void **)&pDI); if (FAILED(hr)) { skip("Failed to instantiate a IDirectInputA instance: 0x%08x\n", hr); return; } for (i = 0; i < ARRAY_SIZE(create_device_tests); i++) { if (create_device_tests[i].pdev) pDID = (void *)0xdeadbeef; hr = IDirectInput8_CreateDevice(pDI, create_device_tests[i].rguid, create_device_tests[i].pdev ? &pDID : NULL, NULL); ok(hr == create_device_tests[i].expected_hr, "[%d] IDirectInput8_CreateDevice returned 0x%08x\n", i, hr); if (create_device_tests[i].pdev) ok(pDID == NULL, "[%d] Output interface pointer is %p\n", i, pDID); } for (i = 0; i < ARRAY_SIZE(enum_devices_tests); i++) { hr = IDirectInput8_EnumDevices(pDI, enum_devices_tests[i].dwDevType, enum_devices_tests[i].lpCallback, NULL, enum_devices_tests[i].dwFlags); todo_wine_if(enum_devices_tests[i].todo) ok(hr == enum_devices_tests[i].expected_hr, "[%d] IDirectInput8_EnumDevice returned 0x%08x\n", i, hr); } hr = IDirectInput8_GetDeviceStatus(pDI, NULL); ok(hr == E_POINTER, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr); hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_Unknown); ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr); hr = IDirectInput8_GetDeviceStatus(pDI, &GUID_SysMouse); ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_GetDeviceStatus returned 0x%08x\n", hr); hr = IDirectInput8_RunControlPanel(pDI, NULL, 0); ok(hr == DIERR_NOTINITIALIZED, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); hr = IDirectInput8_RunControlPanel(pDI, NULL, ~0u); ok(hr == DIERR_INVALIDPARAM, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, 0); ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); hr = IDirectInput8_RunControlPanel(pDI, (HWND)0xdeadbeef, ~0u); ok(hr == E_HANDLE, "IDirectInput8_RunControlPanel returned 0x%08x\n", hr); IDirectInput8_Release(pDI); }
static void test_color_formats(void) { static const struct { char bit_depth, color_type; const GUID *format; const GUID *format_PLTE; const GUID *format_PLTE_tRNS; BOOL todo; BOOL todo_load; } td[] = { /* 2 - PNG_COLOR_TYPE_RGB */ { 1, 2, NULL, NULL, NULL }, { 2, 2, NULL, NULL, NULL }, { 4, 2, NULL, NULL, NULL }, { 8, 2, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR }, /* libpng refuses to load our test image complaining about extra compressed data, * but libpng is still able to load the image with other combination of type/depth * making RGB 16 bpp case special for some reason. Therefore todo = TRUE. */ { 16, 2, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, TRUE, TRUE }, { 24, 2, NULL, NULL, NULL }, { 32, 2, NULL, NULL, NULL }, /* 0 - PNG_COLOR_TYPE_GRAY */ { 1, 0, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat1bppIndexed, TRUE }, { 2, 0, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppIndexed, TRUE }, { 4, 0, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppIndexed, TRUE }, { 8, 0, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppIndexed, TRUE }, { 16, 0, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat64bppRGBA, TRUE }, { 24, 0, NULL, NULL, NULL }, { 32, 0, NULL, NULL, NULL }, /* 3 - PNG_COLOR_TYPE_PALETTE */ { 1, 3, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed }, { 2, 3, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed }, { 4, 3, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed }, { 8, 3, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed }, { 16, 3, NULL, NULL, NULL }, { 24, 3, NULL, NULL, NULL }, { 32, 3, NULL, NULL, NULL }, }; char buf[sizeof(png_1x1_data)]; HRESULT hr; IWICBitmapDecoder *decoder; IWICBitmapFrameDecode *frame; GUID format; int i, PLTE_off = 0, tRNS_off = 0; memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); for (i = 0; i < sizeof(png_1x1_data) - 4; i++) { if (!memcmp(buf + i, "tRNS", 4)) tRNS_off = i; else if (!memcmp(buf + i, "PLTE", 4)) PLTE_off = i; } ok(PLTE_off && tRNS_off, "PLTE offset %d, tRNS offset %d\n", PLTE_off, tRNS_off); if (!PLTE_off || !tRNS_off) return; /* In order to test the image data with and without PLTE and tRNS chunks * it's been decided to simply sero out the chunk id for testing puposes, * and under Windows such images get loaded just fine. But unfortunately * libpng refuses to load such images complaining about unknown chunk type. * A workaround for this libpng limitation is to mark the "disabled" chunks * with tEXt id. */ for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) { /* with the tRNS and PLTE chunks */ memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); buf[24] = td[i].bit_depth; buf[25] = td[i].color_type; hr = create_decoder(buf, sizeof(buf), &decoder); if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE)) ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr); else todo_wine_if(td[i].todo_load) ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr); if (hr != S_OK) goto next_1; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); todo_wine_if(td[i].todo) ok(IsEqualGUID(&format, td[i].format_PLTE_tRNS), "PLTE+tRNS: expected %s, got %s (type %d, bpp %d)\n", wine_dbgstr_guid(td[i].format_PLTE_tRNS), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth); IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder); next_1: /* without the tRNS chunk */ memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); buf[24] = td[i].bit_depth; buf[25] = td[i].color_type; memcpy(buf + tRNS_off, "tEXt", 4); hr = create_decoder(buf, sizeof(buf), &decoder); if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE)) ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr); else todo_wine_if(td[i].todo_load) ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr); if (hr != S_OK) goto next_2; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); ok(IsEqualGUID(&format, td[i].format_PLTE), "PLTE: expected %s, got %s (type %d, bpp %d)\n", wine_dbgstr_guid(td[i].format_PLTE), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth); IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder); next_2: /* without the tRNS and PLTE chunks */ memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); buf[24] = td[i].bit_depth; buf[25] = td[i].color_type; memcpy(buf + PLTE_off, "tEXt", 4); memcpy(buf + tRNS_off, "tEXt", 4); hr = create_decoder(buf, sizeof(buf), &decoder); if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE)) ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr); else todo_wine_if(td[i].todo_load) ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr); if (hr != S_OK) goto next_3; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); ok(IsEqualGUID(&format, td[i].format), "expected %s, got %s (type %d, bpp %d)\n", wine_dbgstr_guid(td[i].format), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth); IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder); next_3: /* without the PLTE chunk */ memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); buf[24] = td[i].bit_depth; buf[25] = td[i].color_type; memcpy(buf + PLTE_off, "tEXt", 4); hr = create_decoder(buf, sizeof(buf), &decoder); if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE)) ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr); else todo_wine_if(td[i].todo_load) ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr); if (hr != S_OK) continue; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); todo_wine_if(td[i].todo) ok(IsEqualGUID(&format, td[i].format_PLTE_tRNS), "tRNS: expected %s, got %s (type %d, bpp %d)\n", wine_dbgstr_guid(td[i].format_PLTE_tRNS), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth); IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder); } }
static void test_IWbemPath_SetText(void) { static const struct { const WCHAR *path; ULONG mode; HRESULT ret; BOOL todo; } test[] = { { path1, 0, WBEM_E_INVALID_PARAMETER }, { path1, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }, { path2, 0, WBEM_E_INVALID_PARAMETER }, { path2, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }, { path3, 0, WBEM_E_INVALID_PARAMETER }, { path3, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }, { path4, 0, WBEM_E_INVALID_PARAMETER }, { path4, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }, { path5, 0, WBEM_E_INVALID_PARAMETER }, { path5, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }, { path6, 0, WBEM_E_INVALID_PARAMETER }, { path6, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }, { path7, 0, WBEM_E_INVALID_PARAMETER }, { path7, WBEMPATH_CREATE_ACCEPT_RELATIVE, S_OK }, { path7, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK }, { path7, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }, { path7, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS, WBEM_E_INVALID_PARAMETER, TRUE }, { path7, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK }, { path8, WBEMPATH_CREATE_ACCEPT_RELATIVE, S_OK }, { path8, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, TRUE }, { path8, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }, { path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS, WBEM_E_INVALID_PARAMETER, TRUE }, { path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK }, { path9, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK }, { path10, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, TRUE }, { path11, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK }, { path15, WBEMPATH_CREATE_ACCEPT_ALL, S_OK } }; IWbemPath *path; HRESULT hr; UINT i; if (!(path = create_path())) return; hr = IWbemPath_SetText( path, 0, NULL ); ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr ); hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, NULL ); ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr ); for (i = 0; i < sizeof(test)/sizeof(test[0]); i++) { hr = IWbemPath_SetText( path, test[i].mode, test[i].path ); todo_wine_if (test[i].todo) ok( hr == test[i].ret, "%u got %08x\n", i, hr ); if (test[i].ret == S_OK) { WCHAR buf[128]; ULONG len; memset( buf, 0x55, sizeof(buf) ); len = sizeof(buf)/sizeof(buf[0]); hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, buf ); ok( hr == S_OK, "%u got %08x\n", i, hr ); ok( !lstrcmpW( buf, test[i].path ), "%u unexpected path %s\n", i, wine_dbgstr_w(buf) ); ok( len == lstrlenW( test[i].path ) + 1, "%u unexpected length %u\n", i, len ); } } IWbemPath_Release( path ); }