2 * Tests for autocomplete
4 * Copyright 2008 Jan de Mooij
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
23 #include <wine/test.h>
32 static HWND hMainWnd, hEdit;
33 static HINSTANCE hinst;
34 static int killfocus_count;
36 static BOOL test_init(void) {
41 /* AutoComplete instance */
42 r = CoCreateInstance(&CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER,
43 &IID_IAutoComplete, (LPVOID*)&ac);
44 if (r == REGDB_E_CLASSNOTREG)
46 win_skip("CLSID_AutoComplete is not registered\n");
49 ok(SUCCEEDED(r), "no IID_IAutoComplete (0x%08x)\n", r);
51 /* AutoComplete source */
52 r = CoCreateInstance(&CLSID_ACLMulti, NULL, CLSCTX_INPROC_SERVER,
53 &IID_IACList, (LPVOID*)&acSource);
54 if (r == REGDB_E_CLASSNOTREG)
56 win_skip("CLSID_ACLMulti is not registered\n");
59 ok(SUCCEEDED(r), "no IID_IACList (0x%08x)\n", r);
61 /* bind to edit control */
62 r = IAutoComplete_Init(ac, hEdit, acSource, NULL, NULL);
63 ok(SUCCEEDED(r), "Init failed (0x%08x)\n", r);
67 static void test_killfocus(void) {
68 /* Test if WM_KILLFOCUS messages are handled properly by checking if
69 * the parent receives an EN_KILLFOCUS message. */
73 ok(killfocus_count == 1, "Expected one EN_KILLFOCUS message, got: %d\n", killfocus_count);
75 static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
78 /* create edit control */
79 hEdit = CreateWindowEx(0, "EDIT", "Some text", 0, 10, 10, 300, 300,
80 hWnd, NULL, hinst, NULL);
81 ok(hEdit != NULL, "Can't create edit control\n");
84 if(HIWORD(wParam) == EN_KILLFOCUS)
88 return DefWindowProcA(hWnd, msg, wParam, lParam);
90 static void createMainWnd(void) {
92 wc.style = CS_HREDRAW | CS_VREDRAW;
95 wc.hInstance = GetModuleHandleA(NULL);
97 wc.hCursor = LoadCursorA(NULL, IDC_IBEAM);
98 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
99 wc.lpszMenuName = NULL;
100 wc.lpszClassName = "MyTestWnd";
101 wc.lpfnWndProc = MyWndProc;
104 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
105 CW_USEDEFAULT, CW_USEDEFAULT, 130, 105, NULL, NULL, GetModuleHandleA(NULL), 0);
107 START_TEST(autocomplete) {
111 r = CoInitialize(NULL);
112 ok(SUCCEEDED(r), "CoInitialize failed (0x%08x). Tests aborted.\n", r);
118 if(!ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n"))
126 while(GetMessageA(&msg,0,0,0)) {
127 TranslateMessage(&msg);
128 DispatchMessageA(&msg);
132 DestroyWindow(hEdit);
133 DestroyWindow(hMainWnd);