static void test_empty_image(void) { LPBYTE data; LPSTREAM stream; IPicture* pic = NULL; HRESULT hres; LPVOID pvObj = NULL; HGLOBAL hglob; OLE_HANDLE handle; ULARGE_INTEGER newpos1; LARGE_INTEGER seekto; short type; DWORD attr; /* Empty image. Happens occasionally in VB programs. */ hglob = GlobalAlloc (0, 8); data = GlobalLock (hglob); memcpy(data,"lt\0\0",4); ((DWORD*)data)[1] = 0; hres = CreateStreamOnHGlobal (hglob, TRUE, &stream); ok (hres == S_OK, "CreatestreamOnHGlobal failed? doubt it... hres 0x%08x\n", hres); memset(&seekto,0,sizeof(seekto)); hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1); ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08x\n", hres); pvObj = NULL; hres = pOleLoadPicture(stream, 8, TRUE, &IID_IPicture, &pvObj); pic = pvObj; ok(hres == S_OK,"empty picture not loaded, hres 0x%08x\n", hres); ok(pic != NULL,"empty picture not loaded, pic is NULL\n"); hres = IPicture_get_Type (pic, &type); ok (hres == S_OK,"empty picture get type failed with hres 0x%08x\n", hres); ok (type == PICTYPE_NONE,"type is %d, but should be PICTYPE_NONE(0)\n", type); attr = 0xdeadbeef; hres = IPicture_get_Attributes (pic, &attr); ok (hres == S_OK,"empty picture get attributes failed with hres 0x%08x\n", hres); ok (attr == 0,"attr is %d, but should be 0\n", attr); hres = IPicture_get_Handle (pic, &handle); ok (hres == S_OK,"empty picture get handle failed with hres 0x%08x\n", hres); ok (handle == 0, "empty picture get handle did not return 0, but 0x%08x\n", handle); IPicture_Release (pic); IStream_Release (stream); }
static void test_empty_image_2(void) { LPBYTE data; LPSTREAM stream; IPicture* pic = NULL; HRESULT hres; LPVOID pvObj = NULL; HGLOBAL hglob; ULARGE_INTEGER newpos1; LARGE_INTEGER seekto; short type; /* Empty image at random stream position. */ hglob = GlobalAlloc (0, 200); data = GlobalLock (hglob); data += 42; memcpy(data,"lt\0\0",4); ((DWORD*)data)[1] = 0; hres = CreateStreamOnHGlobal (hglob, TRUE, &stream); ok (hres == S_OK, "CreatestreamOnHGlobal failed? doubt it... hres 0x%08x\n", hres); memset(&seekto,0,sizeof(seekto)); seekto.u.LowPart = 42; hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1); ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08x\n", hres); pvObj = NULL; hres = pOleLoadPicture(stream, 8, TRUE, &IID_IPicture, &pvObj); pic = pvObj; ok(hres == S_OK,"empty picture not loaded, hres 0x%08x\n", hres); ok(pic != NULL,"empty picture not loaded, pic is NULL\n"); hres = IPicture_get_Type (pic, &type); ok (hres == S_OK,"empty picture get type failed with hres 0x%08x\n", hres); ok (type == PICTYPE_NONE,"type is %d, but should be PICTYPE_NONE(0)\n", type); IPicture_Release (pic); IStream_Release (stream); }
static void test_Invoke(void) { IPictureDisp *picdisp; HRESULT hr; VARIANTARG vararg; DISPPARAMS dispparams; VARIANT varresult; IStream *stream; HGLOBAL hglob; void *data; hglob = GlobalAlloc (0, sizeof(gifimage)); data = GlobalLock(hglob); memcpy(data, gifimage, sizeof(gifimage)); GlobalUnlock(hglob); hr = CreateStreamOnHGlobal (hglob, FALSE, &stream); ok_ole_success(hr, "CreateStreamOnHGlobal"); hr = pOleLoadPicture(stream, sizeof(gifimage), TRUE, &IID_IPictureDisp, (void **)&picdisp); IStream_Release(stream); ok_ole_success(hr, "OleLoadPicture"); V_VT(&vararg) = VT_BOOL; V_BOOL(&vararg) = VARIANT_FALSE; dispparams.cNamedArgs = 0; dispparams.rgdispidNamedArgs = NULL; dispparams.cArgs = 1; dispparams.rgvarg = &vararg; hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_IPictureDisp, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_UNKNOWNNAME, "IPictureDisp_Invoke should have returned DISP_E_UNKNOWNNAME instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_IUnknown, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_UNKNOWNNAME, "IPictureDisp_Invoke should have returned DISP_E_UNKNOWNNAME instead of 0x%08lx\n", hr); dispparams.cArgs = 0; dispparams.rgvarg = NULL; hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, NULL, NULL, NULL); ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL); ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, &varresult, NULL, NULL); ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); ok_ole_success(hr, "IPictureDisp_Invoke"); ok(V_VT(&varresult) == VT_I4, "V_VT(&varresult) should have been VT_UINT instead of %d\n", V_VT(&varresult)); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL); ok(hr == DISP_E_MEMBERNOTFOUND, "IPictureDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, 0xdeadbeef, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); ok(hr == DISP_E_MEMBERNOTFOUND, "IPictureDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08lx\n", hr); dispparams.cArgs = 1; dispparams.rgvarg = &vararg; hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr); dispparams.cArgs = 1; dispparams.rgvarg = &vararg; hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr); IPictureDisp_Release(picdisp); }
static void test_pic_with_stream(LPSTREAM stream, unsigned int imgsize) { IPicture* pic = NULL; HRESULT hres; LPVOID pvObj = NULL; OLE_HANDLE handle, hPal; OLE_XSIZE_HIMETRIC width; OLE_YSIZE_HIMETRIC height; short type; DWORD attr; ULONG res; pvObj = NULL; hres = pOleLoadPicture(stream, imgsize, TRUE, &IID_IPicture, &pvObj); pic = pvObj; ok(hres == S_OK,"OLP (NULL,..) does not return 0, but 0x%08lx\n",hres); ok(pic != NULL,"OLP (NULL,..) returns NULL, instead of !NULL\n"); if (pic == NULL) return; pvObj = NULL; hres = IPicture_QueryInterface (pic, &IID_IPicture, &pvObj); ok(hres == S_OK,"IPicture_QI does not return S_OK, but 0x%08lx\n", hres); ok(pvObj != NULL,"IPicture_QI does return NULL, instead of a ptr\n"); IPicture_Release ((IPicture*)pvObj); handle = 0; hres = IPicture_get_Handle (pic, &handle); ok(hres == S_OK,"IPicture_get_Handle does not return S_OK, but 0x%08lx\n", hres); ok(handle != 0, "IPicture_get_Handle returns a NULL handle, but it should be non NULL\n"); width = 0; hres = IPicture_get_Width (pic, &width); ok(hres == S_OK,"IPicture_get_Width does not return S_OK, but 0x%08lx\n", hres); ok(width != 0, "IPicture_get_Width returns 0, but it should not be 0.\n"); height = 0; hres = IPicture_get_Height (pic, &height); ok(hres == S_OK,"IPicture_get_Height does not return S_OK, but 0x%08lx\n", hres); ok(height != 0, "IPicture_get_Height returns 0, but it should not be 0.\n"); type = 0; hres = IPicture_get_Type (pic, &type); ok(hres == S_OK,"IPicture_get_Type does not return S_OK, but 0x%08lx\n", hres); ok(type == PICTYPE_BITMAP, "IPicture_get_Type returns %d, but it should be PICTYPE_BITMAP(%d).\n", type, PICTYPE_BITMAP); attr = 0; hres = IPicture_get_Attributes (pic, &attr); ok(hres == S_OK,"IPicture_get_Attributes does not return S_OK, but 0x%08lx\n", hres); ok(attr == 0, "IPicture_get_Attributes returns %ld, but it should be 0.\n", attr); hPal = 0; hres = IPicture_get_hPal (pic, &hPal); ok(hres == S_OK,"IPicture_get_hPal does not return S_OK, but 0x%08lx\n", hres); /* a single pixel b/w image has no palette */ ok(hPal == 0, "IPicture_get_hPal returns %ld, but it should be 0.\n", (long)hPal); res = IPicture_Release (pic); ok (res == 0, "refcount after release is %ld, but should be 0?\n", res); }