comcat/tests: Skip tests if we can't create a test category.

This commit is contained in:
Alexandre Julliard 2009-01-25 17:08:20 +01:00
parent f63d950df7
commit 6996a9c83f
1 changed files with 22 additions and 19 deletions

View File

@ -31,19 +31,19 @@
#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x \n", hr)
static void register_testentry(void)
static BOOL register_testentry(void)
{
HKEY hkey,hkey2;
RegCreateKeyA(HKEY_CLASSES_ROOT,"CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}",
&hkey);
RegSetValueA(hkey,NULL,REG_SZ,"ComCat Test key",16);
RegCreateKeyA(hkey,
"Implemented Categories\\{deadcafe-0000-0000-0000-000000000000}",
&hkey2);
HKEY hkey = 0, hkey2 = 0;
DWORD ret;
ret = RegCreateKeyA(HKEY_CLASSES_ROOT,"CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}", &hkey);
if (!ret) ret = RegSetValueA(hkey,NULL,REG_SZ,"ComCat Test key",16);
if (!ret) ret = RegCreateKeyA(hkey,
"Implemented Categories\\{deadcafe-0000-0000-0000-000000000000}",
&hkey2);
RegCloseKey(hkey);
RegCloseKey(hkey2);
return !ret;
}
static void unregister_testentry(void)
@ -106,19 +106,22 @@ static void do_enum(void)
hr = IEnumGUID_Next(pIEnum,1,the_guid, &fetched);
ok (fetched == 0,"Fetched wrong number of guids %u\n",fetched);
IEnumGUID_Release(pIEnum);
register_testentry();
hr = ICatInformation_EnumClassesOfCategories(pICat, 1, the_cat, -1, NULL,
&pIEnum);
ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories");
hr = IEnumGUID_Next(pIEnum,1,the_guid, &fetched);
ok (fetched == 1,"Fetched wrong number of guids %u\n",fetched);
ok (IsEqualGUID(the_guid,&wanted_guid),"Guids do not match\n");
if (register_testentry())
{
hr = ICatInformation_EnumClassesOfCategories(pICat, 1, the_cat, -1, NULL, &pIEnum);
ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories");
hr = IEnumGUID_Next(pIEnum,1,the_guid, &fetched);
ok (fetched == 1,"Fetched wrong number of guids %u\n",fetched);
ok (IsEqualGUID(the_guid,&wanted_guid),"Guids do not match\n");
IEnumGUID_Release(pIEnum);
unregister_testentry();
}
else skip( "Could not register the test category\n" );
IEnumGUID_Release(pIEnum);
ICatInformation_Release(pICat);
unregister_testentry();
OleUninitialize();
}