Add all modules within a test to the treeview

svn path=/trunk/; revision=34024
This commit is contained in:
Ged Murphy 2008-06-19 11:57:14 +00:00
parent febcfe8913
commit 671448e212
3 changed files with 66 additions and 13 deletions

View file

@ -14,6 +14,7 @@
#define IL_TEST 1
typedef wchar_t *(__cdecl *DLLNAME)();
typedef int (_cdecl *MODULES)(char **);
static INT
GetNumberOfDllsInFolder(LPWSTR lpFolder)
@ -135,6 +136,7 @@ PopulateTreeView(PMAIN_WND_INFO pInfo)
HTREEITEM hRoot;
HIMAGELIST hImgList;
DLLNAME GetTestName;
MODULES GetModulesInTest;
HMODULE hDll;
LPWSTR lpDllPath;
LPWSTR lpTestName;
@ -171,16 +173,47 @@ PopulateTreeView(PMAIN_WND_INFO pInfo)
GetTestName = (DLLNAME)GetProcAddress(hDll, "GetTestName");
if (GetTestName)
{
HTREEITEM hParent;
LPSTR lpModules, ptr;
LPWSTR lpModW;
INT numMods;
lpTestName = GetTestName();
InsertIntoTreeView(pInfo->hBrowseTV,
hRoot,
lpTestName,
lpDllPath,
IL_TEST);
hParent = InsertIntoTreeView(pInfo->hBrowseTV,
hRoot,
lpTestName,
lpDllPath,
IL_TEST);
// add individual tests as children
if (hParent)
{
GetModulesInTest = (MODULES)GetProcAddress(hDll, "GetModulesInTest");
if ((numMods = GetModulesInTest(&lpModules)))
{
ptr = lpModules;
while (numMods && *ptr != '\0')
{
if (AnsiToUnicode(ptr, &lpModW))
{
InsertIntoTreeView(pInfo->hBrowseTV,
hParent,
lpModW,
lpModW,
IL_TEST);
HeapFree(GetProcessHeap(), 0, lpModW);
}
while (*(ptr++) != '\0')
;
numMods--;
}
HeapFree(GetProcessHeap(), 0, lpModules);
}
}
}
FreeLibrary(hDll);

View file

@ -24,7 +24,7 @@ LengthOfStrResource(IN HINSTANCE hInst,
}
/* There are always blocks of 16 strings */
lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
lpName = (LPWSTR)MAKEINTRESOURCEW((uID >> 4) + 1);
/* Find the string table block */
if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
@ -238,12 +238,12 @@ InitImageList(UINT StartResource,
/* Add all icons to the image list */
for (i = StartResource; i <= EndResource; i++)
{
hIcon = (HBITMAP)LoadImage(hInstance,
MAKEINTRESOURCE(i),
IMAGE_ICON,
Width,
Height,
LR_DEFAULTCOLOR);
hIcon = (HBITMAP)LoadImageW(hInstance,
MAKEINTRESOURCEW(i),
IMAGE_ICON,
Width,
Height,
LR_DEFAULTCOLOR);
if (hIcon == NULL)
goto fail;
@ -261,3 +261,21 @@ fail:
ImageList_Destroy(hImageList);
return NULL;
}
DWORD
AnsiToUnicode(LPCSTR lpSrcStr,
LPWSTR *lpDstStr)
{
INT length;
INT ret = 0;
length = strlen(lpSrcStr) + 1;
*lpDstStr = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR));
if (*lpDstStr)
{
ret = MultiByteToWideChar(CP_ACP, 0, lpSrcStr, -1, *lpDstStr, length);
}
return ret;
}

View file

@ -32,6 +32,7 @@ typedef struct _MAIN_WND_INFO
/* dll exports */
wchar_t *GetTestName();
int GetModulesInTest(char **modules);
/* browsewnd.c */
@ -41,5 +42,6 @@ BOOL CALLBACK BrowseDlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lPara
HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT Height);
VOID DisplayString(LPWSTR lpMsg);
VOID DisplayError(INT err);
DWORD AnsiToUnicode(LPCSTR lpSrcStr, LPWSTR *lpDstStr);
#endif /* __WINETESTGUI_PRECOMP_H */