Sweden-Number/dlls/explorerframe/tests/nstc.c

126 lines
4.5 KiB
C
Raw Normal View History

/*
* Unit tests for the NamespaceTree Control
*
* Copyright 2010 David Hedberg
*
* 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 <stdio.h>
#define COBJMACROS
#include "shlobj.h"
#include "wine/test.h"
static HWND hwnd;
/* "Intended for internal use" */
#define TVS_EX_NOSINGLECOLLAPSE 0x1
/* Returns FALSE if the NamespaceTreeControl failed to be instantiated. */
static BOOL test_initialization(void)
{
INameSpaceTreeControl *pnstc;
2010-08-03 03:43:06 +02:00
IUnknown *punk;
LONG lres;
HRESULT hr;
2010-08-03 03:43:06 +02:00
RECT rc;
hr = CoCreateInstance(&CLSID_NamespaceTreeControl, NULL, CLSCTX_INPROC_SERVER,
&IID_INameSpaceTreeControl, (void**)&pnstc);
ok(hr == S_OK || hr == REGDB_E_CLASSNOTREG, "Got 0x%08x\n", hr);
if(FAILED(hr))
{
return FALSE;
}
2010-08-03 03:43:06 +02:00
hr = INameSpaceTreeControl_Initialize(pnstc, NULL, NULL, 0);
ok(hr == HRESULT_FROM_WIN32(ERROR_TLW_WITH_WSCHILD), "Got (0x%08x)\n", hr);
hr = INameSpaceTreeControl_Initialize(pnstc, (HWND)0xDEADBEEF, NULL, 0);
ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_WINDOW_HANDLE), "Got (0x%08x)\n", hr);
ZeroMemory(&rc, sizeof(RECT));
hr = INameSpaceTreeControl_Initialize(pnstc, NULL, &rc, 0);
ok(hr == HRESULT_FROM_WIN32(ERROR_TLW_WITH_WSCHILD), "Got (0x%08x)\n", hr);
hr = INameSpaceTreeControl_Initialize(pnstc, (HWND)0xDEADBEEF, &rc, 0);
ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_WINDOW_HANDLE), "Got (0x%08x)\n", hr);
hr = INameSpaceTreeControl_Initialize(pnstc, hwnd, NULL, 0);
ok(hr == S_OK, "Got (0x%08x)\n", hr);
/* Some "random" interfaces */
hr = INameSpaceTreeControl_QueryInterface(pnstc, &IID_IOleInPlaceObject, (void**)&punk);
ok(hr == E_NOINTERFACE || hr == S_OK /* vista, w2k8 */, "Got (0x%08x)\n", hr);
if(SUCCEEDED(hr)) IUnknown_Release(punk);
hr = INameSpaceTreeControl_QueryInterface(pnstc, &IID_IOleInPlaceActiveObject, (void**)&punk);
ok(hr == E_NOINTERFACE || hr == S_OK /* vista, w2k8 */, "Got (0x%08x)\n", hr);
if(SUCCEEDED(hr)) IUnknown_Release(punk);
hr = INameSpaceTreeControl_QueryInterface(pnstc, &IID_IOleInPlaceObjectWindowless, (void**)&punk);
ok(hr == E_NOINTERFACE || hr == S_OK /* vista, w2k8 */, "Got (0x%08x)\n", hr);
if(SUCCEEDED(hr)) IUnknown_Release(punk);
hr = INameSpaceTreeControl_QueryInterface(pnstc, &IID_IOleInPlaceUIWindow, (void**)&punk);
ok(hr == E_NOINTERFACE, "Got (0x%08x)\n", hr);
hr = INameSpaceTreeControl_QueryInterface(pnstc, &IID_IOleInPlaceFrame, (void**)&punk);
ok(hr == E_NOINTERFACE, "Got (0x%08x)\n", hr);
hr = INameSpaceTreeControl_QueryInterface(pnstc, &IID_IOleInPlaceSite, (void**)&punk);
ok(hr == E_NOINTERFACE, "Got (0x%08x)\n", hr);
hr = INameSpaceTreeControl_QueryInterface(pnstc, &IID_IOleInPlaceSiteEx, (void**)&punk);
ok(hr == E_NOINTERFACE, "Got (0x%08x)\n", hr);
hr = INameSpaceTreeControl_QueryInterface(pnstc, &IID_IOleInPlaceSiteWindowless, (void**)&punk);
ok(hr == E_NOINTERFACE, "Got (0x%08x)\n", hr);
/* On windows, the reference count won't go to zero until the
* window is destroyed. */
lres = INameSpaceTreeControl_Release(pnstc);
ok(lres, "lres was %d\n", lres);
return TRUE;
}
static void setup_window(void)
{
WNDCLASSA wc;
static const char nstctest_wnd_name[] = "nstctest_wnd";
ZeroMemory(&wc, sizeof(WNDCLASSA));
wc.lpfnWndProc = DefWindowProcA;
wc.lpszClassName = nstctest_wnd_name;
RegisterClassA(&wc);
hwnd = CreateWindowA(nstctest_wnd_name, NULL, WS_TABSTOP,
0, 0, 200, 200, NULL, 0, 0, NULL);
ok(hwnd != NULL, "Failed to create window for test (lasterror: %d).\n",
GetLastError());
}
static void destroy_window(void)
{
DestroyWindow(hwnd);
}
START_TEST(nstc)
{
OleInitialize(NULL);
setup_window();
test_initialization();
destroy_window();
OleUninitialize();
}