lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Manual test of automated GUI test


From: Vadim Zeitlin
Subject: Re: [lmi] Manual test of automated GUI test
Date: Sun, 19 Oct 2014 02:16:15 +0200

On Sat, 18 Oct 2014 22:44:58 +0000 Greg Chicares <address@hidden> wrote:

GC> [Others could easily do this by accident, so would it make sense
GC> to forestall it...e.g., by issuing an 'Esc' keypress before doing
GC> anything else in the GUI test, if that's possible?]

 The patch below (to be applied on top of the previous patch) does this and
also incidentally fixes the crash, as explained in the commit message below.

 I'm still a bit uncomfortable with running the testing code from inside
the "About" modal dialog event loop instead of from the main event loop, I
have a nasty feeling that bad things might happen because of it. But for
now things seem to work.

 Normally you should have exactly the same results with this patch and
without the special command line option as you have just obtained without
the patch and with this option.

 Sorry again for not being more clear about this option being required in
the first place,
VZ

-- >8 --
>From 81cc7ba584167adfc219724983284cee8106703a Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <address@hidden>
Date: Sun, 19 Oct 2014 02:09:14 +0200
Subject: [PATCH] Try to close any initially opened dialogs before running the
 tests.

This ensures that the test start with the expected state and also fixes a
crash if the "About" dialog was shown on startup as testing code closes the
main program window at the end which leads to a crash if this dialog, which is
the child of the main window, still exists by then.
---
 main_wx_test.cpp |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/main_wx_test.cpp b/main_wx_test.cpp
index 81c853a..8c1a927 100644
--- a/main_wx_test.cpp
+++ b/main_wx_test.cpp
@@ -41,6 +41,7 @@
 #include <wx/frame.h>
 #include <wx/init.h>                    // wxEntry()
 #include <wx/stopwatch.h>
+#include <wx/uiaction.h>
 #include <wx/wfstream.h>
 
 #include <boost/scoped_ptr.hpp>
@@ -539,9 +540,32 @@ void SkeletonTest::RunTheTests()
             return wxLogWindow::OnFrameClose(frame);
         }
     };
-    LogWindow* const log = new LogWindow();
 
     wxWindow* const mainWin = GetTopWindow();
+
+    // Close any initially opened dialogs (e.g. "About" dialog shown unless a
+    // special command line option is specified).
+    for (;;)
+        {
+        wxWindow* const activeWin = wxGetActiveWindow();
+        if (!activeWin || activeWin == mainWin)
+            break;
+
+        // Try to close the dialog.
+        wxUIActionSimulator ui;
+        ui.Char(WXK_ESCAPE);
+        wxYield();
+
+        // But stop trying if it didn't work.
+        if (wxGetActiveWindow() == activeWin)
+            {
+            wxLogError("Failed to close the currently opened window, "
+                       "please ensure it doesn't appear on program startup.");
+            return;
+            }
+        }
+
+    LogWindow* const log = new LogWindow();
     mainWin->SetFocus();
 
     wxStopWatch sw;
-- 
1.7.9


reply via email to

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