2008-12-02 17:57:45 +01:00
|
|
|
/*
|
|
|
|
* Tests for autocomplete
|
|
|
|
*
|
|
|
|
* Copyright 2008 Jan de Mooij
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <wine/test.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windows.h"
|
|
|
|
#include "shobjidl.h"
|
|
|
|
#include "shlguid.h"
|
|
|
|
#include "initguid.h"
|
|
|
|
#include "shldisp.h"
|
|
|
|
|
|
|
|
static HWND hMainWnd, hEdit;
|
|
|
|
static HINSTANCE hinst;
|
|
|
|
static int killfocus_count;
|
|
|
|
|
2009-12-29 20:02:16 +01:00
|
|
|
static IAutoComplete *test_init(void)
|
2009-12-29 20:01:29 +01:00
|
|
|
{
|
2008-12-02 17:57:45 +01:00
|
|
|
HRESULT r;
|
|
|
|
IAutoComplete* ac;
|
|
|
|
IUnknown *acSource;
|
|
|
|
|
|
|
|
/* AutoComplete instance */
|
|
|
|
r = CoCreateInstance(&CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IAutoComplete, (LPVOID*)&ac);
|
2009-03-09 14:08:52 +01:00
|
|
|
if (r == REGDB_E_CLASSNOTREG)
|
|
|
|
{
|
|
|
|
win_skip("CLSID_AutoComplete is not registered\n");
|
2009-12-29 20:02:16 +01:00
|
|
|
return NULL;
|
2009-03-09 14:08:52 +01:00
|
|
|
}
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "no IID_IAutoComplete (0x%08x)\n", r);
|
2008-12-02 17:57:45 +01:00
|
|
|
|
|
|
|
/* AutoComplete source */
|
|
|
|
r = CoCreateInstance(&CLSID_ACLMulti, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IACList, (LPVOID*)&acSource);
|
2009-03-09 14:08:52 +01:00
|
|
|
if (r == REGDB_E_CLASSNOTREG)
|
|
|
|
{
|
|
|
|
win_skip("CLSID_ACLMulti is not registered\n");
|
2009-12-29 20:02:16 +01:00
|
|
|
return NULL;
|
2009-03-09 14:08:52 +01:00
|
|
|
}
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "no IID_IACList (0x%08x)\n", r);
|
2008-12-02 17:57:45 +01:00
|
|
|
|
2010-03-21 16:55:34 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
|
|
|
r = IAutoComplete_Init(ac, hEdit, NULL, NULL, NULL);
|
|
|
|
}
|
2008-12-02 17:57:45 +01:00
|
|
|
/* bind to edit control */
|
|
|
|
r = IAutoComplete_Init(ac, hEdit, acSource, NULL, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "Init failed (0x%08x)\n", r);
|
2009-03-09 14:08:52 +01:00
|
|
|
|
2009-12-29 20:02:16 +01:00
|
|
|
IUnknown_Release(acSource);
|
|
|
|
|
|
|
|
return ac;
|
2008-12-02 17:57:45 +01:00
|
|
|
}
|
2009-12-29 20:01:29 +01:00
|
|
|
|
|
|
|
static void test_killfocus(void)
|
|
|
|
{
|
2008-12-02 17:57:45 +01:00
|
|
|
/* Test if WM_KILLFOCUS messages are handled properly by checking if
|
|
|
|
* the parent receives an EN_KILLFOCUS message. */
|
|
|
|
SetFocus(hEdit);
|
|
|
|
killfocus_count = 0;
|
|
|
|
SetFocus(0);
|
|
|
|
ok(killfocus_count == 1, "Expected one EN_KILLFOCUS message, got: %d\n", killfocus_count);
|
|
|
|
}
|
2009-12-29 20:01:29 +01:00
|
|
|
|
|
|
|
static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2008-12-02 17:57:45 +01:00
|
|
|
switch(msg) {
|
|
|
|
case WM_CREATE:
|
|
|
|
/* create edit control */
|
|
|
|
hEdit = CreateWindowEx(0, "EDIT", "Some text", 0, 10, 10, 300, 300,
|
|
|
|
hWnd, NULL, hinst, NULL);
|
|
|
|
ok(hEdit != NULL, "Can't create edit control\n");
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
if(HIWORD(wParam) == EN_KILLFOCUS)
|
|
|
|
killfocus_count++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
|
|
|
}
|
2009-12-29 20:01:29 +01:00
|
|
|
|
|
|
|
static void createMainWnd(void)
|
|
|
|
{
|
2008-12-02 17:57:45 +01:00
|
|
|
WNDCLASSA wc;
|
|
|
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = GetModuleHandleA(NULL);
|
|
|
|
wc.hIcon = NULL;
|
|
|
|
wc.hCursor = LoadCursorA(NULL, IDC_IBEAM);
|
|
|
|
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = "MyTestWnd";
|
|
|
|
wc.lpfnWndProc = MyWndProc;
|
|
|
|
RegisterClassA(&wc);
|
|
|
|
|
|
|
|
hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, 130, 105, NULL, NULL, GetModuleHandleA(NULL), 0);
|
|
|
|
}
|
2009-12-29 20:01:29 +01:00
|
|
|
|
|
|
|
START_TEST(autocomplete)
|
|
|
|
{
|
2008-12-02 17:57:45 +01:00
|
|
|
HRESULT r;
|
|
|
|
MSG msg;
|
2009-12-29 20:02:16 +01:00
|
|
|
IAutoComplete* ac;
|
2008-12-02 17:57:45 +01:00
|
|
|
|
|
|
|
r = CoInitialize(NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(r == S_OK, "CoInitialize failed (0x%08x). Tests aborted.\n", r);
|
|
|
|
if (r != S_OK)
|
2008-12-02 17:57:45 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
createMainWnd();
|
2010-02-24 16:04:05 +01:00
|
|
|
ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n");
|
|
|
|
if (!hMainWnd) return;
|
2008-12-02 17:57:45 +01:00
|
|
|
|
2009-12-29 20:02:16 +01:00
|
|
|
ac = test_init();
|
|
|
|
if (!ac)
|
2009-03-09 14:08:52 +01:00
|
|
|
goto cleanup;
|
2008-12-02 17:57:45 +01:00
|
|
|
test_killfocus();
|
|
|
|
|
|
|
|
PostQuitMessage(0);
|
|
|
|
while(GetMessageA(&msg,0,0,0)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageA(&msg);
|
|
|
|
}
|
|
|
|
|
2009-12-29 20:02:16 +01:00
|
|
|
IAutoComplete_Release(ac);
|
|
|
|
|
2009-03-09 14:08:52 +01:00
|
|
|
cleanup:
|
2008-12-02 17:57:45 +01:00
|
|
|
DestroyWindow(hEdit);
|
|
|
|
DestroyWindow(hMainWnd);
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|