ReactOS 0.4.16-dev-197-g92996da
propertybag.c File Reference
#include <stdarg.h>
#include <math.h>
#include "windef.h"
#include "objbase.h"
#include "wincodec.h"
#include "wincodecsdk.h"
#include "wine/test.h"
Include dependency graph for propertybag.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 

Functions

static void test_propertybag_getpropertyinfo (IPropertyBag2 *property, ULONG expected_count)
 
static void test_propertybag_countproperties (IPropertyBag2 *property, ULONG expected_count)
 
static void test_propertybag_read (IPropertyBag2 *property)
 
static void test_propertybag_write (IPropertyBag2 *property)
 
static void test_empty_propertybag (void)
 
static void test_filled_propertybag (void)
 
 START_TEST (propertybag)
 

Variables

static const WCHAR wszTestProperty1 [] = {'P','r','o','p','e','r','t','y','1',0}
 
static const WCHAR wszTestProperty2 [] = {'P','r','o','p','e','r','t','y','2',0}
 
static const WCHAR wszTestInvalidProperty [] = {'I','n','v','a','l','i','d',0}
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file propertybag.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 23 of file propertybag.c.

Function Documentation

◆ START_TEST()

START_TEST ( propertybag  )

Definition at line 283 of file propertybag.c.

284{
286
288
290
292}
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_empty_propertybag(void)
Definition: propertybag.c:227
static void test_filled_propertybag(void)
Definition: propertybag.c:251
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278

◆ test_empty_propertybag()

static void test_empty_propertybag ( void  )
static

Definition at line 227 of file propertybag.c.

228{
229 HRESULT hr;
232
233 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
234 &IID_IWICComponentFactory, (void**)&factory);
235 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
236
237 hr = IWICComponentFactory_CreateEncoderPropertyBag(factory, NULL, 0, &property);
238
239 ok(hr == S_OK, "Creating EncoderPropertyBag failed, hr=%x\n", hr);
240 if (FAILED(hr)) return;
241
243
245
246 IPropertyBag2_Release(property);
247
248 IWICComponentFactory_Release(factory);
249}
#define ok(value,...)
Definition: atltest.h:57
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
static void test_propertybag_countproperties(IPropertyBag2 *property, ULONG expected_count)
Definition: propertybag.c:78
static void test_propertybag_getpropertyinfo(IPropertyBag2 *property, ULONG expected_count)
Definition: propertybag.c:35
HRESULT hr
Definition: shlfolder.c:183
Definition: main.c:439

Referenced by START_TEST().

◆ test_filled_propertybag()

static void test_filled_propertybag ( void  )
static

Definition at line 251 of file propertybag.c.

252{
253 HRESULT hr;
256 PROPBAG2 opts[2]= {
257 {PROPBAG2_TYPE_DATA, VT_UI1, 0, 0, (LPOLESTR)wszTestProperty1, {0}},
258 {PROPBAG2_TYPE_DATA, VT_R4, 0, 0, (LPOLESTR)wszTestProperty2, {0}}
259 };
260
261 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
262 &IID_IWICComponentFactory, (void**)&factory);
263 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
264
265 hr = IWICComponentFactory_CreateEncoderPropertyBag(factory, opts, 2, &property);
266
267 ok(hr == S_OK, "Creating EncoderPropertyBag failed, hr=%x\n", hr);
268 if (FAILED(hr)) return;
269
271
273
275
277
278 IPropertyBag2_Release(property);
279
280 IWICComponentFactory_Release(factory);
281}
@ VT_R4
Definition: compat.h:2299
@ VT_UI1
Definition: compat.h:2311
static LPOLESTR
Definition: stg_prop.c:27
static void test_propertybag_read(IPropertyBag2 *property)
Definition: propertybag.c:95
static const WCHAR wszTestProperty1[]
Definition: propertybag.c:31
static void test_propertybag_write(IPropertyBag2 *property)
Definition: propertybag.c:180
static const WCHAR wszTestProperty2[]
Definition: propertybag.c:32

Referenced by START_TEST().

◆ test_propertybag_countproperties()

