(file) Return to hhtest.c CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / twiki / pub / WineDev / Group6

  1 rizwank 1.1 //Chris Watmore and Aditya Advani
  2             
  3             //#include <wine/test.h>
  4             #include <windows.h>
  5             #include <winuser.h>
  6             #include <stdlib.h>
  7             #include <stdarg.h>
  8             #include <stdio.h>
  9             //#include <winuser.h>
 10             #include <windef.h>
 11             #include <winbase.h>
 12             #include <htmlhelp.h>
 13             
 14             //#define DEBUG
 15             
 16             #ifndef STANDALONE
 17             #include "wine/test.h"
 18             #define ok2 ok
 19             #else
 20             // To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ hhtest.c htmlhelp.lib User32.lib Advapi32.lib
 21             #include <assert.h>
 22 rizwank 1.1 #include <stdio.h>
 23             #define START_TEST(name) main(int argc, char **argv)
 24             #define ok(condition, msg)       \
 25             	do { \
 26             		if(!(condition)) {  \
 27             		fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__); \
 28              		exit(1);         \
 29             		} \
 30             	} while(0)
 31             #define ok2(condition, msg, arg) \
 32                     do { if(!(condition)) {  \
 33             		fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__, arg); \
 34             		exit(1);         \
 35             	} } while(0)
 36             #define ok3(condition, msg, arg1, arg2) \
 37                     do { if(!(condition)) {  \
 38             		fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__, arg1, arg2); \
 39             		exit(1);         \
 40             	} } while(0)
 41             #define todo_wine
 42             #endif
 43 rizwank 1.1 
 44             
 45             //auxiliary functions and definitions here 
 46             
 47             typedef struct tagHH_LAST_ERROR
 48             {
 49                  int      cbStruct ;
 50                  HRESULT  hr ;
 51                  BSTR     description ;
 52             } HH_LAST_ERROR ;
 53             
 54             HH_WINTYPE create_wintype_struct()
 55             {
 56             	// Create an HH_WINTYPE structure.
 57                HH_WINTYPE WinType;
 58             
 59                // Initialize all structure members to zero.
 60                ZeroMemory(&WinType, sizeof(HH_WINTYPE));
 61             
 62                // Define a custom message for use with idNotify.
 63                // ID must not conflict with other Windows/MFC messages.
 64 rizwank 1.1    #define IDD_HELPTAB 69999
 65             
 66                // Set the size of the structure.
 67                WinType.cbStruct = sizeof(HH_WINTYPE);
 68             
 69               // *NOTE: fsValidMembers must be set for various attributes.
 70             
 71                // Set up the properties of the HTML window:
 72                // tripane window, sync topic with index/TOC, and so forth.
 73                WinType.fsWinProperties = HHWIN_PROP_TRI_PANE | HHWIN_PROP_AUTO_SYNC;
 74             
 75                // Put BACK, HOME, FORWARD, and EXPAND buttons on toolbar pane.
 76                WinType.fsToolBarFlags = HHWIN_BUTTON_BACK | HHWIN_BUTTON_HOME | HHWIN_BUTTON_FORWARD | HHWIN_BUTTON_EXPAND;
 77             
 78                // Default htm file to display (doesn't seem to matter whether this is specified at the moment)
 79                WinType.pszFile = "c:\\hhtest\\hhintro.htm";
 80             
 81                // Full Paths or CHM locations of various files (if used).
 82                // To specify that a file is within a CHM, use the following
 83                // syntax: "CHMFileName.chm::\\FileName.xxx"
 84                
 85 rizwank 1.1    // Home Page:
 86                WinType.pszHome = "c:\\hhtest\\hhintro.htm";
 87                // Table of Contents:
 88                WinType.pszToc = "c:\\hhtest\\Contents.hhc";
 89                // Index:
 90                WinType.pszIndex = "c:\\hhtest\\Index.hhk";
 91             
 92                // Expansion width of navigation pane (left pane):
 93                WinType.iNavWidth = 200;
 94             
 95                // Initial display state:
 96                WinType.nShowState = SW_RESTORE;
 97             
 98                // TOC should be activated.
 99                WinType.curNavType = HHWIN_NAVTYPE_TOC;
100             
101                // Tabs on top.
102                WinType.tabpos = HHWIN_NAVTAB_TOP;
103             
104                // ID to use in WPARAM in WM_NOTIFY:
105                WinType.idNotify = IDD_HELPTAB;
106 rizwank 1.1 
107                // Title of Help Window:
108                WinType.pszCaption= "My Title";
109             
110                // Valid structure fields.
111                WinType.fsValidMembers = HHWIN_PARAM_STYLES | HHWIN_PARAM_PROPERTIES | HHWIN_PARAM_RECT | HHWIN_PARAM_TB_FLAGS 
112             							| HHWIN_PARAM_NAV_WIDTH | HHWIN_PARAM_SHOWSTATE | HHWIN_PARAM_TABPOS | HHWIN_PARAM_CUR_TAB;
113             
114                //Name of the window definition.
115                WinType.pszType = "MyWindowName\0";
116             
117             	return 	WinType;
118             }
119             
120             
121             void test_SetWinType(HH_WINTYPE hhWinTypeData)
122             {
123             
124             	struct HWND__ *helpwinHandle = NULL;
125             	HH_LAST_ERROR lasterror;
126             
127 rizwank 1.1 	// Initialize all structure members to zero.
128             	ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
129             	lasterror.cbStruct = sizeof(HH_LAST_ERROR);
130             
131             	// This call creates the new type from the values in the HH_WINTYPE structure
132             	helpwinHandle=HtmlHelp(GetDesktopWindow(), "c:\\hhtest\\hhtest.chm", HH_SET_WIN_TYPE, (DWORD) &hhWinTypeData);
133             	
134             	ok((NULL!=helpwinHandle || (NULL==helpwinHandle && hhWinTypeData.pszType!=NULL)),"Error:Window Type has not been defined");
135             
136             	helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
137             	if (helpwinHandle !=0)
138             	  ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "GET_LAST_ERROR message: %08X\n%S", 
139             	      lasterror.hr, lasterror.description);
140             
141             }
142             
143             void test_DisplayTopic(HH_WINTYPE hhWinTypeData)
144             {
145             
146             	struct HWND__ *helpwinHandle = NULL;
147             	HH_LAST_ERROR lasterror;
148 rizwank 1.1 
149             	// Initialize all structure members to zero.
150             	ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
151             	lasterror.cbStruct = sizeof(HH_LAST_ERROR);
152             
153             	//opens the window
154             	helpwinHandle = HtmlHelp(GetDesktopWindow(), "c:\\hhtest\\hhtest.chm::/hhintro.htm>MyWindowName", HH_DISPLAY_TOPIC,0);
155             	
156             	ok( NULL!=helpwinHandle, "Error:Window could not be displayed");
157             
158             	helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
159             
160             	if (helpwinHandle !=0)
161             	  ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S", lasterror.hr, lasterror.description);
162             
163             }
164             
165             void test_CloseAll()
166             {
167             
168             	struct HWND__ *helpwinHandle = NULL;
169 rizwank 1.1 	HH_LAST_ERROR lasterror;
170             
171             	// Initialize all structure members to zero.
172             	ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
173             	lasterror.cbStruct = sizeof(HH_LAST_ERROR);
174             
175             	HtmlHelp(NULL,NULL,HH_CLOSE_ALL,0);
176             
177             	helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
178             
179             	if (helpwinHandle !=0)
180             	  ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S", lasterror.hr, lasterror.description);
181             
182             }
183             
184             void test_DisplayTextPopup()
185             {
186             
187             /*Tests for three uses, opening a popup with:
188             		An explicit text string. 
189             		A text string based on a resource ID. 
190 rizwank 1.1 		A text string ID based on a text file contained in a compiled help (.chm) file. 
191             */
192             
193             	HH_POPUP popup;
194             	
195             	struct HWND__ *helpwinHandle = NULL;
196             
197             	HH_LAST_ERROR lasterror;
198             
199             	// Initialize all structure members to zero.
200             	ZeroMemory(&popup, sizeof(HH_POPUP));
201             
202             	popup.cbStruct = sizeof(HH_POPUP);
203             	popup.pszText = "You should see this text in the popup window";
204             	popup.pt.x = 400;
205             	popup.pt.y = 300;
206             	
207             	// Initialize all structure members to zero.
208             	ZeroMemory(&lasterror, sizeof(HH_LAST_ERROR));
209             	lasterror.cbStruct = sizeof(HH_LAST_ERROR);
210             
211 rizwank 1.1 	//opens the popup
212             	helpwinHandle =	HtmlHelp(GetDesktopWindow(), NULL, HH_DISPLAY_TEXT_POPUP, (DWORD)&popup) ;
213             	//fprintf(stderr,"failed at %d, msg:",__LINE__);
214             	
215             	helpwinHandle = HtmlHelp(GetDesktopWindow(), NULL, HH_GET_LAST_ERROR, (DWORD)&lasterror) ;
216             
217             	if (helpwinHandle !=0)
218             	  ok3(!(FAILED(lasterror.hr) && lasterror.description!=NULL), "ERROR: %08X\n%S", lasterror.hr, lasterror.description);
219             
220             }
221             
222             START_TEST(htmlhelp)
223             {
224             
225             #ifdef DEBUG
226             	char * hold=NULL;
227             #endif	
228             	
229             	/*create necessary files first
230             	  files will be named:
231             	  hhintro.htm
232 rizwank 1.1 	  Contents.hhc
233                   Index.hhk
234             	  hhtest.chm
235             	*/
236             
237             	HH_WINTYPE hhWinTypeData;
238             	hhWinTypeData = create_wintype_struct();
239             	
240                 test_SetWinType(hhWinTypeData);
241                 test_DisplayTopic(hhWinTypeData);  
242             	test_DisplayTextPopup();
243             	test_CloseAll();
244             
245             #ifdef DEBUG
246             	gets(hold);
247             #endif
248             }

Rizwan Kassim
Powered by
ViewCVS 0.9.2