static void test_get_Attributes(void) { IPicture *pic; HRESULT hres; short type; DWORD attr; OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (VOID**)&pic); hres = IPicture_get_Type(pic, &type); ok(hres == S_OK, "IPicture_get_Type does not return S_OK, but 0x%08x\n", hres); ok(type == PICTYPE_UNINITIALIZED, "Expected type = PICTYPE_UNINITIALIZED, got = %d\n", type); hres = IPicture_get_Attributes(pic, NULL); ole_expect(hres, E_POINTER); attr = 0xdeadbeef; hres = IPicture_get_Attributes(pic, &attr); ole_expect(hres, S_OK); ok(attr == 0, "IPicture_get_Attributes does not reset attr to zero, got %d\n", attr); IPicture_Release(pic); }
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_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); }