2 * Component Object Tests
4 * Copyright 2005 Robert Shearman
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wine/test.h"
31 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08lx\n", hr)
33 static const CLSID CLSID_non_existent = { 0x12345678, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
34 static const CLSID CLSID_CDeviceMoniker = { 0x4315d437, 0x5b8c, 0x11d0, { 0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86 } };
35 static const WCHAR devicedotone[] = {'d','e','v','i','c','e','.','1',0};
36 static const WCHAR wszCLSID_CDeviceMoniker[] =
39 '4','3','1','5','d','4','3','7','-',
43 '0','0','a','0','c','9','1','1','c','e','8','6',
47 static void test_ProgIDFromCLSID(void)
50 HRESULT hr = ProgIDFromCLSID(&CLSID_CDeviceMoniker, &progid);
51 ok(hr == S_OK, "ProgIDFromCLSID failed with error 0x%08lx\n", hr);
54 ok(!lstrcmpiW(progid, devicedotone), "Didn't get expected prog ID\n");
55 CoTaskMemFree(progid);
58 progid = (LPWSTR)0xdeadbeef;
59 hr = ProgIDFromCLSID(&CLSID_non_existent, &progid);
60 ok(hr == REGDB_E_CLASSNOTREG, "ProgIDFromCLSID returned %08lx\n", hr);
61 ok(progid == NULL, "ProgIDFromCLSID returns with progid %p\n", progid);
64 static void test_CLSIDFromProgID(void)
67 HRESULT hr = CLSIDFromProgID(devicedotone, &clsid);
68 ok(hr == S_OK, "CLSIDFromProgID failed with error 0x%08lx\n", hr);
69 ok(IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker), "clsid wasn't equal to CLSID_CDeviceMoniker\n");
71 hr = CLSIDFromString((LPOLESTR)devicedotone, &clsid);
72 ok_ole_success(hr, "CLSIDFromString");
73 ok(IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker), "clsid wasn't equal to CLSID_CDeviceMoniker\n");
76 static void test_CLSIDFromString(void)
79 HRESULT hr = CLSIDFromString((LPOLESTR)wszCLSID_CDeviceMoniker, &clsid);
80 ok_ole_success(hr, "CLSIDFromString");
81 ok(IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker), "clsid wasn't equal to CLSID_CDeviceMoniker\n");
86 test_ProgIDFromCLSID();
87 test_CLSIDFromProgID();
88 test_CLSIDFromString();