oleaut32/tests: Test marshalling of complex structs.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-03-31 23:31:20 -05:00 committed by Alexandre Julliard
parent ad2cba9d84
commit c299f09e25
2 changed files with 65 additions and 1 deletions

View File

@ -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 = &pi;
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)

View File

@ -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);