ReactOS 0.4.16-dev-2320-ge1853c6
roapi.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winstring.h"
#include "initguid.h"
#include "roapi.h"
#include "wine/test.h"
Include dependency graph for roapi.c:

Go to the source code of this file.

Classes

struct  unk_impl
 
struct  test_RoGetAgileReference_thread_param
 

Macros

#define COBJMACROS
 
#define EXPECT_REF(obj, ref)   _expect_ref((IUnknown*)obj, ref, __LINE__)
 
#define check_thread_apartment(a)   check_thread_apartment_(__LINE__, FALSE, a)
 
#define check_thread_apartment_broken(a)   check_thread_apartment_(__LINE__, TRUE, a)
 

Functions

static void _expect_ref (IUnknown *obj, ULONG ref, int line)
 
static void flush_events (void)
 
static void load_resource (const WCHAR *filename)
 
static void test_ActivationFactories (void)
 
static DWORD WINAPI check_apartment_thread (void *dummy)
 
static void check_thread_apartment_ (unsigned int line, BOOL broken_fail, HRESULT expected_hr_thread)
 
static DWORD WINAPI mta_init_thread (void *dummy)
 
static DWORD WINAPI mta_init_implicit_thread (void *dummy)
 
static void test_implicit_mta (void)
 
static struct unk_implimpl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI unk_QueryInterface (IUnknown *iface, REFIID riid, void **ppv)
 
static HRESULT WINAPI unk_no_marshal_QueryInterface (IUnknown *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI unk_AddRef (IUnknown *iface)
 
static ULONG WINAPI unk_Release (IUnknown *iface)
 
static DWORD CALLBACK test_RoGetAgileReference_thread_proc (void *arg)
 
static void test_RoGetAgileReference (void)
 
 START_TEST (roapi)
 

Variables

static APTTYPE check_thread_apttype
 
static APTTYPEQUALIFIER check_thread_aptqualifier
 
static HRESULT check_thread_hr
 
static HANDLE mta_init_thread_init_done_event
 
static HANDLE mta_init_thread_done_event
 
static const IUnknownVtbl unk_vtbl
 
static const IUnknownVtbl unk_no_marshal_vtbl
 

Macro Definition Documentation

◆ check_thread_apartment

#define check_thread_apartment (   a)    check_thread_apartment_(__LINE__, FALSE, a)

Definition at line 157 of file roapi.c.

◆ check_thread_apartment_broken

#define check_thread_apartment_broken (   a)    check_thread_apartment_(__LINE__, TRUE, a)

Definition at line 158 of file roapi.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 18 of file roapi.c.

◆ EXPECT_REF

#define EXPECT_REF (   obj,
  ref 
)    _expect_ref((IUnknown*)obj, ref, __LINE__)

Definition at line 31 of file roapi.c.

Function Documentation

◆ _expect_ref()

static void _expect_ref ( IUnknown obj,
ULONG  ref,
int  line 
)
static

Definition at line 32 of file roapi.c.

33{
34 ULONG rc;
35 IUnknown_AddRef(obj);
36 rc = IUnknown_Release(obj);
37 ok_(__FILE__,line)(rc == ref, "expected refcount %ld, got %ld\n", ref, rc);
38}
#define ok_(x1, x2)
Definition: atltest.h:61
Definition: parser.c:49
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ check_apartment_thread()

static DWORD WINAPI check_apartment_thread ( void dummy)
static

Definition at line 149 of file roapi.c.

150{
151 check_thread_apttype = 0xdeadbeef;
152 check_thread_aptqualifier = 0xdeadbeef;
154 return 0;
155}
HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier)
Definition: combase.c:2928
static HRESULT check_thread_hr
Definition: roapi.c:147
static APTTYPEQUALIFIER check_thread_aptqualifier
Definition: roapi.c:146
static APTTYPE check_thread_apttype
Definition: roapi.c:145

Referenced by check_thread_apartment_().

◆ check_thread_apartment_()

static void check_thread_apartment_ ( unsigned int  line,
BOOL  broken_fail,
HRESULT  expected_hr_thread 
)
static

Definition at line 159 of file roapi.c.

