From: Vibhav Pant vibhavp@gmail.com
--- dlls/combase/tests/roapi.c | 66 +++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-)
diff --git a/dlls/combase/tests/roapi.c b/dlls/combase/tests/roapi.c index fb40dc60f5a..a3337ed9b08 100644 --- a/dlls/combase/tests/roapi.c +++ b/dlls/combase/tests/roapi.c @@ -27,6 +27,9 @@ #include "roapi.h" #include "roerrorapi.h"
+#define WIDL_using_Windows_Foundation_Metadata +#include "windows.foundation.metadata.h" + #include "wine/test.h"
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__) @@ -427,6 +430,7 @@ struct test_RoGetAgileReference_thread_param RO_INIT_TYPE to_type; IAgileReference *agile_reference; IUnknown *unk_obj; + const GUID *iid; BOOLEAN obj_is_agile; };
@@ -441,7 +445,7 @@ static DWORD CALLBACK test_RoGetAgileReference_thread_proc(void *arg) RoInitialize(param->to_type);
unknown = NULL; - hr = IAgileReference_Resolve(param->agile_reference, &IID_IUnknown, (void **)&unknown); + hr = IAgileReference_Resolve(param->agile_reference, param->iid, (void **)&unknown); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(!!unknown, "Expected pointer not NULL.\n"); if (param->obj_is_agile) @@ -473,19 +477,26 @@ static DWORD CALLBACK test_RoGetAgileReference_thread_proc(void *arg)
static void test_RoGetAgileReference(void) { + static const WCHAR *class_name = RuntimeClass_Windows_Foundation_Metadata_ApiInformation; struct test_RoGetAgileReference_thread_param param; struct unk_impl unk_no_marshal_obj = {{&unk_no_marshal_vtbl}, 1}; struct unk_impl unk_obj = {{&unk_vtbl}, 1}; struct unk_impl unk_agile_obj = {{&unk_agile_vtbl}, 1}; + IApiInformationStatics *statics, *statics2; enum AgileReferenceOptions option; IAgileReference *agile_reference; RO_INIT_TYPE from_type, to_type; IUnknown *unknown, *unknown2; IAgileObject *agile_object; HANDLE thread; + HSTRING str; HRESULT hr; DWORD ret;
+ /* A known agile ActivationFactory */ + hr = WindowsCreateString(class_name, wcslen(class_name), &str); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + for (option = AGILEREFERENCE_DEFAULT; option <= AGILEREFERENCE_DELAYEDMARSHAL; option++) { for (from_type = RO_INIT_SINGLETHREADED; from_type <= RO_INIT_MULTITHREADED; from_type++) @@ -551,6 +562,7 @@ static void test_RoGetAgileReference(void) param.agile_reference = agile_reference; param.unk_obj = &unk_obj.IUnknown_iface; param.obj_is_agile = FALSE; + param.iid = &IID_IUnknown; thread = CreateThread(NULL, 0, test_RoGetAgileReference_thread_proc, ¶m, 0, NULL); flush_events(); ret = WaitForSingleObject(thread, 100); @@ -583,6 +595,7 @@ static void test_RoGetAgileReference(void) param.to_type = to_type; param.agile_reference = agile_reference; param.unk_obj = &unk_agile_obj.IUnknown_iface; + param.iid = &IID_IUnknown; param.obj_is_agile = TRUE; thread = CreateThread(NULL, 0, test_RoGetAgileReference_thread_proc, ¶m, 0, NULL); flush_events(); @@ -594,10 +607,61 @@ static void test_RoGetAgileReference(void) IAgileReference_Release(agile_reference); EXPECT_REF(&unk_obj, 1);
+ /* Test marshaling WinRT interfaces. */ + hr = RoGetActivationFactory(str, &IID_IApiInformationStatics, (void **)&statics); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + agile_reference = NULL; + hr = RoGetAgileReference(option, &IID_IApiInformationStatics, (IUnknown *)statics, &agile_reference); + todo_wine_if(option == AGILEREFERENCE_DEFAULT) + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine_if(option == AGILEREFERENCE_DEFAULT) + ok(!!agile_reference, "Got unexpected agile_reference.\n"); + todo_wine_if(option == AGILEREFERENCE_DEFAULT) + EXPECT_REF(statics, 3); + + if (SUCCEEDED(hr)) + { + statics2 = NULL; + hr = IAgileReference_Resolve(agile_reference, &IID_IApiInformationStatics, (void **)&statics2); + todo_wine + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + todo_wine + ok(!!statics2, "Expected pointer not NULL.\n"); + todo_wine + ok(statics2 == statics, "Expected the same object.\n"); + todo_wine + EXPECT_REF(statics, 4); + + if (SUCCEEDED(hr)) + { + IApiInformationStatics_Release( statics2 ); + for (to_type = RO_INIT_SINGLETHREADED; to_type <= RO_INIT_MULTITHREADED; to_type++) + { + param.option = option; + param.from_type = from_type; + param.to_type = to_type; + param.agile_reference = agile_reference; + param.unk_obj = (IUnknown *)statics; + param.obj_is_agile = TRUE; + param.iid = &IID_IApiInformationStatics; + thread = CreateThread(NULL, 0, test_RoGetAgileReference_thread_proc, ¶m, 0, NULL); + flush_events(); + ret = WaitForSingleObject(thread, 100); + ok(!ret, "WaitForSingleObject failed, error %ld.\n", GetLastError()); + } + } + IAgileReference_Release( agile_reference ); + } + EXPECT_REF(statics, 2); + IApiInformationStatics_Release( statics ); + + RoUninitialize(); winetest_pop_context(); } } + + WindowsDeleteString(str); }
static void test_RoGetErrorReportingFlags(void)