- Auto expand the list of available tests

- Add the selected test to the main combo
- Tag the dll path to each combo item
- Run the test when the 'run' button is hit. 
We can now run all Wine tests from the GUI, but we get no feedback yet.

svn path=/trunk/; revision=34043
This commit is contained in:
Ged Murphy 2008-06-21 19:19:22 +00:00
parent 3ee18cdb67
commit 3c16ea89b9
4 changed files with 210 additions and 27 deletions

View file

@ -63,7 +63,9 @@ GetListOfTestDlls(PMAIN_WND_INFO pInfo)
numFiles = GetNumberOfDllsInFolder(szDllPath); numFiles = GetNumberOfDllsInFolder(szDllPath);
if (!numFiles) return 0; if (!numFiles) return 0;
pInfo->lpDllList = HeapAlloc(GetProcessHeap(), 0, numFiles * (MAX_PATH * sizeof(WCHAR))); pInfo->lpDllList = HeapAlloc(GetProcessHeap(),
0,
numFiles * (MAX_PATH * sizeof(WCHAR)));
if (!pInfo->lpDllList) if (!pInfo->lpDllList)
return 0; return 0;
@ -329,6 +331,13 @@ PopulateTreeView(PMAIN_WND_INFO pInfo)
FreeLibrary(hDll); FreeLibrary(hDll);
} }
} }
if (hRoot)
{
TreeView_Expand(pInfo->hBrowseTV,
hRoot,
TVE_EXPAND);
}
} }
static VOID static VOID
@ -341,7 +350,6 @@ PopulateTestList(PMAIN_WND_INFO pInfo)
} }
} }
static BOOL static BOOL
OnInitBrowseDialog(HWND hDlg, OnInitBrowseDialog(HWND hDlg,
LPARAM lParam) LPARAM lParam)
@ -361,7 +369,6 @@ OnInitBrowseDialog(HWND hDlg,
return TRUE; return TRUE;
} }
BOOL CALLBACK BOOL CALLBACK
BrowseDlgProc(HWND hDlg, BrowseDlgProc(HWND hDlg,
UINT Message, UINT Message,
@ -433,6 +440,8 @@ BrowseDlgProc(HWND hDlg,
TraverseTreeView(pInfo, hItem); TraverseTreeView(pInfo, hItem);
pInfo->hBrowseDlg = NULL;
break; break;
} }
@ -442,4 +451,4 @@ HandleDefaultMessage:
} }
return FALSE; return FALSE;
} }

View file

