[PATCH] mscoree: Add a test to show that first non-default domain is not made current automatically.

Nikolay Sivov nsivov at codeweavers.com
Tue Aug 20 12:53:19 CDT 2019


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/mscoree/corruntimehost.c | 22 ++++++++++++++++++++--
 dlls/mscoree/tests/mscoree.c  | 18 +++++++++++++++++-
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c
index 2ccc7bc4f5..d2e4bc8496 100644
--- a/dlls/mscoree/corruntimehost.c
+++ b/dlls/mscoree/corruntimehost.c
@@ -793,8 +793,26 @@ static HRESULT WINAPI corruntimehost_CurrentDomain(
     ICorRuntimeHost* iface,
     IUnknown **appDomain)
 {
-    FIXME("stub %p\n", iface);
-    return E_NOTIMPL;
+    RuntimeHost *This = impl_from_ICorRuntimeHost(iface);
+    MonoDomain *prev_domain, *default_domain;
+    HRESULT hr;
+
+    TRACE("(%p, %p)\n", iface, appDomain);
+
+    if (!is_mono_started)
+        return E_FAIL;
+
+    hr = RuntimeHost_GetDefaultDomain(This, NULL, &default_domain);
+    if (FAILED(hr))
+        return hr;
+
+    prev_domain = domain_attach(default_domain);
+
+    hr = RuntimeHost_GetIUnknownForDomain(This, default_domain, appDomain);
+
+    domain_restore(prev_domain);
+
+    return hr;
 }
 
 static const struct ICorRuntimeHostVtbl corruntimehost_vtbl =
diff --git a/dlls/mscoree/tests/mscoree.c b/dlls/mscoree/tests/mscoree.c
index bb2a17046b..82dbb3066b 100644
--- a/dlls/mscoree/tests/mscoree.c
+++ b/dlls/mscoree/tests/mscoree.c
@@ -540,7 +540,7 @@ static void test_createdomain(void)
     ICLRRuntimeInfo *runtimeinfo;
     ICorRuntimeHost *runtimehost;
     IUnknown *domain, *defaultdomain_unk, *defaultdomain, *newdomain_unk, *newdomain, *domainsetup,
-        *newdomain2_unk, *newdomain2;
+        *newdomain2_unk, *newdomain2, *current_domain;
     HRESULT hr;
 
     if (!pCLRCreateInstance)
@@ -559,12 +559,20 @@ static void test_createdomain(void)
         (void **)&runtimehost);
     ok(SUCCEEDED(hr), "ICLRRuntimeInfo::GetInterface failed, hr=%#.8x\n", hr);
 
+    hr = ICorRuntimeHost_CurrentDomain(runtimehost, &current_domain);
+    ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
+
     hr = ICorRuntimeHost_Start(runtimehost);
     ok(SUCCEEDED(hr), "ICorRuntimeHost::Start failed, hr=%#.8x\n", hr);
 
     hr = ICorRuntimeHost_GetDefaultDomain(runtimehost, &domain);
     ok(SUCCEEDED(hr), "ICorRuntimeHost::GetDefaultDomain failed, hr=%#.8x\n", hr);
 
+    hr = ICorRuntimeHost_CurrentDomain(runtimehost, &current_domain);
+    ok(SUCCEEDED(hr), "Failed to get current domain, hr %#x.\n", hr);
+    ok(current_domain == domain, "Unexpected domain %p, %p.\n", current_domain, domain);
+    IUnknown_Release(current_domain);
+
     hr = IUnknown_QueryInterface(domain, &IID_IUnknown, (void **)&defaultdomain_unk);
     ok(SUCCEEDED(hr), "COM object doesn't support IUnknown?!\n");
 
@@ -584,6 +592,14 @@ static void test_createdomain(void)
 
     IUnknown_Release(domain);
 
+    hr = ICorRuntimeHost_GetDefaultDomain(runtimehost, &domain);
+    ok(SUCCEEDED(hr), "ICorRuntimeHost::GetDefaultDomain failed, hr=%#.8x\n", hr);
+    hr = ICorRuntimeHost_CurrentDomain(runtimehost, &current_domain);
+    ok(SUCCEEDED(hr), "Failed to get current domain, hr %#x.\n", hr);
+    ok(current_domain == domain, "Unexpected domain %p, %p.\n", current_domain, domain);
+    IUnknown_Release(current_domain);
+    IUnknown_Release(domain);
+
     ok(defaultdomain_unk != newdomain_unk, "New and default domain objects are the same\n");
 
     hr = ICorRuntimeHost_CreateDomainSetup(runtimehost, &domainsetup);
-- 
2.23.0.rc1




More information about the wine-devel mailing list