160{
162
163 check_thread_hr = 0xdeadbeef;
167 ok_(__FILE__, line)(check_thread_hr == expected_hr_thread
168 || broken(broken_fail && expected_hr_thread == S_OK && check_thread_hr == CO_E_NOTINITIALIZED),
169 "got %#lx, expected %#lx.\n", check_thread_hr, expected_hr_thread);
171 {
172 ok_(__FILE__, line)(check_thread_apttype == APTTYPE_MTA, "got %d.\n", check_thread_apttype);
174 }
175}
#define CO_E_NOTINITIALIZED
#define broken(x)
Definition: atltest.h:178
static HANDLE thread
Definition: service.c:33
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define INFINITE
Definition: serial.h:102
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static DWORD WINAPI check_apartment_thread(void *dummy)
Definition: roapi.c:149
enum APTTYPE_MTA
@ APTTYPEQUALIFIER_IMPLICIT_MTA
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82

◆ flush_events()

static void flush_events ( void  )
static

Definition at line 40 of file roapi.c.

41{
42 int diff = 200;
43 DWORD time;
44 MSG msg;
45
46 time = GetTickCount() + diff;
47 while (diff > 0)
48 {
50 break;
51 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
53 diff = time - GetTickCount();
54 }
55}
#define msg(x)
Definition: auth_time.c:54
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define FALSE
Definition: types.h:117
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
unsigned long DWORD
Definition: ntddk_ex.h:95
__u16 time
Definition: mkdosfs.c:8
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define QS_ALLINPUT
Definition: winuser.h:914
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define PM_REMOVE
Definition: winuser.h:1207
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)

Referenced by test_RoGetAgileReference().

◆ impl_from_IUnknown()

static struct unk_impl * impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 346 of file roapi.c.

347{
348 return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface);
349}
Definition: api.c:544
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by unk_AddRef(), and unk_Release().

◆ load_resource()

static void load_resource ( const WCHAR filename)
static

Definition at line 57 of file roapi.c.

58{
59 DWORD written;
61 HRSRC res;
62 void *ptr;
63
65 ok(file != INVALID_HANDLE_VALUE, "failed to create %s, error %lu\n", debugstr_w(filename), GetLastError());
66
67 res = FindResourceW(NULL, filename, L"TESTDLL");
68 ok(res != 0, "couldn't find resource\n");
71 ok(written == SizeofResource(GetModuleHandleW(NULL), res), "couldn't write resource\n");
73}
#define ok(value,...)
Definition: atltest.h:57
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
#define L(x)
Definition: resources.c:13
GLuint res
Definition: glext.h:9613
const char * filename
Definition: ioapi.h:137
#define debugstr_w
Definition: kernel32.h:32
#define CREATE_ALWAYS
Definition: disk.h:72
static PVOID ptr
Definition: dispmode.c:27
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: fci.c:127
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ mta_init_implicit_thread()

static DWORD WINAPI mta_init_implicit_thread ( void dummy)
static

Definition at line 192 of file roapi.c.

193{
195 HSTRING str;
196 HRESULT hr;
197
199 ok(hr == S_OK, "got %#lx.\n", hr);
200
201 hr = WindowsCreateString(L"Does.Not.Exist", ARRAY_SIZE(L"Does.Not.Exist") - 1, &str);
202 ok(hr == S_OK, "got %#lx.\n", hr);
203 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
204 ok(hr == REGDB_E_CLASSNOTREG, "got %#lx.\n", hr);
206
209
210 /* No CoUninitialize(), testing cleanup on thread exit. */
211 return 0;
212}
#define ARRAY_SIZE(A)
Definition: main.h:20
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(void *reserved, DWORD model)
Definition: combase.c:2803
HRESULT WINAPI DECLSPEC_HOTPATCH RoGetActivationFactory(HSTRING classid, REFIID iid, void **class_factory)
Definition: roapi.c:146
HRESULT WINAPI WindowsCreateString(LPCWSTR ptr, UINT32 len, HSTRING *out)
Definition: string.c:87
HRESULT WINAPI WindowsDeleteString(HSTRING str)
Definition: string.c:143
static HANDLE mta_init_thread_init_done_event
Definition: roapi.c:177
static HANDLE mta_init_thread_done_event
Definition: roapi.c:177
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:279
const WCHAR * str
HRESULT hr
Definition: shlfolder.c:183
Definition: main.c:439
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:3801

Referenced by test_implicit_mta().

◆ mta_init_thread()

static DWORD WINAPI mta_init_thread ( void dummy)
static

Definition at line 179 of file roapi.c.

180{
181 HRESULT hr;
182
184 ok(hr == S_OK, "got %#lx.\n", hr);
186
189 return 0;
190}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
@ COINIT_MULTITHREADED
Definition: objbase.h:280

Referenced by test_implicit_mta().

◆ START_TEST()

START_TEST ( roapi  )

Definition at line 540 of file roapi.c.

541{
542 BOOL ret;
543
544 load_resource(L"wine.combase.test.dll");
545
549
550 SetLastError(0xdeadbeef);
551 ret = DeleteFileW(L"wine.combase.test.dll");
553 ok(ret, "Failed to delete file, error %lu\n", GetLastError());
554}
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
#define todo_wine_if(is_todo)
Definition: minitest.h:81
static void load_resource(const WCHAR *filename)
Definition: roapi.c:57
static void test_implicit_mta(void)
Definition: roapi.c:214
static void test_RoGetAgileReference(void)
Definition: roapi.c:445
static void test_ActivationFactories(void)
Definition: roapi.c:75

◆ test_ActivationFactories()

static void test_ActivationFactories ( void  )
static

Definition at line 75 of file roapi.c.

76{
77 HRESULT hr;
80 IInspectable *inspect = NULL;
81 ULONG ref;
82
83 hr = WindowsCreateString(L"Windows.Data.Xml.Dom.XmlDocument",
84 ARRAY_SIZE(L"Windows.Data.Xml.Dom.XmlDocument") - 1, &str);
85 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
86
87 hr = WindowsCreateString(L"Does.Not.Exist", ARRAY_SIZE(L"Does.Not.Exist") - 1, &str2);
88 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
89
91 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
92
93 hr = RoGetActivationFactory(str2, &IID_IActivationFactory, (void **)&factory);
94 ok(hr == REGDB_E_CLASSNOTREG, "Unexpected hr %#lx.\n", hr);
95
96 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
97 todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
98 if(factory)
99 IActivationFactory_Release(factory);
100
101 hr = RoActivateInstance(str2, &inspect);
102 ok(hr == REGDB_E_CLASSNOTREG, "Unexpected hr %#lx.\n", hr);
103
104 hr = RoActivateInstance(str, &inspect);
105 todo_wine ok(hr == S_OK, "UNexpected hr %#lx.\n", hr);
106 if(inspect)
107 IInspectable_Release(inspect);
108
111
112 hr = WindowsCreateString(L"Wine.Test.Missing", ARRAY_SIZE(L"Wine.Test.Missing") - 1, &str);
113 ok(hr == S_OK, "WindowsCreateString returned %#lx.\n", hr);
114 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
115 ok(hr == REGDB_E_CLASSNOTREG, "RoGetActivationFactory returned %#lx.\n", hr);
116 ok(factory == NULL, "got factory %p.\n", factory);
118 hr = WindowsCreateString(L"Wine.Test.Class", ARRAY_SIZE(L"Wine.Test.Class") - 1, &str);
119 ok(hr == S_OK, "WindowsCreateString returned %#lx.\n", hr);
120 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
122 ok(hr == E_NOTIMPL || broken(hr == REGDB_E_CLASSNOTREG) /* <= w1064v1809 */,
123 "RoGetActivationFactory returned %#lx.\n", hr);
125 ok(factory == NULL, "got factory %p.\n", factory);
126 if (factory) IActivationFactory_Release(factory);
128 hr = WindowsCreateString(L"Wine.Test.Trusted", ARRAY_SIZE(L"Wine.Test.Trusted") - 1, &str);
129 ok(hr == S_OK, "WindowsCreateString returned %#lx.\n", hr);
130 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
131 ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG) /* <= w1064v1809 */,
132 "RoGetActivationFactory returned %#lx.\n", hr);
133 if (hr == REGDB_E_CLASSNOTREG)
134 ok(!factory, "got factory %p.\n", factory);
135 else
136 ok(!!factory, "got factory %p.\n", factory);
137 if (!factory) ref = 0;
138 else ref = IActivationFactory_Release(factory);
139 ok(ref == 0, "Release returned %lu\n", ref);
141
143}
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT WINAPI RoActivateInstance(HSTRING classid, IInspectable **instance)
Definition: roapi.c:219
HRESULT WINAPI RoInitialize(RO_INIT_TYPE type)
Definition: roapi.c:123
void WINAPI RoUninitialize(void)
Definition: roapi.c:138
#define todo_wine
Definition: minitest.h:80
@ RO_INIT_MULTITHREADED
Definition: roapi.h:27
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35

Referenced by START_TEST().

◆ test_implicit_mta()

static void test_implicit_mta ( void  )
static

Definition at line 214 of file roapi.c.

215{
216 static const struct
217 {
218 BOOL ro_init;
219 BOOL mta;
220 }
221 tests[] =
222 {
223 { FALSE, FALSE },
224 { FALSE, TRUE },
225 { TRUE, FALSE },
226 { TRUE, TRUE },
227 };
228 APTTYPEQUALIFIER aptqualifier;
230 APTTYPE apttype;
231 unsigned int i;
233 HSTRING str;
234 HRESULT hr;
235
236 hr = WindowsCreateString(L"Does.Not.Exist", ARRAY_SIZE(L"Does.Not.Exist") - 1, &str);
237 ok(hr == S_OK, "got %#lx.\n", hr);
238 /* RoGetActivationFactory doesn't implicitly initialize COM. */
239 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
240 ok(hr == CO_E_NOTINITIALIZED, "got %#lx.\n", hr);
241
243
244 /* RoGetActivationFactory initializes implicit MTA. */
245 for (i = 0; i < ARRAY_SIZE(tests); ++i)
246 {
247 winetest_push_context("test %u", i);
248 if (tests[i].ro_init)
250 else
252 ok(hr == S_OK, "got %#lx.\n", hr);
254 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
255 ok(hr == REGDB_E_CLASSNOTREG, "got %#lx.\n", hr);
256 check_thread_apartment_broken(S_OK); /* Broken on Win8. */
257 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
258 ok(hr == REGDB_E_CLASSNOTREG, "got %#lx.\n", hr);
259 check_thread_apartment_broken(S_OK); /* Broken on Win8. */
260 if (tests[i].ro_init)
262 else
266 }
267
270
271 /* RoGetActivationFactory references implicit MTA in a current thread
272 * even if implicit MTA was already initialized: check with STA init
273 * after RoGetActivationFactory(). */
275 ok(!!thread, "failed.\n");
278
279 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
280 ok(hr == REGDB_E_CLASSNOTREG, "got %#lx.\n", hr);
282
283 hr = CoGetApartmentType(&apttype, &aptqualifier);
284 ok(hr == S_OK, "got %#lx.\n", hr);
285 ok(apttype == APTTYPE_MTA, "got %d.\n", apttype);
286 ok(aptqualifier == APTTYPEQUALIFIER_IMPLICIT_MTA, "got %d.\n", aptqualifier);
287
289 ok(hr == S_OK, "got %#lx.\n", hr);
290
291 hr = CoGetApartmentType(&apttype, &aptqualifier);
292 ok(hr == S_OK, "got %#lx.\n", hr);
293 ok(apttype == APTTYPE_MAINSTA, "got %d.\n", apttype);
294 ok(aptqualifier == APTTYPEQUALIFIER_NONE, "got %d.\n", aptqualifier);
295
299 check_thread_apartment_broken(S_OK); /* Broken on Win8. */
302
303 /* RoGetActivationFactory references implicit MTA in a current thread
304 * even if implicit MTA was already initialized: check with STA init
305 * before RoGetActivationFactory(). */
307 ok(!!thread, "failed.\n");
310
312 ok(hr == S_OK, "got %#lx.\n", hr);
313
314 hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
315 ok(hr == REGDB_E_CLASSNOTREG, "got %#lx.\n", hr);
317
321 check_thread_apartment_broken(S_OK); /* Broken on Win8. */
324
325 /* Test implicit MTA apartment thread exit. */
327 ok(!!thread, "failed.\n");
329 check_thread_apartment_broken(S_OK); /* Broken on Win8. */
334
338}
static struct apartment * mta
Definition: apartment.c:50
#define TRUE
Definition: types.h:120
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
static struct test_info tests[]
static DWORD WINAPI mta_init_implicit_thread(void *dummy)
Definition: roapi.c:192
#define check_thread_apartment_broken(a)
Definition: roapi.c:158
static DWORD WINAPI mta_init_thread(void *dummy)
Definition: roapi.c:179
#define check_thread_apartment(a)
Definition: roapi.c:157
@ APTTYPEQUALIFIER_NONE
enum _APTTYPEQUALIFIER APTTYPEQUALIFIER
@ RO_INIT_SINGLETHREADED
Definition: roapi.h:26
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587

Referenced by START_TEST().

◆ test_RoGetAgileReference()

static void test_RoGetAgileReference ( void  )
static

Definition at line 445 of file roapi.c.

446{
448 struct unk_impl unk_no_marshal_obj = {{&unk_no_marshal_vtbl}, 1};
449 struct unk_impl unk_obj = {{&unk_vtbl}, 1};
452 RO_INIT_TYPE from_type, to_type;
453 IUnknown *unknown, *unknown2;
454 IAgileObject *agile_object;
456 HRESULT hr;
457 DWORD ret;
458
460 {
461 for (from_type = RO_INIT_SINGLETHREADED; from_type <= RO_INIT_MULTITHREADED; from_type++)
462 {
463 winetest_push_context("%d %d", option, from_type);
464
466 ok(hr == CO_E_NOTINITIALIZED, "Got unexpected hr %#lx.\n", hr);
467
468 RoInitialize(from_type);
469
471 EXPECT_REF(&unk_obj, 1);
472
473 /* Invalid option */
475 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
476
477 /* Non-existent interface for the object */
478 hr = RoGetAgileReference(option, &IID_IActivationFactory, &unk_obj.IUnknown_iface, &agile_reference);
479 ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
480
481 /* Objects that implements INoMarshal */
483 ok(hr == CO_E_NOT_SUPPORTED, "Got unexpected hr %#lx.\n", hr);
484
485 /* Create agile reference object */
487 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
488 ok(!!agile_reference, "Got unexpected agile_reference.\n");
490 EXPECT_REF(&unk_obj, 2);
491
492 /* Check the created agile reference object has IAgileObject */
493 hr = IAgileReference_QueryInterface(agile_reference, &IID_IAgileObject, (void **)&agile_object);
494 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
495 IAgileObject_Release(agile_object);
496
497 /* Resolve once */
498 unknown = NULL;
499 hr = IAgileReference_Resolve(agile_reference, &IID_IUnknown, (void **)&unknown);
500 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
501 ok(!!unknown, "Expected pointer not NULL.\n");
502 ok(unknown == &unk_obj.IUnknown_iface, "Expected the same object.\n");
504 EXPECT_REF(&unk_obj, 3);
505
506 /* Resolve twice */
507 unknown2 = NULL;
508 hr = IAgileReference_Resolve(agile_reference, &IID_IUnknown, (void **)&unknown2);
509 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
510 ok(!!unknown2, "Expected pointer not NULL.\n");
511 ok(unknown2 == &unk_obj.IUnknown_iface, "Expected the same object.\n");
513 EXPECT_REF(&unk_obj, 4);
514
515 /* Resolve in another apartment */
516 for (to_type = RO_INIT_SINGLETHREADED; to_type <= RO_INIT_MULTITHREADED; to_type++)
517 {
518 param.option = option;
519 param.from_type = from_type;
520 param.to_type = to_type;
521 param.agile_reference = agile_reference;
522 param.unk_obj = &unk_obj.IUnknown_iface;
524 flush_events();
526 ok(!ret, "WaitForSingleObject failed, error %ld.\n", GetLastError());
527 }
528
529 IUnknown_Release(unknown2);
530 IUnknown_Release(unknown);
531 IAgileReference_Release(agile_reference);
532 EXPECT_REF(&unk_obj, 1);
533
536 }
537 }
538}
const GUID IID_IUnknown
AgileReferenceOptions
Definition: combaseapi.h:48
@ AGILEREFERENCE_DEFAULT
Definition: combaseapi.h:49
@ AGILEREFERENCE_DELAYEDMARSHAL
Definition: combaseapi.h:50
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI RoGetAgileReference(enum AgileReferenceOptions option, REFIID riid, IUnknown *obj, IAgileReference **agile_reference)
Definition: roapi.c:360
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
GLfloat param
Definition: glext.h:5796
static DWORD CALLBACK test_RoGetAgileReference_thread_proc(void *arg)
Definition: roapi.c:411
static const IUnknownVtbl unk_no_marshal_vtbl
Definition: roapi.c:395
static void flush_events(void)
Definition: roapi.c:40
#define EXPECT_REF(obj, ref)
Definition: roapi.c:31
static const IUnknownVtbl unk_vtbl
Definition: roapi.c:388
RO_INIT_TYPE
Definition: roapi.h:25
Definition: getopt.h:109
IUnknown IUnknown_iface
Definition: api.c:545
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CO_E_NOT_SUPPORTED
Definition: winerror.h:3510

Referenced by START_TEST().

◆ test_RoGetAgileReference_thread_proc()

static DWORD CALLBACK test_RoGetAgileReference_thread_proc ( void arg)
static

Definition at line 411 of file roapi.c.

412{
415 HRESULT hr;
416
417 winetest_push_context("%d %d %d", param->option, param->from_type, param->to_type);
418
419 RoInitialize(param->to_type);
420
421 unknown = NULL;
422 hr = IAgileReference_Resolve(param->agile_reference, &IID_IUnknown, (void **)&unknown);
423 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
424 ok(!!unknown, "Expected pointer not NULL.\n");
425 if (param->from_type == RO_INIT_MULTITHREADED && param->to_type == RO_INIT_MULTITHREADED)
426 {
427 ok(unknown == param->unk_obj, "Expected the same object.\n");
429 EXPECT_REF(param->unk_obj, param->option == AGILEREFERENCE_DEFAULT ? 5 : 6);
430 }
431 else
432 {
433 ok(unknown != param->unk_obj, "Expected a different object pointer.\n");
435 EXPECT_REF(param->unk_obj, param->option == AGILEREFERENCE_DEFAULT ? 4 : 5);
437 }
438 IUnknown_Release(unknown);
439
442 return 0;
443}

Referenced by test_RoGetAgileReference().

◆ unk_AddRef()

static ULONG WINAPI unk_AddRef ( IUnknown iface)
static

Definition at line 376 of file roapi.c.

377{
378 struct unk_impl *impl = impl_from_IUnknown(iface);
379 return InterlockedIncrement(&impl->ref);
380}
#define InterlockedIncrement
Definition: armddk.h:53
static struct unk_impl * impl_from_IUnknown(IUnknown *iface)
Definition: roapi.c:346
LONG ref
Definition: api.c:546

◆ unk_no_marshal_QueryInterface()

static HRESULT WINAPI unk_no_marshal_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 363 of file roapi.c.

364{
366 || IsEqualGUID(riid, &IID_INoMarshal))
367 {
368 *ppv = iface;
369 IUnknown_AddRef(iface);
370 return S_OK;
371 }
372
373 return E_NOINTERFACE;
374}
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

◆ unk_QueryInterface()

static HRESULT WINAPI unk_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 351 of file roapi.c.

352{
354 {
355 *ppv = iface;
356 IUnknown_AddRef(iface);
357 return S_OK;
358 }
359
360 return E_NOINTERFACE;
361}

◆ unk_Release()

static ULONG WINAPI unk_Release ( IUnknown iface)
static

Definition at line 382 of file roapi.c.

383{
384 struct unk_impl *impl = impl_from_IUnknown(iface);
385 return InterlockedDecrement(&impl->ref);
386}
#define InterlockedDecrement
Definition: armddk.h:52

Variable Documentation

◆ check_thread_aptqualifier

APTTYPEQUALIFIER check_thread_aptqualifier
static

Definition at line 146 of file roapi.c.

Referenced by check_apartment_thread(), and check_thread_apartment_().

◆ check_thread_apttype

APTTYPE check_thread_apttype
static

Definition at line 145 of file roapi.c.

Referenced by check_apartment_thread(), and check_thread_apartment_().

◆ check_thread_hr

HRESULT check_thread_hr
static

Definition at line 147 of file roapi.c.

Referenced by check_apartment_thread(), and check_thread_apartment_().

◆ mta_init_thread_done_event

HANDLE mta_init_thread_done_event
static

Definition at line 177 of file roapi.c.

Referenced by mta_init_implicit_thread(), mta_init_thread(), and test_implicit_mta().

◆ mta_init_thread_init_done_event

HANDLE mta_init_thread_init_done_event
static

Definition at line 177 of file roapi.c.

Referenced by mta_init_implicit_thread(), mta_init_thread(), and test_implicit_mta().

◆ unk_no_marshal_vtbl

const IUnknownVtbl unk_no_marshal_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI unk_no_marshal_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: roapi.c:363
static ULONG WINAPI unk_Release(IUnknown *iface)
Definition: roapi.c:382
static ULONG WINAPI unk_AddRef(IUnknown *iface)
Definition: roapi.c:376

Definition at line 395 of file roapi.c.

Referenced by test_RoGetAgileReference().

◆ unk_vtbl

const IUnknownVtbl unk_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: roapi.c:351

Definition at line 388 of file roapi.c.

Referenced by test_RoGetAgileReference().