static void test_propertybag_countproperties ( IPropertyBag2 property,
ULONG  expected_count 
)
static

Definition at line 78 of file propertybag.c.

79{
80 ULONG count = (ULONG)-1;
81 HRESULT hr;
82
83 hr = IPropertyBag2_CountProperties(property, NULL);
84 ok(hr == E_INVALIDARG, "CountProperties returned unexpected result, hr=%x\n", hr);
85
86 hr = IPropertyBag2_CountProperties(property, &count);
87 ok(hr == S_OK, "CountProperties failed, hr=%x\n", hr);
88
89 if (FAILED(hr))
90 return;
91
92 ok(count == expected_count, "CountProperties returned invalid value, count=%i\n", count);
93}
#define E_INVALIDARG
Definition: ddrawi.h:101
GLuint GLuint GLsizei count
Definition: gl.h:1545
static int expected_count(int *sink)
uint32_t ULONG
Definition: typedefs.h:59

Referenced by test_empty_propertybag(), and test_filled_propertybag().

◆ test_propertybag_getpropertyinfo()

static void test_propertybag_getpropertyinfo ( IPropertyBag2 property,
ULONG  expected_count 
)
static

Definition at line 35 of file propertybag.c.

36{
37 HRESULT hr;
38 PROPBAG2 pb[2];
40
41 /* iProperty: Out of bounce */
42 hr = IPropertyBag2_GetPropertyInfo(property, expected_count, 1, pb, &out_count);
44 "GetPropertyInfo handled iProperty out of bounce wrong, hr=%x\n", hr);
45
46 /* cProperty: Out of bounce */
47 hr = IPropertyBag2_GetPropertyInfo(property, 0, expected_count+1, pb, &out_count);
49 "GetPropertyInfo handled cProperty out of bounce wrong, hr=%x\n", hr);
50
51 /* GetPropertyInfo can be called for zero items on Windows 8 but not on Windows 7 (wine behaves like Win8) */
52 if (expected_count == 0)
53 return;
54
55 hr = IPropertyBag2_GetPropertyInfo(property, 0, expected_count, pb, &out_count);
56 ok(hr == S_OK, "GetPropertyInfo failed, hr=%x\n", hr);
57 if (FAILED(hr))
58 return;
59
61 "GetPropertyInfo returned unexpected property count, %i != %i)\n",
63
64 if(expected_count != 2)
65 return;
66
67 ok(pb[0].vt == VT_UI1, "Invalid variant type, pb[0].vt=%x\n", pb[0].vt);
68 ok(pb[0].dwType == PROPBAG2_TYPE_DATA, "Invalid variant type, pb[0].dwType=%x\n", pb[0].dwType);
69 ok(lstrcmpW(pb[0].pstrName, wszTestProperty1) == 0, "Invalid property name, pb[0].pstrName=%s\n", wine_dbgstr_w(pb[0].pstrName));
70 CoTaskMemFree(pb[0].pstrName);
71
72 ok(pb[1].vt == VT_R4, "Invalid variant type, pb[1].vt=%x\n", pb[1].vt);
73 ok(pb[1].dwType == PROPBAG2_TYPE_DATA, "Invalid variant type, pb[1].dwType=%x\n", pb[1].dwType);
74 ok(lstrcmpW(pb[1].pstrName, wszTestProperty2) == 0, "Invalid property name, pb[1].pstrName=%s\n", wine_dbgstr_w(pb[1].pstrName));
75 CoTaskMemFree(pb[1].pstrName);
76}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:91
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define wine_dbgstr_w
Definition: kernel32.h:34
static UINT UINT * out_count
Definition: clipboard.c:35
#define WINCODEC_ERR_VALUEOUTOFRANGE
Definition: winerror.h:3282

Referenced by test_empty_propertybag(), and test_filled_propertybag().

◆ test_propertybag_read()

static void test_propertybag_read ( IPropertyBag2 property)
static

Definition at line 95 of file propertybag.c.

