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:
@@ -23,16 +23,23 @@
|
|||||||
#include <wx/file.h>
|
#include <wx/file.h>
|
||||||
#include <wx/app.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
|
// conditional compilation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// what to test?
|
// what to test (in alphabetic order)?
|
||||||
|
|
||||||
//#define TEST_ARRAYS
|
//#define TEST_ARRAYS
|
||||||
//#define TEST_CMDLINE
|
//#define TEST_CMDLINE
|
||||||
|
//#define TEST_DATETIME
|
||||||
//#define TEST_DIR
|
//#define TEST_DIR
|
||||||
#define TEST_EXECUTE
|
//#define TEST_EXECUTE
|
||||||
//#define TEST_FILECONF
|
//#define TEST_FILECONF
|
||||||
//#define TEST_HASH
|
//#define TEST_HASH
|
||||||
//#define TEST_LOG
|
//#define TEST_LOG
|
||||||
@@ -41,18 +48,18 @@
|
|||||||
//#define TEST_SOCKETS
|
//#define TEST_SOCKETS
|
||||||
//#define TEST_STRINGS
|
//#define TEST_STRINGS
|
||||||
//#define TEST_THREADS
|
//#define TEST_THREADS
|
||||||
//#define TEST_TIME
|
#define TEST_TIMER
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
#ifdef TEST_CMDLINE
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxCmdLineParser
|
// wxCmdLineParser
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef TEST_CMDLINE
|
||||||
|
|
||||||
#include <wx/cmdline.h>
|
#include <wx/cmdline.h>
|
||||||
#include <wx/datetime.h>
|
#include <wx/datetime.h>
|
||||||
|
|
||||||
@@ -715,11 +722,42 @@ static void TestSocketClient()
|
|||||||
|
|
||||||
#endif // TEST_SOCKETS
|
#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
|
// date time
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef TEST_TIME
|
#ifdef TEST_DATETIME
|
||||||
|
|
||||||
#include <wx/date.h>
|
#include <wx/date.h>
|
||||||
|
|
||||||
@@ -1659,7 +1697,7 @@ static void TestTimeCompatibility()
|
|||||||
|
|
||||||
#endif // 0
|
#endif // 0
|
||||||
|
|
||||||
#endif // TEST_TIME
|
#endif // TEST_DATETIME
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// threads
|
// threads
|
||||||
@@ -2389,7 +2427,11 @@ int main(int argc, char **argv)
|
|||||||
TestSocketClient();
|
TestSocketClient();
|
||||||
#endif // TEST_SOCKETS
|
#endif // TEST_SOCKETS
|
||||||
|
|
||||||
#ifdef TEST_TIME
|
#ifdef TEST_TIMER
|
||||||
|
TestStopWatch();
|
||||||
|
#endif // TEST_TIMER
|
||||||
|
|
||||||
|
#ifdef TEST_DATETIME
|
||||||
if ( 0 )
|
if ( 0 )
|
||||||
{
|
{
|
||||||
TestTimeSet();
|
TestTimeSet();
|
||||||
@@ -2408,7 +2450,7 @@ int main(int argc, char **argv)
|
|||||||
TestTimeHolidays();
|
TestTimeHolidays();
|
||||||
if ( 0 )
|
if ( 0 )
|
||||||
TestInteractive();
|
TestInteractive();
|
||||||
#endif // TEST_TIME
|
#endif // TEST_DATETIME
|
||||||
|
|
||||||
wxUninitialize();
|
wxUninitialize();
|
||||||
|
|
||||||
|
@@ -310,7 +310,10 @@ void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
|
|||||||
if ( !cmd )
|
if ( !cmd )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
wxLogStatus(_T("'%s' is running please wait..."), cmd.c_str());
|
||||||
|
|
||||||
int code = wxExecute(cmd, TRUE /* sync */);
|
int code = wxExecute(cmd, TRUE /* sync */);
|
||||||
|
|
||||||
wxLogStatus(_T("Process '%s' terminated with exit code %d."),
|
wxLogStatus(_T("Process '%s' terminated with exit code %d."),
|
||||||
cmd.c_str(), code);
|
cmd.c_str(), code);
|
||||||
m_cmdLast = cmd;
|
m_cmdLast = cmd;
|
||||||
@@ -326,7 +329,8 @@ void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
wxProcess *process = new MyProcess(this, cmd);
|
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());
|
wxLogError(_T("Execution of '%s' failed."), cmd.c_str());
|
||||||
|
|
||||||
@@ -334,6 +338,8 @@ void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
wxLogStatus(_T("Process %ld (%s) launched."), pid, cmd.c_str());
|
||||||
|
|
||||||
m_cmdLast = cmd;
|
m_cmdLast = cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user