diff --git a/rostests/winetests/GUI/browsewnd.c b/rostests/winetests/GUI/browsewnd.c index ae4f83d8950..16d104f0f73 100644 --- a/rostests/winetests/GUI/browsewnd.c +++ b/rostests/winetests/GUI/browsewnd.c @@ -63,7 +63,9 @@ GetListOfTestDlls(PMAIN_WND_INFO pInfo) numFiles = GetNumberOfDllsInFolder(szDllPath); 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) return 0; @@ -329,6 +331,13 @@ PopulateTreeView(PMAIN_WND_INFO pInfo) FreeLibrary(hDll); } } + + if (hRoot) + { + TreeView_Expand(pInfo->hBrowseTV, + hRoot, + TVE_EXPAND); + } } static VOID @@ -341,7 +350,6 @@ PopulateTestList(PMAIN_WND_INFO pInfo) } } - static BOOL OnInitBrowseDialog(HWND hDlg, LPARAM lParam) @@ -361,7 +369,6 @@ OnInitBrowseDialog(HWND hDlg, return TRUE; } - BOOL CALLBACK BrowseDlgProc(HWND hDlg, UINT Message, @@ -433,6 +440,8 @@ BrowseDlgProc(HWND hDlg, TraverseTreeView(pInfo, hItem); + pInfo->hBrowseDlg = NULL; + break; } @@ -442,4 +451,4 @@ HandleDefaultMessage: } return FALSE; -} \ No newline at end of file +} diff --git a/rostests/winetests/GUI/mainwnd.c b/rostests/winetests/GUI/mainwnd.c index 113dcd091eb..485de7ab60b 100644 --- a/rostests/winetests/GUI/mainwnd.c +++ b/rostests/winetests/GUI/mainwnd.c @@ -11,15 +11,13 @@ HINSTANCE hInstance; - - +typedef int (_cdecl *RUNTEST)(char **); static BOOL OnInitMainDialog(HWND hDlg, LPARAM lParam) { PMAIN_WND_INFO pInfo; - //HMENU hSysMenu; LPWSTR lpAboutText; pInfo = (PMAIN_WND_INFO)lParam; @@ -32,11 +30,11 @@ OnInitMainDialog(HWND hDlg, (LONG_PTR)pInfo); pInfo->hSmIcon = LoadImageW(hInstance, - MAKEINTRESOURCEW(IDI_ICON), - IMAGE_ICON, - 16, - 16, - 0); + MAKEINTRESOURCEW(IDI_ICON), + IMAGE_ICON, + 16, + 16, + 0); if (pInfo->hSmIcon) { SendMessageW(hDlg, @@ -46,11 +44,11 @@ OnInitMainDialog(HWND hDlg, } pInfo->hBgIcon = LoadImageW(hInstance, - MAKEINTRESOURCEW(IDI_ICON), - IMAGE_ICON, - 32, - 32, - 0); + MAKEINTRESOURCEW(IDI_ICON), + IMAGE_ICON, + 32, + 32, + 0); if (pInfo->hBgIcon) { SendMessageW(hDlg, @@ -62,6 +60,132 @@ OnInitMainDialog(HWND hDlg, 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 MainDlgProc(HWND hDlg, @@ -89,27 +213,45 @@ MainDlgProc(HWND hDlg, switch(LOWORD(wParam)) { case IDC_BROWSE: - DialogBoxParamW(hInstance, - MAKEINTRESOURCEW(IDD_TESTBROWSER), - hDlg, - (DLGPROC)BrowseDlgProc, - (LPARAM)pInfo); + { + INT_PTR ret; + ret = DialogBoxParamW(hInstance, + MAKEINTRESOURCEW(IDD_TESTBROWSER), + hDlg, + (DLGPROC)BrowseDlgProc, + (LPARAM)pInfo); + if (ret == IDOK) + { + AddTestToCombo(pInfo); + } + + break; + } + + case IDC_RUN: + RunSelectedTest(pInfo); break; case IDOK: EndDialog(hDlg, 0); - break; + break; } } break; case WM_CLOSE: - if (pInfo->hSmIcon) + EndDialog(hDlg, 0); + break; + + case WM_DESTROY: + if (pInfo->hSmIcon) DestroyIcon(pInfo->hSmIcon); if (pInfo->hBgIcon) DestroyIcon(pInfo->hBgIcon); - EndDialog(hDlg, 0); + + FreeTestCmdStrings(pInfo); + break; HandleDefaultMessage: diff --git a/rostests/winetests/GUI/misc.c b/rostests/winetests/GUI/misc.c index 215b3d3119b..a77db7ff210 100644 --- a/rostests/winetests/GUI/misc.c +++ b/rostests/winetests/GUI/misc.c @@ -274,8 +274,38 @@ AnsiToUnicode(LPCSTR lpSrcStr, *lpDstStr = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR)); if (*lpDstStr) { - ret = MultiByteToWideChar(CP_ACP, 0, lpSrcStr, -1, *lpDstStr, length); + ret = MultiByteToWideChar(CP_ACP, + 0, + lpSrcStr, + -1, + *lpDstStr, + length); } return ret; -} \ No newline at end of file +} + +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; +} diff --git a/rostests/winetests/GUI/precomp.h b/rostests/winetests/GUI/precomp.h index 91d3481f335..900276f4cb5 100644 --- a/rostests/winetests/GUI/precomp.h +++ b/rostests/winetests/GUI/precomp.h @@ -39,6 +39,7 @@ typedef struct _MAIN_WND_INFO /* dll exports */ wchar_t *GetTestName(); int GetModulesInTest(char **modules); +int RunTest(const char *lpTest); /* browsewnd.c */ @@ -49,5 +50,6 @@ HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT VOID DisplayMessage(LPWSTR lpMsg); VOID DisplayError(INT err); DWORD AnsiToUnicode(LPCSTR lpSrcStr, LPWSTR *lpDstStr); +DWORD UnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR *lpDstStr); #endif /* __WINETESTGUI_PRECOMP_H */