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

File:
1 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} 
Note: See TracChangeset for help on using the changeset viewer.