static void test_QueryInterface(void) { LPVOID pvObj = NULL; HRESULT hr; IFont* font = NULL; LONG ref; hr = pOleCreateFontIndirect(NULL, &IID_IFont, NULL); EXPECT_HR(hr, E_POINTER); hr = pOleCreateFontIndirect(NULL, &IID_IFont, &pvObj); font = pvObj; EXPECT_HR(hr, S_OK); ok(font != NULL,"OCFI (NULL,..) returns NULL, instead of !NULL\n"); pvObj = NULL; hr = IFont_QueryInterface( font, &IID_IFont, &pvObj); EXPECT_HR(hr, S_OK); /* Test if QueryInterface increments ref counter for IFONTs */ ref = IFont_AddRef(font); ok(ref == 3 || broken(ref == 1), /* win95 */ "IFont_QI expected ref value 3 but instead got %d\n", ref); IFont_Release(font); ok(pvObj != NULL,"IFont_QI does return NULL, instead of a ptr\n"); IFont_Release(font); IFont_Release(font); }
static void test_returns(void) { IFont *pFont; FONTDESC fontdesc; HRESULT hr; fontdesc.cbSizeofstruct = sizeof(fontdesc); fontdesc.lpstrName = MSSansSerif_font; fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */ fontdesc.sWeight = FW_NORMAL; fontdesc.sCharset = 0; fontdesc.fItalic = FALSE; fontdesc.fUnderline = FALSE; fontdesc.fStrikethrough = FALSE; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&pFont); EXPECT_HR(hr, S_OK); hr = IFont_put_Name(pFont, NULL); EXPECT_HR(hr, CTL_E_INVALIDPROPERTYVALUE); hr = IFont_get_Name(pFont, NULL); EXPECT_HR(hr, E_POINTER); hr = IFont_get_Size(pFont, NULL); EXPECT_HR(hr, E_POINTER); hr = IFont_get_Bold(pFont, NULL); EXPECT_HR(hr, E_POINTER); IFont_Release(pFont); }
static void test_OleCreateFontIndirect(void) { FONTDESC fontdesc; IFont *font; HRESULT hr; fontdesc.cbSizeofstruct = sizeof(fontdesc); fontdesc.lpstrName = arial_font; fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */ fontdesc.sWeight = FW_NORMAL; fontdesc.sCharset = ANSI_CHARSET; fontdesc.fItalic = FALSE; fontdesc.fUnderline = FALSE; fontdesc.fStrikethrough = FALSE; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font); EXPECT_HR(hr, S_OK); IFont_Release(font); /* play with cbSizeofstruct value */ fontdesc.cbSizeofstruct = sizeof(fontdesc)-1; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font); EXPECT_HR(hr, S_OK); IFont_Release(font); fontdesc.cbSizeofstruct = sizeof(fontdesc)+1; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font); EXPECT_HR(hr, S_OK); IFont_Release(font); fontdesc.cbSizeofstruct = 0; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font); EXPECT_HR(hr, S_OK); IFont_Release(font); }
static void test_service(void) { static const WCHAR spooler[] = {'S','p','o','o','l','e','r',0}; static const WCHAR dummyW[] = {'d','u','m','m','y',0}; SERVICE_STATUS_PROCESS status; SC_HANDLE scm, service; IShellDispatch2 *sd; DWORD dummy; HRESULT hr; BSTR name; VARIANT v; hr = CoCreateInstance(&CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, &IID_IShellDispatch2, (void**)&sd); if (hr != S_OK) { win_skip("IShellDispatch2 not supported\n"); return; } V_VT(&v) = VT_I2; V_I2(&v) = 10; hr = IShellDispatch2_IsServiceRunning(sd, NULL, &v); ok(V_VT(&v) == VT_BOOL, "got %d\n", V_VT(&v)); ok(V_BOOL(&v) == VARIANT_FALSE, "got %d\n", V_BOOL(&v)); EXPECT_HR(hr, S_OK); scm = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT); service = OpenServiceW(scm, spooler, SERVICE_QUERY_STATUS); QueryServiceStatusEx(service, SC_STATUS_PROCESS_INFO, (BYTE *)&status, sizeof(SERVICE_STATUS_PROCESS), &dummy); CloseServiceHandle(service); CloseServiceHandle(scm); /* service should exist */ name = SysAllocString(spooler); V_VT(&v) = VT_I2; hr = IShellDispatch2_IsServiceRunning(sd, name, &v); EXPECT_HR(hr, S_OK); ok(V_VT(&v) == VT_BOOL, "got %d\n", V_VT(&v)); if (status.dwCurrentState == SERVICE_RUNNING) ok(V_BOOL(&v) == VARIANT_TRUE, "got %d\n", V_BOOL(&v)); else ok(V_BOOL(&v) == VARIANT_FALSE, "got %d\n", V_BOOL(&v)); SysFreeString(name); /* service doesn't exist */ name = SysAllocString(dummyW); V_VT(&v) = VT_I2; hr = IShellDispatch2_IsServiceRunning(sd, name, &v); EXPECT_HR(hr, S_OK); ok(V_VT(&v) == VT_BOOL, "got %d\n", V_VT(&v)); ok(V_BOOL(&v) == VARIANT_FALSE, "got %d\n", V_BOOL(&v)); SysFreeString(name); IShellDispatch2_Release(sd); }
static void test_OleCreateFontIndirect(void) { FONTDESC fontdesc; IUnknown *unk, *unk2; IFont *font; HRESULT hr; fontdesc.cbSizeofstruct = sizeof(fontdesc); fontdesc.lpstrName = arial_font; fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */ fontdesc.sWeight = FW_NORMAL; fontdesc.sCharset = ANSI_CHARSET; fontdesc.fItalic = FALSE; fontdesc.fUnderline = FALSE; fontdesc.fStrikethrough = FALSE; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font); EXPECT_HR(hr, S_OK); IFont_Release(font); /* play with cbSizeofstruct value */ fontdesc.cbSizeofstruct = sizeof(fontdesc)-1; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font); EXPECT_HR(hr, S_OK); IFont_Release(font); fontdesc.cbSizeofstruct = sizeof(fontdesc)+1; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font); EXPECT_HR(hr, S_OK); IFont_Release(font); fontdesc.cbSizeofstruct = 0; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void**)&font); EXPECT_HR(hr, S_OK); IFont_Release(font); hr = OleInitialize(NULL); ok(hr == S_OK, "got 0x%08x\n", hr); hr = CoGetClassObject(&CLSID_StdFont, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&unk); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void**)&unk2); ok(hr == S_OK, "got 0x%08x\n", hr); IUnknown_Release(unk); IUnknown_Release(unk2); OleUninitialize(); }
static void test_GetFontFamily(void) { IDWriteFontFamily *family, *family2; IDWriteGdiInterop *interop; IDWriteFont *font; LOGFONTW logfont; HRESULT hr; hr = IDWriteFactory_GetGdiInterop(factory, &interop); EXPECT_HR(hr, S_OK); memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = FW_NORMAL; logfont.lfItalic = 1; lstrcpyW(logfont.lfFaceName, tahomaW); hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); EXPECT_HR(hr, S_OK); if (0) /* crashes on native */ hr = IDWriteFont_GetFontFamily(font, NULL); EXPECT_REF(font, 1); hr = IDWriteFont_GetFontFamily(font, &family); EXPECT_HR(hr, S_OK); EXPECT_REF(font, 1); EXPECT_REF(family, 2); hr = IDWriteFont_GetFontFamily(font, &family2); EXPECT_HR(hr, S_OK); ok(family2 == family, "got %p, previous %p\n", family2, family); EXPECT_REF(font, 1); EXPECT_REF(family, 3); IDWriteFontFamily_Release(family2); hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFontFamily, (void**)&family2); EXPECT_HR(hr, E_NOINTERFACE); ok(family2 == NULL, "got %p\n", family2); IDWriteFontFamily_Release(family); IDWriteFont_Release(font); IDWriteGdiInterop_Release(interop); }
static void test_GetMetrics(void) { IDWriteGdiInterop *interop; DWRITE_FONT_METRICS metrics; OUTLINETEXTMETRICW otm; IDWriteFont *font; LOGFONTW logfont; HRESULT hr; HDC hdc; HFONT hfont; int ret; hr = IDWriteFactory_GetGdiInterop(factory, &interop); EXPECT_HR(hr, S_OK); memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = FW_NORMAL; logfont.lfItalic = 1; lstrcpyW(logfont.lfFaceName, tahomaW); hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); ok(hr == S_OK, "got 0x%08x\n", hr); hfont = CreateFontIndirectW(&logfont); hdc = CreateCompatibleDC(0); SelectObject(hdc, hfont); otm.otmSize = sizeof(otm); ret = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm); ok(ret, "got %d\n", ret); DeleteDC(hdc); DeleteObject(hfont); if (0) /* crashes on native */ IDWriteFont_GetMetrics(font, NULL); memset(&metrics, 0, sizeof(metrics)); IDWriteFont_GetMetrics(font, &metrics); ok(metrics.designUnitsPerEm != 0, "designUnitsPerEm %u\n", metrics.designUnitsPerEm); ok(metrics.ascent != 0, "ascent %u\n", metrics.ascent); ok(metrics.descent != 0, "descent %u\n", metrics.descent); todo_wine ok(metrics.lineGap == 0, "lineGap %d\n", metrics.lineGap); ok(metrics.capHeight, "capHeight %u\n", metrics.capHeight); ok(metrics.xHeight != 0, "xHeight %u\n", metrics.xHeight); ok(metrics.underlinePosition < 0, "underlinePosition %d\n", metrics.underlinePosition); ok(metrics.underlineThickness != 0, "underlineThickness %u\n", metrics.underlineThickness); ok(metrics.strikethroughPosition > 0, "strikethroughPosition %d\n", metrics.strikethroughPosition); ok(metrics.strikethroughThickness != 0, "strikethroughThickness %u\n", metrics.strikethroughThickness); IDWriteFont_Release(font); IDWriteGdiInterop_Release(interop); }
static void test_Invoke(void) { IFontDisp *fontdisp; HRESULT hr; VARIANTARG vararg; DISPPARAMS dispparams; VARIANT varresult; hr = pOleCreateFontIndirect(NULL, &IID_IFontDisp, (void **)&fontdisp); EXPECT_HR(hr, S_OK); V_VT(&vararg) = VT_BOOL; V_BOOL(&vararg) = VARIANT_FALSE; dispparams.cNamedArgs = 0; dispparams.rgdispidNamedArgs = NULL; dispparams.cArgs = 1; dispparams.rgvarg = &vararg; hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_IFontDisp, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); EXPECT_HR(hr, DISP_E_UNKNOWNINTERFACE); dispparams.cArgs = 0; dispparams.rgvarg = NULL; hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); EXPECT_HR(hr, DISP_E_BADPARAMCOUNT); hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, NULL, NULL, NULL); EXPECT_HR(hr, DISP_E_PARAMNOTOPTIONAL); hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL); EXPECT_HR(hr, DISP_E_PARAMNOTOPTIONAL); hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, &varresult, NULL, NULL); EXPECT_HR(hr, S_OK); hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_METHOD, NULL, &varresult, NULL, NULL); EXPECT_HR(hr, DISP_E_MEMBERNOTFOUND); hr = IFontDisp_Invoke(fontdisp, 0xdeadbeef, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, &varresult, NULL, NULL); EXPECT_HR(hr, DISP_E_MEMBERNOTFOUND); dispparams.cArgs = 1; dispparams.rgvarg = &vararg; hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); EXPECT_HR(hr, S_OK); IFontDisp_Release(fontdisp); }
static void test_realization(void) { IFont *font; FONTDESC fontdesc; HRESULT hr; BSTR name; SHORT cs; /* Try to create a symbol only font (marlett) with charset set to ANSI. This will result in another, ANSI, font being selected */ fontdesc.cbSizeofstruct = sizeof(fontdesc); fontdesc.lpstrName = marlett_font; fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */ fontdesc.sWeight = FW_NORMAL; fontdesc.sCharset = ANSI_CHARSET; fontdesc.fItalic = FALSE; fontdesc.fUnderline = FALSE; fontdesc.fStrikethrough = FALSE; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font); EXPECT_HR(hr, S_OK); hr = IFont_get_Charset(font, &cs); EXPECT_HR(hr, S_OK); ok(cs == ANSI_CHARSET, "got charset %d\n", cs); IFont_Release(font); /* Now create an ANSI font and change the name to marlett */ fontdesc.lpstrName = arial_font; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font); EXPECT_HR(hr, S_OK); hr = IFont_get_Charset(font, &cs); EXPECT_HR(hr, S_OK); ok(cs == ANSI_CHARSET, "got charset %d\n", cs); name = SysAllocString(marlett_font); hr = IFont_put_Name(font, name); EXPECT_HR(hr, S_OK); SysFreeString(name); hr = IFont_get_Name(font, &name); EXPECT_HR(hr, S_OK); ok(!lstrcmpiW(name, marlett_font), "got name %s\n", wine_dbgstr_w(name)); SysFreeString(name); hr = IFont_get_Charset(font, &cs); EXPECT_HR(hr, S_OK); ok(cs == SYMBOL_CHARSET, "got charset %d\n", cs); IFont_Release(font); }
static void set_xhr_site(IXMLHttpRequest *xhr) { IObjectWithSite *obj_site; HRESULT hr; hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site); ok(hr == S_OK, "Could not get IObjectWithSite iface: %08x\n", hr); g_enablecallchecks = TRUE; SET_EXPECT(site_qi_IServiceProvider); SET_EXPECT(sp_queryservice_SID_SBindHost); SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2); SET_EXPECT(sp_queryservice_SID_secmgr_htmldoc2); SET_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc); SET_EXPECT(sp_queryservice_SID_secmgr_secmgr); /* calls to IHTMLDocument2 */ SET_EXPECT(htmldoc2_get_all); SET_EXPECT(collection_get_length); SET_EXPECT(htmldoc2_get_url); SET_EXPECT(site_qi_IXMLDOMDocument); SET_EXPECT(site_qi_IOleClientSite); hr = IObjectWithSite_SetSite(obj_site, &testsite); EXPECT_HR(hr, S_OK); CHECK_CALLED(site_qi_IServiceProvider); todo_wine CHECK_CALLED(sp_queryservice_SID_SBindHost); CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2); CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2); todo_wine CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc); /* this one isn't very reliable CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */ todo_wine { CHECK_CALLED(htmldoc2_get_all); CHECK_CALLED(collection_get_length); } CHECK_CALLED(htmldoc2_get_url); todo_wine { CHECK_CALLED(site_qi_IXMLDOMDocument); CHECK_CALLED(site_qi_IOleClientSite); } g_enablecallchecks = FALSE; IObjectWithSite_Release(obj_site); }
static void test_CreateFontFace(void) { IDWriteFontFace *fontface, *fontface2; IDWriteGdiInterop *interop; IDWriteFont *font; LOGFONTW logfont; HRESULT hr; hr = IDWriteFactory_GetGdiInterop(factory, &interop); EXPECT_HR(hr, S_OK); memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = FW_NORMAL; logfont.lfItalic = 1; lstrcpyW(logfont.lfFaceName, tahomaW); hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFontFace, (void**)&fontface); ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr); if (0) /* crashes on native */ hr = IDWriteFont_CreateFontFace(font, NULL); hr = IDWriteFont_CreateFontFace(font, &fontface); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IDWriteFont_CreateFontFace(font, &fontface2); ok(hr == S_OK, "got 0x%08x\n", hr); ok(fontface == fontface2, "got %p, was %p\n", fontface2, fontface); /* the fontface refcount is increased here */ IDWriteFontFace_Release(fontface); IDWriteFontFace_Release(fontface); IDWriteFont_Release(font); IDWriteGdiInterop_Release(interop); }
static void test_XMLHTTP(void) { static const char bodyA[] = "mode=Test"; static const char urlA[] = "http://crossover.codeweavers.com/posttest.php"; static const char xmltestA[] = "http://crossover.codeweavers.com/xmltest.xml"; static const char referertesturl[] = "http://test.winehq.org/tests/referer.php"; static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0}; static const CHAR xmltestbodyA[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n"; static const WCHAR norefererW[] = {'n','o',' ','r','e','f','e','r','e','r',' ','s','e','t',0}; IXMLHttpRequest *xhr; IObjectWithSite *obj_site, *obj_site2; BSTR bstrResponse, str, str1; VARIANT varbody, varbody_ref; VARIANT dummy; LONG state, status, bound; IDispatch *event; void *ptr; HRESULT hr; HGLOBAL g; xhr = create_xhr(); VariantInit(&dummy); V_VT(&dummy) = VT_ERROR; V_ERROR(&dummy) = DISP_E_MEMBERNOTFOUND; hr = IXMLHttpRequest_put_onreadystatechange(xhr, NULL); EXPECT_HR(hr, S_OK); hr = IXMLHttpRequest_abort(xhr); EXPECT_HR(hr, S_OK); V_VT(&varbody) = VT_I2; V_I2(&varbody) = 1; hr = IXMLHttpRequest_get_responseBody(xhr, &varbody); EXPECT_HR(hr, E_PENDING); ok(V_VT(&varbody) == VT_EMPTY, "got type %d\n", V_VT(&varbody)); ok(V_I2(&varbody) == 1, "got %d\n", V_I2(&varbody)); V_VT(&varbody) = VT_I2; V_I2(&varbody) = 1; hr = IXMLHttpRequest_get_responseStream(xhr, &varbody); EXPECT_HR(hr, E_PENDING); ok(V_VT(&varbody) == VT_EMPTY, "got type %d\n", V_VT(&varbody)); ok(V_I2(&varbody) == 1, "got %d\n", V_I2(&varbody)); /* send before open */ hr = IXMLHttpRequest_send(xhr, dummy); ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); /* initial status code */ hr = IXMLHttpRequest_get_status(xhr, NULL); ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); status = 0xdeadbeef; hr = IXMLHttpRequest_get_status(xhr, &status); ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); ok(status == READYSTATE_UNINITIALIZED || broken(status == 0xdeadbeef) /* <win8 */, "got %d\n", status); hr = IXMLHttpRequest_get_statusText(xhr, &str); ok(hr == E_FAIL, "got 0x%08x\n", hr); /* invalid parameters */ test_open(xhr, NULL, NULL, E_INVALIDARG); test_open(xhr, "POST", NULL, E_INVALIDARG); test_open(xhr, NULL, urlA, E_INVALIDARG); hr = IXMLHttpRequest_setRequestHeader(xhr, NULL, NULL); EXPECT_HR(hr, E_INVALIDARG); hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_("header1"), NULL); ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); hr = IXMLHttpRequest_setRequestHeader(xhr, NULL, _bstr_("value1")); EXPECT_HR(hr, E_INVALIDARG); hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_("header1"), _bstr_("value1")); ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); hr = IXMLHttpRequest_get_readyState(xhr, NULL); ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); state = -1; hr = IXMLHttpRequest_get_readyState(xhr, &state); EXPECT_HR(hr, S_OK); ok(state == READYSTATE_UNINITIALIZED, "got %d, expected READYSTATE_UNINITIALIZED\n", state); httpreq = xhr; event = create_dispevent(); EXPECT_REF(event, 1); hr = IXMLHttpRequest_put_onreadystatechange(xhr, event); EXPECT_HR(hr, S_OK); EXPECT_REF(event, 2); g_unexpectedcall = g_expectedcall = 0; test_open(xhr, "POST", urlA, S_OK); ok(g_unexpectedcall == 0, "unexpected disp event call\n"); ok(g_expectedcall == 1 || broken(g_expectedcall == 0) /* win2k */, "no expected disp event call\n"); /* status code after ::open() */ status = 0xdeadbeef; hr = IXMLHttpRequest_get_status(xhr, &status); ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); ok(status == READYSTATE_UNINITIALIZED || broken(status == 0xdeadbeef) /* <win8 */, "got %d\n", status); state = -1; hr = IXMLHttpRequest_get_readyState(xhr, &state); EXPECT_HR(hr, S_OK); ok(state == READYSTATE_LOADING, "got %d, expected READYSTATE_LOADING\n", state); hr = IXMLHttpRequest_abort(xhr); EXPECT_HR(hr, S_OK); state = -1; hr = IXMLHttpRequest_get_readyState(xhr, &state); EXPECT_HR(hr, S_OK); ok(state == READYSTATE_UNINITIALIZED || broken(state == READYSTATE_LOADING) /* win2k */, "got %d, expected READYSTATE_UNINITIALIZED\n", state); test_open(xhr, "POST", urlA, S_OK); hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_("header1"), _bstr_("value1")); EXPECT_HR(hr, S_OK); hr = IXMLHttpRequest_setRequestHeader(xhr, NULL, _bstr_("value1")); EXPECT_HR(hr, E_INVALIDARG); hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_(""), _bstr_("value1")); EXPECT_HR(hr, E_INVALIDARG); V_VT(&varbody) = VT_BSTR; V_BSTR(&varbody) = _bstr_(bodyA); hr = IXMLHttpRequest_send(xhr, varbody); if (hr == INET_E_RESOURCE_NOT_FOUND) { skip("No connection could be made with crossover.codeweavers.com\n"); IXMLHttpRequest_Release(xhr); return; } EXPECT_HR(hr, S_OK); /* response headers */ hr = IXMLHttpRequest_getAllResponseHeaders(xhr, NULL); ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); hr = IXMLHttpRequest_getAllResponseHeaders(xhr, &str); EXPECT_HR(hr, S_OK); /* status line is stripped already */ ok(memcmp(str, _bstr_("HTTP"), 4*sizeof(WCHAR)), "got response headers %s\n", wine_dbgstr_w(str)); ok(*str, "got empty headers\n"); hr = IXMLHttpRequest_getAllResponseHeaders(xhr, &str1); EXPECT_HR(hr, S_OK); ok(str1 != str, "got %p\n", str1); SysFreeString(str1); SysFreeString(str); hr = IXMLHttpRequest_getResponseHeader(xhr, NULL, NULL); EXPECT_HR(hr, E_INVALIDARG); hr = IXMLHttpRequest_getResponseHeader(xhr, _bstr_("Date"), NULL); ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); hr = IXMLHttpRequest_getResponseHeader(xhr, _bstr_("Date"), &str); EXPECT_HR(hr, S_OK); ok(*str != ' ', "got leading space in header %s\n", wine_dbgstr_w(str)); SysFreeString(str); /* status code after ::send() */ status = 0xdeadbeef; hr = IXMLHttpRequest_get_status(xhr, &status); EXPECT_HR(hr, S_OK); ok(status == 200, "got %d\n", status); hr = IXMLHttpRequest_get_statusText(xhr, NULL); ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); hr = IXMLHttpRequest_get_statusText(xhr, &str); EXPECT_HR(hr, S_OK); ok(!lstrcmpW(str, _bstr_("OK")), "got status %s\n", wine_dbgstr_w(str)); SysFreeString(str); /* another ::send() after completed request */ V_VT(&varbody) = VT_BSTR; V_BSTR(&varbody) = _bstr_(bodyA); hr = IXMLHttpRequest_send(xhr, varbody); ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr); hr = IXMLHttpRequest_get_responseText(xhr, &bstrResponse); EXPECT_HR(hr, S_OK); /* the server currently returns "FAILED" because the Content-Type header is * not what the server expects */ if(hr == S_OK) { ok(!memcmp(bstrResponse, wszExpectedResponse, sizeof(wszExpectedResponse)), "expected %s, got %s\n", wine_dbgstr_w(wszExpectedResponse), wine_dbgstr_w(bstrResponse)); SysFreeString(bstrResponse); } /* POST: VT_VARIANT|VT_BYREF body */ test_open(xhr, "POST", urlA, S_OK); V_VT(&varbody_ref) = VT_VARIANT|VT_BYREF; V_VARIANTREF(&varbody_ref) = &varbody; hr = IXMLHttpRequest_send(xhr, varbody_ref); EXPECT_HR(hr, S_OK); /* GET request */ test_open(xhr, "GET", xmltestA, S_OK); V_VT(&varbody) = VT_EMPTY; hr = IXMLHttpRequest_send(xhr, varbody); if (hr == INET_E_RESOURCE_NOT_FOUND) { skip("No connection could be made with crossover.codeweavers.com\n"); IXMLHttpRequest_Release(xhr); return; } EXPECT_HR(hr, S_OK); hr = IXMLHttpRequest_get_responseText(xhr, NULL); ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr); hr = IXMLHttpRequest_get_responseText(xhr, &bstrResponse); EXPECT_HR(hr, S_OK); ok(!memcmp(bstrResponse, _bstr_(xmltestbodyA), sizeof(xmltestbodyA)*sizeof(WCHAR)), "expected %s, got %s\n", xmltestbodyA, wine_dbgstr_w(bstrResponse)); SysFreeString(bstrResponse); hr = IXMLHttpRequest_get_responseBody(xhr, NULL); EXPECT_HR(hr, E_INVALIDARG); V_VT(&varbody) = VT_EMPTY; hr = IXMLHttpRequest_get_responseBody(xhr, &varbody); EXPECT_HR(hr, S_OK); ok(V_VT(&varbody) == (VT_ARRAY|VT_UI1), "got type %d, expected %d\n", V_VT(&varbody), VT_ARRAY|VT_UI1); ok(SafeArrayGetDim(V_ARRAY(&varbody)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody))); bound = -1; hr = SafeArrayGetLBound(V_ARRAY(&varbody), 1, &bound); EXPECT_HR(hr, S_OK); ok(bound == 0, "got %d, expected zero bound\n", bound); hr = SafeArrayAccessData(V_ARRAY(&varbody), &ptr); EXPECT_HR(hr, S_OK); ok(memcmp(ptr, xmltestbodyA, sizeof(xmltestbodyA)-1) == 0, "got wrong body data\n"); SafeArrayUnaccessData(V_ARRAY(&varbody)); VariantClear(&varbody); /* get_responseStream */ hr = IXMLHttpRequest_get_responseStream(xhr, NULL); EXPECT_HR(hr, E_INVALIDARG); V_VT(&varbody) = VT_EMPTY; hr = IXMLHttpRequest_get_responseStream(xhr, &varbody); ok(V_VT(&varbody) == VT_UNKNOWN, "got type %d\n", V_VT(&varbody)); EXPECT_HR(hr, S_OK); EXPECT_REF(V_UNKNOWN(&varbody), 1); g = NULL; hr = GetHGlobalFromStream((IStream*)V_UNKNOWN(&varbody), &g); EXPECT_HR(hr, S_OK); ok(g != NULL, "got %p\n", g); IDispatch_Release(event); /* test if referrer header is sent */ test_open(xhr, "GET", referertesturl, S_OK); V_VT(&varbody) = VT_EMPTY; hr = IXMLHttpRequest_send(xhr, varbody); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IXMLHttpRequest_get_responseText(xhr, &str); ok(hr == S_OK, "got 0x%08x\n", hr); ok(!lstrcmpW(str, norefererW), "got response text %s\n", wine_dbgstr_w(str)); SysFreeString(str); /* interaction with object site */ hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site); EXPECT_HR(hr, S_OK); hr = IObjectWithSite_SetSite(obj_site, NULL); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site2); EXPECT_HR(hr, S_OK); ok(obj_site == obj_site2 || broken(obj_site != obj_site2), "got new instance\n"); IObjectWithSite_Release(obj_site2); set_xhr_site(xhr); test_open(xhr, "GET", "tests/referer.php", S_OK); str1 = a2bstr("http://test.winehq.org/"); V_VT(&varbody) = VT_EMPTY; hr = IXMLHttpRequest_send(xhr, varbody); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IXMLHttpRequest_get_responseText(xhr, &str); ok(hr == S_OK, "got 0x%08x\n", hr); ok(!lstrcmpW(str, str1), "got response text %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str1)); SysFreeString(str); SysFreeString(str1); /* try to set site another time */ hr = IObjectWithSite_SetSite(obj_site, &testsite); EXPECT_HR(hr, S_OK); IObjectWithSite_Release(obj_site); IXMLHttpRequest_Release(xhr); free_bstrs(); }
static void test_xmlelem(void) { HRESULT hr; IXMLDocument *doc = NULL; IXMLElement *element = NULL, *parent; IXMLElement *child, *child2; IXMLElementCollection *children; VARIANT vType, vName; VARIANT vIndex, vValue; BSTR str, val, name; LONG type, num_child; IDispatch *disp; ITypeInfo *ti; static const WCHAR propName[] = {'p','r','o','p',0}; static const WCHAR propVal[] = {'v','a','l',0}; static const WCHAR nextVal[] = {'n','e','x','t',0}; static const WCHAR noexist[] = {'n','o','e','x','i','s','t',0}; static const WCHAR crazyCase1[] = {'C','R','a','z','Y','c','A','S','E',0}; static const WCHAR crazyCase2[] = {'C','R','A','Z','Y','C','A','S','E',0}; hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDocument, (LPVOID*)&doc); EXPECT_HR(hr, S_OK); V_VT(&vType) = VT_I4; V_I4(&vType) = XMLELEMTYPE_ELEMENT; V_VT(&vName) = VT_NULL; hr = IXMLDocument_createElement(doc, vType, vName, &element); EXPECT_HR(hr, S_OK); ok(element != NULL, "Expected non-NULL element\n"); /* test for IDispatch */ disp = NULL; hr = IXMLElement_QueryInterface(element, &IID_IDispatch, (void**)&disp); EXPECT_HR(hr, S_OK); hr = IDispatch_GetTypeInfo(disp, 0, 0, &ti); EXPECT_HR(hr, S_OK); name = NULL; hr = ITypeInfo_GetDocumentation(ti, DISPID_XMLELEMENT_TAGNAME, &name, NULL, NULL, NULL); EXPECT_HR(hr, S_OK); SysFreeString(name); ITypeInfo_Release(ti); IDispatch_Release(disp); hr = IXMLElement_get_tagName(element, &str); EXPECT_HR(hr, S_OK); ok(!str, "Expected empty tag name, got %s\n", wine_dbgstr_w(str)); SysFreeString(str); parent = (IXMLElement *)0xdeadbeef; hr = IXMLElement_get_parent(element, &parent); ok(hr == 1, "Expected 1, got %08x\n", hr); ok(parent == NULL, "Expected NULL parent\n"); str = SysAllocString(noexist); hr = IXMLElement_getAttribute(element, str, &vValue); ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr); ok(V_VT(&vValue) == VT_EMPTY, "Expected VT_EMPTY, got %d\n", V_VT(&vValue)); ok(V_BSTR(&vValue) == NULL, "Expected null value\n"); VariantClear(&vValue); SysFreeString(str); str = SysAllocString(crazyCase1); val = SysAllocString(propVal); V_VT(&vValue) = VT_BSTR; V_BSTR(&vValue) = val; hr = IXMLElement_setAttribute(element, str, vValue); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); SysFreeString(str); SysFreeString(val); str = SysAllocString(crazyCase2); hr = IXMLElement_getAttribute(element, str, &vValue); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(V_VT(&vValue) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&vValue)); ok(!lstrcmpW(V_BSTR(&vValue), propVal), "Expected 'val'\n"); VariantClear(&vValue); SysFreeString(str); str = SysAllocString(propName); val = SysAllocString(propVal); V_VT(&vValue) = VT_BSTR; V_BSTR(&vValue) = val; hr = IXMLElement_setAttribute(element, str, vValue); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); SysFreeString(val); hr = IXMLElement_getAttribute(element, str, &vValue); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(V_VT(&vValue) == VT_BSTR, "Expected VT_BSTR, got %d\n", V_VT(&vValue)); ok(!lstrcmpW(V_BSTR(&vValue), propVal), "Expected 'val'\n"); VariantClear(&vValue); hr = IXMLElement_removeAttribute(element, str); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); /* remove now nonexistent attribute */ hr = IXMLElement_removeAttribute(element, str); ok(hr == S_FALSE, "Expected S_FALSE, got %08x\n", hr); hr = IXMLElement_getAttribute(element, str, &vValue); ok(hr == 1, "Expected 1, got %08x\n", hr); ok(V_VT(&vValue) == VT_EMPTY, "Expected VT_EMPTY, got %d\n", V_VT(&vValue)); ok(V_BSTR(&vValue) == NULL, "Expected null value\n"); SysFreeString(str); VariantClear(&vValue); children = (IXMLElementCollection *)0xdeadbeef; hr = IXMLElement_get_children(element, &children); ok(hr == 1, "Expected 1, got %08x\n", hr); ok(children == NULL, "Expected NULL collection\n"); hr = IXMLElement_get_type(element, &type); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type); hr = IXMLElement_get_text(element, &str); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(lstrlenW(str) == 0, "Expected empty text\n"); SysFreeString(str); /* put_text with an ELEMENT */ str = SysAllocString(propVal); hr = IXMLElement_put_text(element, str); ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr); SysFreeString(str); V_VT(&vType) = VT_I4; V_I4(&vType) = XMLELEMTYPE_TEXT; V_VT(&vName) = VT_NULL; hr = IXMLDocument_createElement(doc, vType, vName, &child); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(child != NULL, "Expected non-NULL child\n"); hr = IXMLElement_addChild(element, child, 0, -1); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); str = SysAllocString(propVal); hr = IXMLElement_put_text(child, str); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); SysFreeString(str); parent = (IXMLElement *)0xdeadbeef; hr = IXMLElement_get_parent(child, &parent); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(parent != element, "Expected parent != element\n"); hr = IXMLElement_get_type(parent, &type); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type); children = (IXMLElementCollection *)0xdeadbeef; hr = IXMLElement_get_children(element, &children); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(children != NULL, "Expected non-NULL collection\n"); hr = IXMLElementCollection_get_length(children, &num_child); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(num_child == 1, "Expected 1, got %d\n", num_child); V_VT(&vIndex) = VT_I4; V_I4(&vIndex) = 0; V_VT(&vName) = VT_ERROR; V_ERROR(&vName) = DISP_E_PARAMNOTFOUND; hr = IXMLElementCollection_item(children, vIndex, vName, (IDispatch **)&child2); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(child2 != NULL, "Expected non-NULL child\n"); hr = IXMLElement_get_type(child2, &type); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(type == XMLELEMTYPE_TEXT, "Expected XMLELEMTYPE_TEXT, got %d\n", type); hr = IXMLElement_get_text(element, &str); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(str, propVal), "Expected 'val'\n"); SysFreeString(str); hr = IXMLElement_get_text(child2, &str); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(str, propVal), "Expected 'val'\n"); SysFreeString(str); /* try put_text on ELEMENT again, now that it has a text child */ str = SysAllocString(nextVal); hr = IXMLElement_put_text(element, str); ok(hr == E_NOTIMPL, "Expected E_NOTIMPL, got %08x\n", hr); SysFreeString(str); str = SysAllocString(nextVal); hr = IXMLElement_put_text(child2, str); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); SysFreeString(str); hr = IXMLElement_get_text(element, &str); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(str, nextVal), "Expected 'val'\n"); SysFreeString(str); IXMLElement_Release(child2); IXMLElementCollection_Release(children); IXMLElement_Release(parent); IXMLElement_Release(child); IXMLElement_Release(element); IXMLDocument_Release(doc); }
static void test_hfont_lifetime(void) { IFont *font, *font2; FONTDESC fontdesc; HRESULT hr; HFONT hfont, first_hfont = NULL; CY size; DWORD obj_type; int i; fontdesc.cbSizeofstruct = sizeof(fontdesc); fontdesc.lpstrName = arial_font; fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */ fontdesc.sWeight = FW_NORMAL; fontdesc.sCharset = ANSI_CHARSET; fontdesc.fItalic = FALSE; fontdesc.fUnderline = FALSE; fontdesc.fStrikethrough = FALSE; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font); EXPECT_HR(hr, S_OK); hr = IFont_get_hFont(font, &hfont); EXPECT_HR(hr, S_OK); /* show that if the font is updated the old hfont is deleted when the new font is realized */ for(i = 0; i < 100; i++) { HFONT last_hfont = hfont; size.int64 = (i + 10) * 20000; obj_type = GetObjectType(hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); hr = IFont_put_Size(font, size); EXPECT_HR(hr, S_OK); /* put_Size doesn't cause the new font to be realized */ obj_type = GetObjectType(last_hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); hr = IFont_get_hFont(font, &hfont); EXPECT_HR(hr, S_OK); obj_type = GetObjectType(last_hfont); ok(obj_type == 0, "%d: got obj type %d\n", i, obj_type); } /* now show that if we take a reference on the hfont, it persists until the font object is released */ for(i = 0; i < 100; i++) { size.int64 = (i + 10) * 20000; obj_type = GetObjectType(hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); hr = IFont_put_Size(font, size); EXPECT_HR(hr, S_OK); hr = IFont_get_hFont(font, &hfont); EXPECT_HR(hr, S_OK); hr = IFont_AddRefHfont(font, hfont); EXPECT_HR(hr, S_OK); if(i == 0) first_hfont = hfont; obj_type = GetObjectType(first_hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); } IFont_Release(font); obj_type = GetObjectType(first_hfont); ok(obj_type == 0, "got obj type %d\n", obj_type); /* An AddRefHfont followed by a ReleaseHfont means the font doesn't not persist through re-realization */ hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font); EXPECT_HR(hr, S_OK); hr = IFont_get_hFont(font, &hfont); EXPECT_HR(hr, S_OK); for(i = 0; i < 100; i++) { HFONT last_hfont = hfont; size.int64 = (i + 10) * 20000; obj_type = GetObjectType(hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); hr = IFont_put_Size(font, size); EXPECT_HR(hr, S_OK); /* put_Size doesn't cause the new font to be realized */ obj_type = GetObjectType(last_hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); hr = IFont_get_hFont(font, &hfont); EXPECT_HR(hr, S_OK); hr = IFont_AddRefHfont(font, hfont); EXPECT_HR(hr, S_OK); hr = IFont_ReleaseHfont(font, hfont); EXPECT_HR(hr, S_OK); obj_type = GetObjectType(last_hfont); ok(obj_type == 0, "%d: got obj type %d\n", i, obj_type); } /* Interestingly if we release a nonexistent reference on the hfont, * it persists until the font object is released */ for(i = 0; i < 100; i++) { size.int64 = (i + 10) * 20000; obj_type = GetObjectType(hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); hr = IFont_put_Size(font, size); EXPECT_HR(hr, S_OK); hr = IFont_get_hFont(font, &hfont); EXPECT_HR(hr, S_OK); hr = IFont_ReleaseHfont(font, hfont); EXPECT_HR(hr, S_OK); if(i == 0) first_hfont = hfont; obj_type = GetObjectType(first_hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); } IFont_Release(font); obj_type = GetObjectType(first_hfont); ok(obj_type == 0, "got obj type %d\n", obj_type); /* If we take two internal references on a hfont then we can release it twice. So it looks like there's a total reference count that includes internal and external references */ hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font); EXPECT_HR(hr, S_OK); hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font2); EXPECT_HR(hr, S_OK); hr = IFont_get_hFont(font, &hfont); EXPECT_HR(hr, S_OK); hr = IFont_get_hFont(font2, &first_hfont); EXPECT_HR(hr, S_OK); todo_wine ok(hfont == first_hfont, "fonts differ\n"); hr = IFont_ReleaseHfont(font, hfont); EXPECT_HR(hr, S_OK); hr = IFont_ReleaseHfont(font, hfont); todo_wine EXPECT_HR(hr, S_OK); hr = IFont_ReleaseHfont(font, hfont); EXPECT_HR(hr, S_FALSE); obj_type = GetObjectType(hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); IFont_Release(font); obj_type = GetObjectType(hfont); ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type); IFont_Release(font2); obj_type = GetObjectType(hfont); ok(obj_type == 0, "got obj type %d\n", obj_type); }
static void test_wshshell(void) { static const WCHAR notepadW[] = {'n','o','t','e','p','a','d','.','e','x','e',0}; static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0}; static const WCHAR lnk1W[] = {'f','i','l','e','.','l','n','k',0}; static const WCHAR pathW[] = {'%','P','A','T','H','%',0}; static const WCHAR sysW[] = {'S','Y','S','T','E','M',0}; static const WCHAR path2W[] = {'P','A','T','H',0}; static const WCHAR dummydirW[] = {'d','e','a','d','p','a','r','r','o','t',0}; static const WCHAR emptyW[] = {'e','m','p','t','y',0}; IWshEnvironment *env; IWshExec *shexec; IWshShell3 *sh3; IDispatchEx *dispex; IWshCollection *coll; IDispatch *disp, *shortcut; IUnknown *shell, *unk; IFolderCollection *folders; IWshShortcut *shcut; ITypeInfo *ti; HRESULT hr; TYPEATTR *tattr; DISPPARAMS dp; EXCEPINFO ei; VARIANT arg, res, arg2; BSTR str, ret; DWORD retval; UINT err; hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IDispatch, (void**)&disp); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IDispatch_QueryInterface(disp, &IID_IWshShell3, (void**)&shell); EXPECT_HR(hr, S_OK); IDispatch_Release(disp); hr = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); EXPECT_HR(hr, E_NOINTERFACE); hr = IUnknown_QueryInterface(shell, &IID_IWshShell3, (void**)&sh3); EXPECT_HR(hr, S_OK); hr = IWshShell3_QueryInterface(sh3, &IID_IObjectWithSite, (void**)&unk); ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr); hr = IWshShell3_QueryInterface(sh3, &IID_IWshShell, (void**)&unk); ok(hr == S_OK, "got 0x%08x\n", hr); IUnknown_Release(unk); hr = IWshShell3_QueryInterface(sh3, &IID_IWshShell2, (void**)&unk); ok(hr == S_OK, "got 0x%08x\n", hr); IUnknown_Release(unk); hr = IWshShell3_get_SpecialFolders(sh3, &coll); EXPECT_HR(hr, S_OK); hr = IWshCollection_QueryInterface(coll, &IID_IFolderCollection, (void**)&folders); EXPECT_HR(hr, E_NOINTERFACE); hr = IWshCollection_QueryInterface(coll, &IID_IDispatch, (void**)&disp); EXPECT_HR(hr, S_OK); hr = IDispatch_GetTypeInfo(disp, 0, 0, &ti); EXPECT_HR(hr, S_OK); hr = ITypeInfo_GetTypeAttr(ti, &tattr); EXPECT_HR(hr, S_OK); ok(IsEqualIID(&tattr->guid, &IID_IWshCollection), "got wrong type guid\n"); ITypeInfo_ReleaseTypeAttr(ti, tattr); /* try to call Item() with normal IDispatch procedure */ str = SysAllocString(desktopW); V_VT(&arg) = VT_BSTR; V_BSTR(&arg) = str; dp.rgvarg = &arg; dp.rgdispidNamedArgs = NULL; dp.cArgs = 1; dp.cNamedArgs = 0; hr = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 1033, DISPATCH_PROPERTYGET, &dp, &res, &ei, &err); EXPECT_HR(hr, DISP_E_MEMBERNOTFOUND); /* try Item() directly, it returns directory path apparently */ V_VT(&res) = VT_EMPTY; hr = IWshCollection_Item(coll, &arg, &res); EXPECT_HR(hr, S_OK); ok(V_VT(&res) == VT_BSTR, "got res type %d\n", V_VT(&res)); SysFreeString(str); VariantClear(&res); /* CreateShortcut() */ str = SysAllocString(lnk1W); hr = IWshShell3_CreateShortcut(sh3, str, &shortcut); EXPECT_HR(hr, S_OK); SysFreeString(str); hr = IDispatch_QueryInterface(shortcut, &IID_IWshShortcut, (void**)&shcut); EXPECT_HR(hr, S_OK); hr = IWshShortcut_get_Arguments(shcut, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); hr = IWshShortcut_get_IconLocation(shcut, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); IWshShortcut_Release(shcut); IDispatch_Release(shortcut); /* ExpandEnvironmentStrings */ hr = IWshShell3_ExpandEnvironmentStrings(sh3, NULL, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); str = SysAllocString(pathW); hr = IWshShell3_ExpandEnvironmentStrings(sh3, str, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); SysFreeString(str); V_VT(&arg) = VT_BSTR; V_BSTR(&arg) = SysAllocString(sysW); hr = IWshShell3_get_Environment(sh3, &arg, &env); ok(hr == S_OK, "got 0x%08x\n", hr); VariantClear(&arg); hr = IWshEnvironment_get_Item(env, NULL, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); ret = (BSTR)0x1; hr = IWshEnvironment_get_Item(env, NULL, &ret); ok(hr == S_OK, "got 0x%08x\n", hr); ok(ret && !*ret, "got %p\n", ret); SysFreeString(ret); /* invalid var name */ str = SysAllocString(lnk1W); hr = IWshEnvironment_get_Item(env, str, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); ret = NULL; hr = IWshEnvironment_get_Item(env, str, &ret); ok(hr == S_OK, "got 0x%08x\n", hr); ok(ret && *ret == 0, "got %s\n", wine_dbgstr_w(ret)); SysFreeString(ret); SysFreeString(str); /* valid name */ str = SysAllocString(path2W); hr = IWshEnvironment_get_Item(env, str, &ret); ok(hr == S_OK, "got 0x%08x\n", hr); ok(ret && *ret != 0, "got %s\n", wine_dbgstr_w(ret)); SysFreeString(ret); SysFreeString(str); IWshEnvironment_Release(env); V_VT(&arg) = VT_I2; V_I2(&arg) = 0; V_VT(&arg2) = VT_ERROR; V_ERROR(&arg2) = DISP_E_PARAMNOTFOUND; str = SysAllocString(notepadW); hr = IWshShell3_Run(sh3, str, &arg, &arg2, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); retval = 10; hr = IWshShell3_Run(sh3, str, NULL, &arg2, &retval); ok(hr == E_POINTER, "got 0x%08x\n", hr); ok(retval == 10, "got %u\n", retval); retval = 10; hr = IWshShell3_Run(sh3, str, &arg, NULL, &retval); ok(hr == E_POINTER, "got 0x%08x\n", hr); ok(retval == 10, "got %u\n", retval); retval = 10; V_VT(&arg2) = VT_ERROR; V_ERROR(&arg2) = 0; hr = IWshShell3_Run(sh3, str, &arg, &arg2, &retval); ok(hr == DISP_E_TYPEMISMATCH, "got 0x%08x\n", hr); ok(retval == 10, "got %u\n", retval); SysFreeString(str); /* current directory */ if (0) /* crashes on native */ hr = IWshShell3_get_CurrentDirectory(sh3, NULL); str = NULL; hr = IWshShell3_get_CurrentDirectory(sh3, &str); ok(hr == S_OK, "got 0x%08x\n", hr); ok(str && str[0] != 0, "got empty string\n"); SysFreeString(str); hr = IWshShell3_put_CurrentDirectory(sh3, NULL); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); str = SysAllocString(emptyW); hr = IWshShell3_put_CurrentDirectory(sh3, str); ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr); SysFreeString(str); str = SysAllocString(dummydirW); hr = IWshShell3_put_CurrentDirectory(sh3, str); ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr); SysFreeString(str); /* Exec */ hr = IWshShell3_Exec(sh3, NULL, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); hr = IWshShell3_Exec(sh3, NULL, &shexec); ok(hr == DISP_E_EXCEPTION, "got 0x%08x\n", hr); str = SysAllocString(emptyW); hr = IWshShell3_Exec(sh3, str, &shexec); ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr); SysFreeString(str); IWshCollection_Release(coll); IDispatch_Release(disp); IWshShell3_Release(sh3); IUnknown_Release(shell); }
static void test_font_events_disp(void) { static const WCHAR nameW[] = {'N','a','m','e',0}; static const WCHAR sizeW[] = {'S','i','z','e',0}; static const WCHAR boldW[] = {'B','o','l','d',0}; static const WCHAR italicW[] = {'I','t','a','l','i','c',0}; static const WCHAR underlineW[] = {'U','n','d','e','r','l','i','n','e',0}; static const WCHAR strikeW[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0}; static const WCHAR weightW[] = {'W','e','i','g','h','t',0}; static const WCHAR charsetW[] = {'C','h','a','r','s','e','t',0}; static const struct font_dispid font_dispids[] = { { DISPID_FONT_NAME, nameW }, { DISPID_FONT_SIZE, sizeW }, { DISPID_FONT_BOLD, boldW }, { DISPID_FONT_ITALIC, italicW }, { DISPID_FONT_UNDER, underlineW }, { DISPID_FONT_STRIKE, strikeW }, { DISPID_FONT_WEIGHT, weightW }, { DISPID_FONT_CHARSET, charsetW } }; IFont *pFont; IFont *pFont2; IConnectionPointContainer *pCPC; IConnectionPoint *pCP; FONTDESC fontdesc; HRESULT hr; DWORD dwCookie; IFontDisp *pFontDisp; DISPPARAMS dispparams; VARIANTARG vararg; INT i; fontdesc.cbSizeofstruct = sizeof(fontdesc); fontdesc.lpstrName = MSSansSerif_font; fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */ fontdesc.sWeight = FW_NORMAL; fontdesc.sCharset = 0; fontdesc.fItalic = FALSE; fontdesc.fUnderline = FALSE; fontdesc.fStrikethrough = FALSE; hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&pFont); EXPECT_HR(hr, S_OK); hr = IFont_QueryInterface(pFont, &IID_IConnectionPointContainer, (void **)&pCPC); EXPECT_HR(hr, S_OK); hr = IConnectionPointContainer_FindConnectionPoint(pCPC, &IID_IFontEventsDisp, &pCP); EXPECT_HR(hr, S_OK); IConnectionPointContainer_Release(pCPC); hr = IConnectionPoint_Advise(pCP, (IUnknown *)&FontEventsDisp, &dwCookie); EXPECT_HR(hr, S_OK); IConnectionPoint_Release(pCP); fonteventsdisp_invoke_called = 0; fonteventsdisp_invoke_arg0 = NULL; hr = IFont_put_Bold(pFont, TRUE); EXPECT_HR(hr, S_OK); ok(fonteventsdisp_invoke_called == 1, "IFontEventDisp::Invoke wasn't called once\n"); SysFreeString(fonteventsdisp_invoke_arg0); hr = IFont_QueryInterface(pFont, &IID_IFontDisp, (void **)&pFontDisp); EXPECT_HR(hr, S_OK); for (i = 0; i < sizeof(font_dispids)/sizeof(font_dispids[0]); i++) { switch (font_dispids[i].dispid) { case DISPID_FONT_NAME: { static const WCHAR arialW[] = {'A','r','i','a','l',0}; V_VT(&vararg) = VT_BSTR; V_BSTR(&vararg) = SysAllocString(arialW); break; } case DISPID_FONT_SIZE: V_VT(&vararg) = VT_CY; S(V_CY(&vararg)).Lo = 25; S(V_CY(&vararg)).Hi = 0; break; case DISPID_FONT_BOLD: V_VT(&vararg) = VT_BOOL; V_BOOL(&vararg) = VARIANT_FALSE; break; case DISPID_FONT_ITALIC: case DISPID_FONT_UNDER: case DISPID_FONT_STRIKE: V_VT(&vararg) = VT_BOOL; V_BOOL(&vararg) = VARIANT_TRUE; break; case DISPID_FONT_WEIGHT: V_VT(&vararg) = VT_I2; V_I2(&vararg) = FW_BLACK; break; case DISPID_FONT_CHARSET: V_VT(&vararg) = VT_I2; V_I2(&vararg) = 1; break; default: ; } dispparams.cNamedArgs = 0; dispparams.rgdispidNamedArgs = NULL; dispparams.cArgs = 1; dispparams.rgvarg = &vararg; fonteventsdisp_invoke_called = 0; hr = IFontDisp_Invoke(pFontDisp, font_dispids[i].dispid, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); ok(hr == S_OK, "dispid=%d, got 0x%08x\n", font_dispids[i].dispid, hr); ok(fonteventsdisp_invoke_called == 1, "dispid=%d, DISPID_FONT_CHANGED not called, got %d\n", font_dispids[i].dispid, fonteventsdisp_invoke_called); if (hr == S_OK) { ok(!lstrcmpW(font_dispids[i].name, fonteventsdisp_invoke_arg0), "dispid=%d, got %s, expected %s\n", font_dispids[i].dispid, wine_dbgstr_w(fonteventsdisp_invoke_arg0), wine_dbgstr_w(font_dispids[i].name)); SysFreeString(fonteventsdisp_invoke_arg0); } VariantClear(&vararg); } IFontDisp_Release(pFontDisp); hr = IFont_Clone(pFont, &pFont2); EXPECT_HR(hr, S_OK); IFont_Release(pFont); /* this test shows that the notification routine isn't called again */ fonteventsdisp_invoke_called = 0; hr = IFont_put_Bold(pFont2, FALSE); EXPECT_HR(hr, S_OK); ok(fonteventsdisp_invoke_called == 0, "got %d\n", fonteventsdisp_invoke_called); IFont_Release(pFont2); }
static void test_wshshell(void) { static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0}; static const WCHAR lnk1W[] = {'f','i','l','e','.','l','n','k',0}; IWshShell3 *sh3; IDispatchEx *dispex; IWshCollection *coll; IDispatch *disp, *shortcut; IUnknown *shell, *unk; IFolderCollection *folders; ITypeInfo *ti; HRESULT hr; TYPEATTR *tattr; DISPPARAMS dp; EXCEPINFO ei; VARIANT arg, res; BSTR str; UINT err; hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IDispatch, (void**)&disp); if(FAILED(hr)) { win_skip("Could not create WshShell object: %08x\n", hr); return; } hr = IDispatch_QueryInterface(disp, &IID_IWshShell3, (void**)&shell); EXPECT_HR(hr, S_OK); IDispatch_Release(disp); hr = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); EXPECT_HR(hr, E_NOINTERFACE); hr = IUnknown_QueryInterface(shell, &IID_IWshShell3, (void**)&sh3); EXPECT_HR(hr, S_OK); hr = IWshShell3_get_SpecialFolders(sh3, &coll); EXPECT_HR(hr, S_OK); hr = IWshCollection_QueryInterface(coll, &IID_IFolderCollection, (void**)&folders); EXPECT_HR(hr, E_NOINTERFACE); hr = IWshCollection_QueryInterface(coll, &IID_IDispatch, (void**)&disp); EXPECT_HR(hr, S_OK); hr = IDispatch_GetTypeInfo(disp, 0, 0, &ti); EXPECT_HR(hr, S_OK); hr = ITypeInfo_GetTypeAttr(ti, &tattr); EXPECT_HR(hr, S_OK); ok(IsEqualIID(&tattr->guid, &IID_IWshCollection), "got wrong type guid\n"); ITypeInfo_ReleaseTypeAttr(ti, tattr); /* try to call Item() with normal IDispatch procedure */ str = SysAllocString(desktopW); V_VT(&arg) = VT_BSTR; V_BSTR(&arg) = str; dp.rgvarg = &arg; dp.rgdispidNamedArgs = NULL; dp.cArgs = 1; dp.cNamedArgs = 0; hr = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 1033, DISPATCH_PROPERTYGET, &dp, &res, &ei, &err); EXPECT_HR(hr, DISP_E_MEMBERNOTFOUND); /* try Item() directly, it returns directory path apparently */ V_VT(&res) = VT_EMPTY; hr = IWshCollection_Item(coll, &arg, &res); EXPECT_HR(hr, S_OK); ok(V_VT(&res) == VT_BSTR, "got res type %d\n", V_VT(&res)); SysFreeString(str); VariantClear(&res); /* CreateShortcut() */ str = SysAllocString(lnk1W); hr = IWshShell3_CreateShortcut(sh3, str, &shortcut); EXPECT_HR(hr, S_OK); SysFreeString(str); hr = IDispatch_QueryInterface(shortcut, &IID_IWshShortcut, (void**)&unk); EXPECT_HR(hr, S_OK); IUnknown_Release(unk); IDispatch_Release(shortcut); IWshCollection_Release(coll); IDispatch_Release(disp); IWshShell3_Release(sh3); IUnknown_Release(shell); }
static void test_CreateBitmapRenderTarget(void) { IDWriteBitmapRenderTarget *target, *target2; IDWriteGdiInterop *interop; DIBSECTION ds; HBITMAP hbm; HRESULT hr; SIZE size; HDC hdc; int ret; hr = IDWriteFactory_GetGdiInterop(factory, &interop); EXPECT_HR(hr, S_OK); target = NULL; hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 0, 0, &target); EXPECT_HR(hr, S_OK); if (0) /* crashes on native */ hr = IDWriteBitmapRenderTarget_GetSize(target, NULL); size.cx = size.cy = -1; hr = IDWriteBitmapRenderTarget_GetSize(target, &size); EXPECT_HR(hr, S_OK); ok(size.cx == 0, "got %d\n", size.cx); ok(size.cy == 0, "got %d\n", size.cy); target2 = NULL; hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 0, 0, &target2); EXPECT_HR(hr, S_OK); ok(target != target2, "got %p, %p\n", target2, target); IDWriteBitmapRenderTarget_Release(target2); hdc = IDWriteBitmapRenderTarget_GetMemoryDC(target); ok(hdc != NULL, "got %p\n", hdc); hbm = GetCurrentObject(hdc, OBJ_BITMAP); ok(hbm != NULL, "got %p\n", hbm); /* check DIB properties */ ret = GetObjectW(hbm, sizeof(ds), &ds); ok(ret == sizeof(BITMAP), "got %d\n", ret); ok(ds.dsBm.bmWidth == 1, "got %d\n", ds.dsBm.bmWidth); ok(ds.dsBm.bmHeight == 1, "got %d\n", ds.dsBm.bmHeight); ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes); ok(ds.dsBm.bmBitsPixel == 1, "got %d\n", ds.dsBm.bmBitsPixel); ok(!ds.dsBm.bmBits, "got %p\n", ds.dsBm.bmBits); IDWriteBitmapRenderTarget_Release(target); hbm = GetCurrentObject(hdc, OBJ_BITMAP); ok(!hbm, "got %p\n", hbm); target = NULL; hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 10, 5, &target); EXPECT_HR(hr, S_OK); hdc = IDWriteBitmapRenderTarget_GetMemoryDC(target); ok(hdc != NULL, "got %p\n", hdc); hbm = GetCurrentObject(hdc, OBJ_BITMAP); ok(hbm != NULL, "got %p\n", hbm); /* check DIB properties */ ret = GetObjectW(hbm, sizeof(ds), &ds); ok(ret == sizeof(ds), "got %d\n", ret); ok(ds.dsBm.bmWidth == 10, "got %d\n", ds.dsBm.bmWidth); ok(ds.dsBm.bmHeight == 5, "got %d\n", ds.dsBm.bmHeight); ok(ds.dsBm.bmPlanes == 1, "got %d\n", ds.dsBm.bmPlanes); ok(ds.dsBm.bmBitsPixel == 32, "got %d\n", ds.dsBm.bmBitsPixel); ok(ds.dsBm.bmBits != NULL, "got %p\n", ds.dsBm.bmBits); size.cx = size.cy = -1; hr = IDWriteBitmapRenderTarget_GetSize(target, &size); EXPECT_HR(hr, S_OK); ok(size.cx == 10, "got %d\n", size.cx); ok(size.cy == 5, "got %d\n", size.cy); IDWriteBitmapRenderTarget_Release(target); IDWriteGdiInterop_Release(interop); }
static void test_xmldoc(void) { IXMLElement *element = NULL, *child = NULL, *value = NULL; IXMLElementCollection *collection = NULL, *inner = NULL; IPersistStreamInit *psi = NULL; IXMLDocument *doc = NULL; IStream *stream = NULL; VARIANT vIndex, vName; LONG type, num_child; CHAR path[MAX_PATH]; IDispatch *disp; ITypeInfo *ti; HRESULT hr; BSTR name; static const WCHAR szBankAccount[] = {'B','A','N','K','A','C','C','O','U','N','T',0}; static const WCHAR szNumber[] = {'N','U','M','B','E','R',0}; static const WCHAR szNumVal[] = {'1','2','3','4',0}; static const WCHAR szName[] = {'N','A','M','E',0}; static const WCHAR szNameVal[] = {'C','a','p','t','a','i','n',' ','A','h','a','b',0}; static const WCHAR szVersion[] = {'1','.','0',0}; static const WCHAR rootW[] = {'r','o','o','t',0}; hr = CoCreateInstance(&CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLDocument, (void**)&doc); EXPECT_HR(hr, S_OK); /* IDispatch */ hr = IXMLDocument_QueryInterface(doc, &IID_IDispatch, (void**)&disp); EXPECT_HR(hr, S_OK); /* just to make sure we're on right type data */ hr = IDispatch_GetTypeInfo(disp, 0, 0, &ti); EXPECT_HR(hr, S_OK); name = NULL; hr = ITypeInfo_GetDocumentation(ti, DISPID_XMLDOCUMENT_ROOT, &name, NULL, NULL, NULL); EXPECT_HR(hr, S_OK); ok(!lstrcmpW(name, rootW), "got name %s\n", wine_dbgstr_w(name)); SysFreeString(name); ITypeInfo_Release(ti); IDispatch_Release(disp); hr = IXMLDocument_QueryInterface(doc, &IID_IXMLDOMDocument, (void**)&disp); EXPECT_HR(hr, E_NOINTERFACE); create_xml_file("bank.xml"); GetFullPathNameA("bank.xml", MAX_PATH, path, NULL); create_stream_on_file(&stream, path); hr = IXMLDocument_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&psi); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(psi != NULL, "Expected non-NULL psi\n"); hr = IXMLDocument_get_root(doc, &element); ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr); ok(element == NULL, "Expected NULL element\n"); hr = IPersistStreamInit_Load(psi, stream); ok(hr == S_OK || hr == XML_E_INVALIDATROOTLEVEL, "Expected S_OK, got %08x\n", hr); if(hr == XML_E_INVALIDATROOTLEVEL) goto cleanup; ok(stream != NULL, "Expected non-NULL stream\n"); /* version field */ hr = IXMLDocument_get_version(doc, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); name = NULL; hr = IXMLDocument_get_version(doc, &name); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(name, szVersion), "Expected 1.0, got %s\n", wine_dbgstr_w(name)); SysFreeString(name); /* doctype */ hr = IXMLDocument_get_doctype(doc, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); hr = IXMLDocument_get_doctype(doc, &name); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(name, szBankAccount), "Expected BANKACCOUNT, got %s\n", wine_dbgstr_w(name)); SysFreeString(name); hr = IXMLDocument_get_root(doc, &element); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(element != NULL, "Expected non-NULL element\n"); /* ::root() returns new instance each time */ hr = IXMLDocument_get_root(doc, &child); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(child != NULL, "Expected non-NULL element\n"); ok(child != element, "Expected new element instance\n"); IXMLElement_Release(child); hr = IXMLElement_get_type(element, &type); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type); hr = IXMLElement_get_tagName(element, &name); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(name, szBankAccount), "Expected BANKACCOUNT\n"); SysFreeString(name); hr = IXMLElement_get_children(element, &collection); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(collection != NULL, "Expected non-NULL collection\n"); hr = IXMLElementCollection_get_length(collection, &num_child); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(num_child == 2, "Expected 2, got %d\n", num_child); V_VT(&vIndex) = VT_I4; V_I4(&vIndex) = 0; V_VT(&vName) = VT_ERROR; V_ERROR(&vName) = DISP_E_PARAMNOTFOUND; hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(child != NULL, "Expected non-NULL child\n"); hr = IXMLElement_get_type(child, &type); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type); hr = IXMLElement_get_tagName(child, &name); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(name, szNumber), "Expected NUMBER\n"); SysFreeString(name); hr = IXMLElement_get_children(child, &inner); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(inner != NULL, "Expected non-NULL inner\n"); hr = IXMLElementCollection_get_length(inner, &num_child); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(num_child == 1, "Expected 1, got %d\n", num_child); hr = IXMLElementCollection_item(inner, vIndex, vName, (IDispatch **)&value); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(value != NULL, "Expected non-NULL value\n"); hr = IXMLElement_get_type(value, &type); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(type == XMLELEMTYPE_TEXT, "Expected XMLELEMTYPE_TEXT, got %d\n", type); hr = IXMLElement_get_text(value, &name); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(name, szNumVal), "Expected '1234'\n"); SysFreeString(name); IXMLElementCollection_Release(inner); inner = (IXMLElementCollection *)0xdeadbeef; hr = IXMLElement_get_children(value, &inner); ok(hr == 1, "Expected 1, got %08x\n", hr); ok(inner == NULL, "Expected NULL inner, got %p\n", inner); IXMLElement_Release(value); IXMLElement_Release(child); value = NULL; child = NULL; V_I4(&vIndex) = 1; hr = IXMLElementCollection_item(collection, vIndex, vName, (IDispatch **)&child); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(child != NULL, "Expected non-NULL child\n"); hr = IXMLElement_get_type(child, &type); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(type == XMLELEMTYPE_ELEMENT, "Expected XMLELEMTYPE_ELEMENT, got %d\n", type); hr = IXMLElement_get_tagName(child, &name); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(name, szName), "Expected NAME\n"); SysFreeString(name); hr = IXMLElement_get_children(child, &inner); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(inner != NULL, "Expected non-NULL inner\n"); hr = IXMLElementCollection_get_length(inner, &num_child); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(num_child == 1, "Expected 1, got %d\n", num_child); V_I4(&vIndex) = 0; hr = IXMLElementCollection_item(inner, vIndex, vName, (IDispatch **)&value); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(value != NULL, "Expected non-NULL value\n"); hr = IXMLElement_get_type(value, &type); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(type == XMLELEMTYPE_TEXT, "Expected XMLELEMTYPE_TEXT, got %d\n", type); hr = IXMLElement_get_text(value, &name); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpW(name, szNameVal), "Expected 'Captain Ahab'\n"); SysFreeString(name); IXMLElementCollection_Release(inner); inner = (IXMLElementCollection *)0xdeadbeef; hr = IXMLElement_get_children(value, &inner); ok(hr == 1, "Expected 1, got %08x\n", hr); ok(inner == NULL, "Expected NULL inner, got %p\n", inner); IXMLElement_Release(value); IXMLElement_Release(child); IXMLElementCollection_Release(collection); IXMLElement_Release(element); cleanup: IStream_Release(stream); IPersistStreamInit_Release(psi); IXMLDocument_Release(doc); DeleteFileA("bank.xml"); }
static void test_CreateFontFromLOGFONT(void) { static const WCHAR tahomaspW[] = {'T','a','h','o','m','a',' ',0}; IDWriteGdiInterop *interop; DWRITE_FONT_WEIGHT weight; DWRITE_FONT_STYLE style; IDWriteFont *font; LOGFONTW logfont; LONG weights[][2] = { {FW_NORMAL, DWRITE_FONT_WEIGHT_NORMAL}, {FW_BOLD, DWRITE_FONT_WEIGHT_BOLD}, { 0, DWRITE_FONT_WEIGHT_NORMAL}, { 50, DWRITE_FONT_WEIGHT_NORMAL}, {150, DWRITE_FONT_WEIGHT_NORMAL}, {250, DWRITE_FONT_WEIGHT_NORMAL}, {350, DWRITE_FONT_WEIGHT_NORMAL}, {450, DWRITE_FONT_WEIGHT_NORMAL}, {650, DWRITE_FONT_WEIGHT_BOLD}, {750, DWRITE_FONT_WEIGHT_BOLD}, {850, DWRITE_FONT_WEIGHT_BOLD}, {950, DWRITE_FONT_WEIGHT_BOLD}, {960, DWRITE_FONT_WEIGHT_BOLD}, }; OUTLINETEXTMETRICW otm; HRESULT hr; BOOL ret; HDC hdc; HFONT hfont; int i; UINT r; hr = IDWriteFactory_GetGdiInterop(factory, &interop); EXPECT_HR(hr, S_OK); if (0) /* null out parameter crashes this call */ hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, NULL, NULL); hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, NULL, &font); EXPECT_HR(hr, E_INVALIDARG); memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = FW_NORMAL; logfont.lfItalic = 1; lstrcpyW(logfont.lfFaceName, tahomaW); hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); EXPECT_HR(hr, S_OK); hfont = CreateFontIndirectW(&logfont); hdc = CreateCompatibleDC(0); SelectObject(hdc, hfont); otm.otmSize = sizeof(otm); r = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm); ok(r, "got %d\n", r); DeleteDC(hdc); DeleteObject(hfont); /* now check properties */ weight = IDWriteFont_GetWeight(font); ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "got %d\n", weight); style = IDWriteFont_GetStyle(font); todo_wine { ok(style == DWRITE_FONT_STYLE_OBLIQUE, "got %d\n", style); ok(otm.otmfsSelection == 1, "got 0x%08x\n", otm.otmfsSelection); } ret = IDWriteFont_IsSymbolFont(font); ok(!ret, "got %d\n", ret); IDWriteFont_Release(font); /* weight values */ for (i = 0; i < sizeof(weights)/(2*sizeof(LONG)); i++) { memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = weights[i][0]; lstrcpyW(logfont.lfFaceName, tahomaW); hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); EXPECT_HR(hr, S_OK); weight = IDWriteFont_GetWeight(font); ok(weight == weights[i][1], "%d: got %d, expected %d\n", i, weight, weights[i][1]); IDWriteFont_Release(font); } /* weight not from enum */ memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = 550; lstrcpyW(logfont.lfFaceName, tahomaW); hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); EXPECT_HR(hr, S_OK); weight = IDWriteFont_GetWeight(font); ok(weight == DWRITE_FONT_WEIGHT_NORMAL || broken(weight == DWRITE_FONT_WEIGHT_BOLD) /* win7 w/o SP */, "got %d\n", weight); IDWriteFont_Release(font); /* empty or nonexistent face name */ memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = FW_NORMAL; lstrcpyW(logfont.lfFaceName, blahW); font = (void*)0xdeadbeef; hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); todo_wine { EXPECT_HR(hr, DWRITE_E_NOFONT); ok(font == NULL, "got %p\n", font); if(font) IDWriteFont_Release(font); } memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = FW_NORMAL; lstrcpyW(logfont.lfFaceName, tahomaspW); font = (void*)0xdeadbeef; hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); todo_wine { EXPECT_HR(hr, DWRITE_E_NOFONT); ok(font == NULL, "got %p\n", font); if(font) IDWriteFont_Release(font); } memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = FW_NORMAL; font = (void*)0xdeadbeef; hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); todo_wine { EXPECT_HR(hr, DWRITE_E_NOFONT); ok(font == NULL, "got %p\n", font); if(font) IDWriteFont_Release(font); } IDWriteGdiInterop_Release(interop); }
static void test_GetFamilyNames(void) { IDWriteFontFamily *family; IDWriteLocalizedStrings *names, *names2; IDWriteGdiInterop *interop; IDWriteFont *font; LOGFONTW logfont; WCHAR buffer[100]; HRESULT hr; UINT32 len; hr = IDWriteFactory_GetGdiInterop(factory, &interop); EXPECT_HR(hr, S_OK); memset(&logfont, 0, sizeof(logfont)); logfont.lfHeight = 12; logfont.lfWidth = 12; logfont.lfWeight = FW_NORMAL; logfont.lfItalic = 1; lstrcpyW(logfont.lfFaceName, tahomaW); hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font); EXPECT_HR(hr, S_OK); hr = IDWriteFont_GetFontFamily(font, &family); EXPECT_HR(hr, S_OK); if (0) /* crashes on native */ hr = IDWriteFontFamily_GetFamilyNames(family, NULL); hr = IDWriteFontFamily_GetFamilyNames(family, &names); ok(hr == S_OK, "got 0x%08x\n", hr); EXPECT_REF(names, 1); hr = IDWriteFontFamily_GetFamilyNames(family, &names2); ok(hr == S_OK, "got 0x%08x\n", hr); EXPECT_REF(names2, 1); ok(names != names2, "got %p, was %p\n", names2, names); IDWriteLocalizedStrings_Release(names2); /* GetStringLength */ if (0) /* crashes on native */ hr = IDWriteLocalizedStrings_GetStringLength(names, 0, NULL); len = 100; hr = IDWriteLocalizedStrings_GetStringLength(names, 10, &len); ok(hr == E_FAIL, "got 0x%08x\n", hr); ok(len == (UINT32)-1, "got %u\n", len); len = 0; hr = IDWriteLocalizedStrings_GetStringLength(names, 0, &len); ok(hr == S_OK, "got 0x%08x\n", hr); ok(len > 0, "got %u\n", len); /* GetString */ hr = IDWriteLocalizedStrings_GetString(names, 0, NULL, 0); ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr); hr = IDWriteLocalizedStrings_GetString(names, 10, NULL, 0); ok(hr == E_FAIL, "got 0x%08x\n", hr); if (0) hr = IDWriteLocalizedStrings_GetString(names, 0, NULL, 100); buffer[0] = 1; hr = IDWriteLocalizedStrings_GetString(names, 10, buffer, 100); ok(hr == E_FAIL, "got 0x%08x\n", hr); ok(buffer[0] == 0, "got %x\n", buffer[0]); buffer[0] = 1; hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len-1); ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr); ok(buffer[0] == 0, "got %x\n", buffer[0]); buffer[0] = 1; hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len); ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr); ok(buffer[0] == 0, "got %x\n", buffer[0]); buffer[0] = 0; hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len+1); ok(hr == S_OK, "got 0x%08x\n", hr); ok(buffer[0] != 0, "got %x\n", buffer[0]); IDWriteLocalizedStrings_Release(names); IDWriteFontFamily_Release(family); IDWriteFont_Release(font); IDWriteGdiInterop_Release(interop); }