ddraw: Set dwMaxVertexCount to 2048.
[wine.git] / dlls / atl / tests / atl_ax.c
blob26e4ea5a54d25941301b9b9cbf9187537d308ee5
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>
38 #include <atlbase.h>
40 static HRESULT (WINAPI *pAtlAxAttachControl)(IUnknown *, HWND, IUnknown **);
42 static void init_function_pointers(void)
44 HMODULE hatl = GetModuleHandleA("atl.dll");
46 pAtlAxAttachControl = (void *)GetProcAddress(hatl, "AtlAxAttachControl");
49 static ATOM register_class(void)
51 WNDCLASSA wndclassA;
53 wndclassA.style = 0;
54 wndclassA.lpfnWndProc = DefWindowProcA;
55 wndclassA.cbClsExtra = 0;
56 wndclassA.cbWndExtra = 0;
57 wndclassA.hInstance = GetModuleHandleA(NULL);
58 wndclassA.hIcon = NULL;
59 wndclassA.hCursor = LoadCursorA(NULL, (LPSTR)IDC_ARROW);
60 wndclassA.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
61 wndclassA.lpszMenuName = NULL;
62 wndclassA.lpszClassName = "WineAtlTestClass";
64 return RegisterClassA(&wndclassA);
67 static void test_AtlAxAttachControl(void)
69 HWND hwnd = CreateWindowA("WineAtlTestClass", "Wine ATL Test Window", 0,
70 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
71 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
72 HRESULT hr;
73 IUnknown *pObj, *pContainer;
75 hr = pAtlAxAttachControl(NULL, NULL, NULL);
76 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08lx\n", hr);
78 pContainer = (IUnknown *)0xdeadbeef;
79 hr = pAtlAxAttachControl(NULL, NULL, &pContainer);
80 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08lx\n", hr);
81 ok(pContainer == (IUnknown *)0xdeadbeef,
82 "Expected the output container pointer to be untouched, got %p\n", pContainer);
84 hr = pAtlAxAttachControl(NULL, hwnd, NULL);
85 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08lx\n", hr);
87 hr = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
88 &IID_IOleObject, (void **)&pObj);
89 ok(hr == S_OK, "Expected CoCreateInstance to return S_OK, got 0x%08lx\n", hr);
91 if (FAILED(hr))
93 skip("Couldn't obtain a test IOleObject instance\n");
94 return;
97 hr = pAtlAxAttachControl(pObj, NULL, NULL);
98 ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08lx\n", hr);
100 pContainer = NULL;
101 hr = pAtlAxAttachControl(pObj, NULL, &pContainer);
102 ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08lx\n", hr);
103 ok(pContainer != NULL, "got %p\n", pContainer);
104 IUnknown_Release(pContainer);
106 hr = pAtlAxAttachControl(pObj, hwnd, NULL);
107 ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08lx\n", hr);
109 IUnknown_Release(pObj);
111 DestroyWindow(hwnd);
114 static void test_ax_win(void)
116 BOOL ret;
117 WNDCLASSEXW wcex;
118 static HMODULE hinstance = 0;
120 ret = AtlAxWinInit();
121 ok(ret, "AtlAxWinInit failed\n");
123 hinstance = GetModuleHandleA(NULL);
124 memset(&wcex, 0, sizeof(wcex));
125 wcex.cbSize = sizeof(wcex);
126 ret = GetClassInfoExW(hinstance, L"AtlAxWin", &wcex);
127 ok(ret, "AtlAxWin has not registered\n");
128 ok(wcex.style == CS_GLOBALCLASS, "wcex.style %08x\n", wcex.style);
131 START_TEST(atl_ax)
133 init_function_pointers();
135 if (!register_class())
136 return;
138 CoInitialize(NULL);
140 if (pAtlAxAttachControl)
141 test_AtlAxAttachControl();
142 else
143 win_skip("AtlAxAttachControl is not available\n");
145 test_ax_win();
147 CoUninitialize();