1. wxStopWatch tests in console

2. some more messages in exec


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2000-03-05 02:23:53 +00:00
parent f7bd3a7d8f
commit d31b7b682c
2 changed files with 58 additions and 10 deletions

View File

@ -23,16 +23,23 @@
#include <wx/file.h>
#include <wx/app.h>
// without this pragma, the stupid compiler precompiles #defines below so that
// changing them doesn't "take place" later!
#ifdef __VISUALC__
#pragma hdrstop
#endif
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
// what to test?
// what to test (in alphabetic order)?
//#define TEST_ARRAYS
//#define TEST_CMDLINE
//#define TEST_DATETIME
//#define TEST_DIR
#define TEST_EXECUTE
//#define TEST_EXECUTE
//#define TEST_FILECONF
//#define TEST_HASH
//#define TEST_LOG
@ -41,18 +48,18 @@
//#define TEST_SOCKETS
//#define TEST_STRINGS
//#define TEST_THREADS
//#define TEST_TIME
#define TEST_TIMER
// ============================================================================
// implementation
// ============================================================================
#ifdef TEST_CMDLINE
// ----------------------------------------------------------------------------
// wxCmdLineParser
// ----------------------------------------------------------------------------
#ifdef TEST_CMDLINE
#include <wx/cmdline.h>
#include <wx/datetime.h>
@ -715,11 +722,42 @@ static void TestSocketClient()
#endif // TEST_SOCKETS
// ----------------------------------------------------------------------------
// timers
// ----------------------------------------------------------------------------
#ifdef TEST_TIMER
#include <wx/timer.h>
#include <wx/utils.h>
static void TestStopWatch()
{
puts("*** Testing wxStopWatch ***\n");
wxStopWatch sw;
printf("Sleeping 3 seconds...");
wxSleep(3);
printf("\telapsed time: %ld\n", sw.Time());
sw.Pause();
printf("Sleeping 2 more seconds...");
wxSleep(2);
printf("\telapsed time: %ld\n", sw.Time());
sw.Resume();
printf("And 3 more seconds...");
wxSleep(3);
printf("\telapsed time: %ld\n", sw.Time());
}
#endif // TEST_TIMER
// ----------------------------------------------------------------------------
// date time
// ----------------------------------------------------------------------------
#ifdef TEST_TIME
#ifdef TEST_DATETIME
#include <wx/date.h>
@ -1659,7 +1697,7 @@ static void TestTimeCompatibility()
#endif // 0
#endif // TEST_TIME
#endif // TEST_DATETIME
// ----------------------------------------------------------------------------
// threads
@ -2389,7 +2427,11 @@ int main(int argc, char **argv)
TestSocketClient();
#endif // TEST_SOCKETS
#ifdef TEST_TIME
#ifdef TEST_TIMER
TestStopWatch();
#endif // TEST_TIMER
#ifdef TEST_DATETIME
if ( 0 )
{
TestTimeSet();
@ -2408,7 +2450,7 @@ int main(int argc, char **argv)
TestTimeHolidays();
if ( 0 )
TestInteractive();
#endif // TEST_TIME
#endif // TEST_DATETIME
wxUninitialize();

View File

@ -310,7 +310,10 @@ void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
if ( !cmd )
return;
wxLogStatus(_T("'%s' is running please wait..."), cmd.c_str());
int code = wxExecute(cmd, TRUE /* sync */);
wxLogStatus(_T("Process '%s' terminated with exit code %d."),
cmd.c_str(), code);
m_cmdLast = cmd;
@ -326,7 +329,8 @@ void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
return;
wxProcess *process = new MyProcess(this, cmd);
if ( !wxExecute(cmd, FALSE /* async */, process) )
long pid = wxExecute(cmd, FALSE /* async */, process);
if ( !pid )
{
wxLogError(_T("Execution of '%s' failed."), cmd.c_str());
@ -334,6 +338,8 @@ void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
}
else
{
wxLogStatus(_T("Process %ld (%s) launched."), pid, cmd.c_str());
m_cmdLast = cmd;
}
}