msi: Add support for storing strings with embedded nulls in the string table.
[wine.git] / dlls / atl / tests / atl_ax.c
blob4555bd6053e5fc5e7bebe3f9f33abfe2fef61ac5
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 static HRESULT (WINAPI *pAtlAxAttachControl)(IUnknown *, HWND, IUnknown **);
41 static void init_function_pointers(void)
43 HMODULE hatl = GetModuleHandleA("atl.dll");
45 pAtlAxAttachControl = (void *)GetProcAddress(hatl, "AtlAxAttachControl");
48 static ATOM register_class(void)
50 WNDCLASSA wndclassA;
52 wndclassA.style = 0;
53 wndclassA.lpfnWndProc = DefWindowProc;
54 wndclassA.cbClsExtra = 0;
55 wndclassA.cbWndExtra = 0;
56 wndclassA.hInstance = GetModuleHandleA(NULL);
57 wndclassA.hIcon = NULL;
58 wndclassA.hCursor = LoadCursorA(NULL, IDC_ARROW);
59 wndclassA.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
60 wndclassA.lpszMenuName = NULL;
61 wndclassA.lpszClassName = "WineAtlTestClass";
63 return RegisterClassA(&wndclassA);
66 static void test_AtlAxAttachControl(void)
68 HWND hwnd = CreateWindowA("WineAtlTestClass", "Wine ATL Test Window", 0,
69 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
70 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
71 HRESULT hr;
72 IUnknown *pObj, *pContainer;
74 hr = pAtlAxAttachControl(NULL, NULL, NULL);
75 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
77 pContainer = (IUnknown *)0xdeadbeef;
78 hr = pAtlAxAttachControl(NULL, NULL, &pContainer);
79 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
80 ok(pContainer == (IUnknown *)0xdeadbeef,
81 "Expected the output container pointer to be untouched, got %p\n", pContainer);
83 hr = pAtlAxAttachControl(NULL, hwnd, NULL);
84 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
86 hr = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
87 &IID_IOleObject, (void **)&pObj);
88 ok(hr == S_OK, "Expected CoCreateInstance to return S_OK, got 0x%08x\n", hr);
90 if (FAILED(hr))
92 skip("Couldn't obtain a test IOleObject instance\n");
93 return;
96 hr = pAtlAxAttachControl(pObj, NULL, NULL);
97 ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
99 pContainer = (IUnknown *)0xdeadbeef;
100 hr = pAtlAxAttachControl(pObj, NULL, &pContainer);
101 ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
102 ok(pContainer != (IUnknown *)0xdeadbeef &&
103 pContainer != NULL,
104 "Expected the output container pointer to be initialized to non-NULL, got %p\n", pContainer);
106 if (pContainer != (IUnknown *)0xdeadbeef && pContainer != NULL)
107 IUnknown_Release(pContainer);
109 hr = pAtlAxAttachControl(pObj, hwnd, NULL);
110 ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08x\n", hr);
112 IUnknown_Release(pObj);
114 DestroyWindow(hwnd);
117 START_TEST(atl_ax)
119 init_function_pointers();
121 if (!register_class())
122 return;
124 CoInitialize(NULL);
126 if (pAtlAxAttachControl)
127 test_AtlAxAttachControl();
128 else
129 win_skip("AtlAxAttachControl is not available\n");
131 CoUninitialize();