Author: gedmurphy
Date: Sat Jun 21 14:19:22 2008
New Revision: 34043
URL:
http://svn.reactos.org/svn/reactos?rev=34043&view=rev
Log:
- 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.
Modified:
trunk/rostests/winetests/GUI/browsewnd.c
trunk/rostests/winetests/GUI/mainwnd.c
trunk/rostests/winetests/GUI/misc.c
trunk/rostests/winetests/GUI/precomp.h
Modified: trunk/rostests/winetests/GUI/browsewnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/GUI/browsewnd.c…
==============================================================================
--- trunk/rostests/winetests/GUI/browsewnd.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/GUI/browsewnd.c [iso-8859-1] Sat Jun 21 14:19:22 2008
@@ -63,7 +63,9 @@
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 @@
FreeLibrary(hDll);
}
}
+
+ if (hRoot)
+ {
+ TreeView_Expand(pInfo->hBrowseTV,
+ hRoot,
+ TVE_EXPAND);
+ }
}
static VOID
@@ -340,7 +349,6 @@
PopulateTreeView(pInfo);
}
}
-
static BOOL
OnInitBrowseDialog(HWND hDlg,
@@ -360,7 +368,6 @@
return TRUE;
}
-
BOOL CALLBACK
BrowseDlgProc(HWND hDlg,
@@ -433,6 +440,8 @@
TraverseTreeView(pInfo, hItem);
+ pInfo->hBrowseDlg = NULL;
+
break;
}
@@ -442,4 +451,4 @@
}
return FALSE;
-}
+}
Modified: trunk/rostests/winetests/GUI/mainwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/GUI/mainwnd.c?r…
==============================================================================
--- trunk/rostests/winetests/GUI/mainwnd.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/GUI/mainwnd.c [iso-8859-1] Sat Jun 21 14:19:22 2008
@@ -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 @@
(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 @@
}
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 @@
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 @@
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:
Modified: trunk/rostests/winetests/GUI/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/GUI/misc.c?rev=…
==============================================================================
--- trunk/rostests/winetests/GUI/misc.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/GUI/misc.c [iso-8859-1] Sat Jun 21 14:19:22 2008
@@ -274,8 +274,38 @@
*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;
-}
+}
+
+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;
+}
Modified: trunk/rostests/winetests/GUI/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/GUI/precomp.h?r…
==============================================================================
--- trunk/rostests/winetests/GUI/precomp.h [iso-8859-1] (original)
+++ trunk/rostests/winetests/GUI/precomp.h [iso-8859-1] Sat Jun 21 14:19:22 2008
@@ -39,6 +39,7 @@
/* dll exports */
wchar_t *GetTestName();
int GetModulesInTest(char **modules);
+int RunTest(const char *lpTest);
/* browsewnd.c */
@@ -49,5 +50,6 @@
VOID DisplayMessage(LPWSTR lpMsg);
VOID DisplayError(INT err);
DWORD AnsiToUnicode(LPCSTR lpSrcStr, LPWSTR *lpDstStr);
+DWORD UnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR *lpDstStr);
#endif /* __WINETESTGUI_PRECOMP_H */