@ -11,15 +11,13 @@
HINSTANCE hInstance; HINSTANCE hInstance;
typedef int (_cdecl *RUNTEST)(char **);
static BOOL static BOOL
OnInitMainDialog(HWND hDlg, OnInitMainDialog(HWND hDlg,
LPARAM lParam) LPARAM lParam)
{ {
PMAIN_WND_INFO pInfo; PMAIN_WND_INFO pInfo;
//HMENU hSysMenu;
LPWSTR lpAboutText; LPWSTR lpAboutText;
pInfo = (PMAIN_WND_INFO)lParam; pInfo = (PMAIN_WND_INFO)lParam;
@ -32,11 +30,11 @@ OnInitMainDialog(HWND hDlg,
(LONG_PTR)pInfo); (LONG_PTR)pInfo);
pInfo->hSmIcon = LoadImageW(hInstance, pInfo->hSmIcon = LoadImageW(hInstance,
MAKEINTRESOURCEW(IDI_ICON), MAKEINTRESOURCEW(IDI_ICON),
IMAGE_ICON, IMAGE_ICON,
16, 16,
16, 16,
0); 0);
if (pInfo->hSmIcon) if (pInfo->hSmIcon)
{ {
SendMessageW(hDlg, SendMessageW(hDlg,
@ -46,11 +44,11 @@ OnInitMainDialog(HWND hDlg,
} }
pInfo->hBgIcon = LoadImageW(hInstance, pInfo->hBgIcon = LoadImageW(hInstance,
MAKEINTRESOURCEW(IDI_ICON), MAKEINTRESOURCEW(IDI_ICON),
IMAGE_ICON, IMAGE_ICON,
32, 32,
32, 32,
0); 0);
if (pInfo->hBgIcon) if (pInfo->hBgIcon)
{ {
SendMessageW(hDlg, SendMessageW(hDlg,
@ -62,6 +60,132 @@ OnInitMainDialog(HWND hDlg,
return TRUE; return TRUE;
} }
static VOID
RunSelectedTest(PMAIN_WND_INFO pInfo)
{
HWND hRunCmd;
WCHAR szTextCmd[MAX_RUN_CMD];
LPWSTR lpDllPath;
INT sel, len;
hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION);
sel = SendMessageW(hRunCmd,
CB_GETCURSEL,
0,
0);
if (sel != CB_ERR)
{
if (SendMessageW(hRunCmd,
CB_GETLBTEXT,
sel,
szTextCmd) != CB_ERR)
{
lpDllPath = SendMessage(hRunCmd,
CB_GETITEMDATA,
0,
0);
if (lpDllPath)
{
LPWSTR module = szTextCmd;
LPSTR lpTest;
while (*(module++) != L':' && *module != L'\0')
;
if (*module)
{
if (UnicodeToAnsi(module, &lpTest))
{
HMODULE hDll;
RUNTEST RunTest;
hDll = LoadLibraryW(lpDllPath);
if (hDll)
{
RunTest = (RUNTEST)GetProcAddress(hDll, "RunTest");
if (RunTest)
{
RunTest(lpTest);
}
FreeLibrary(hDll);
}
DisplayError(GetLastError());
HeapFree(GetProcessHeap(), 0, lpTest);
}
}
}
}
}
}
static VOID
AddTestToCombo(PMAIN_WND_INFO pInfo)
{
HWND hRunCmd;
LPWSTR lpDllPath;
INT len;
hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION);
if (hRunCmd)
{
SendMessageW(hRunCmd,
CB_INSERTSTRING,
0,
pInfo->SelectedTest.szRunString);
len = (wcslen(pInfo->SelectedTest.szSelectedDll) + 1) * sizeof(WCHAR);
lpDllPath = HeapAlloc(GetProcessHeap(), 0, len);
if (lpDllPath)
{
wcsncpy(lpDllPath,
pInfo->SelectedTest.szSelectedDll,
len / sizeof(WCHAR));
}
SendMessageW(hRunCmd,
CB_SETITEMDATA,
0,
lpDllPath);
SendMessageW(hRunCmd,
CB_SETCURSEL,
0,
0);
}
}
static VOID
FreeTestCmdStrings(PMAIN_WND_INFO pInfo)
{
HWND hRunCmd;
WCHAR szTextCmd[MAX_RUN_CMD];
LPWSTR lpDllPath;
INT cnt, i;
hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION);
cnt = SendMessageW(hRunCmd,
CB_GETCOUNT,
0,
0);
if (cnt != CB_ERR)
{
for (i = 0; i < cnt; i++)
{
lpDllPath = SendMessage(hRunCmd,
CB_GETITEMDATA,
i,
0);
if (lpDllPath)
{
HeapFree(GetProcessHeap(), 0, lpDllPath);
}
}
}
}
static BOOL CALLBACK static BOOL CALLBACK
MainDlgProc(HWND hDlg, MainDlgProc(HWND hDlg,
@ -89,27 +213,45 @@ MainDlgProc(HWND hDlg,
switch(LOWORD(wParam)) switch(LOWORD(wParam))
{ {
case IDC_BROWSE: case IDC_BROWSE:
DialogBoxParamW(hInstance, {
MAKEINTRESOURCEW(IDD_TESTBROWSER), INT_PTR ret;
hDlg,
(DLGPROC)BrowseDlgProc,
(LPARAM)pInfo);
ret = DialogBoxParamW(hInstance,
MAKEINTRESOURCEW(IDD_TESTBROWSER),
hDlg,
(DLGPROC)BrowseDlgProc,
(LPARAM)pInfo);
if (ret == IDOK)
{
AddTestToCombo(pInfo);
}
break;
}
case IDC_RUN:
RunSelectedTest(pInfo);
break; break;
case IDOK: case IDOK:
EndDialog(hDlg, 0); EndDialog(hDlg, 0);
break; break;
} }
} }
break; break;
case WM_CLOSE: case WM_CLOSE:
if (pInfo->hSmIcon) EndDialog(hDlg, 0);
break;
case WM_DESTROY:
if (pInfo->hSmIcon)
DestroyIcon(pInfo->hSmIcon); DestroyIcon(pInfo->hSmIcon);
if (pInfo->hBgIcon) if (pInfo->hBgIcon)
DestroyIcon(pInfo->hBgIcon); DestroyIcon(pInfo->hBgIcon);
EndDialog(hDlg, 0);
FreeTestCmdStrings(pInfo);
break; break;
HandleDefaultMessage: HandleDefaultMessage:

View file

@ -274,8 +274,38 @@ AnsiToUnicode(LPCSTR lpSrcStr,
*lpDstStr = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR)); *lpDstStr = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR));
if (*lpDstStr) if (*lpDstStr)
{ {
ret = MultiByteToWideChar(CP_ACP, 0, lpSrcStr, -1, *lpDstStr, length); ret = MultiByteToWideChar(CP_ACP,
0,
lpSrcStr,
-1,
*lpDstStr,
length);
} }
return ret; return ret;
} }
DWORD
UnicodeToAnsi(LPCWSTR lpSrcStr,
LPSTR *lpDstStr)
{
INT length;
INT ret = 0;
length = wcslen(lpSrcStr) + 1;
*lpDstStr = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, length);
if (*lpDstStr)
{
ret = WideCharToMultiByte(CP_ACP,
0,
lpSrcStr,
-1,
*lpDstStr,
length,
NULL,
NULL);
}
return ret;
}

View file

@ -39,6 +39,7 @@ typedef struct _MAIN_WND_INFO
/* dll exports */ /* dll exports */
wchar_t *GetTestName(); wchar_t *GetTestName();
int GetModulesInTest(char **modules); int GetModulesInTest(char **modules);
int RunTest(const char *lpTest);
/* browsewnd.c */ /* browsewnd.c */
@ -49,5 +50,6 @@ HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT
VOID DisplayMessage(LPWSTR lpMsg); VOID DisplayMessage(LPWSTR lpMsg);
VOID DisplayError(INT err); VOID DisplayError(INT err);
DWORD AnsiToUnicode(LPCSTR lpSrcStr, LPWSTR *lpDstStr); DWORD AnsiToUnicode(LPCSTR lpSrcStr, LPWSTR *lpDstStr);
DWORD UnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR *lpDstStr);
#endif /* __WINETESTGUI_PRECOMP_H */ #endif /* __WINETESTGUI_PRECOMP_H */