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
26 #include <wine/test.h>
39 HRESULT WINAPI
AtlAxAttachControl(IUnknown
*, HWND
, IUnknown
**);
41 static ATOM
register_class(void)
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
);
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
);
85 skip("Couldn't obtain a test IOleObject instance\n");
89 hr
= AtlAxAttachControl(pObj
, NULL
, NULL
);
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
);
96 ok(hr
== S_FALSE
, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr
);
97 ok(pContainer
!= (IUnknown
*)0xdeadbeef &&
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
);
114 if (!register_class())
119 test_AtlAxAttachControl();