Zebediah Figura : oleaut32/tests: Test marshalling of complex structs.
Alexandre Julliard
julliard at winehq.org
Mon Apr 1 16:32:03 CDT 2019
Module: wine
Branch: master
Commit: c299f09e255fdea7f6e06ea2f59c9b799c86a5b2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c299f09e255fdea7f6e06ea2f59c9b799c86a5b2
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Sun Mar 31 23:31:20 2019 -0500
oleaut32/tests: Test marshalling of complex structs.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/oleaut32/tests/tmarshal.c | 45 ++++++++++++++++++++++++++++++++++++++++
dlls/oleaut32/tests/tmarshal.idl | 21 ++++++++++++++++++-
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c
index 9a7d995..4f84442 100644
--- a/dlls/oleaut32/tests/tmarshal.c
+++ b/dlls/oleaut32/tests/tmarshal.c
@@ -1441,6 +1441,28 @@ static HRESULT WINAPI Widget_rect(IWidget *iface, RECT in, RECT *out, RECT *in_p
return S_OK;
}
+static HRESULT WINAPI Widget_complex_struct(IWidget *iface, struct complex in)
+{
+ HRESULT hr;
+
+ ok(in.c == 98, "Got char %d.\n", in.c);
+ ok(in.i == 76543, "Got int %d.\n", in.i);
+ ok(*in.pi == 2, "Got int pointer %d.\n", *in.pi);
+ ok(**in.ppi == 10, "Got int double pointer %d.\n", **in.ppi);
+ hr = ISomethingFromDispatch_anotherfn(in.iface);
+ ok(hr == 0x01234567, "Got wrong hr %#x.\n", hr);
+ hr = ISomethingFromDispatch_anotherfn(*in.iface_ptr);
+ ok(hr == 0x01234567, "Got wrong hr %#x.\n", hr);
+ ok(!lstrcmpW(in.bstr, test_bstr2), "Got string %s.\n", wine_dbgstr_w(in.bstr));
+ ok(V_VT(&in.var) == VT_I4, "Got wrong type %u.\n", V_VT(&in.var));
+ ok(V_I4(&in.var) == 123, "Got wrong value %d.\n", V_I4(&in.var));
+ ok(!memcmp(&in.mystruct, &test_mystruct1, sizeof(MYSTRUCT)), "Structs didn't match.\n");
+ ok(!memcmp(in.arr, test_array1, sizeof(array_t)), "Arrays didn't match.\n");
+ ok(in.myint == 456, "Got int %d.\n", in.myint);
+
+ 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};
@@ -1600,6 +1622,7 @@ static const struct IWidgetVtbl Widget_VTable =
Widget_mystruct_ptr_ptr,
Widget_thin_struct,
Widget_rect,
+ Widget_complex_struct,
Widget_array,
Widget_variant_array,
Widget_mystruct_array,
@@ -2500,6 +2523,9 @@ static void test_marshal_struct(IWidget *widget, IDispatch *disp)
{
MYSTRUCT out, in_ptr, in_out, *in_ptr_ptr;
RECT rect_out, rect_in_ptr, rect_in_out;
+ ISomethingFromDispatch *sfd;
+ struct complex complex;
+ int i, i2, *pi = &i2;
HRESULT hr;
memcpy(&out, &test_mystruct2, sizeof(MYSTRUCT));
@@ -2531,6 +2557,25 @@ static void test_marshal_struct(IWidget *widget, IDispatch *disp)
ok(EqualRect(&rect_out, &test_rect5), "Rects didn't match.\n");
ok(EqualRect(&rect_in_ptr, &test_rect3), "Rects didn't match.\n");
ok(EqualRect(&rect_in_out, &test_rect7), "Rects didn't match.\n");
+
+ /* Test complex structs. */
+ complex.c = 98;
+ complex.i = 76543;
+ i = 2;
+ complex.pi = &i;
+ i2 = 10;
+ complex.ppi = π
+ complex.iface = create_disp_obj();
+ sfd = create_disp_obj();
+ complex.iface_ptr = &sfd;
+ complex.bstr = SysAllocString(test_bstr2);
+ V_VT(&complex.var) = VT_I4;
+ V_I4(&complex.var) = 123;
+ memcpy(&complex.mystruct, &test_mystruct1, sizeof(MYSTRUCT));
+ memcpy(complex.arr, test_array1, sizeof(array_t));
+ complex.myint = 456;
+ hr = IWidget_complex_struct(widget, complex);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
}
static void test_marshal_array(IWidget *widget, IDispatch *disp)
diff --git a/dlls/oleaut32/tests/tmarshal.idl b/dlls/oleaut32/tests/tmarshal.idl
index cdc7dc1..14b80c4 100644
--- a/dlls/oleaut32/tests/tmarshal.idl
+++ b/dlls/oleaut32/tests/tmarshal.idl
@@ -65,6 +65,7 @@ enum IWidget_dispids
DISPID_TM_STRUCT_PTR_PTR,
DISPID_TM_THIN_STRUCT,
DISPID_TM_RECT,
+ DISPID_TM_COMPLEX_STRUCT,
DISPID_TM_ARRAY,
DISPID_TM_VARIANT_ARRAY,
DISPID_TM_STRUCT_ARRAY,
@@ -105,6 +106,8 @@ library TestTypelib
typedef [public] int myint_t;
+ typedef int array_t[4];
+
coclass ApplicationObject2;
[
@@ -335,7 +338,23 @@ 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];
+ struct complex
+ {
+ char c;
+ int i;
+ int *pi;
+ int **ppi;
+ ISomethingFromDispatch *iface;
+ ISomethingFromDispatch **iface_ptr;
+ BSTR bstr;
+ VARIANT var;
+ MYSTRUCT mystruct;
+ array_t arr;
+ myint_t myint;
+ };
+
+ [id(DISPID_TM_COMPLEX_STRUCT)]
+ HRESULT complex_struct([in] struct complex in);
[id(DISPID_TM_ARRAY)]
HRESULT array([in] array_t in, [out] array_t out, [in, out] array_t in_out);
More information about the wine-cvs
mailing list