2010-06-29 16:06:35 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for Active Template Library ActiveX functions
|
|
|
|
*
|
|
|
|
* Copyright 2010 Andrew Nguyen
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <wine/test.h>
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <winuser.h>
|
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winnls.h>
|
|
|
|
#include <winerror.h>
|
|
|
|
#include <winnt.h>
|
|
|
|
#include <wtypes.h>
|
|
|
|
#include <olectl.h>
|
|
|
|
#include <ocidl.h>
|
|
|
|
#include <exdisp.h>
|
2013-03-15 15:16:20 +01:00
|
|
|
#include <atlbase.h>
|
2010-06-29 16:06:35 +02:00
|
|
|
|
2010-07-19 13:14:51 +02:00
|
|
|
static HRESULT (WINAPI *pAtlAxAttachControl)(IUnknown *, HWND, IUnknown **);
|
|
|
|
|
|
|
|
static void init_function_pointers(void)
|
|
|
|
{
|
|
|
|
HMODULE hatl = GetModuleHandleA("atl.dll");
|
|
|
|
|
|
|
|
pAtlAxAttachControl = (void *)GetProcAddress(hatl, "AtlAxAttachControl");
|
|
|
|
}
|
2010-06-29 16:06:35 +02:00
|
|
|
|
|
|
|
static ATOM register_class(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA wndclassA;
|
|
|
|
|
|
|
|
wndclassA.style = 0;
|
2013-10-01 23:26:28 +02:00
|
|
|
wndclassA.lpfnWndProc = DefWindowProcA;
|
2010-06-29 16:06:35 +02:00
|
|
|
wndclassA.cbClsExtra = 0;
|
|
|
|
wndclassA.cbWndExtra = 0;
|
|
|
|
wndclassA.hInstance = GetModuleHandleA(NULL);
|
|
|
|
wndclassA.hIcon = NULL;
|
2013-10-01 23:26:28 +02:00
|
|
|
wndclassA.hCursor = LoadCursorA(NULL, (LPSTR)IDC_ARROW);
|
2010-06-29 16:06:35 +02:00
|
|
|
wndclassA.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
|
|
|
|
wndclassA.lpszMenuName = NULL;
|
|
|
|
wndclassA.lpszClassName = "WineAtlTestClass";
|
|
|
|
|
|
|
|
return RegisterClassA(&wndclassA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_AtlAxAttachControl(void)
|
|
|
|
{
|
|
|
|
HWND hwnd = CreateWindowA("WineAtlTestClass", "Wine ATL Test Window", 0,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, NULL, NULL, NULL, NULL);
|
|
|
|
HRESULT hr;
|
|
|
|
IUnknown *pObj, *pContainer;
|
|
|
|
|
2010-07-19 13:14:51 +02:00
|
|
|
hr = pAtlAxAttachControl(NULL, NULL, NULL);
|
2010-06-29 16:06:35 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
pContainer = (IUnknown *)0xdeadbeef;
|
2010-07-19 13:14:51 +02:00
|
|
|
hr = pAtlAxAttachControl(NULL, NULL, &pContainer);
|
2010-06-29 16:06:35 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
|
|
|
|
ok(pContainer == (IUnknown *)0xdeadbeef,
|
|
|
|
"Expected the output container pointer to be untouched, got %p\n", pContainer);
|
|
|
|
|
2010-07-19 13:14:51 +02:00
|
|
|
hr = pAtlAxAttachControl(NULL, hwnd, NULL);
|
2010-06-29 16:06:35 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
|
|
|
|
&IID_IOleObject, (void **)&pObj);
|
|
|
|
ok(hr == S_OK, "Expected CoCreateInstance to return S_OK, got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
skip("Couldn't obtain a test IOleObject instance\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-07-19 13:14:51 +02:00
|
|
|
hr = pAtlAxAttachControl(pObj, NULL, NULL);
|
2010-06-29 16:06:35 +02:00
|
|
|
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
pContainer = (IUnknown *)0xdeadbeef;
|
2010-07-19 13:14:51 +02:00
|
|
|
hr = pAtlAxAttachControl(pObj, NULL, &pContainer);
|
2010-06-29 16:06:35 +02:00
|
|
|
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
|
|
|
|
ok(pContainer != (IUnknown *)0xdeadbeef &&
|
|
|
|
pContainer != NULL,
|
|
|
|
"Expected the output container pointer to be initialized to non-NULL, got %p\n", pContainer);
|
|
|
|
|
|
|
|
if (pContainer != (IUnknown *)0xdeadbeef && pContainer != NULL)
|
|
|
|
IUnknown_Release(pContainer);
|
|
|
|
|
2010-07-19 13:14:51 +02:00
|
|
|
hr = pAtlAxAttachControl(pObj, hwnd, NULL);
|
2010-06-29 16:06:35 +02:00
|
|
|
ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IUnknown_Release(pObj);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2013-03-15 15:16:20 +01:00
|
|
|
static void test_ax_win(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
WNDCLASSEXW wcex;
|
|
|
|
static const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n',0};
|
|
|
|
static HMODULE hinstance = 0;
|
|
|
|
|
|
|
|
ret = AtlAxWinInit();
|
|
|
|
ok(ret, "AtlAxWinInit failed\n");
|
|
|
|
|
|
|
|
hinstance = GetModuleHandleA(NULL);
|
|
|
|
memset(&wcex, 0, sizeof(wcex));
|
|
|
|
wcex.cbSize = sizeof(wcex);
|
|
|
|
ret = GetClassInfoExW(hinstance, AtlAxWin, &wcex);
|
|
|
|
ok(ret, "AtlAxWin has not registered\n");
|
|
|
|
ok(wcex.style == CS_GLOBALCLASS, "wcex.style %08x\n", wcex.style);
|
|
|
|
}
|
|
|
|
|
2010-06-29 16:06:35 +02:00
|
|
|
START_TEST(atl_ax)
|
|
|
|
{
|
2010-07-19 13:14:51 +02:00
|
|
|
init_function_pointers();
|
|
|
|
|
2010-06-29 16:06:35 +02:00
|
|
|
if (!register_class())
|
|
|
|
return;
|
|
|
|
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2010-07-19 13:14:51 +02:00
|
|
|
if (pAtlAxAttachControl)
|
|
|
|
test_AtlAxAttachControl();
|
|
|
|
else
|
|
|
|
win_skip("AtlAxAttachControl is not available\n");
|
2010-06-29 16:06:35 +02:00
|
|
|
|
2013-03-15 15:16:20 +01:00
|
|
|
test_ax_win();
|
|
|
|
|
2010-06-29 16:06:35 +02:00
|
|
|
CoUninitialize();
|
|
|
|
}
|