Commit 55e3a4d8 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

oleaut32/tests: Add some tests for marshalling base types.

parent 1d15103c
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
* *
*/ */
#include <math.h>
#define COBJMACROS #define COBJMACROS
#define CONST_VTABLE #define CONST_VTABLE
...@@ -27,7 +29,6 @@ ...@@ -27,7 +29,6 @@
#include "wine/test.h" #include "wine/test.h"
#include "tmarshal.h" #include "tmarshal.h"
#include "tmarshal_dispids.h"
static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT); static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
...@@ -923,6 +924,44 @@ static HRESULT WINAPI Widget_Coclass( ...@@ -923,6 +924,44 @@ static HRESULT WINAPI Widget_Coclass(
return S_OK; return S_OK;
} }
static HRESULT WINAPI Widget_basetypes_in(IWidget *iface, signed char c, short s, int i, hyper h,
unsigned char uc, unsigned short us, unsigned int ui, MIDL_uhyper uh,
float f, double d, STATE st)
{
ok(c == 5, "Got char %d.\n", c);
ok(s == -123, "Got short %d.\n", s);
ok(i == -100000, "Got int %d.\n", i);
ok(h == (LONGLONG)-100000 * 1000000, "Got hyper %s.\n", wine_dbgstr_longlong(h));
ok(uc == 0, "Got unsigned char %u.\n", uc);
ok(us == 456, "Got unsigned short %u.\n", us);
ok(ui == 0xdeadbeef, "Got unsigned int %i.\n", ui);
ok(uh == (ULONGLONG)1234567890 * 9876543210, "Got unsigned hyper %s.\n", wine_dbgstr_longlong(uh));
ok(f == (float)M_PI, "Got float %f.\n", f);
ok(d == M_E, "Got double %f.\n", d);
ok(st == STATE_WIDGETIFIED, "Got state %u.\n", st);
return S_OK;
}
static HRESULT WINAPI Widget_basetypes_out(IWidget *iface, signed char *c, short *s, int *i, hyper *h,
unsigned char *uc, unsigned short *us, unsigned int *ui, MIDL_uhyper *uh,
float *f, double *d, STATE *st)
{
*c = 10;
*s = -321;
*i = -200000;
*h = (LONGLONG)-200000 * 1000000;
*uc = 254;
*us = 256;
*ui = 0xf00dfade;
*uh = (((ULONGLONG)0xabcdef01) << 32) | (ULONGLONG)0x23456789;
*f = M_LN2;
*d = M_LN10;
*st = STATE_UNWIDGETIFIED;
return S_OK;
}
static const struct IWidgetVtbl Widget_VTable = static const struct IWidgetVtbl Widget_VTable =
{ {
Widget_QueryInterface, Widget_QueryInterface,
...@@ -964,6 +1003,8 @@ static const struct IWidgetVtbl Widget_VTable = ...@@ -964,6 +1003,8 @@ static const struct IWidgetVtbl Widget_VTable =
Widget_VarArg_Run, Widget_VarArg_Run,
Widget_VarArg_Ref_Run, Widget_VarArg_Ref_Run,
Widget_Coclass, Widget_Coclass,
Widget_basetypes_in,
Widget_basetypes_out,
}; };
static HRESULT WINAPI StaticWidget_QueryInterface(IStaticWidget *iface, REFIID riid, void **ppvObject) static HRESULT WINAPI StaticWidget_QueryInterface(IStaticWidget *iface, REFIID riid, void **ppvObject)
...@@ -1277,6 +1318,90 @@ static ITypeInfo *NonOleAutomation_GetTypeInfo(void) ...@@ -1277,6 +1318,90 @@ static ITypeInfo *NonOleAutomation_GetTypeInfo(void)
return NULL; return NULL;
} }
static void test_marshal_basetypes(IWidget *widget, IDispatch *disp)
{
VARIANTARG arg[11];
DISPPARAMS dispparams = {arg, NULL, ARRAY_SIZE(arg), 0};
HRESULT hr;
signed char c;
short s;
int i;
hyper h;
unsigned char uc;
unsigned short us;
unsigned int ui;
MIDL_uhyper uh;
float f;
double d;
STATE st;
V_VT(&arg[10]) = VT_I1; V_I1(&arg[10]) = 5;
V_VT(&arg[9]) = VT_I2; V_I2(&arg[9]) = -123;
V_VT(&arg[8]) = VT_I4; V_I4(&arg[8]) = -100000;
V_VT(&arg[7]) = VT_I8; V_I8(&arg[7]) = (LONGLONG)-100000 * 1000000;
V_VT(&arg[6]) = VT_UI1; V_UI1(&arg[6]) = 0;
V_VT(&arg[5]) = VT_UI2; V_UI2(&arg[5]) = 456;
V_VT(&arg[4]) = VT_UI4; V_UI4(&arg[4]) = 0xdeadbeef;
V_VT(&arg[3]) = VT_UI8; V_UI8(&arg[3]) = (ULONGLONG)1234567890 * 9876543210;
V_VT(&arg[2]) = VT_R4; V_R4(&arg[2]) = M_PI;
V_VT(&arg[1]) = VT_R8; V_R8(&arg[1]) = M_E;
V_VT(&arg[0]) = VT_I4; V_I4(&arg[0]) = STATE_WIDGETIFIED;
hr = IDispatch_Invoke(disp, DISPID_TM_BASETYPES_IN, &IID_NULL, LOCALE_NEUTRAL,
DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IWidget_basetypes_in(widget, 5, -123, -100000, (LONGLONG)-100000 * 1000000, 0, 456,
0xdeadbeef, (ULONGLONG)1234567890 * 9876543210, M_PI, M_E, STATE_WIDGETIFIED);
ok(hr == S_OK, "Got hr %#x.\n", hr);
c = s = i = h = uc = us = ui = uh = f = d = st = 0;
V_VT(&arg[10]) = VT_BYREF|VT_I1; V_I1REF(&arg[10]) = &c;
V_VT(&arg[9]) = VT_BYREF|VT_I2; V_I2REF(&arg[9]) = &s;
V_VT(&arg[8]) = VT_BYREF|VT_I4; V_I4REF(&arg[8]) = &i;
V_VT(&arg[7]) = VT_BYREF|VT_I8; V_I8REF(&arg[7]) = &h;
V_VT(&arg[6]) = VT_BYREF|VT_UI1; V_UI1REF(&arg[6]) = &uc;
V_VT(&arg[5]) = VT_BYREF|VT_UI2; V_UI2REF(&arg[5]) = &us;
V_VT(&arg[4]) = VT_BYREF|VT_UI4; V_UI4REF(&arg[4]) = &ui;
V_VT(&arg[3]) = VT_BYREF|VT_UI8; V_UI8REF(&arg[3]) = &uh;
V_VT(&arg[2]) = VT_BYREF|VT_R4; V_R4REF(&arg[2]) = &f;
V_VT(&arg[1]) = VT_BYREF|VT_R8; V_R8REF(&arg[1]) = &d;
V_VT(&arg[0]) = VT_BYREF|VT_I4; V_I4REF(&arg[0]) = (int *)&st;
hr = IDispatch_Invoke(disp, DISPID_TM_BASETYPES_OUT, &IID_NULL, LOCALE_NEUTRAL,
DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(c == 10, "Got char %d.\n", c);
ok(s == -321, "Got short %d.\n", s);
ok(i == -200000, "Got int %d.\n", i);
ok(h == (LONGLONG)-200000 * 1000000L, "Got hyper %s.\n", wine_dbgstr_longlong(h));
ok(uc == 254, "Got unsigned char %u.\n", uc);
ok(us == 256, "Got unsigned short %u.\n", us);
ok(ui == 0xf00dfade, "Got unsigned int %i.\n", ui);
ok(uh == ((((ULONGLONG)0xabcdef01) << 32) | (ULONGLONG)0x23456789),
"Got unsigned hyper %s.\n", wine_dbgstr_longlong(uh));
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);
c = s = i = h = uc = us = ui = uh = f = d = st = 0;
hr = IWidget_basetypes_out(widget, &c, &s, &i, &h, &uc, &us, &ui, &uh, &f, &d, &st);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(c == 10, "Got char %d.\n", c);
ok(s == -321, "Got short %d.\n", s);
ok(i == -200000, "Got int %d.\n", i);
ok(h == (LONGLONG)-200000 * 1000000L, "Got hyper %s.\n", wine_dbgstr_longlong(h));
ok(uc == 254, "Got unsigned char %u.\n", uc);
ok(us == 256, "Got unsigned short %u.\n", us);
ok(ui == 0xf00dfade, "Got unsigned int %i.\n", ui);
ok(uh == ((((ULONGLONG)0xabcdef01) << 32) | (ULONGLONG)0x23456789),
"Got unsigned hyper %s.\n", wine_dbgstr_longlong(uh));
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);
}
static void test_typelibmarshal(void) static void test_typelibmarshal(void)
{ {
static const WCHAR szCat[] = { 'C','a','t',0 }; static const WCHAR szCat[] = { 'C','a','t',0 };
...@@ -1887,6 +2012,8 @@ static void test_typelibmarshal(void) ...@@ -1887,6 +2012,8 @@ static void test_typelibmarshal(void)
ok(V_I4(&varresult) == DISPID_TM_NEG_RESTRICTED, "got %x\n", V_I4(&varresult)); ok(V_I4(&varresult) == DISPID_TM_NEG_RESTRICTED, "got %x\n", V_I4(&varresult));
VariantClear(&varresult); VariantClear(&varresult);
test_marshal_basetypes(pWidget, pDispatch);
IDispatch_Release(pDispatch); IDispatch_Release(pDispatch);
IWidget_Release(pWidget); IWidget_Release(pWidget);
......
...@@ -20,9 +20,53 @@ ...@@ -20,9 +20,53 @@
#pragma makedep ident #pragma makedep ident
#pragma makedep typelib #pragma makedep typelib
#include "tmarshal_dispids.h"
import "ocidl.idl"; import "ocidl.idl";
enum IWidget_dispids
{
DISPID_TM_NAME = 1,
DISPID_TM_DOSOMETHING,
DISPID_TM_STATE,
DISPID_TM_MAP,
DISPID_TM_SETOLECOLOR,
DISPID_TM_GETOLECOLOR,
DISPID_TM_CLONE,
DISPID_TM_CLONEDISPATCH,
DISPID_TM_CLONECOCLASS,
DISPID_TM_VALUE,
DISPID_TM_ARRAY,
DISPID_TM_VARARRAYPTR,
DISPID_TM_VARCARRAY,
DISPID_TM_VARIANT,
DISPID_TM_VARARG,
DISPID_TM_STRUCTARGS,
DISPID_TM_ERROR,
DISPID_TM_CLONEINTERFACE,
DISPID_TM_TESTDUAL,
DISPID_TM_PROP_WITH_LCID,
DISPID_TM_PROP_INT,
DISPID_TM_PROP_UINT,
DISPID_TM_BYREF_UINT,
DISPID_TM_PROP_OPT_ARG,
DISPID_TM_PROP_REQ_ARG,
DISPID_TM_RESTRICTED,
DISPID_TM_TESTSECONDIFACE,
DISPID_TM_VARARG_RUN,
DISPID_TM_VARARG_REF_RUN,
DISPID_TM_COCLASS,
DISPID_TM_BASETYPES_IN,
DISPID_TM_BASETYPES_OUT,
};
static const int DISPID_TM_NEG_RESTRICTED = -26;
enum INonOleAutomation_dispids
{
DISPID_NOA_BSTRRET = 1,
DISPID_NOA_ERROR
};
[ [
uuid(d96d8a3e-78b6-4c8d-8f27-059db959be8a), uuid(d96d8a3e-78b6-4c8d-8f27-059db959be8a),
version(2.5), version(2.5),
...@@ -188,6 +232,16 @@ library TestTypelib ...@@ -188,6 +232,16 @@ library TestTypelib
[id(DISPID_TM_COCLASS)] [id(DISPID_TM_COCLASS)]
HRESULT Coclass([in] ApplicationObject2 *param); HRESULT Coclass([in] ApplicationObject2 *param);
[id(DISPID_TM_BASETYPES_IN)]
HRESULT basetypes_in([in] signed char c, [in] short s, [in] int i, [in] hyper h,
[in] unsigned char uc, [in] unsigned short us, [in] unsigned int ui,
[in] unsigned hyper uh, [in] float f, [in] double d, [in] STATE st);
[id(DISPID_TM_BASETYPES_OUT)]
HRESULT basetypes_out([out] signed char *c, [out] short *s, [out] int *i, [out] hyper *h,
[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);
} }
[ [
......
/*
* Copyright (C) 2005-2006 Robert Shearman for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#define DISPID_TM_NAME 1
#define DISPID_TM_DOSOMETHING 2
#define DISPID_TM_STATE 3
#define DISPID_TM_MAP 4
#define DISPID_TM_SETOLECOLOR 5
#define DISPID_TM_GETOLECOLOR 6
#define DISPID_TM_CLONE 7
#define DISPID_TM_CLONEDISPATCH 8
#define DISPID_TM_CLONECOCLASS 9
#define DISPID_TM_ARRAY 10
#define DISPID_TM_VARARRAYPTR 11
#define DISPID_TM_VARIANT 12
#define DISPID_TM_VARARG 13
#define DISPID_TM_ERROR 14
#define DISPID_TM_CLONEINTERFACE 15
#define DISPID_TM_TESTDUAL 16
#define DISPID_TM_STRUCTARGS 17
#define DISPID_TM_PROP_WITH_LCID 18
#define DISPID_TM_PROP_INT 19
#define DISPID_TM_PROP_UINT 20
#define DISPID_TM_BYREF_UINT 21
#define DISPID_TM_PROP_OPT_ARG 22
#define DISPID_TM_PROP_REQ_ARG 23
#define DISPID_TM_VARCARRAY 24
#define DISPID_TM_RESTRICTED 25
#define DISPID_TM_NEG_RESTRICTED -26
#define DISPID_TM_TESTSECONDIFACE 27
#define DISPID_TM_VARARG_RUN 28
#define DISPID_TM_VARARG_REF_RUN 29
#define DISPID_TM_COCLASS 30
#define DISPID_NOA_BSTRRET 1
#define DISPID_NOA_ERROR 2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment