ole32: Add test for registered class becoming invalid when apartment is destroyed.

This commit is contained in:
Rob Shearman 2007-05-07 23:56:43 +01:00 committed by Alexandre Julliard
parent af2c349685
commit 4cbca9ac3a
1 changed files with 17 additions and 0 deletions

View File

@ -651,6 +651,7 @@ static void test_CoRegisterClassObject(void)
}; /* 5201163f-8164-4fd0-a1a2-5d5a3654d3bd */ }; /* 5201163f-8164-4fd0-a1a2-5d5a3654d3bd */
DWORD cookie; DWORD cookie;
HRESULT hr; HRESULT hr;
IClassFactory *pcf;
pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED); pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
@ -699,6 +700,22 @@ static void test_CoRegisterClassObject(void)
hr = CoRevokeClassObject(cookie); hr = CoRevokeClassObject(cookie);
ok_ole_success(hr, "CoRevokeClassObject"); ok_ole_success(hr, "CoRevokeClassObject");
/* test whether registered class becomes invalid when apartment is destroyed */
hr = CoRegisterClassObject(&CLSID_WineOOPTest, (IUnknown *)&Test_ClassFactory,
CLSCTX_INPROC_SERVER, REGCLS_SINGLEUSE, &cookie);
ok_ole_success(hr, "CoRegisterClassObject");
CoUninitialize();
pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER, NULL,
&IID_IClassFactory, (void **)&pcf);
ok(hr == REGDB_E_CLASSNOTREG, "object registered in an apartment shouldn't accessible after it is destroyed\n");
/* crashes with at least win9x DCOM! */
if (0)
hr = CoRevokeClassObject(cookie);
CoUninitialize(); CoUninitialize();
} }