wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / ieframe / tests / ie.c
blobb2c39e7baa739025b427672949b0a5959f2cc2ae
1 /*
2 * Copyright 2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
21 #include <wine/test.h>
22 #include <stdarg.h>
23 #include <stdio.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "ole2.h"
28 #include "exdisp.h"
29 #include "exdispid.h"
30 #include "mshtml.h"
31 #include "initguid.h"
32 #include "ieautomation.h"
34 #define DEFINE_EXPECT(func) \
35 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
37 #define SET_EXPECT(func) \
38 expect_ ## func = TRUE
40 #define CHECK_EXPECT2(func) \
41 do { \
42 ok(expect_ ##func, "unexpected call " #func "\n"); \
43 called_ ## func = TRUE; \
44 }while(0)
46 #define CHECK_EXPECT(func) \
47 do { \
48 CHECK_EXPECT2(func); \
49 expect_ ## func = FALSE; \
50 }while(0)
52 #define CHECK_CALLED(func) \
53 do { \
54 ok(called_ ## func, "expected " #func "\n"); \
55 expect_ ## func = called_ ## func = FALSE; \
56 }while(0)
58 DEFINE_EXPECT(Invoke_NAVIGATECOMPLETE2);
60 static BOOL navigate_complete;
62 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
64 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
65 *ppv = iface;
66 return S_OK;
69 *ppv = NULL;
70 return E_NOINTERFACE;
73 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
75 return 2;
78 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
80 return 1;
83 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
85 ok(0, "unexpected call\n");
86 return E_NOTIMPL;
89 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
90 ITypeInfo **ppTInfo)
92 ok(0, "unexpected call\n");
93 return E_NOTIMPL;
96 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
97 UINT cNames, LCID lcid, DISPID *rgDispId)
99 ok(0, "unexpected call\n");
100 return E_NOTIMPL;
103 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
104 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
105 EXCEPINFO *pExcepInfo, UINT *puArgErr)
107 switch(dispIdMember) {
108 case DISPID_NAVIGATECOMPLETE2:
109 CHECK_EXPECT(Invoke_NAVIGATECOMPLETE2);
110 navigate_complete = TRUE;
111 return S_OK;
114 return E_NOTIMPL;
117 static IDispatchVtbl DispatchVtbl = {
118 Dispatch_QueryInterface,
119 Dispatch_AddRef,
120 Dispatch_Release,
121 Dispatch_GetTypeInfoCount,
122 Dispatch_GetTypeInfo,
123 Dispatch_GetIDsOfNames,
124 Dispatch_Invoke
127 static IDispatch Dispatch = { &DispatchVtbl };
129 static void advise_cp(IUnknown *unk, BOOL init)
131 IConnectionPointContainer *container;
132 IConnectionPoint *point;
133 HRESULT hres;
135 static DWORD cookie = 100;
137 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
138 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
139 if(FAILED(hres))
140 return;
142 hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
143 IConnectionPointContainer_Release(container);
144 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
145 if(FAILED(hres))
146 return;
148 if(init) {
149 hres = IConnectionPoint_Advise(point, (IUnknown*)&Dispatch, &cookie);
150 ok(hres == S_OK, "Advise failed: %08x\n", hres);
151 }else {
152 hres = IConnectionPoint_Unadvise(point, cookie);
153 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
156 IConnectionPoint_Release(point);
160 static void test_visible(IWebBrowser2 *wb)
162 VARIANT_BOOL b;
163 HRESULT hres;
165 b = 0x100;
166 hres = IWebBrowser2_get_Visible(wb, &b);
167 ok(hres == S_OK, "get_Visible failed: %08x\n", hres);
168 ok(b == VARIANT_FALSE, "Visible = %x\n", b);
170 hres = IWebBrowser2_put_Visible(wb, VARIANT_TRUE);
171 ok(hres == S_OK, "put_Visible failed: %08x\n", hres);
173 b = 0x100;
174 hres = IWebBrowser2_get_Visible(wb, &b);
175 ok(hres == S_OK, "get_Visible failed: %08x\n", hres);
176 ok(b == VARIANT_TRUE, "Visible = %x\n", b);
178 hres = IWebBrowser2_put_Visible(wb, VARIANT_FALSE);
179 ok(hres == S_OK, "put_Visible failed: %08x\n", hres);
182 static void test_html_window(IWebBrowser2 *wb)
184 IHTMLWindow2 *html_window;
185 IServiceProvider *sp;
186 HRESULT hres;
188 hres = IWebBrowser2_QueryInterface(wb, &IID_IServiceProvider, (void**)&sp);
189 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
191 hres = IServiceProvider_QueryService(sp, &SID_SHTMLWindow, &IID_IHTMLWindow2, (void**)&html_window);
192 IServiceProvider_Release(sp);
193 ok(hres == S_OK, "Could not get SHTMLWindow service: %08x\n", hres);
195 IHTMLWindow2_Release(html_window);
198 static void test_window(IWebBrowser2 *wb)
200 SHANDLE_PTR handle = 0;
201 HWND hwnd = NULL;
202 char buf[100];
203 HRESULT hres;
205 hres = IWebBrowser2_get_HWND(wb, &handle);
206 ok(hres == S_OK, "get_HWND failed: %08x\n", hres);
207 ok(handle, "handle == 0\n");
209 hwnd = (HWND)handle;
210 GetClassNameA(hwnd, buf, sizeof(buf));
211 ok(!strcmp(buf, "IEFrame"), "Unexpected class name %s\n", buf);
214 static void test_navigate(IWebBrowser2 *wb, const WCHAR *url)
216 VARIANT urlv, emptyv;
217 MSG msg;
218 HRESULT hres;
220 SET_EXPECT(Invoke_NAVIGATECOMPLETE2);
222 V_VT(&urlv) = VT_BSTR;
223 V_BSTR(&urlv) = SysAllocString(url);
224 V_VT(&emptyv) = VT_EMPTY;
225 hres = IWebBrowser2_Navigate2(wb, &urlv, &emptyv, &emptyv, &emptyv, &emptyv);
226 ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
227 SysFreeString(V_BSTR(&urlv));
229 while(!navigate_complete && GetMessageW(&msg, NULL, 0, 0)) {
230 TranslateMessage(&msg);
231 DispatchMessageW(&msg);
234 CHECK_CALLED(Invoke_NAVIGATECOMPLETE2);
237 static void test_busy(IWebBrowser2 *wb)
239 VARIANT_BOOL b;
240 HRESULT hres;
242 b = 0xdead;
243 hres = IWebBrowser2_get_Busy(wb, &b);
244 ok(hres == S_OK, "get_Busy failed: %08x\n", hres);
245 ok(b == VARIANT_FALSE, "Busy = %x\n", b);
248 static void test_InternetExplorer(void)
250 IWebBrowser2 *wb;
251 IUnknown *unk;
252 ULONG ref;
253 HRESULT hres;
255 hres = CoCreateInstance(&CLSID_InternetExplorer, NULL, CLSCTX_SERVER,
256 &IID_IUnknown, (void**)&unk);
257 ok(hres == S_OK, "Could not create InternetExplorer instance: %08x\n", hres);
259 if(hres != S_OK)
260 return;
262 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
263 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
264 if (hres != S_OK) {
265 IUnknown_Release(unk);
266 return;
269 advise_cp(unk, TRUE);
271 test_busy(wb);
272 test_visible(wb);
273 test_html_window(wb);
274 test_window(wb);
275 test_navigate(wb, L"http://test.winehq.org/tests/hello.html");
277 advise_cp(unk, FALSE);
279 IWebBrowser2_Release(wb);
280 ref = IUnknown_Release(unk);
281 ok(!ref, "object not destroyed, ref=%u\n", ref);
284 static void test_InternetExplorerManager(void)
286 IUnknown *unk;
287 ULONG ref;
288 HRESULT hres;
290 hres = CoCreateInstance(&CLSID_InternetExplorerManager, NULL, CLSCTX_LOCAL_SERVER,
291 &IID_IInternetExplorerManager, (void**)&unk);
292 ok(hres == S_OK || broken(hres == REGDB_E_CLASSNOTREG), "Could not create InternetExplorerManager instance: %08x\n", hres);
294 if(hres != S_OK)
296 win_skip("InternetExplorerManager not available\n");
297 return;
300 ref = IUnknown_Release(unk);
301 ok(!ref, "object not destroyed, ref=%u\n", ref);
304 START_TEST(ie)
306 CoInitialize(NULL);
308 test_InternetExplorerManager();
310 test_InternetExplorer();
312 CoUninitialize();