windowscodecs: Basic tests for tiff encoder options.
This commit is contained in:
parent
f08246c25f
commit
31f8c51b0b
|
@ -367,6 +367,147 @@ static void test_default_converter(void)
|
|||
DeleteTestBitmap(src_obj);
|
||||
}
|
||||
|
||||
typedef struct property_opt_test_data
|
||||
{
|
||||
LPCOLESTR name;
|
||||
VARTYPE var_type;
|
||||
VARTYPE initial_var_type;
|
||||
int i_init_val;
|
||||
float f_init_val;
|
||||
} property_opt_test_data;
|
||||
|
||||
static const WCHAR wszTiffCompressionMethod[] = {'T','i','f','f','C','o','m','p','r','e','s','s','i','o','n','M','e','t','h','o','d',0};
|
||||
static const WCHAR wszCompressionQuality[] = {'C','o','m','p','r','e','s','s','i','o','n','Q','u','a','l','i','t','y',0};
|
||||
|
||||
static const struct property_opt_test_data testdata_tiff_props[] = {
|
||||
{ wszTiffCompressionMethod, VT_UI1, VT_UI1, WICTiffCompressionDontCare },
|
||||
{ wszCompressionQuality, VT_R4, VT_EMPTY },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static int find_property_index(const WCHAR* name, PROPBAG2* all_props, int all_prop_cnt)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < all_prop_cnt; i++)
|
||||
{
|
||||
if (lstrcmpW(name, all_props[i].pstrName) == 0)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void test_specific_encoder_properties(IPropertyBag2 *options, const property_opt_test_data* data, PROPBAG2* all_props, int all_prop_cnt)
|
||||
{
|
||||
HRESULT hr;
|
||||
int i = 0;
|
||||
VARIANT pvarValue;
|
||||
HRESULT phrError = S_OK;
|
||||
|
||||
while (data[i].name)
|
||||
{
|
||||
int idx = find_property_index(data[i].name, all_props, all_prop_cnt);
|
||||
PROPBAG2 pb = {0};
|
||||
pb.pstrName = (LPOLESTR)data[i].name;
|
||||
|
||||
hr = IPropertyBag2_Read(options, 1, &pb, NULL, &pvarValue, &phrError);
|
||||
|
||||
ok(idx >= 0, "Property %s not in output of GetPropertyInfo\n",
|
||||
wine_dbgstr_w(data[i].name));
|
||||
if (idx >= 0)
|
||||
{
|
||||
ok(all_props[idx].vt == data[i].var_type, "Property %s has unexpected vt type, vt=%i\n",
|
||||
wine_dbgstr_w(data[i].name), all_props[idx].vt);
|
||||
ok(all_props[idx].dwType == PROPBAG2_TYPE_DATA, "Property %s has unexpected dw type, vt=%i\n",
|
||||
wine_dbgstr_w(data[i].name), all_props[idx].dwType);
|
||||
ok(all_props[idx].cfType == 0, "Property %s has unexpected cf type, vt=%i\n",
|
||||
wine_dbgstr_w(data[i].name), all_props[idx].cfType);
|
||||
}
|
||||
|
||||
ok(SUCCEEDED(hr), "Reading property %s from bag failed, hr=%x\n",
|
||||
wine_dbgstr_w(data[i].name), hr);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
/* On XP the initial type is always VT_EMPTY */
|
||||
ok(V_VT(&pvarValue) == data[i].initial_var_type || V_VT(&pvarValue) == VT_EMPTY,
|
||||
"Property %s has unexpected initial type, V_VT=%i\n",
|
||||
wine_dbgstr_w(data[i].name), V_VT(&pvarValue));
|
||||
|
||||
if(V_VT(&pvarValue) == data[i].initial_var_type)
|
||||
{
|
||||
switch (data[i].initial_var_type)
|
||||
{
|
||||
case VT_BOOL:
|
||||
case VT_UI1:
|
||||
ok(V_UNION(&pvarValue, bVal) == data[i].i_init_val, "Property %s has an unexpected initial value, pvarValue=%i\n",
|
||||
wine_dbgstr_w(data[i].name), V_UNION(&pvarValue, bVal));
|
||||
break;
|
||||
case VT_R4:
|
||||
ok(V_UNION(&pvarValue, fltVal) == data[i].f_init_val, "Property %s has an unexpected initial value, pvarValue=%f\n",
|
||||
wine_dbgstr_w(data[i].name), V_UNION(&pvarValue, fltVal));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
VariantClear(&pvarValue);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_encoder_properties(const CLSID* clsid_encoder, IPropertyBag2 *options)
|
||||
{
|
||||
HRESULT hr;
|
||||
ULONG cProperties = 0;
|
||||
ULONG cProperties2 = 0;
|
||||
PROPBAG2 all_props[64] = {{0}}; /* Should be enough for every encoder out there */
|
||||
int i;
|
||||
|
||||
/* CountProperties */
|
||||
{
|
||||
hr = IPropertyBag2_CountProperties(options, &cProperties);
|
||||
ok(SUCCEEDED(hr), "Reading property count, hr=%x\n", hr);
|
||||
}
|
||||
|
||||
/* GetPropertyInfo */
|
||||
{
|
||||
hr = IPropertyBag2_GetPropertyInfo(options, cProperties, 1, all_props, &cProperties2);
|
||||
ok(hr == WINCODEC_ERR_VALUEOUTOFRANGE, "IPropertyBag2::GetPropertyInfo - iProperty out of bounce handled wrong, hr=%x\n", hr);
|
||||
|
||||
hr = IPropertyBag2_GetPropertyInfo(options, 0, cProperties+1, all_props, &cProperties2);
|
||||
ok(hr == WINCODEC_ERR_VALUEOUTOFRANGE, "IPropertyBag2::GetPropertyInfo - cProperty out of bounce handled wrong, hr=%x\n", hr);
|
||||
|
||||
if (cProperties == 0) /* GetPropertyInfo can be called for zero items on Windows 8 but not on Windows 7 (wine behaves like Win8) */
|
||||
{
|
||||
cProperties2 = cProperties;
|
||||
hr = S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = IPropertyBag2_GetPropertyInfo(options, 0, min(64, cProperties), all_props, &cProperties2);
|
||||
ok(SUCCEEDED(hr), "Reading infos from property bag failed, hr=%x\n", hr);
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
return;
|
||||
|
||||
ok(cProperties == cProperties2, "Missmatch of property count (IPropertyBag2::CountProperties=%i, IPropertyBag2::GetPropertyInfo=%i)\n",
|
||||
(int)cProperties, (int)cProperties2);
|
||||
}
|
||||
|
||||
if (clsid_encoder == &CLSID_WICTiffEncoder)
|
||||
todo_wine test_specific_encoder_properties(options, testdata_tiff_props, all_props, cProperties2);
|
||||
|
||||
for (i=0; i < cProperties2; i++)
|
||||
{
|
||||
ok(all_props[i].pstrName != NULL, "Unset property name in output of IPropertyBag2::GetPropertyInfo\n");
|
||||
CoTaskMemFree(all_props[i].pstrName);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* clsid_encoder,
|
||||
const struct bitmap_data **dsts, const CLSID *clsid_decoder, const char *name)
|
||||
{
|
||||
|
@ -409,6 +550,10 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
|
|||
ok(SUCCEEDED(hr), "CreateFrame failed, hr=%x\n", hr);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ok(options != NULL, "Encoder initialization has not created an property bag");
|
||||
if(options)
|
||||
test_encoder_properties(clsid_encoder, options);
|
||||
|
||||
hr = IWICBitmapFrameEncode_Initialize(frameencode, options);
|
||||
ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue