Commit a1195184 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ole32: Report the implicit MTA in CoGetApartmentType().

parent 878e15e2
...@@ -5108,8 +5108,9 @@ HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) ...@@ -5108,8 +5108,9 @@ HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier) HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier)
{ {
struct oletls *info = COM_CurrentInfo(); struct oletls *info = COM_CurrentInfo();
APARTMENT *apt;
FIXME("(%p, %p): semi-stub\n", type, qualifier); TRACE("(%p, %p)\n", type, qualifier);
if (!type || !qualifier) if (!type || !qualifier)
return E_INVALIDARG; return E_INVALIDARG;
...@@ -5128,6 +5129,13 @@ HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier) ...@@ -5128,6 +5129,13 @@ HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier)
*qualifier = APTTYPEQUALIFIER_NONE; *qualifier = APTTYPEQUALIFIER_NONE;
if (!info->apt && (apt = apartment_find_mta()))
{
apartment_release(apt);
*type = APTTYPE_MTA;
*qualifier = APTTYPEQUALIFIER_IMPLICIT_MTA;
}
return info->apt ? S_OK : CO_E_NOTINITIALIZED; return info->apt ? S_OK : CO_E_NOTINITIALIZED;
} }
......
...@@ -602,9 +602,8 @@ static void test_StringFromGUID2(void) ...@@ -602,9 +602,8 @@ static void test_StringFromGUID2(void)
ok(len == 0, "len: %d (expected 0)\n", len); ok(len == 0, "len: %d (expected 0)\n", len);
} }
#define test_apt_type(t, q, t_t, t_q) _test_apt_type(t, q, t_t, t_q, __LINE__) #define test_apt_type(t, q) _test_apt_type(t, q, __LINE__)
static void _test_apt_type(APTTYPE expected_type, APTTYPEQUALIFIER expected_qualifier, BOOL todo_type, static void _test_apt_type(APTTYPE expected_type, APTTYPEQUALIFIER expected_qualifier, int line)
BOOL todo_qualifier, int line)
{ {
APTTYPEQUALIFIER qualifier = ~0u; APTTYPEQUALIFIER qualifier = ~0u;
APTTYPE type = ~0u; APTTYPE type = ~0u;
...@@ -615,9 +614,7 @@ static void _test_apt_type(APTTYPE expected_type, APTTYPEQUALIFIER expected_qual ...@@ -615,9 +614,7 @@ static void _test_apt_type(APTTYPE expected_type, APTTYPEQUALIFIER expected_qual
hr = pCoGetApartmentType(&type, &qualifier); hr = pCoGetApartmentType(&type, &qualifier);
ok_(__FILE__, line)(hr == S_OK || hr == CO_E_NOTINITIALIZED, "Unexpected return code: 0x%08x\n", hr); ok_(__FILE__, line)(hr == S_OK || hr == CO_E_NOTINITIALIZED, "Unexpected return code: 0x%08x\n", hr);
todo_wine_if(todo_type)
ok_(__FILE__, line)(type == expected_type, "Wrong apartment type %d, expected %d\n", type, expected_type); ok_(__FILE__, line)(type == expected_type, "Wrong apartment type %d, expected %d\n", type, expected_type);
todo_wine_if(todo_qualifier)
ok_(__FILE__, line)(qualifier == expected_qualifier, "Wrong apartment qualifier %d, expected %d\n", qualifier, ok_(__FILE__, line)(qualifier == expected_qualifier, "Wrong apartment qualifier %d, expected %d\n", qualifier,
expected_qualifier); expected_qualifier);
} }
...@@ -660,7 +657,7 @@ static void test_CoCreateInstance(void) ...@@ -660,7 +657,7 @@ static void test_CoCreateInstance(void)
hr = CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&pUnk); hr = CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&pUnk);
ok(hr == CO_E_NOTINITIALIZED, "CoCreateInstance should have returned CO_E_NOTINITIALIZED instead of 0x%08x\n", hr); ok(hr == CO_E_NOTINITIALIZED, "CoCreateInstance should have returned CO_E_NOTINITIALIZED instead of 0x%08x\n", hr);
test_apt_type(APTTYPE_CURRENT, APTTYPEQUALIFIER_NONE, FALSE, FALSE); test_apt_type(APTTYPE_CURRENT, APTTYPEQUALIFIER_NONE);
} }
static void test_CoGetClassObject(void) static void test_CoGetClassObject(void)
...@@ -682,7 +679,7 @@ static void test_CoGetClassObject(void) ...@@ -682,7 +679,7 @@ static void test_CoGetClassObject(void)
broken(hr == CO_E_NOTINITIALIZED), /* win9x */ broken(hr == CO_E_NOTINITIALIZED), /* win9x */
"CoGetClassObject should have returned E_INVALIDARG instead of 0x%08x\n", hr); "CoGetClassObject should have returned E_INVALIDARG instead of 0x%08x\n", hr);
test_apt_type(APTTYPE_CURRENT, APTTYPEQUALIFIER_NONE, FALSE, FALSE); test_apt_type(APTTYPE_CURRENT, APTTYPEQUALIFIER_NONE);
if (!pRegOverridePredefKey) if (!pRegOverridePredefKey)
{ {
...@@ -1797,7 +1794,7 @@ static void test_CoGetObjectContext(void) ...@@ -1797,7 +1794,7 @@ static void test_CoGetObjectContext(void)
pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED); pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
test_apt_type(APTTYPE_MAINSTA, APTTYPEQUALIFIER_NONE, FALSE, FALSE); test_apt_type(APTTYPE_MAINSTA, APTTYPEQUALIFIER_NONE);
hr = pCoGetObjectContext(&IID_IComThreadingInfo, (void **)&pComThreadingInfo); hr = pCoGetObjectContext(&IID_IComThreadingInfo, (void **)&pComThreadingInfo);
ok_ole_success(hr, "CoGetObjectContext"); ok_ole_success(hr, "CoGetObjectContext");
...@@ -1993,11 +1990,11 @@ static void test_CoGetContextToken(void) ...@@ -1993,11 +1990,11 @@ static void test_CoGetContextToken(void)
ok(hr == CO_E_NOTINITIALIZED, "Expected CO_E_NOTINITIALIZED, got 0x%08x\n", hr); ok(hr == CO_E_NOTINITIALIZED, "Expected CO_E_NOTINITIALIZED, got 0x%08x\n", hr);
ok(token == 0xdeadbeef, "Expected 0, got 0x%lx\n", token); ok(token == 0xdeadbeef, "Expected 0, got 0x%lx\n", token);
test_apt_type(APTTYPE_CURRENT, APTTYPEQUALIFIER_NONE, FALSE, FALSE); test_apt_type(APTTYPE_CURRENT, APTTYPEQUALIFIER_NONE);
CoInitialize(NULL); CoInitialize(NULL);
test_apt_type(APTTYPE_MAINSTA, APTTYPEQUALIFIER_NONE, FALSE, FALSE); test_apt_type(APTTYPE_MAINSTA, APTTYPEQUALIFIER_NONE);
hr = pCoGetContextToken(NULL); hr = pCoGetContextToken(NULL);
ok(hr == E_POINTER, "Expected E_POINTER, got 0x%08x\n", hr); ok(hr == E_POINTER, "Expected E_POINTER, got 0x%08x\n", hr);
...@@ -3705,7 +3702,7 @@ static DWORD CALLBACK implicit_mta_proc(void *param) ...@@ -3705,7 +3702,7 @@ static DWORD CALLBACK implicit_mta_proc(void *param)
CLSID clsid; CLSID clsid;
HRESULT hr; HRESULT hr;
test_apt_type(APTTYPE_MTA, APTTYPEQUALIFIER_IMPLICIT_MTA, TRUE, TRUE); test_apt_type(APTTYPE_MTA, APTTYPEQUALIFIER_IMPLICIT_MTA);
hr = CoCreateInstance(&CLSID_InternetZoneManager, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk); hr = CoCreateInstance(&CLSID_InternetZoneManager, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk);
ok_ole_success(hr, "CoCreateInstance"); ok_ole_success(hr, "CoCreateInstance");
......
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