Signed-off-by: Zebediah Figura z.figura12@gmail.com --- v2: remove tests that fail on Windows < 7. v3: temporarily disable tests that fail on Wine.
dlls/oleaut32/tests/tmarshal.c | 166 +++++++++++++++++++------------ dlls/oleaut32/tests/tmarshal.idl | 22 ++-- 2 files changed, 118 insertions(+), 70 deletions(-)
diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c index 7567a53ee3..887c4c8134 100644 --- a/dlls/oleaut32/tests/tmarshal.c +++ b/dlls/oleaut32/tests/tmarshal.c @@ -67,6 +67,13 @@ static const RECT test_rect5 = {17,18,19,20}; static const RECT test_rect6 = {21,22,23,24}; static const RECT test_rect7 = {25,26,27,28};
+static const array_t test_array1 = {1,2,3,4}; +static const array_t test_array2 = {5,6,7,8}; +static const array_t test_array3 = {9,10,11,12}; +static const array_t test_array4 = {13,14,15,16}; +static const array_t test_array5 = {17,18,19,20}; +static const array_t test_array6 = {21,22,23,24}; + #define RELEASEMARSHALDATA WM_USER
struct host_object_data @@ -727,14 +734,6 @@ static HRESULT WINAPI Widget_Value( return S_OK; }
-static HRESULT WINAPI Widget_Array( - IWidget * iface, - SAFEARRAY * values) -{ - trace("Array(%p)\n", values); - return S_OK; -} - static HRESULT WINAPI Widget_VariantArrayPtr( IWidget * iface, SAFEARRAY ** values) @@ -743,46 +742,6 @@ static HRESULT WINAPI Widget_VariantArrayPtr( return S_OK; }
-static HRESULT WINAPI Widget_VariantCArray( - IWidget * iface, - ULONG count, - VARIANT values[]) -{ - ULONG i; - - trace("VariantCArray(%u,%p)\n", count, values); - - ok(count == 2, "count is %d\n", count); - for (i = 0; i < count; i++) - ok(V_VT(&values[i]) == VT_I4, "values[%d] is not VT_I4\n", i); - - if (pVarAdd) - { - VARIANT inc, res; - HRESULT hr; - - V_VT(&inc) = VT_I4; - V_I4(&inc) = 1; - for (i = 0; i < count; i++) { - VariantInit(&res); - hr = pVarAdd(&values[i], &inc, &res); - if (FAILED(hr)) { - ok(0, "VarAdd failed at %u with error 0x%x\n", i, hr); - return hr; - } - hr = VariantCopy(&values[i], &res); - if (FAILED(hr)) { - ok(0, "VariantCopy failed at %u with error 0x%x\n", i, hr); - return hr; - } - } - } - else - win_skip("VarAdd is not available\n"); - - return S_OK; -} - static HRESULT WINAPI Widget_VarArg( IWidget * iface, int numexpect, @@ -1310,6 +1269,51 @@ static HRESULT WINAPI Widget_rect(IWidget *iface, RECT in, RECT *out, RECT *in_p return S_OK; }
+static HRESULT WINAPI Widget_array(IWidget *iface, array_t in, array_t out, array_t in_out) +{ + static const array_t empty = {0}; + ok(!memcmp(in, test_array1, sizeof(array_t)), "Arrays didn't match.\n"); +todo_wine + ok(!memcmp(out, empty, sizeof(array_t)), "Arrays didn't match.\n"); + ok(!memcmp(in_out, test_array3, sizeof(array_t)), "Arrays didn't match.\n"); + + memcpy(in, test_array4, sizeof(array_t)); + memcpy(out, test_array5, sizeof(array_t)); + memcpy(in_out, test_array6, sizeof(array_t)); + + return S_OK; +} + +static HRESULT WINAPI Widget_variant_array(IWidget *iface, VARIANT in[2], VARIANT out[2], VARIANT in_out[2]) +{ + ok(V_VT(&in[0]) == VT_I4, "Got wrong type %u.\n", V_VT(&in[0])); + ok(V_I4(&in[0]) == 1, "Got wrong value %d.\n", V_I4(&in[0])); + ok(V_VT(&in[1]) == VT_I4, "Got wrong type %u.\n", V_VT(&in[1])); + ok(V_I4(&in[1]) == 2, "Got wrong value %d.\n", V_I4(&in[1])); + ok(V_VT(&out[0]) == VT_EMPTY, "Got wrong type %u.\n", V_VT(&out[0])); + ok(V_VT(&out[1]) == VT_EMPTY, "Got wrong type %u.\n", V_VT(&out[1])); + ok(V_VT(&in_out[0]) == VT_I4, "Got wrong type %u.\n", V_VT(&in_out[0])); + ok(V_I4(&in_out[0]) == 5, "Got wrong type %u.\n", V_VT(&in_out[0])); + ok(V_VT(&in_out[1]) == VT_I4, "Got wrong type %u.\n", V_VT(&in_out[1])); + ok(V_I4(&in_out[1]) == 6, "Got wrong type %u.\n", V_VT(&in_out[1])); + + V_VT(&in[0]) = VT_I1; V_I1(&in[0]) = 7; + V_VT(&in[1]) = VT_I1; V_I1(&in[1]) = 8; + V_VT(&out[0]) = VT_I1; V_I1(&out[0]) = 9; + V_VT(&out[1]) = VT_I1; V_I1(&out[1]) = 10; + V_VT(&in_out[0]) = VT_I1; V_I1(&in_out[0]) = 11; + V_VT(&in_out[1]) = VT_I1; V_I1(&in_out[1]) = 12; + + return S_OK; +} + +static HRESULT WINAPI Widget_mystruct_array(IWidget *iface, MYSTRUCT in[2]) +{ + ok(!memcmp(&in[0], &test_mystruct1, sizeof(MYSTRUCT)), "Structs didn't match.\n"); + ok(!memcmp(&in[1], &test_mystruct2, sizeof(MYSTRUCT)), "Structs didn't match.\n"); + return S_OK; +} + static const struct IWidgetVtbl Widget_VTable = { Widget_QueryInterface, @@ -1331,9 +1335,7 @@ static const struct IWidgetVtbl Widget_VTable = Widget_CloneDispatch, Widget_CloneCoclass, Widget_Value, - Widget_Array, Widget_VariantArrayPtr, - Widget_VariantCArray, Widget_VarArg, Widget_Error, Widget_CloneInterface, @@ -1363,6 +1365,9 @@ static const struct IWidgetVtbl Widget_VTable = Widget_mystruct_ptr_ptr, Widget_thin_struct, Widget_rect, + Widget_array, + Widget_variant_array, + Widget_mystruct_array, };
static HRESULT WINAPI StaticWidget_QueryInterface(IStaticWidget *iface, REFIID riid, void **ppvObject) @@ -2285,6 +2290,54 @@ static void test_marshal_struct(IWidget *widget, IDispatch *disp) ok(EqualRect(&rect_in_out, &test_rect7), "Rects didn't match.\n"); }
+static void test_marshal_array(IWidget *widget, IDispatch *disp) +{ + VARIANT var_in[2], var_out[2], var_in_out[2]; + array_t in, out, in_out; + MYSTRUCT struct_in[2]; + HRESULT hr; + +if (0) { + memcpy(in, test_array1, sizeof(array_t)); + memcpy(out, test_array2, sizeof(array_t)); + memcpy(in_out, test_array3, sizeof(array_t)); + hr = IWidget_array(widget, in, out, in_out); + ok(hr == S_OK, "Got hr %#x.\n", hr); +todo_wine + ok(!memcmp(&in, &test_array1, sizeof(array_t)), "Arrays didn't match.\n"); + ok(!memcmp(&out, &test_array5, sizeof(array_t)), "Arrays didn't match.\n"); + ok(!memcmp(&in_out, &test_array6, sizeof(array_t)), "Arrays didn't match.\n"); +} + + V_VT(&var_in[0]) = VT_I4; V_I4(&var_in[0]) = 1; + V_VT(&var_in[1]) = VT_I4; V_I4(&var_in[1]) = 2; + V_VT(&var_out[0]) = VT_I4; V_I4(&var_out[0]) = 3; + V_VT(&var_out[1]) = VT_I4; V_I4(&var_out[1]) = 4; + V_VT(&var_in_out[0]) = VT_I4; V_I4(&var_in_out[0]) = 5; + V_VT(&var_in_out[1]) = VT_I4; V_I4(&var_in_out[1]) = 6; + hr = IWidget_variant_array(widget, var_in, var_out, var_in_out); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(V_VT(&var_in[0]) == VT_I4, "Got wrong type %u.\n", V_VT(&var_in[0])); + ok(V_I4(&var_in[0]) == 1, "Got wrong value %d.\n", V_I4(&var_in[0])); + ok(V_VT(&var_in[1]) == VT_I4, "Got wrong type %u.\n", V_VT(&var_in[1])); + ok(V_I4(&var_in[1]) == 2, "Got wrong value %d.\n", V_I4(&var_in[1])); +todo_wine { + ok(V_VT(&var_out[0]) == VT_I1, "Got wrong type %u.\n", V_VT(&var_out[0])); + ok(V_I1(&var_out[0]) == 9, "Got wrong value %u.\n", V_VT(&var_out[0])); + ok(V_VT(&var_out[1]) == VT_I1, "Got wrong type %u.\n", V_VT(&var_out[1])); + ok(V_I1(&var_out[1]) == 10, "Got wrong value %u.\n", V_VT(&var_out[1])); + ok(V_VT(&var_in_out[0]) == VT_I1, "Got wrong type %u.\n", V_VT(&var_in_out[0])); + ok(V_I1(&var_in_out[0]) == 11, "Got wrong value %u.\n", V_VT(&var_in_out[0])); + ok(V_VT(&var_in_out[1]) == VT_I1, "Got wrong type %u.\n", V_VT(&var_in_out[1])); + ok(V_I1(&var_in_out[1]) == 12, "Got wrong value %u.\n", V_VT(&var_in_out[1])); +} + + memcpy(&struct_in[0], &test_mystruct1, sizeof(MYSTRUCT)); + memcpy(&struct_in[1], &test_mystruct2, sizeof(MYSTRUCT)); + hr = IWidget_mystruct_array(widget, struct_in); + ok(hr == S_OK, "Got hr %#x.\n", hr); +} + static void test_typelibmarshal(void) { static const WCHAR szCat[] = { 'C','a','t',0 }; @@ -2579,18 +2632,6 @@ static void test_typelibmarshal(void) ok(hr == DISP_E_TYPEMISMATCH || hr == DISP_E_BADVARTYPE, "expected DISP_E_TYPEMISMATCH, got %#x\n", hr); SysFreeString(V_BSTR(&vararg[0]));
- /* call VariantCArray - test marshaling of variant arrays */ - V_VT(&vararg[0]) = VT_I4; - V_I4(&vararg[0]) = 1; - V_VT(&vararg[1]) = VT_I4; - V_I4(&vararg[1]) = 2; - hr = IWidget_VariantCArray(pWidget, 2, vararg); - ok_ole_success(hr, IWidget_VariantCArray); -todo_wine - ok(V_VT(&vararg[0]) == VT_I4 && V_I4(&vararg[0]) == 2, "vararg[0] = %d[%d]\n", V_VT(&vararg[0]), V_I4(&vararg[0])); -todo_wine - ok(V_VT(&vararg[1]) == VT_I4 && V_I4(&vararg[1]) == 3, "vararg[1] = %d[%d]\n", V_VT(&vararg[1]), V_I4(&vararg[1])); - /* call VarArg */ VariantInit(&vararg[3]); V_VT(&vararg[3]) = VT_I4; @@ -2877,6 +2918,7 @@ todo_wine test_marshal_variant(pWidget, pDispatch); test_marshal_safearray(pWidget, pDispatch); test_marshal_struct(pWidget, pDispatch); + test_marshal_array(pWidget, pDispatch);
IDispatch_Release(pDispatch); IWidget_Release(pWidget); diff --git a/dlls/oleaut32/tests/tmarshal.idl b/dlls/oleaut32/tests/tmarshal.idl index d2ebc0b010..cce97cd977 100644 --- a/dlls/oleaut32/tests/tmarshal.idl +++ b/dlls/oleaut32/tests/tmarshal.idl @@ -34,9 +34,7 @@ enum IWidget_dispids DISPID_TM_CLONEDISPATCH, DISPID_TM_CLONECOCLASS, DISPID_TM_VALUE, - DISPID_TM_ARRAY, DISPID_TM_VARARRAYPTR, - DISPID_TM_VARCARRAY, DISPID_TM_VARARG, DISPID_TM_ERROR, DISPID_TM_CLONEINTERFACE, @@ -67,6 +65,9 @@ enum IWidget_dispids DISPID_TM_STRUCT_PTR_PTR, DISPID_TM_THIN_STRUCT, DISPID_TM_RECT, + DISPID_TM_ARRAY, + DISPID_TM_VARIANT_ARRAY, + DISPID_TM_STRUCT_ARRAY, };
static const int DISPID_TM_NEG_RESTRICTED = -26; @@ -184,15 +185,9 @@ library TestTypelib [propget, id(DISPID_VALUE)] HRESULT Value([in] VARIANT *value, [out, retval] VARIANT *retval);
- [id(DISPID_TM_ARRAY)] - HRESULT Array([in] SAFEARRAY(BSTR) values); - [id(DISPID_TM_VARARRAYPTR)] HRESULT VariantArrayPtr([in] SAFEARRAY(VARIANT) *values);
- [id(DISPID_TM_VARCARRAY)] - HRESULT VariantCArray([in] ULONG count, [in, out] VARIANT values[2]); - [vararg, id(DISPID_TM_VARARG)] HRESULT VarArg([in] int numexpect, [in] SAFEARRAY(VARIANT) values);
@@ -289,6 +284,17 @@ library TestTypelib
[id(DISPID_TM_RECT)] HRESULT rect([in] RECT in, [out] RECT *out, [in] RECT *in_ptr, [in, out] RECT *in_out); + + typedef int array_t[4]; + + [id(DISPID_TM_ARRAY)] + HRESULT array([in] array_t in, [out] array_t out, [in, out] array_t in_out); + + [id(DISPID_TM_VARIANT_ARRAY)] + HRESULT variant_array([in] VARIANT in[2], [out] VARIANT out[2], [in, out] VARIANT in_out[2]); + + [id(DISPID_TM_STRUCT_ARRAY)] + HRESULT mystruct_array([in] MYSTRUCT in[2]); }
[
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/oleaut32/tests/tmarshal.c | 19 ++++++++++++++++++- dlls/oleaut32/tests/tmarshal.idl | 6 ++++++ 2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c index 887c4c8134..75970a1abd 100644 --- a/dlls/oleaut32/tests/tmarshal.c +++ b/dlls/oleaut32/tests/tmarshal.c @@ -1314,6 +1314,14 @@ static HRESULT WINAPI Widget_mystruct_array(IWidget *iface, MYSTRUCT in[2]) return S_OK; }
+static HRESULT WINAPI Widget_myint(IWidget *iface, myint_t val, myint_t *ptr, myint_t **ptr_ptr) +{ + ok(val == 123, "Got value %d.\n", val); + ok(*ptr == 456, "Got single ptr ref %d.\n", *ptr); + ok(**ptr_ptr == 789, "Got double ptr ref %d.\n", **ptr_ptr); + return S_OK; +} + static const struct IWidgetVtbl Widget_VTable = { Widget_QueryInterface, @@ -1368,6 +1376,7 @@ static const struct IWidgetVtbl Widget_VTable = Widget_array, Widget_variant_array, Widget_mystruct_array, + Widget_myint, };
static HRESULT WINAPI StaticWidget_QueryInterface(IStaticWidget *iface, REFIID riid, void **ppvObject) @@ -1689,7 +1698,7 @@ static void test_marshal_basetypes(IWidget *widget, IDispatch *disp)
signed char c; short s; - int i; + int i, i2, *pi; hyper h; unsigned char uc; unsigned short us; @@ -1763,6 +1772,14 @@ static void test_marshal_basetypes(IWidget *widget, IDispatch *disp) ok(f == (float)M_LN2, "Got float %f.\n", f); ok(d == M_LN10, "Got double %f.\n", d); ok(st == STATE_UNWIDGETIFIED, "Got state %u.\n", st); + + /* Test marshalling of public typedefs. */ + + i = 456; + i2 = 789; + pi = &i2; + hr = IWidget_myint(widget, 123, &i, &pi); + ok(hr == S_OK, "Got hr %#x.\n", hr); }
static void test_marshal_pointer(IWidget *widget, IDispatch *disp) diff --git a/dlls/oleaut32/tests/tmarshal.idl b/dlls/oleaut32/tests/tmarshal.idl index cce97cd977..6bf969cf09 100644 --- a/dlls/oleaut32/tests/tmarshal.idl +++ b/dlls/oleaut32/tests/tmarshal.idl @@ -68,6 +68,7 @@ enum IWidget_dispids DISPID_TM_ARRAY, DISPID_TM_VARIANT_ARRAY, DISPID_TM_STRUCT_ARRAY, + DISPID_TM_TYPEDEF, };
static const int DISPID_TM_NEG_RESTRICTED = -26; @@ -100,6 +101,8 @@ library TestTypelib UINT uarr[8]; } MYSTRUCT;
+ typedef [public] int myint_t; + coclass ApplicationObject2;
[ @@ -295,6 +298,9 @@ library TestTypelib
[id(DISPID_TM_STRUCT_ARRAY)] HRESULT mystruct_array([in] MYSTRUCT in[2]); + + [id(DISPID_TM_TYPEDEF)] + HRESULT myint([in] myint_t val, [in] myint_t *ptr, [in] myint_t **ptr_ptr); }
[
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/oleaut32/tests/tmarshal.c | 17 +++++++++++++++++ dlls/oleaut32/tests/tmarshal.idl | 4 ++++ 2 files changed, 21 insertions(+)
diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c index 75970a1abd..c92e208795 100644 --- a/dlls/oleaut32/tests/tmarshal.c +++ b/dlls/oleaut32/tests/tmarshal.c @@ -981,6 +981,17 @@ static HRESULT WINAPI Widget_basetypes_out(IWidget *iface, signed char *c, short return S_OK; }
+static HRESULT WINAPI Widget_float_abi(IWidget *iface, float f, double d, int i, float f2, double d2) +{ + ok(f == 1.0f, "Got float %f.\n", f); + ok(d == 2.0, "Got double %f.\n", d); + ok(i == 3, "Got int %d.\n", i); + ok(f2 == 4.0f, "Got float %f.\n", f2); + ok(d2 == 5.0, "Got double %f.\n", d2); + + return S_OK; +} + static HRESULT WINAPI Widget_int_ptr(IWidget *iface, int *in, int *out, int *in_out) { ok(*in == 123, "Got [in] %d.\n", *in); @@ -1361,6 +1372,7 @@ static const struct IWidgetVtbl Widget_VTable = Widget_Coclass, Widget_basetypes_in, Widget_basetypes_out, + Widget_float_abi, Widget_int_ptr, Widget_int_ptr_ptr, Widget_iface_in, @@ -1780,6 +1792,11 @@ static void test_marshal_basetypes(IWidget *widget, IDispatch *disp) pi = &i2; hr = IWidget_myint(widget, 123, &i, &pi); ok(hr == S_OK, "Got hr %#x.\n", hr); + + /* Test that different float ABIs are correctly handled. */ + + hr = IWidget_float_abi(widget, 1.0f, 2.0, 3, 4.0f, 5.0); + ok(hr == S_OK, "Got hr %#x.\n", hr); }
static void test_marshal_pointer(IWidget *widget, IDispatch *disp) diff --git a/dlls/oleaut32/tests/tmarshal.idl b/dlls/oleaut32/tests/tmarshal.idl index 6bf969cf09..543d229ce2 100644 --- a/dlls/oleaut32/tests/tmarshal.idl +++ b/dlls/oleaut32/tests/tmarshal.idl @@ -53,6 +53,7 @@ enum IWidget_dispids
DISPID_TM_BASETYPES_IN, DISPID_TM_BASETYPES_OUT, + DISPID_TM_FLOAT_ABI, DISPID_TM_INT_PTR, DISPID_TM_INT_PTR_PTR, DISPID_TM_IFACE_IN, @@ -246,6 +247,9 @@ library TestTypelib [out] unsigned char *uc, [out] unsigned short *us, [out] unsigned int *ui, [out] unsigned hyper *uh, [out] float *f, [out] double *d, [out] STATE *st);
+ [id(DISPID_TM_FLOAT_ABI)] + HRESULT float_abi([in] float f, [in] double d, [in] int i, [in] float f2, [in] double d2); + [id(DISPID_TM_INT_PTR)] HRESULT int_ptr([in] int *in, [out] int *out, [in, out] int *in_out);