Changeset 104 for trunk/MFCtooling


Ignore:
Timestamp:
07/05/11 11:10:35 (13 years ago)
Author:
sherbold
Message:
  • improved output in case of wrong startup parameters
  • parameter for application under test now mandatory
  • automatically closes application under test at the end of a session in case it is still open

+ support for multiple sessions in one replay file

Location:
trunk/MFCtooling/replay
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MFCtooling/replay/LogParser.cpp

    r32 r104  
    66#include "WindowFinder.h" 
    77 
    8 LogParser::LogParser(void) 
     8LogParser::LogParser(_TCHAR* runCommand, unsigned int startupTime, bool useDefaultDelay) : runCommand(runCommand), startupTime(startupTime), useDefaultDelay(useDefaultDelay) 
    99{ 
    1010         
     
    2828        std::wstring localName(pwchLocalName); 
    2929        if( localName.compare(L"session")==0 ) { 
    30                 // TODO 
     30                std::wstring sessionId = GetAttributeValue(pAttributes, L"id", L""); 
     31                std::wcout << L"================================================" << std::endl; 
     32                std::wcout << L"starting session " << sessionId << std::endl; 
     33                std::wcout << L"executing " << runCommand << std::endl; 
     34                PROCESS_INFORMATION pi; 
     35                STARTUPINFO si; 
     36                ZeroMemory(&pi, sizeof(pi)); 
     37                ZeroMemory(&si, sizeof(si)); 
     38                CreateProcess(NULL, runCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); 
     39                hProcess = pi.hProcess; 
     40                CloseHandle(pi.hThread); 
     41                std::wcout << L"waiting " << startupTime << L" ms for application under test to intialize" << std::endl; 
     42                Sleep(startupTime); 
     43                std::wcout << L"replay starting..." << std::endl; 
    3144        } 
    3245        else if( localName.compare(L"msg")==0 ) { 
     
    7689        std::wstring localName(pwchLocalName); 
    7790        if( localName.compare(L"session")==0 ) { 
    78                 // TODO 
     91                std::wcout << L"session completed" << std::endl; 
     92                BOOL retVal = TerminateProcess(hProcess, 0); 
     93                if( retVal!=0 ) { 
     94                        std::wcout << L"application terminated" << std::endl; 
     95                } 
     96                CloseHandle(hProcess); 
    7997        }  
    8098        else if( localName.compare(L"msg")==0 ) { 
     
    129147 
    130148void LogParser::sendMessage(HWND hwnd) { 
    131         std::wcout << L"Sending " << msgType << L" to " << hwnd << "L - LPARAM: " << lParam << L" - WPARAM: " << wParam << std::endl; 
     149        std::wcout << L"  Sending " << msgType << L" to " << hwnd << "L - LPARAM: " << lParam << L" - WPARAM: " << wParam << std::endl; 
    132150        PostMessage(hwnd, msgType, wParam, lParam); 
    133         Sleep(defaultMsgDelay); 
    134         //Sleep(delay); 
     151        if( useDefaultDelay ) { 
     152                Sleep(defaultMsgDelay); 
     153        } else { 
     154                Sleep(delay); 
     155        } 
    135156} 
  • trunk/MFCtooling/replay/LogParser.h

    r32 r104  
    1717        WPARAM wParam; 
    1818 
     19        boolean useDefaultDelay; 
    1920        int delay; 
    2021 
    2122        void sendMessage(HWND hwnd); 
    2223 
     24        _TCHAR * runCommand; 
     25        unsigned int startupTime; 
     26        HANDLE hProcess; 
     27 
    2328public: 
    24         LogParser(void); 
     29        LogParser(_TCHAR * runCommand, unsigned int startupChar, bool useDefaultDelay = false); 
    2530        ~LogParser(void); 
    2631 
  • trunk/MFCtooling/replay/replay.cpp

    r65 r104  
    1010int _tmain(int argc, _TCHAR* argv[]) 
    1111{ 
    12         if (argc<2)  
     12        if (argc<3)  
    1313        { 
    14                 wprintf(L"no argument provided\n"); 
     14                std::wcout << "Usage: " << argv[0] << "<replayfile> <applicationundertest>" << std::endl; 
    1515                return 0; 
    1616        } 
    1717 
    1818        // execute application to be replayed 
    19         if (argc>2) { 
     19        /*if (argc>2) { 
    2020                std::wcout << "executing " << argv[2] << std::endl; 
    2121                PROCESS_INFORMATION pi; 
     
    2525                CreateProcess(NULL, argv[2], NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); 
    2626                Sleep(10000); 
    27         } 
     27        }*/ 
    2828 
    2929 
     
    4141 
    4242        if( !FAILED(hr) ) { 
    43                 LogParser * parser = new LogParser(); 
     43                std::wcout << L"replaying sessions in " << argv[1] << std::endl; 
     44                LogParser * parser = new LogParser(argv[2], 5000, true); 
    4445                pXMLReader->putContentHandler(parser); 
    4546                hr = pXMLReader->parseURL(argv[1]); 
    46  
    4747                pXMLReader->Release(); 
     48                std::wcout << L"================================================" << std::endl; 
     49                std::wcout << L"replay completed" << std::endl; 
    4850        } 
    4951 
    5052        CoUninitialize(); 
    5153 
    52         std::wcout << "Press enter to exit ..."; 
     54        std::wcout << L"press enter to exit ..."; 
    5355        getchar(); 
    5456 
Note: See TracChangeset for help on using the changeset viewer.