Release 1.6-rc2.
[wine/testsucceed.git] / dlls / shell32 / tests / assoc.c
blob29524dc601a31740d7c437e25d851bc05a6a2ab7
1 /* Unit test suite for various shell Association objects
3 * Copyright 2012 Detlef Riekenberg
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define COBJMACROS
22 #include <stdarg.h>
24 #include "shlwapi.h"
25 #include "shlguid.h"
26 #include "shobjidl.h"
28 #include "wine/test.h"
31 static void test_IQueryAssociations_QueryInterface(void)
33 IQueryAssociations *qa;
34 IQueryAssociations *qa2;
35 IUnknown *unk;
36 HRESULT hr;
38 /* this works since XP */
39 hr = CoCreateInstance(&CLSID_QueryAssociations, NULL, CLSCTX_INPROC_SERVER, &IID_IQueryAssociations, (void*)&qa);
41 if (FAILED(hr)) {
42 win_skip("CoCreateInstance for IQueryAssociations returned 0x%x\n", hr);
43 return;
46 hr = IQueryAssociations_QueryInterface(qa, &IID_IQueryAssociations, (void**)&qa2);
47 ok(hr == S_OK, "QueryInterface (IQueryAssociations) returned 0x%x\n", hr);
48 if (SUCCEEDED(hr)) {
49 IQueryAssociations_Release(qa2);
52 hr = IQueryAssociations_QueryInterface(qa, &IID_IUnknown, (void**)&unk);
53 ok(hr == S_OK, "QueryInterface (IUnknown) returned 0x%x\n", hr);
54 if (SUCCEEDED(hr)) {
55 IUnknown_Release(unk);
58 hr = IQueryAssociations_QueryInterface(qa, &IID_IUnknown, NULL);
59 ok(hr == E_POINTER, "got 0x%x (expected E_POINTER)\n", hr);
61 IQueryAssociations_Release(qa);
65 static void test_IApplicationAssociationRegistration_QueryInterface(void)
67 IApplicationAssociationRegistration *appreg;
68 IApplicationAssociationRegistration *appreg2;
69 IUnknown *unk;
70 HRESULT hr;
72 /* this works since Vista */
73 hr = CoCreateInstance(&CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC_SERVER,
74 &IID_IApplicationAssociationRegistration, (LPVOID*)&appreg);
76 if (FAILED(hr)) {
77 skip("IApplicationAssociationRegistration not created: 0x%x\n", hr);
78 return;
81 hr = IApplicationAssociationRegistration_QueryInterface(appreg, &IID_IApplicationAssociationRegistration,
82 (void**)&appreg2);
83 ok(hr == S_OK, "QueryInterface (IApplicationAssociationRegistration) returned 0x%x\n", hr);
84 if (SUCCEEDED(hr)) {
85 IApplicationAssociationRegistration_Release(appreg2);
88 hr = IApplicationAssociationRegistration_QueryInterface(appreg, &IID_IUnknown, (void**)&unk);
89 ok(hr == S_OK, "QueryInterface (IUnknown) returned 0x%x\n", hr);
90 if (SUCCEEDED(hr)) {
91 IUnknown_Release(unk);
94 hr = IApplicationAssociationRegistration_QueryInterface(appreg, &IID_IUnknown, NULL);
95 ok(hr == E_POINTER, "got 0x%x (expected E_POINTER)\n", hr);
97 IApplicationAssociationRegistration_Release(appreg);
101 START_TEST(assoc)
103 CoInitialize(NULL);
105 test_IQueryAssociations_QueryInterface();
106 test_IApplicationAssociationRegistration_QueryInterface();
108 CoUninitialize();