1 rizwank 1.1 This patch adds a conformance test for the htmlhelp API.
2 Currently it tests a subset of the possible commands.
3 In the very near future we expect to write tests for the rest of the functions
4 as well as correct any mistakes in the current tests, and overall finetune
5 the code. Any feedback would be VERY MUCH appreciated. Please address feedback
6 to chris.watmore@gmail.com
7
8
9 Changelog:
10 * configure.ac
11 added dlls/hhctrl.ocx/tests/Makefile to be generated
12 * dlls/hhctrl.ocx/tests/Makefile.in
13 standard Makefile.in for tests
14 * dlls/hhctrl.ocx/tests/hhtest.c
15 actual test code for htmlhelp commands
16
17 --- wine/configure.ac~ 2005-02-17 19:11:55.000000000 -0800
18 +++ wine/configure.ac 2005-02-17 19:14:01.000000000 -0800
19 @@ -1567,6 +1567,7 @@
20 dlls/glu32/Makefile
21 dlls/glut32/Makefile
22 rizwank 1.1 dlls/hhctrl.ocx/Makefile
23 +dlls/hhctrl.ocx/tests/Makefile
24 dlls/iccvid/Makefile
25 dlls/icmp/Makefile
26 dlls/ifsmgr.vxd/Makefile
27 --- wine/dlls/hhctrl.ocx/tests/Makefile.in~ 1969-12-31 16:00:00.000000000 -0800
28 +++ wine/dlls/hhctrl.ocx/tests/Makefile.in 2005-02-17 19:21:33.000000000 -0800
29 @@ -0,0 +1,13 @@
30 +TOPSRCDIR = @top_srcdir@
31 +TOPOBJDIR = ../../..
32 +SRCDIR = @srcdir@
33 +VPATH = @srcdir@
34 +TESTDLL = hhctrl.ocx
35 +IMPORTS = htmlhelp Advapi32 winuser
36 +
37 +CTESTS = \
38 + hhtest.c
39 +
40 +@MAKE_TEST_RULES@
41 +
42 +### Dependencies:
43 rizwank 1.1 --- wine/dlls/hhctrl.ocx/tests/hhtest.c~ 1969-12-31 16:00:00.000000000 -0800
44 +++ wine/dlls/hhctrl.ocx/tests/hhtest.c 2005-02-17 19:24:25.000000000 -0800
45 @@ -0,0 +1,398 @@
46 +/*
47 + * Unit test suite for htmlhelp functions
48 + *
49 + * Copyright 2005 Chris Watmore, Aditya Advani
50 + *
51 + * This library is free software; you can redistribute it and/or
52 + * modify it under the terms of the GNU Lesser General Public
53 + * License as published by the Free Software Foundation; either
54 + * version 2.1 of the License, or (at your option) any later version.
55 + *
56 + * This library is distributed in the hope that it will be useful,
57 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
58 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
59 + * Lesser General Public License for more details.
60 + *
61 + * You should have received a copy of the GNU Lesser General Public
62 + * License along with this library; if not, write to the Free Software
63 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
64 rizwank 1.1 + *
65 + * This conformance test references a chm file located in the same directory
66 + * as this file is placed named hhtest.chm
67 + * Currently only a subset of the API is tested.
68 + *
69 + *
70 + *
71 + */
72 +
73 +
74 +//#define DEBUG
75 +
76 +#include <windows.h>
77 +#include <stdlib.h>
78 +#include <stdarg.h>
79 +#include <windef.h>
80 +#include <winbase.h>
81 +#include <htmlhelp.h>
82 +
83 +
84 +#ifndef STANDALONE
85 rizwank 1.1 +#include "wine/test.h"
86 +#define ok2 ok
87 +#define ok3 ok
88 +#define CHMFILE "./hhtest.chm"
89 +#define CHMINTRO "./hhtest.chm::\\hhintro.htm"
90 +#define CHMINDEX "./hhtest.chm::\\Index.hhk"
91 +#define CHMTOC "./htest.chm::\\Contents.hhc"
92 +#define CHM_FILE_PLUS_TYPE "./hhtest.chm::/hhintro.htm>MyWindowName"
93 +#else
94 +// To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ hhtest.c htmlhelp.lib User32.lib Advapi32.lib
95 +#include <assert.h>
96 +#include <stdio.h>
97 +#define START_TEST(name) main(int argc, char **argv)
98 +#define ok(condition, msg) \
99 + do { \
100 + if(!(condition)) { \
101 + fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__); \
102 + exit(1); \
103 + } \
104 + } while(0)
105 +#define ok2(condition, msg, arg) \
106 rizwank 1.1 + do { if(!(condition)) { \
107 + fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__, arg); \
108 + exit(1); \
109 + } } while(0)
110 +#define ok3(condition, msg, arg1, arg2) \
111 + do { if(!(condition)) { \
112 + fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__, arg1, arg2); \
113 + exit(1); \
114 + } } while(0)
115 +#define todo_wine
116 +#define CHMFILE "hhtest\\hhtest.chm"
117 +#define CHMINTRO "hhtest\\hhtest.chm::\\hhintro.htm"
118 +#define CHMINDEX "hhtest\\hhtest.chm::\\Index.hhk"
119 +#define CHMTOC "hhtest\\hhtest.chm::\\Contents.hhc"
120 +#define CHM_FILE_PLUS_TYPE "hhtest\\hhtest.chm::/hhintro.htm>MyWindowName"
121 +#endif
122 +
123 +
124 +
125 +
126 +//auxiliary functions and definitions here
127 rizwank 1.1 +
128 +typedef struct tagHH_LAST_ERROR
129 +{
130 + int cbStruct ;
131 + HRESULT hr ;
132 + BSTR description ;
133 +} HH_LAST_ERROR ;
134 +
135 +HH_WINTYPE create_wintype_struct()
136 +{
137 + // Create an HH_WINTYPE structure.
138 + HH_WINTYPE WinType;
139 +
140 + // Initialize all structure members to zero.
141 + ZeroMemory(&WinType, sizeof(HH_WINTYPE));
142 +
143 + // Define a custom message for use with idNotify.
144 + // ID must not conflict with other Windows/MFC messages.
145 + #define IDD_HELPTAB 69999
146 +
147 + // Set the size of the structure.
148 rizwank 1.1 + WinType.cbStruct = sizeof(HH_WINTYPE);
149 +
150 +// *NOTE: fsValidMembers must be set for various attributes.
151 +
152 + // Set up the properties of the HTML window:
153 +
154 + WinType.fsWinProperties = HHWIN_PROP_TRI_PANE | HHWIN_PROP_AUTO_SYNC;
155 +
156 + // Put BACK, HOME, FORWARD, and EXPAND buttons on toolbar pane.
157 + WinType.fsToolBarFlags = HHWIN_BUTTON_BACK | HHWIN_BUTTON_HOME | HHWIN_BUTTON_FORWARD | HHWIN_BUTTON_EXPAND;
158 +
159 + // Default htm file to display (doesn't seem to matter whether this is specified at the moment)
160 + WinType.pszFile = CHMINTRO;
161 +
162 + // CHM locations of various files (if used).
163 + // To specify that a file is within a CHM, use the following
164 + // syntax: "CHMFileName.chm::\\FileName.xxx"
165 +
166 +
167 + WinType.pszHome = CHMINTRO; // Home Page:
168 + WinType.pszToc = CHMTOC; // Table of Contents
169 rizwank 1.1 + WinType.pszIndex = CHMINDEX; // Index:
170 +
171 + WinType.iNavWidth = 200; // Expansion width of navigation pane (left pane):
172 +
173 + WinType.nShowState = SW_RESTORE; // Initial display state:
174 +
175 + WinType.curNavType = HHWIN_NAVTYPE_TOC; // TOC should be activated.
176 +
177 + WinType.tabpos = HHWIN_NAVTAB_TOP; // Tabs on top.
178 +
179 + WinType.idNotify = IDD_HELPTAB; // ID to use in WPARAM in WM_NOTIFY:
180 +
181 + WinType.pszCaption= "My Title"; // Title of Help Window:
182 +
183 + // Valid structure fields.
184 + WinType.fsValidMembers = HHWIN_PARAM_STYLES | HHWIN_PARAM_PROPERTIES | HHWIN_PARAM_RECT | HHWIN_PARAM_TB_FLAGS
185 + | HHWIN_PARAM_NAV_WIDTH | HHWIN_PARAM_SHOWSTATE | HHWIN_PARAM_TABPOS | HHWIN_PARAM_CUR_TAB;
186 +
187 + WinType.pszType = "MyWindowName\0"; //Name of the window definition.
188 +
189 + return WinType;
190 rizwank 1.1 +}
191 +
192 +
193 +void test_SetWinType(HH_WINTYPE hhWinTypeData)
194 +{
195 +
196 + struct HWND__ *helpwinHandle = NULL;
197 + HH_LAST_ERROR lasterror;
198 +
199 + // Initialize all structure members to zero.
200 + ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
201 + lasterror.cbStruct = sizeof(HH_LAST_ERROR);
202 +
203 + // This call creates the new type from the values in the HH_WINTYPE structure
204 + helpwinHandle=HtmlHelp(GetDesktopWindow(), CHMFILE, HH_SET_WIN_TYPE, (DWORD) &hhWinTypeData);
205 +
206 + ok((NULL!=helpwinHandle || (NULL==helpwinHandle && hhWinTypeData.pszType!=NULL)),"Error:Window Type has not been defined");
207 +
208 + helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
209 + if (helpwinHandle !=0)
210 + ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "GET_LAST_ERROR message: %08X\n%S",
211 rizwank 1.1 + lasterror.hr, lasterror.description);
212 +
213 +}
214 +
215 +void test_GetWinType(HH_WINTYPE hhWinTypeData)
216 +{
217 +
218 +
219 +
220 +
221 +
222 +
223 +
224 +
225 +
226 +}
227 +
228 +HWND test_DisplayTopic1()
229 +{
230 +
231 + HWND helpwinHandle = NULL;
232 rizwank 1.1 + HWND helpwinHandle2 = NULL;
233 + HH_LAST_ERROR lasterror;
234 +
235 + // Initialize all structure members to zero.
236 + ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
237 + lasterror.cbStruct = sizeof(HH_LAST_ERROR);
238 +
239 + //opens the window
240 + helpwinHandle = HtmlHelp(GetDesktopWindow(), CHMFILE, HH_DISPLAY_TOPIC,0);
241 + printf("Default helpwinHandle: %X\n", helpwinHandle);
242 + printf("Default helpwinHandle: %X\n", GetDesktopWindow());
243 +
244 + ok( NULL!=helpwinHandle, "Error:Window could not be displayed");
245 +
246 + helpwinHandle2 = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
247 +
248 + if (helpwinHandle2 !=0)
249 + ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S", lasterror.hr, lasterror.description);
250 +
251 + return helpwinHandle;
252 +}
253 rizwank 1.1 +
254 +HWND test_DisplayTopic2()
255 +{
256 +
257 + HWND helpwinHandle = NULL;
258 + HWND helpwinHandle2 = NULL;
259 + HH_LAST_ERROR lasterror;
260 +
261 + // Initialize all structure members to zero.
262 + ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
263 + lasterror.cbStruct = sizeof(HH_LAST_ERROR);
264 +//"c:\\hhtest\\hhtest.chm::/hhintro.htm>MyWindowName"
265 + //opens the window
266 +
267 + helpwinHandle = GetDesktopWindow();
268 + helpwinHandle2 = HtmlHelp(helpwinHandle, CHM_FILE_PLUS_TYPE, HH_DISPLAY_TOPIC,0);
269 + printf("Non-Default helpwinHandle: %X\n", helpwinHandle);
270 +
271 + ok( NULL!=helpwinHandle, "Error:Window could not be displayed");
272 +
273 + helpwinHandle2 = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
274 rizwank 1.1 +
275 + if (helpwinHandle2 !=0)
276 + ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S", lasterror.hr, lasterror.description);
277 +
278 + return helpwinHandle;
279 +}
280 +
281 +void test_CloseAll()
282 +{
283 +
284 + HWND helpwinHandle = NULL;
285 + HH_LAST_ERROR lasterror;
286 +
287 + // Initialize all structure members to zero.
288 + ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
289 + lasterror.cbStruct = sizeof(HH_LAST_ERROR);
290 +
291 + HtmlHelp(NULL,NULL,HH_CLOSE_ALL,0);
292 +
293 + helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
294 +
295 rizwank 1.1 + if (helpwinHandle !=0)
296 + ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S", lasterror.hr, lasterror.description);
297 +
298 +}
299 +
300 +void test_DisplayIndex()
301 +{
302 +
303 + HWND helpwinHandle = NULL;
304 + HH_LAST_ERROR lasterror;
305 +
306 + // Initialize all structure members to zero.
307 + ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
308 + lasterror.cbStruct = sizeof(HH_LAST_ERROR);
309 +
310 +
311 + helpwinHandle = HtmlHelp(GetDesktopWindow(), CHMFILE, HH_DISPLAY_INDEX, (DWORD)"index1") ;
312 + printf("Index helpwinHandle: %X\n", helpwinHandle);
313 +
314 + helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
315 +
316 rizwank 1.1 + if (helpwinHandle !=0)
317 + ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S", lasterror.hr, lasterror.description);
318 +
319 +}
320 +
321 +void test_DisplayTOC()
322 +{
323 +
324 + HWND helpwinHandle = NULL;
325 + HH_LAST_ERROR lasterror;
326 +
327 + // Initialize all structure members to zero.
328 + ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
329 + lasterror.cbStruct = sizeof(HH_LAST_ERROR);
330 +
331 + helpwinHandle = HtmlHelp(GetDesktopWindow(), CHMFILE, HH_DISPLAY_TOC, 0) ;
332 +
333 + helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
334 +
335 + if (helpwinHandle !=0)
336 + ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S", lasterror.hr, lasterror.description);
337 rizwank 1.1 +
338 +}
339 +
340 +void test_DisplaySearch()
341 +{
342 +
343 + HWND helpwinHandle = NULL;
344 + HH_LAST_ERROR lasterror;
345 + HH_FTS_QUERY query;
346 +
347 + // Set error struct properties.
348 + ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
349 + lasterror.cbStruct = sizeof(HH_LAST_ERROR);
350 +
351 + //Set query struct properties
352 + ZeroMemory(&query, sizeof(HH_FTS_QUERY));
353 + query.cbStruct = sizeof(HH_FTS_QUERY);
354 + query.pszWindow = "MyWindowName";
355 + query.pszSearchQuery = "TESTING";
356 + query.fTitleOnly = TRUE;
357 +
358 rizwank 1.1 +/* Struct Attributes:
359 + BOOL fUniCodeStrings;
360 + LPCTSTR pszSearchQuery;
361 + LONG iProximity;
362 + BOOL fStemmedSearch;
363 + BOOL fTitleOnly;
364 + BOOL fExecute;
365 + LPCTSTR pszWindow;
366 +*/
367 +
368 + helpwinHandle = HtmlHelp(GetDesktopWindow(), CHMFILE, HH_DISPLAY_SEARCH, (DWORD)&query) ;
369 +
370 + helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
371 +
372 + if (helpwinHandle !=0)
373 + ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S",
374 + lasterror.hr, lasterror.description);
375 +
376 +
377 +}
378 +
379 rizwank 1.1 +
380 +void test_DisplayTextPopup()
381 +{
382 +
383 +/*Tests for three uses, opening a popup with:
384 + An explicit text string.
385 + A text string based on a resource ID. (currently not implemented)
386 + A text string ID based on a text file contained in a compiled help (.chm) file. (currently not implemented)
387 +*/
388 +
389 + HH_POPUP popup;
390 +
391 + HWND helpwinHandle = NULL;
392 +
393 + HH_LAST_ERROR lasterror;
394 +
395 + // Initialize all structure members to zero.
396 + ZeroMemory(&popup, sizeof(HH_POPUP));
397 +
398 + popup.cbStruct = sizeof(HH_POPUP);
399 + popup.pszText = "You should see this text in the popup window";
400 rizwank 1.1 + popup.pt.x = 400;
401 + popup.pt.y = 300;
402 +
403 + // Initialize all structure members to zero.
404 + ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
405 + lasterror.cbStruct = sizeof(HH_LAST_ERROR);
406 +
407 + //opens the popup
408 + helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_DISPLAY_TEXT_POPUP, (DWORD)&popup) ;
409 + //fprintf(stderr,"failed at %d, msg:",__LINE__);
410 +
411 + helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
412 +
413 + if (helpwinHandle !=0)
414 + ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S", lasterror.hr, lasterror.description);
415 +
416 +}
417 +
418 +START_TEST(htmlhelp)
419 +{
420 +
421 rizwank 1.1 +#ifdef DEBUG
422 + char * hold=NULL;
423 +#endif
424 +
425 + HWND WinHandle;
426 + HH_WINTYPE hhWinTypeData;
427 + hhWinTypeData = create_wintype_struct();
428 + test_DisplayTopic1(); // test for creation of default window type
429 + test_CloseAll();
430 + test_SetWinType(hhWinTypeData);
431 + WinHandle = test_DisplayTopic2(); //test for creation of specified window type
432 + test_DisplayIndex();
433 + test_DisplayTOC();
434 + test_DisplaySearch();
435 + test_DisplayTextPopup();
436 +
437 +#ifndef DEBUG
438 + test_CloseAll();
439 +#endif
440 +#ifdef DEBUG
441 + gets(hold);
442 rizwank 1.1 +#endif
443 +}
444 \ No newline at end of file
|