lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [5986] Log (tests) output to a wxLogWindow.


From: Vadim Zeitlin
Subject: [lmi-commits] [5986] Log (tests) output to a wxLogWindow.
Date: Tue, 14 Oct 2014 23:25:54 +0000

Revision: 5986
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5986
Author:   zeitlin
Date:     2014-10-14 23:25:53 +0000 (Tue, 14 Oct 2014)
Log Message:
-----------
Log (tests) output to a wxLogWindow.

Modified Paths:
--------------
    lmi/trunk/main_wx_test.cpp

Modified: lmi/trunk/main_wx_test.cpp
===================================================================
--- lmi/trunk/main_wx_test.cpp  2014-10-14 23:25:47 UTC (rev 5985)
+++ lmi/trunk/main_wx_test.cpp  2014-10-14 23:25:53 UTC (rev 5986)
@@ -38,6 +38,7 @@
 #include <boost/filesystem/operations.hpp>
 
 #include <wx/dialog.h>
+#include <wx/frame.h>
 #include <wx/init.h>                    // wxEntry()
 #include <wx/testing.h>
 #include <wx/uiaction.h>
@@ -151,8 +152,35 @@
 
 void SkeletonTest::RunTheTests()
 {
+    // Create log window for output that should be checked by the user.
+    class LogWindow : public wxLogWindow
+    {
+      public:
+        LogWindow() : wxLogWindow(NULL, "Log Messages", true, false) {}
+        virtual bool OnFrameClose(wxFrame* frame)
+        {
+            wxTheApp->ExitMainLoop();
+            return wxLogWindow::OnFrameClose(frame);
+        }
+    };
+    LogWindow *log = new LogWindow();
+
+    wxWindow *mainWin = GetTopWindow();
+    mainWin->SetFocus();
+
     application_test::test();
-    ExitMainLoop();
+
+    // We want to show log output after the tests finished running and hide the
+    // app window, which is no longer in use. This doesn't work out of the box,
+    // because the main window is set application's top window and closing it
+    // terminates the app. LogWindow's window, on the other hand, doesn't keep
+    // the app running because it returns false from ShouldPreventAppExit().
+    // This code (together with LogWindow::OnFrameClose above) does the right
+    // thing: close the main window and keep running until the user closes the
+    // log window.
+    log->GetFrame()->SetFocus();
+    SetExitOnFrameDelete(false);
+    mainWin->Close();
 }
 
 int main(int argc, char* argv[])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]