[CREDUI_WINETEST] Sync with Wine Staging 1.9.4. CORE-10912
[reactos.git] / rostests / winetests / ole32 / errorinfo.c
1 /*
2 * Error Info Tests
3 *
4 * Copyright 2007 Robert Shearman
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #define WIN32_NO_STATUS
22 #define _INC_WINDOWS
23 #define COM_NO_WINDOWS_H
24
25 #define COBJMACROS
26 #define CONST_VTABLE
27
28 #include <stdarg.h>
29
30 #include <windef.h>
31 #include <winbase.h>
32 #include <ole2.h>
33 //#include "objbase.h"
34
35 #include <wine/test.h>
36
37 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
38
39 static const CLSID CLSID_WineTest =
40 { /* 9474ba1a-258b-490b-bc13-516e9239ace0 */
41 0x9474ba1a,
42 0x258b,
43 0x490b,
44 {0xbc, 0x13, 0x51, 0x6e, 0x92, 0x39, 0xac, 0xe0}
45 };
46
47 static void test_error_info(void)
48 {
49 HRESULT hr;
50 ICreateErrorInfo *pCreateErrorInfo;
51 IErrorInfo *pErrorInfo;
52 static WCHAR wszDescription[] = {'F','a','i','l','e','d',' ','S','p','r','o','c','k','e','t',0};
53 static WCHAR wszHelpFile[] = {'s','p','r','o','c','k','e','t','.','h','l','p',0};
54 static WCHAR wszSource[] = {'s','p','r','o','c','k','e','t',0};
55 IUnknown *unk;
56
57 hr = CreateErrorInfo(&pCreateErrorInfo);
58 ok_ole_success(hr, "CreateErrorInfo");
59
60 hr = ICreateErrorInfo_QueryInterface(pCreateErrorInfo, &IID_IUnknown, (void**)&unk);
61 ok_ole_success(hr, "QI");
62 IUnknown_Release(unk);
63
64 hr = ICreateErrorInfo_SetDescription(pCreateErrorInfo, NULL);
65 ok_ole_success(hr, "ICreateErrorInfo_SetDescription");
66
67 hr = ICreateErrorInfo_SetDescription(pCreateErrorInfo, wszDescription);
68 ok_ole_success(hr, "ICreateErrorInfo_SetDescription");
69
70 hr = ICreateErrorInfo_SetGUID(pCreateErrorInfo, &CLSID_WineTest);
71 ok_ole_success(hr, "ICreateErrorInfo_SetGUID");
72
73 hr = ICreateErrorInfo_SetHelpContext(pCreateErrorInfo, 0xdeadbeef);
74 ok_ole_success(hr, "ICreateErrorInfo_SetHelpContext");
75
76 hr = ICreateErrorInfo_SetHelpFile(pCreateErrorInfo, NULL);
77 ok_ole_success(hr, "ICreateErrorInfo_SetHelpFile");
78
79 hr = ICreateErrorInfo_SetHelpFile(pCreateErrorInfo, wszHelpFile);
80 ok_ole_success(hr, "ICreateErrorInfo_SetHelpFile");
81
82 hr = ICreateErrorInfo_SetSource(pCreateErrorInfo, NULL);
83 ok_ole_success(hr, "ICreateErrorInfo_SetSource");
84
85 hr = ICreateErrorInfo_SetSource(pCreateErrorInfo, wszSource);
86 ok_ole_success(hr, "ICreateErrorInfo_SetSource");
87
88 hr = ICreateErrorInfo_QueryInterface(pCreateErrorInfo, &IID_IErrorInfo, (void **)&pErrorInfo);
89 ok_ole_success(hr, "ICreateErrorInfo_QueryInterface");
90
91 hr = IErrorInfo_QueryInterface(pErrorInfo, &IID_IUnknown, (void**)&unk);
92 ok_ole_success(hr, "QI");
93 IUnknown_Release(unk);
94
95 ICreateErrorInfo_Release(pCreateErrorInfo);
96
97 hr = SetErrorInfo(0, pErrorInfo);
98 ok_ole_success(hr, "SetErrorInfo");
99
100 IErrorInfo_Release(pErrorInfo);
101 pErrorInfo = NULL;
102
103 hr = GetErrorInfo(0, &pErrorInfo);
104 ok_ole_success(hr, "GetErrorInfo");
105
106 IErrorInfo_Release(pErrorInfo);
107
108 hr = GetErrorInfo(0, &pErrorInfo);
109 ok(hr == S_FALSE, "GetErrorInfo should have returned S_FALSE instead of 0x%08x\n", hr);
110 ok(!pErrorInfo, "pErrorInfo should be set to NULL\n");
111
112 hr = SetErrorInfo(0, NULL);
113 ok_ole_success(hr, "SetErrorInfo");
114
115 hr = GetErrorInfo(0xdeadbeef, &pErrorInfo);
116 ok(hr == E_INVALIDARG, "GetErrorInfo should have returned E_INVALIDARG instead of 0x%08x\n", hr);
117
118 hr = SetErrorInfo(0xdeadbeef, NULL);
119 ok(hr == E_INVALIDARG, "SetErrorInfo should have returned E_INVALIDARG instead of 0x%08x\n", hr);
120 }
121
122 START_TEST(errorinfo)
123 {
124 test_error_info();
125 }