push 738d605ff53d3691640a21cc20e5d55aef342d7c
[wine/hacks.git] / dlls / atl / tests / atl_ax.c
blob8b9966c26dfea74b5d9d9d1b20e3c99694c11879
1 /*
2 * Unit tests for Active Template Library ActiveX functions
4 * Copyright 2010 Andrew Nguyen
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include <wine/test.h>
27 #include <windef.h>
28 #include <winbase.h>
29 #include <winuser.h>
30 #include <wingdi.h>
31 #include <winnls.h>
32 #include <winerror.h>
33 #include <winnt.h>
34 #include <wtypes.h>
35 #include <olectl.h>
36 #include <ocidl.h>
37 #include <exdisp.h>
39 HRESULT WINAPI AtlAxAttachControl(IUnknown *, HWND, IUnknown **);
41 static ATOM register_class(void)
43 WNDCLASSA wndclassA;
45 wndclassA.style = 0;
46 wndclassA.lpfnWndProc = DefWindowProc;
47 wndclassA.cbClsExtra = 0;
48 wndclassA.cbWndExtra = 0;
49 wndclassA.hInstance = GetModuleHandleA(NULL);
50 wndclassA.hIcon = NULL;
51 wndclassA.hCursor = LoadCursorA(NULL, IDC_ARROW);
52 wndclassA.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
53 wndclassA.lpszMenuName = NULL;
54 wndclassA.lpszClassName = "WineAtlTestClass";
56 return RegisterClassA(&wndclassA);
59 static void test_AtlAxAttachControl(void)
61 HWND hwnd = CreateWindowA("WineAtlTestClass", "Wine ATL Test Window", 0,
62 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
63 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
64 HRESULT hr;
65 IUnknown *pObj, *pContainer;
67 hr = AtlAxAttachControl(NULL, NULL, NULL);
68 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
70 pContainer = (IUnknown *)0xdeadbeef;
71 hr = AtlAxAttachControl(NULL, NULL, &pContainer);
72 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
73 ok(pContainer == (IUnknown *)0xdeadbeef,
74 "Expected the output container pointer to be untouched, got %p\n", pContainer);
76 hr = AtlAxAttachControl(NULL, hwnd, NULL);
77 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
79 hr = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
80 &IID_IOleObject, (void **)&pObj);
81 ok(hr == S_OK, "Expected CoCreateInstance to return S_OK, got 0x%08x\n", hr);
83 if (FAILED(hr))
85 skip("Couldn't obtain a test IOleObject instance\n");
86 return;
89 hr = AtlAxAttachControl(pObj, NULL, NULL);
90 todo_wine
91 ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
93 pContainer = (IUnknown *)0xdeadbeef;
94 hr = AtlAxAttachControl(pObj, NULL, &pContainer);
95 todo_wine
96 ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
97 ok(pContainer != (IUnknown *)0xdeadbeef &&
98 pContainer != NULL,
99 "Expected the output container pointer to be initialized to non-NULL, got %p\n", pContainer);
101 if (pContainer != (IUnknown *)0xdeadbeef && pContainer != NULL)
102 IUnknown_Release(pContainer);
104 hr = AtlAxAttachControl(pObj, hwnd, NULL);
105 ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08x\n", hr);
107 IUnknown_Release(pObj);
109 DestroyWindow(hwnd);
112 START_TEST(atl_ax)
114 if (!register_class())
115 return;
117 CoInitialize(NULL);
119 test_AtlAxAttachControl();
121 CoUninitialize();