2 * tests for comcat functions
4 * Copyright 2006 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/test.h"
31 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x \n", hr)
33 static void register_testentry(void)
37 RegCreateKeyA(HKEY_CLASSES_ROOT,"CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}",
39 RegSetValueA(hkey,NULL,REG_SZ,"ComCat Test key",16);
41 "Implemented Categories\\{deadcafe-0000-0000-0000-000000000000}",
48 static void unregister_testentry(void)
50 RegDeleteKeyA(HKEY_CLASSES_ROOT,
51 "CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}\\Implemented Categories\\{deadcafe-0000-0000-0000-000000000000}");
52 RegDeleteKeyA(HKEY_CLASSES_ROOT,
53 "CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}\\Implemented Categories");
54 RegDeleteKeyA(HKEY_CLASSES_ROOT,
55 "CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}");
58 static void do_enum(void)
61 REFCLSID rclsid = &CLSID_StdComponentCategoriesMgr;
62 ICatInformation *pICat = (ICatInformation*)0xdeadbeef;
68 static WCHAR szCatID[] = {
70 'd','e','a','d','c','a','f','e',
71 '-','0','0','0','0','-','0','0','0','0',
73 '-','0','0','0','0','0','0','0','0','0','0','0','0',
75 static WCHAR szGuid[] = {
77 'd','e','a','d','c','a','f','e','-',
81 'c','a','f','e','b','e','a','d','d','e','a','d',
84 IEnumCLSID *pIEnum =(IEnumCLSID*)0xdeadcafe;
86 CLSIDFromString((LPOLESTR)szCatID,the_cat);
87 CLSIDFromString((LPOLESTR)szGuid,&wanted_guid);
91 hr = CoCreateInstance(rclsid,NULL,CLSCTX_INPROC_SERVER,
92 &IID_ICatInformation, (void **)&pICat);
93 ok_ole_success(hr, "CoCreateInstance");
95 hr = ICatInformation_EnumClassesOfCategories(pICat, -1, NULL, -1, NULL,
97 ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories");
99 IEnumGUID_Release(pIEnum);
101 hr = ICatInformation_EnumClassesOfCategories(pICat, 1, the_cat, -1, NULL,
103 ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories");
105 hr = IEnumGUID_Next(pIEnum,1,the_guid, &fetched);
106 ok (fetched == 0,"Fetched wrong number of guids %u\n",fetched);
107 IEnumGUID_Release(pIEnum);
109 register_testentry();
110 hr = ICatInformation_EnumClassesOfCategories(pICat, 1, the_cat, -1, NULL,
112 ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories");
114 hr = IEnumGUID_Next(pIEnum,1,the_guid, &fetched);
115 ok (fetched == 1,"Fetched wrong number of guids %u\n",fetched);
116 ok (IsEqualGUID(the_guid,&wanted_guid),"Guids do not match\n");
118 IEnumGUID_Release(pIEnum);
119 ICatInformation_Release(pICat);
120 unregister_testentry();