From d31b7b682c8d0cd58bd1774a99bfbcc6b689858d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Mar 2000 02:23:53 +0000 Subject: [PATCH] 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 --- samples/console/console.cpp | 60 +++++++++++++++++++++++++++++++------ samples/exec/exec.cpp | 8 ++++- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 118e1bd80d..56a0493e37 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -23,16 +23,23 @@ #include #include +// 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 #include @@ -715,11 +722,42 @@ static void TestSocketClient() #endif // TEST_SOCKETS +// ---------------------------------------------------------------------------- +// timers +// ---------------------------------------------------------------------------- + +#ifdef TEST_TIMER + +#include +#include + +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 @@ -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(); diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp index 0bc3b509ae..06e51aa59d 100644 --- a/samples/exec/exec.cpp +++ b/samples/exec/exec.cpp @@ -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; } } -- 2.45.2