96{
97 HRESULT hr;
98 PROPBAG2 options[3] = {{0}};
99 VARIANT values[3];
100 HRESULT itm_hr[3] = {S_OK, S_OK, S_OK};
101
102 /* 1. One unknown property */
104 hr = IPropertyBag2_Read(property, 1, options, NULL, values, itm_hr);
105 ok(hr == E_FAIL,
106 "Read for an unknown property did not fail with expected code, hr=%x\n", hr);
107
108 /* 2. One known property */
109 options[0].pstrName = (LPOLESTR)wszTestProperty1;
110 itm_hr[0] = E_FAIL;
111 hr = IPropertyBag2_Read(property, 1, options, NULL, values, itm_hr);
112 ok(hr == S_OK, "Read failed, hr=%x\n", hr);
113 if (SUCCEEDED(hr))
114 {
115 ok(itm_hr[0] == S_OK,
116 "Read failed, itm_hr[0]=%x\n", itm_hr[0]);
117 ok(V_VT(&values[0]) == VT_UI1,
118 "Read failed, V_VT(&values[0])=%x\n", V_VT(&values[0]));
119 ok(V_UNION(&values[0], bVal) == 12,
120 "Read failed, &values[0]=%i\n", V_UNION(&values[0], bVal));
121
122 VariantClear(&values[0]);
123 }
124
125 /* 3. Two known properties */
126 options[0].pstrName = (LPOLESTR)wszTestProperty1;
127 options[1].pstrName = (LPOLESTR)wszTestProperty2;
128 itm_hr[0] = E_FAIL;
129 itm_hr[1] = E_FAIL;
130 hr = IPropertyBag2_Read(property, 2, options, NULL, values, itm_hr);
131 ok(hr == S_OK, "Read failed, hr=%x\n", hr);
132 if (SUCCEEDED(hr))
133 {
134 ok(itm_hr[0] == S_OK, "Read failed, itm_hr[0]=%x\n", itm_hr[0]);
135 ok(V_VT(&values[0]) == VT_UI1, "Read failed, V_VT(&values[0])=%x\n", V_VT(&values[0]));
136 ok(V_UNION(&values[0], bVal) == 12, "Read failed, &values[0]=%i\n", V_UNION(&values[0], bVal));
137
138 ok(itm_hr[1] == S_OK, "Read failed, itm_hr[1]=%x\n", itm_hr[1]);
139 ok(V_VT(&values[1]) == VT_R4, "Read failed, V_VT(&values[1])=%x\n", V_VT(&values[1]));
140 ok(V_UNION(&values[1], fltVal) == (float)3.14, "Read failed, &values[1]=%f\n", V_UNION(&values[1], fltVal));
141
142 VariantClear(&values[0]);
143 VariantClear(&values[1]);
144 }
145
146
147 /* 4. One unknown property between two valid */
148
149 /* Exotic initializations so we can detect what is unchanged */
150 itm_hr[0] = -1; itm_hr[1] = -1; itm_hr[2] = -1;
151 V_VT(&values[0]) = VT_NULL;
152 V_VT(&values[1]) = VT_NULL;
153 V_VT(&values[2]) = VT_NULL;
154 V_UNION(&values[0], bVal) = 254;
155 V_UNION(&values[1], bVal) = 254;
156 V_UNION(&values[2], bVal) = 254;
157
158 options[0].pstrName = (LPOLESTR)wszTestProperty1;
160 options[2].pstrName = (LPOLESTR)wszTestProperty2;
161
162 hr = IPropertyBag2_Read(property, 3, options, NULL, values, itm_hr);
163 ok(hr == E_FAIL, "Read failed, hr=%x\n", hr);
164 if (hr == E_FAIL)
165 {
166 ok(itm_hr[0] == S_OK, "Read error code has unexpected value, itm_hr[0]=%x\n", itm_hr[0]);
167 ok(itm_hr[1] == -1, "Read error code has unexpected value, itm_hr[1]=%x\n", itm_hr[1]);
168 ok(itm_hr[2] == -1, "Read error code has unexpected value, itm_hr[2]=%x\n", itm_hr[2]);
169
170 ok(V_VT(&values[0]) == VT_UI1, "Read variant has unexpected type, V_VT(&values[0])=%x\n", V_VT(&values[0]));
171 ok(V_VT(&values[1]) == VT_NULL, "Read variant has unexpected type, V_VT(&values[1])=%x\n", V_VT(&values[1]));
172 ok(V_VT(&values[2]) == VT_NULL, "Read variant has unexpected type, V_VT(&values[2])=%x\n", V_VT(&values[2]));
173
174 ok(V_UNION(&values[0], bVal) == 12, "Read variant has unexpected value, V_UNION(&values[0])=%i\n", V_UNION(&values[0], bVal));
175 ok(V_UNION(&values[1], bVal) == 254, "Read variant has unexpected value, V_UNION(&values[1])=%i\n", V_UNION(&values[1], bVal));
176 ok(V_UNION(&values[2], bVal) == 254, "Read variant has unexpected value, V_UNION(&values[2])=%i\n", V_UNION(&values[2], bVal));
177 }
178}
#define E_FAIL
Definition: ddrawi.h:102
@ VT_NULL
Definition: compat.h:2296
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static const WCHAR wszTestInvalidProperty[]
Definition: propertybag.c:33
#define V_VT(A)
Definition: oleauto.h:211
#define V_UNION(A, B)
Definition: oleauto.h:212
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648

