diff --git a/rostests/winetests/GUI/browsewnd.c b/rostests/winetests/GUI/browsewnd.c index 16d104f0f73..613fc79dbb5 100644 --- a/rostests/winetests/GUI/browsewnd.c +++ b/rostests/winetests/GUI/browsewnd.c @@ -9,18 +9,16 @@ #include -#define DLL_SEARCH_DIR L"\\Debug\\testlibs\\*" +#define EXE_SEARCH_DIR L"\\Debug\\testexes\\*" #define IL_MAIN 0 #define IL_TEST 1 #define HAS_NO_CHILD 0 #define HAS_CHILD 1 -typedef wchar_t *(__cdecl *DLLNAME)(); -typedef int (_cdecl *MODULES)(char **); static INT -GetNumberOfDllsInFolder(LPWSTR lpFolder) +GetNumberOfExesInFolder(LPWSTR lpFolder) { HANDLE hFind; WIN32_FIND_DATAW findFileData; @@ -46,52 +44,52 @@ GetNumberOfDllsInFolder(LPWSTR lpFolder) } static INT -GetListOfTestDlls(PMAIN_WND_INFO pInfo) +GetListOfTestExes(PMAIN_WND_INFO pInfo) { HANDLE hFind; WIN32_FIND_DATAW findFileData; - WCHAR szDllPath[MAX_PATH]; + WCHAR szExePath[MAX_PATH]; LPWSTR ptr; INT numFiles = 0; INT len; - len = GetCurrentDirectory(MAX_PATH, szDllPath); + len = GetCurrentDirectory(MAX_PATH, szExePath); if (!len) return 0; - wcsncat(szDllPath, DLL_SEARCH_DIR, MAX_PATH - (len + 1)); + wcsncat(szExePath, EXE_SEARCH_DIR, MAX_PATH - (len + 1)); - numFiles = GetNumberOfDllsInFolder(szDllPath); + numFiles = GetNumberOfExesInFolder(szExePath); if (!numFiles) return 0; - pInfo->lpDllList = HeapAlloc(GetProcessHeap(), + pInfo->lpExeList = HeapAlloc(GetProcessHeap(), 0, numFiles * (MAX_PATH * sizeof(WCHAR))); - if (!pInfo->lpDllList) + if (!pInfo->lpExeList) return 0; - hFind = FindFirstFileW(szDllPath, + hFind = FindFirstFileW(szExePath, &findFileData); if (hFind == INVALID_HANDLE_VALUE) { DisplayError(GetLastError()); - HeapFree(GetProcessHeap(), 0, pInfo->lpDllList); + HeapFree(GetProcessHeap(), 0, pInfo->lpExeList); return 0; } /* remove the glob */ - ptr = wcschr(szDllPath, L'*'); + ptr = wcschr(szExePath, L'*'); if (ptr) *ptr = L'\0'; - /* don't mod our base pointer */ - ptr = pInfo->lpDllList; + /* don't modify our base pointer */ + ptr = pInfo->lpExeList; do { if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { /* set the path */ - wcscpy(ptr, szDllPath); + wcscpy(ptr, szExePath); /* tag the file onto the path */ len = MAX_PATH - (wcslen(ptr) + 1); @@ -207,7 +205,7 @@ InsertIntoTreeView(HWND hTreeView, } static PTEST_ITEM -BuildTestItemData(LPWSTR lpDll, +BuildTestItemData(LPWSTR lpExe, LPWSTR lpRun) { PTEST_ITEM pItem; @@ -217,8 +215,8 @@ BuildTestItemData(LPWSTR lpDll, sizeof(TEST_ITEM)); if (pItem) { - if (lpDll) - wcsncpy(pItem->szSelectedDll, lpDll, MAX_PATH); + if (lpExe) + wcsncpy(pItem->szSelectedExe, lpExe, MAX_PATH); if (lpRun) wcsncpy(pItem->szRunString, lpRun, MAX_RUN_CMD); } @@ -232,12 +230,9 @@ PopulateTreeView(PMAIN_WND_INFO pInfo) HTREEITEM hRoot; HIMAGELIST hImgList; PTEST_ITEM pTestItem; - DLLNAME GetTestName; - MODULES GetModulesInTest; - HMODULE hDll; - LPWSTR lpDllPath; + LPWSTR lpExePath; LPWSTR lpTestName; - INT RootImage, i; + INT i; pInfo->hBrowseTV = GetDlgItem(pInfo->hBrowseDlg, IDC_TREEVIEW); @@ -259,76 +254,36 @@ PopulateTreeView(PMAIN_WND_INFO pInfo) hRoot = InsertIntoTreeView(pInfo->hBrowseTV, NULL, L"Full", - pTestItem, + (LPARAM)pTestItem, IL_MAIN, HAS_CHILD); - for (i = 0; i < pInfo->numDlls; i++) + for (i = 0; i < pInfo->numExes; i++) { - lpDllPath = pInfo->lpDllList + (MAX_PATH * i); + HTREEITEM hParent; + LPWSTR lpStr; - hDll = LoadLibraryW(lpDllPath); - if (hDll) + lpExePath = pInfo->lpExeList + (MAX_PATH * i); + + lpTestName = wcsrchr(lpExePath, L'\\'); + if (lpTestName) { - GetTestName = (DLLNAME)GetProcAddress(hDll, "GetTestName"); - if (GetTestName) + lpTestName++; + + lpStr = wcschr(lpTestName, L'_'); + if (lpStr) { - HTREEITEM hParent; - LPSTR lpModules, ptr; - LPWSTR lpModW; - INT numMods; + //FIXME: Query the test name from the exe directly - lpTestName = GetTestName(); - - pTestItem = BuildTestItemData(lpDllPath, lpTestName); + pTestItem = BuildTestItemData(lpExePath, lpTestName); hParent = InsertIntoTreeView(pInfo->hBrowseTV, hRoot, lpTestName, - pTestItem, + (LPARAM)pTestItem, IL_TEST, HAS_CHILD); - if (hParent) - { - /* Get the list of modules a dll offers. This is returned as list of - * Ansi null-terminated strings, terminated with an empty string (double null) */ - GetModulesInTest = (MODULES)GetProcAddress(hDll, "GetModulesInTest"); - if ((numMods = GetModulesInTest(&lpModules))) - { - ptr = lpModules; - while (numMods && *ptr != '\0') - { - /* convert the string to unicode */ - if (AnsiToUnicode(ptr, &lpModW)) - { - WCHAR szRunCmd[MAX_RUN_CMD]; - - _snwprintf(szRunCmd, MAX_RUN_CMD, L"%s:%s", lpTestName, lpModW); - pTestItem = BuildTestItemData(lpDllPath, szRunCmd); - - InsertIntoTreeView(pInfo->hBrowseTV, - hParent, - lpModW, - pTestItem, - IL_TEST, - HAS_NO_CHILD); - - HeapFree(GetProcessHeap(), 0, lpModW); - } - - /* move onto next string */ - while (*(ptr++) != '\0') - ; - - numMods--; - } - - HeapFree(GetProcessHeap(), 0, lpModules); - } - } } - - FreeLibrary(hDll); } } @@ -343,8 +298,8 @@ PopulateTreeView(PMAIN_WND_INFO pInfo) static VOID PopulateTestList(PMAIN_WND_INFO pInfo) { - pInfo->numDlls = GetListOfTestDlls(pInfo); - if (pInfo->numDlls) + pInfo->numExes = GetListOfTestExes(pInfo); + if (pInfo->numExes) { PopulateTreeView(pInfo); } @@ -417,16 +372,17 @@ BrowseDlgProc(HWND hDlg, DisplayMessage(L"Please select an item"); } - break; + return TRUE; } case IDCANCEL: { - HeapFree(GetProcessHeap(), 0, pInfo->lpDllList); - pInfo->lpDllList = NULL; + HeapFree(GetProcessHeap(), 0, pInfo->lpExeList); + pInfo->lpExeList = NULL; EndDialog(hDlg, LOWORD(wParam)); + return TRUE; } } diff --git a/rostests/winetests/GUI/lang/en-US.rc b/rostests/winetests/GUI/lang/en-US.rc index 3b2578cb931..c3a506c1465 100644 --- a/rostests/winetests/GUI/lang/en-US.rc +++ b/rostests/winetests/GUI/lang/en-US.rc @@ -8,7 +8,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,236,241,50,14,WS_GROUP CONTROL "",IDC_LIST,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,69,279,103 EDITTEXT IDC_OUTPUT,7,175,279,62,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY - COMBOBOX IDC_TESTSELECTION,27,12,205,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_TESTSELECTION,27,12,205,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP LTEXT "Test:",IDC_STATIC,6,14,18,8 PUSHBUTTON "Browse...",IDC_BROWSE,236,11,50,14 PUSHBUTTON "Run",IDC_RUN,236,30,50,14 @@ -19,8 +19,9 @@ BEGIN LTEXT "?",IDC_NUMERRORS,85,53,8,8 LTEXT "Failures:",IDC_STATIC,107,53,28,8 LTEXT "?",IDC_NUMFAILURES,141,53,8,8 + PUSHBUTTON "Options",IDC_OPTIONS,181,49,50,14 PUSHBUTTON "Stop",IDC_STOP,236,49,50,14 - CONTROL "Run on start",IDC_RUNONSTART,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,52,56,10 + LTEXT "status bar",IDC_STATUS,7,244,210,8 END @@ -29,7 +30,18 @@ STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME CAPTION "Test hierarchy" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - PUSHBUTTON "Select", IDOK, 202, 7, 50, 14 - PUSHBUTTON "Close", IDCANCEL, 202, 34, 50, 14 - CONTROL "", IDC_TREEVIEW, "SysTreeView32", WS_BORDER | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT, 7, 7, 189, 236 + PUSHBUTTON "Select", IDOK, 202, 7, 50, 14 + PUSHBUTTON "Close", IDCANCEL, 202, 34, 50, 14 + CONTROL "", IDC_TREEVIEW, "SysTreeView32", WS_BORDER | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT, 7, 7, 189, 236 +END + +IDD_OPTIONS DIALOGEX 0, 0, 180, 100 +STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME +CAPTION "Options" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + PUSHBUTTON "OK", IDOK, 70, 80, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 125, 80, 50, 14 + CONTROL "Hide console window",IDC_HIDECONSOLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,10,80,10 + CONTROL "Run on start",IDC_RUNONSTART,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,30,80,10 END diff --git a/rostests/winetests/GUI/mainwnd.c b/rostests/winetests/GUI/mainwnd.c index 485de7ab60b..1fb27dd9ea7 100644 --- a/rostests/winetests/GUI/mainwnd.c +++ b/rostests/winetests/GUI/mainwnd.c @@ -8,17 +8,30 @@ */ #include +#include + +#define BUFSIZE 4096 HINSTANCE hInstance; +WCHAR szPipeName[] = L"\\\\.\\pipe\\winetest_pipe"; + typedef int (_cdecl *RUNTEST)(char **); + +VOID +CreateClientProcess(PMAIN_WND_INFO pInfo, + LPWSTR lpExePath) +{ + +} + + static BOOL OnInitMainDialog(HWND hDlg, LPARAM lParam) { PMAIN_WND_INFO pInfo; - LPWSTR lpAboutText; pInfo = (PMAIN_WND_INFO)lParam; @@ -65,8 +78,8 @@ RunSelectedTest(PMAIN_WND_INFO pInfo) { HWND hRunCmd; WCHAR szTextCmd[MAX_RUN_CMD]; - LPWSTR lpDllPath; - INT sel, len; + LPWSTR lpExePath; + INT sel; hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION); @@ -79,44 +92,15 @@ RunSelectedTest(PMAIN_WND_INFO pInfo) if (SendMessageW(hRunCmd, CB_GETLBTEXT, sel, - szTextCmd) != CB_ERR) + (LPARAM)szTextCmd) != CB_ERR) { - lpDllPath = SendMessage(hRunCmd, - CB_GETITEMDATA, - 0, - 0); - if (lpDllPath) + lpExePath = (LPWSTR)SendMessage(hRunCmd, + CB_GETITEMDATA, + 0, + 0); + if (lpExePath) { - 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); - } - } - + CreateClientProcess(pInfo, lpExePath); } } } @@ -126,7 +110,7 @@ static VOID AddTestToCombo(PMAIN_WND_INFO pInfo) { HWND hRunCmd; - LPWSTR lpDllPath; + LPWSTR lpExePath; INT len; hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION); @@ -135,21 +119,21 @@ AddTestToCombo(PMAIN_WND_INFO pInfo) SendMessageW(hRunCmd, CB_INSERTSTRING, 0, - pInfo->SelectedTest.szRunString); + (LPARAM)pInfo->SelectedTest.szRunString); - len = (wcslen(pInfo->SelectedTest.szSelectedDll) + 1) * sizeof(WCHAR); - lpDllPath = HeapAlloc(GetProcessHeap(), 0, len); - if (lpDllPath) + len = (wcslen(pInfo->SelectedTest.szSelectedExe) + 1) * sizeof(WCHAR); + lpExePath = HeapAlloc(GetProcessHeap(), 0, len); + if (lpExePath) { - wcsncpy(lpDllPath, - pInfo->SelectedTest.szSelectedDll, + wcsncpy(lpExePath, + pInfo->SelectedTest.szSelectedExe, len / sizeof(WCHAR)); } SendMessageW(hRunCmd, CB_SETITEMDATA, 0, - lpDllPath); + (LPARAM)lpExePath); SendMessageW(hRunCmd, CB_SETCURSEL, 0, @@ -161,8 +145,7 @@ static VOID FreeTestCmdStrings(PMAIN_WND_INFO pInfo) { HWND hRunCmd; - WCHAR szTextCmd[MAX_RUN_CMD]; - LPWSTR lpDllPath; + LPWSTR lpExePath; INT cnt, i; hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION); @@ -175,13 +158,13 @@ FreeTestCmdStrings(PMAIN_WND_INFO pInfo) { for (i = 0; i < cnt; i++) { - lpDllPath = SendMessage(hRunCmd, - CB_GETITEMDATA, - i, - 0); - if (lpDllPath) + lpExePath = (LPWSTR)SendMessage(hRunCmd, + CB_GETITEMDATA, + i, + 0); + if (lpExePath) { - HeapFree(GetProcessHeap(), 0, lpDllPath); + HeapFree(GetProcessHeap(), 0, lpExePath); } } } @@ -228,6 +211,13 @@ MainDlgProc(HWND hDlg, break; } + case IDC_OPTIONS: + DialogBoxParamW(hInstance, + MAKEINTRESOURCEW(IDD_OPTIONS), + hDlg, + (DLGPROC)OptionsDlgProc, + (LPARAM)pInfo); + break; case IDC_RUN: RunSelectedTest(pInfo); @@ -271,7 +261,12 @@ wWinMain(HINSTANCE hInst, { INITCOMMONCONTROLSEX iccx; PMAIN_WND_INFO pInfo; - INT Ret = 1; + HANDLE hThread; + INT Ret = -1; + + UNREFERENCED_PARAMETER(hPrev); + UNREFERENCED_PARAMETER(Cmd); + UNREFERENCED_PARAMETER(iCmd); hInstance = hInst; @@ -280,7 +275,9 @@ wWinMain(HINSTANCE hInst, iccx.dwICC = ICC_TAB_CLASSES; InitCommonControlsEx(&iccx); - pInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(MAIN_WND_INFO)); + pInfo = HeapAlloc(GetProcessHeap(), + 0, + sizeof(MAIN_WND_INFO)); if (pInfo) { Ret = (DialogBoxParamW(hInstance, @@ -289,8 +286,9 @@ wWinMain(HINSTANCE hInst, (DLGPROC)MainDlgProc, (LPARAM)pInfo) == IDOK); - HeapFree(GetProcessHeap(), 0, pInfo); - + HeapFree(GetProcessHeap(), + 0, + pInfo); } return Ret; diff --git a/rostests/winetests/GUI/misc.c b/rostests/winetests/GUI/misc.c index a77db7ff210..7830f277315 100644 --- a/rostests/winetests/GUI/misc.c +++ b/rostests/winetests/GUI/misc.c @@ -238,12 +238,12 @@ InitImageList(UINT StartResource, /* Add all icons to the image list */ for (i = StartResource; i <= EndResource; i++) { - hIcon = (HBITMAP)LoadImageW(hInstance, - MAKEINTRESOURCEW(i), - IMAGE_ICON, - Width, - Height, - LR_DEFAULTCOLOR); + hIcon = (HICON)LoadImageW(hInstance, + MAKEINTRESOURCEW(i), + IMAGE_ICON, + Width, + Height, + LR_DEFAULTCOLOR); if (hIcon == NULL) goto fail; @@ -294,7 +294,7 @@ UnicodeToAnsi(LPCWSTR lpSrcStr, length = wcslen(lpSrcStr) + 1; - *lpDstStr = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, length); + *lpDstStr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, length); if (*lpDstStr) { ret = WideCharToMultiByte(CP_ACP, diff --git a/rostests/winetests/GUI/optionswnd.c b/rostests/winetests/GUI/optionswnd.c new file mode 100644 index 00000000000..be5c01b47ee --- /dev/null +++ b/rostests/winetests/GUI/optionswnd.c @@ -0,0 +1,100 @@ +/* + * PROJECT: ReactOS API Test GUI + * LICENSE: GPL - See COPYING in the top level directory + * FILE: + * PURPOSE: options dialog implementation + * COPYRIGHT: Copyright 2008 Ged Murphy + * + */ + +#include + +static BOOL +OnInitBrowseDialog(HWND hDlg, + LPARAM lParam) +{ + PMAIN_WND_INFO pInfo; + + pInfo = (PMAIN_WND_INFO)lParam; + + pInfo->hBrowseDlg = hDlg; + + SetWindowLongPtr(hDlg, + GWLP_USERDATA, + (LONG_PTR)pInfo); + + return TRUE; +} + + +BOOL CALLBACK +OptionsDlgProc(HWND hDlg, + UINT Message, + WPARAM wParam, + LPARAM lParam) +{ + PMAIN_WND_INFO pInfo; + + //UNREFERENCED_PARAM( + + /* Get the window context */ + pInfo = (PMAIN_WND_INFO)GetWindowLongPtr(hDlg, + GWLP_USERDATA); + if (pInfo == NULL && Message != WM_INITDIALOG) + { + goto HandleDefaultMessage; + } + + switch(Message) + { + case WM_INITDIALOG: + return OnInitBrowseDialog(hDlg, lParam); + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDOK: + { + if (SendMessageW(GetDlgItem(hDlg, IDC_RUNONSTART), BM_GETCHECK, 0, 0) == BST_CHECKED) + { + pInfo->bRunOnStart = TRUE; + } + else + { + pInfo->bRunOnStart = FALSE; + } + + if (SendMessageW(GetDlgItem(hDlg, IDC_HIDECONSOLE), BM_GETCHECK, 0, 0) == BST_CHECKED) + { + pInfo->bHideConsole = TRUE; + } + else + { + pInfo->bHideConsole = FALSE; + } + + EndDialog(hDlg, + LOWORD(wParam)); + + return TRUE; + } + + case IDCANCEL: + { + EndDialog(hDlg, + LOWORD(wParam)); + + return TRUE; + } + } + + break; + } +HandleDefaultMessage: + default: + return FALSE; + } + + return FALSE; +} diff --git a/rostests/winetests/GUI/precomp.h b/rostests/winetests/GUI/precomp.h index 900276f4cb5..c601f5b1907 100644 --- a/rostests/winetests/GUI/precomp.h +++ b/rostests/winetests/GUI/precomp.h @@ -13,7 +13,7 @@ extern HINSTANCE hInstance; typedef struct _TEST_ITEM { - WCHAR szSelectedDll[MAX_PATH]; + WCHAR szSelectedExe[MAX_PATH]; WCHAR szRunString[MAX_RUN_CMD]; } TEST_ITEM, *PTEST_ITEM; @@ -24,16 +24,20 @@ typedef struct _MAIN_WND_INFO HWND hBrowseDlg; HWND hBrowseTV; HWND hStatus; + HANDLE hPipe; int nCmdShow; HICON hSmIcon; HICON hBgIcon; - LPWSTR lpDllList; - INT numDlls; + LPWSTR lpExeList; + INT numExes; TEST_ITEM SelectedTest; + BOOL bRunOnStart; + BOOL bHideConsole; + } MAIN_WND_INFO, *PMAIN_WND_INFO; /* dll exports */ @@ -42,9 +46,15 @@ int GetModulesInTest(char **modules); int RunTest(const char *lpTest); +/* mainwnd.c */ +BOOL SendCommandToClient(PMAIN_WND_INFO pInfo, LPWSTR lpCommand); + /* browsewnd.c */ BOOL CALLBACK BrowseDlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam); +/* optionswnd.c */ +BOOL CALLBACK OptionsDlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam); + /* misc.c */ HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT Height); VOID DisplayMessage(LPWSTR lpMsg); diff --git a/rostests/winetests/GUI/resource.h b/rostests/winetests/GUI/resource.h index e206fbcb082..5a0994cb045 100644 --- a/rostests/winetests/GUI/resource.h +++ b/rostests/winetests/GUI/resource.h @@ -1,6 +1,7 @@ #define IDD_WINETESTGUI 102 #define IDD_TESTBROWSER 103 -#define IDM_ABOUT 104 +#define IDD_OPTIONS 104 +//#define IDM_ABOUT 104 #define IDM_EXIT 105 #define IDI_ICON 107 #define IDI_TESTS 108 @@ -16,9 +17,12 @@ #define IDC_NUMERRORS 1007 #define IDC_NUMFAILURES 1008 #define IDC_STOP 1010 -#define IDC_CHECK2 1011 -#define IDC_RUNONSTART 1011 +#define IDC_OPTIONS 1011 +#define IDC_SELECT 1013 +#define IDC_TREEVIEW 1014 + +#define IDC_HIDECONSOLE 1020 +#define IDC_RUNONSTART 1021 #define IDC_STATUS 1012 -#define IDC_SELECT 1020 -#define IDC_TREEVIEW 1021 + #define IDC_STATIC -1