ddraw: Add full implementation of IDirect3DDevice7_Load.
[wine.git] / dlls / comcat / tests / comcat.c
blob914cbe8b2a2275259d5f466225e3bd7482c17ed0
1 /*
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
21 #define COBJMACROS
23 #include <stdio.h>
24 #include <windows.h>
26 #include "objbase.h"
27 #include "comcat.h"
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)
35 HKEY hkey,hkey2;
37 RegCreateKeyA(HKEY_CLASSES_ROOT,"CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}",
38 &hkey);
39 RegSetValueA(hkey,NULL,REG_SZ,"ComCat Test key",16);
40 RegCreateKeyA(hkey,
41 "Implemented Categories\\{deadcafe-0000-0000-0000-000000000000}",
42 &hkey2);
44 RegCloseKey(hkey);
45 RegCloseKey(hkey2);
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)
60 HRESULT hr;
61 REFCLSID rclsid = &CLSID_StdComponentCategoriesMgr;
62 ICatInformation *pICat = (ICatInformation*)0xdeadbeef;
63 GUID the_guid[1];
64 GUID the_cat[1];
65 GUID wanted_guid;
66 ULONG fetched = -1;
68 static WCHAR szCatID[] = {
69 '{',
70 'd','e','a','d','c','a','f','e',
71 '-','0','0','0','0','-','0','0','0','0',
72 '-','0','0','0','0',
73 '-','0','0','0','0','0','0','0','0','0','0','0','0',
74 '}',0};
75 static WCHAR szGuid[] = {
76 '{',
77 'd','e','a','d','c','a','f','e','-',
78 'b','e','e','d','-',
79 'b','e','a','d','-',
80 'd','e','a','d','-',
81 'c','a','f','e','b','e','a','d','d','e','a','d',
82 '}',0};
84 IEnumCLSID *pIEnum =(IEnumCLSID*)0xdeadcafe;
86 CLSIDFromString((LPOLESTR)szCatID,the_cat);
87 CLSIDFromString((LPOLESTR)szGuid,&wanted_guid);
89 OleInitialize(NULL);
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,
96 &pIEnum);
97 ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories");
99 IEnumGUID_Release(pIEnum);
101 hr = ICatInformation_EnumClassesOfCategories(pICat, 1, the_cat, -1, NULL,
102 &pIEnum);
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,
111 &pIEnum);
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();
122 OleUninitialize();
126 START_TEST(comcat)
128 do_enum();