Referenced by test_filled_propertybag().

◆ test_propertybag_write()

static void test_propertybag_write ( IPropertyBag2 property)
static

Definition at line 180 of file propertybag.c.

181{
182 HRESULT hr;
183 PROPBAG2 options[2] = {{0}};
184 VARIANT values[2];
185
186 VariantInit(&values[0]);
187 VariantInit(&values[1]);
188
189 /* 1. One unknown property */
191 hr = IPropertyBag2_Write(property, 1, options, values);
192 ok(hr == E_FAIL, "Write for an unknown property did not fail with expected code, hr=%x\n", hr);
193
194 /* 2. One property without correct type */
195 options[0].pstrName = (LPOLESTR)wszTestProperty1;
196 V_VT(&values[0]) = VT_UI1;
197 V_UNION(&values[0], bVal) = 1;
198 hr = IPropertyBag2_Write(property, 1, options, values);
199 ok(hr == S_OK, "Write for one property failed, hr=%x\n", hr);
200
201 /* 3. One property with mismatching type */
202 options[0].pstrName = (LPOLESTR)wszTestProperty1;
203 V_VT(&values[0]) = VT_I1;
204 V_UNION(&values[0], bVal) = 2;
205 hr = IPropertyBag2_Write(property, 1, options, values);
207 "Write with mismatching type did not fail with expected code hr=%x\n", hr);
208
209 /* 4. Reset one property to empty */
210 options[0].pstrName = (LPOLESTR)wszTestProperty1;
211 VariantClear(&values[0]);
212 hr = IPropertyBag2_Write(property, 1, options, values);
214 "Write to reset to empty value does not fail with expected code, hr=%x\n", hr);
215
216 /* 5. Set two properties */
217 options[0].pstrName = (LPOLESTR)wszTestProperty1;
218 V_VT(&values[0]) = VT_UI1;
219 V_UNION(&values[0], bVal) = 12;
220 options[1].pstrName = (LPOLESTR)wszTestProperty2;
221 V_VT(&values[1]) = VT_R4;
222 V_UNION(&values[1], fltVal) = (float)3.14;
223 hr = IPropertyBag2_Write(property, 2, options, values);
224 ok(hr == S_OK, "Write for two properties failed, hr=%x\n", hr);
225}
@ VT_I1
Definition: compat.h:2310
static float(__cdecl *square_half_float)(float x
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
#define WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE
Definition: winerror.h:3313

Referenced by test_filled_propertybag().

Variable Documentation

◆ wszTestInvalidProperty

const WCHAR wszTestInvalidProperty[] = {'I','n','v','a','l','i','d',0}
static

Definition at line 33 of file propertybag.c.

Referenced by test_propertybag_read(), and test_propertybag_write().

◆ wszTestProperty1

const WCHAR wszTestProperty1[] = {'P','r','o','p','e','r','t','y','1',0}
static

◆ wszTestProperty2

const WCHAR wszTestProperty2[] = {'P','r','o','p','e','r','t','y','2',0}
static