[SHELL32_WINETEST]
[reactos.git] / rostests / winetests / shell32 / assoc.c
1 /* Unit test suite for various shell Association objects
2 *
3 * Copyright 2012 Detlef Riekenberg
4 *
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.
9 *
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.
14 *
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
18 */
19
20 #define COBJMACROS
21
22 #include <stdarg.h>
23
24 #include "shlwapi.h"
25 #include "shlguid.h"
26 #include "shobjidl.h"
27
28 #include "wine/test.h"
29
30
31 static void test_IQueryAssociations_QueryInterface(void)
32 {
33 IQueryAssociations *qa;
34 IQueryAssociations *qa2;
35 IUnknown *unk;
36 HRESULT hr;
37
38 /* this works since XP */
39 hr = CoCreateInstance(&CLSID_QueryAssociations, NULL, CLSCTX_INPROC_SERVER, &IID_IQueryAssociations, (void*)&qa);
40
41 if (FAILED(hr)) {
42 win_skip("CoCreateInstance for IQueryAssociations returned 0x%x\n", hr);
43 return;
44 }
45
46 hr = IUnknown_QueryInterface(qa, &IID_IQueryAssociations, (void**)&qa2);
47 ok(hr == S_OK, "QueryInterface (IQueryAssociations) returned 0x%x\n", hr);
48 if (SUCCEEDED(hr)) {
49 IUnknown_Release(qa2);
50 }
51
52 hr = IUnknown_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);
56 }
57
58 hr = IUnknown_QueryInterface(qa, &IID_IUnknown, NULL);
59 ok(hr == E_POINTER, "got 0x%x (expected E_POINTER)\n", hr);
60
61 IQueryAssociations_Release(qa);
62 }
63
64
65 static void test_IApplicationAssociationRegistration_QueryInterface(void)
66 {
67 IApplicationAssociationRegistration *appreg;
68 IApplicationAssociationRegistration *appreg2;
69 IUnknown *unk;
70 HRESULT hr;
71
72 /* this works since Vista */
73 hr = CoCreateInstance(&CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC_SERVER,
74 &IID_IApplicationAssociationRegistration, (LPVOID*)&appreg);
75
76 if (FAILED(hr)) {
77 skip("IApplicationAssociationRegistration not created: 0x%x\n", hr);
78 return;
79 }
80
81 hr = IUnknown_QueryInterface(appreg, &IID_IApplicationAssociationRegistration, (void**)&appreg2);
82 ok(hr == S_OK, "QueryInterface (IApplicationAssociationRegistration) returned 0x%x\n", hr);
83 if (SUCCEEDED(hr)) {
84 IUnknown_Release(appreg2);
85 }
86
87 hr = IUnknown_QueryInterface(appreg, &IID_IUnknown, (void**)&unk);
88 ok(hr == S_OK, "QueryInterface (IUnknown) returned 0x%x\n", hr);
89 if (SUCCEEDED(hr)) {
90 IUnknown_Release(unk);
91 }
92
93 hr = IUnknown_QueryInterface(appreg, &IID_IUnknown, NULL);
94 ok(hr == E_POINTER, "got 0x%x (expected E_POINTER)\n", hr);
95
96 IApplicationAssociationRegistration_Release(appreg);
97 }
98
99
100 START_TEST(assoc)
101 {
102 CoInitialize(NULL);
103
104 test_IQueryAssociations_QueryInterface();
105 test_IApplicationAssociationRegistration_QueryInterface();
106
107 CoUninitialize();
108 }