lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [6152] Move and rename class wx_test_new_document_base


From: Greg Chicares
Subject: [lmi-commits] [6152] Move and rename class wx_test_new_document_base
Date: Fri, 27 Mar 2015 00:27:16 +0000

Revision: 6152
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6152
Author:   chicares
Date:     2015-03-27 00:27:16 +0000 (Fri, 27 Mar 2015)
Log Message:
-----------
Move and rename class wx_test_new_document_base

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/wx_test_new.hpp

Added Paths:
-----------
    lmi/trunk/wx_test_document.hpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2015-03-27 00:24:49 UTC (rev 6151)
+++ lmi/trunk/ChangeLog 2015-03-27 00:27:16 UTC (rev 6152)
@@ -35942,3 +35942,15 @@
 Guard against future changes in field names. See:
   http://lists.nongnu.org/archive/html/lmi/2015-03/msg00032.html
 
+20150327T0024Z <address@hidden> [516]
+
+  test_coding_rules.cpp
+Forbid obscured email addresses.
+
+20150327T0027Z <address@hidden> [516]
+
+  wx_test_document.hpp [new file]
+  wx_test_new.hpp
+Move and rename class wx_test_new_document_base. See:
+  http://lists.nongnu.org/archive/html/lmi/2015-03/msg00043.html
+

Added: lmi/trunk/wx_test_document.hpp
===================================================================
--- lmi/trunk/wx_test_document.hpp                              (rev 0)
+++ lmi/trunk/wx_test_document.hpp      2015-03-27 00:27:16 UTC (rev 6152)
@@ -0,0 +1,139 @@
+// Helper for creating documents in unattended GUI tests.
+//
+// Copyright (C) 2014, 2015 Gregory W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// http://savannah.nongnu.org/projects/lmi
+// email: <address@hidden>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+// $Id$
+
+#ifndef wx_test_document_hpp
+#define wx_test_document_hpp
+
+#include "config.hpp"
+
+#include "mvc_controller.hpp"
+#include "uncopyable_lmi.hpp"
+
+#include <wx/log.h>
+#include <wx/testing.h>
+#include <wx/uiaction.h>
+
+#include <exception>
+
+/// Helper function for finding and focusing a control with the specified name
+/// inside MvcController (actually it could be any top level window containing
+/// a book control).
+///
+/// Returns the never null pointer to the window.
+///
+/// Throws if the control couldn't be found.
+wxWindow* wx_test_focus_controller_child(MvcController& dialog, char const* 
name);
+
+/// Helper base class for classes creating or opening documents.
+///
+/// This class provides methods for closing the current document, optionally
+/// discarding the changes done to it.
+///
+/// Unfortunately it is impossible to close the document automatically from
+/// this class dtor as doing this may result in an exception and throwing from
+/// dtors is too dangerous, generally speaking (and not allowed at all by
+/// default since C++11), to prefer it to an approach involving explicit calls
+/// to close().
+
+class wx_test_document_base
+    :private lmi::uncopyable<wx_test_document_base>
+{
+  public:
+    wx_test_document_base()
+        :opened_(false)
+    {
+    }
+
+    ~wx_test_document_base()
+    {
+        // Normally either close() or close_discard_changes() should be called,
+        // so complain about forgetting to do this if neither was. Except that
+        // we shouldn't do this if we're unwinding due to an exception from a
+        // test failure, as this is not a bug in the test code then.
+        if(opened_)
+            {
+            if(std::uncaught_exception())
+                {
+                // Moreover, in case of exception, try to close the window to
+                // avoid showing message boxes asking the user if it should be
+                // saved: this is undesirable in an unattended test.
+                do_close();
+
+                wxTEST_DIALOG
+                    (wxYield()
+                    ,wxExpectModal<wxMessageDialog>(wxNO).Optional()
+                    );
+                }
+            else
+                {
+                wxSafeShowMessage
+                    ("Programming error"
+                    ,"A document created during unattended test hasn't been 
closed, "
+                     "please report this."
+                    );
+                }
+            }
+    }
+
+    // Close the document window, the document must not be modified.
+    void close()
+    {
+        do_close();
+
+        wxYield();
+    }
+
+    // Close the document window, the document must have been modified and the
+    // changes to it will be discarded.
+    void close_discard_changes()
+    {
+        do_close();
+
+        wxTEST_DIALOG(wxYield()
+                     ,wxExpectModal<wxMessageDialog>(wxNO).
+                        Describe("message box confirming closing modified 
file")
+                     );
+    }
+
+  protected:
+    // This method should be called by the derived classes when the document
+    // window is really opened.
+    void set_opened() { opened_ = true; }
+
+  private:
+    // Common part of different close() methods.
+    void do_close()
+    {
+        // If we started closing the document, we should reset the flag: even
+        // if closing it fails, we shouldn't complain about forgetting to close
+        // it as we clearly didn't forget to do it.
+        opened_ = false;
+
+        wxUIActionSimulator ui;
+        ui.Char('l', wxMOD_CONTROL);    // "File|Close"
+    }
+
+    bool opened_;
+};
+
+#endif // wx_test_document_hpp


Property changes on: lmi/trunk/wx_test_document.hpp
___________________________________________________________________
Added: svn:keywords
   + Id

Modified: lmi/trunk/wx_test_new.hpp
===================================================================
--- lmi/trunk/wx_test_new.hpp   2015-03-27 00:24:49 UTC (rev 6151)
+++ lmi/trunk/wx_test_new.hpp   2015-03-27 00:27:16 UTC (rev 6152)
@@ -26,116 +26,8 @@
 
 #include "config.hpp"
 
-#include "mvc_controller.hpp"
-#include "uncopyable_lmi.hpp"
+#include "wx_test_document.hpp"
 
-#include <wx/log.h>
-#include <wx/testing.h>
-#include <wx/uiaction.h>
-
-#include <exception>
-
-/// Helper function for finding and focusing a control with the specified name
-/// inside MvcController (actually it could be any top level window containing
-/// a book control).
-///
-/// Returns the never null pointer to the window.
-///
-/// Throws if the control couldn't be found.
-wxWindow* wx_test_focus_controller_child(MvcController& dialog, char const* 
name);
-
-/// Helper base class for classes testing creation of specific new documents.
-///
-/// This class provides methods for closing the current document, optionally
-/// discarding the changes done to it.
-///
-/// Unfortunately it is impossible to close the document automatically from
-/// this class dtor as doing this may result in an exception and throwing from
-/// dtors is too dangerous, generally speaking (and not allowed at all by
-/// default since C++11), to prefer it to an approach involving explicit calls
-/// to close().
-
-class wx_test_new_document_base
-    :private lmi::uncopyable<wx_test_new_document_base>
-{
-  public:
-    wx_test_new_document_base()
-        :opened_(false)
-    {
-    }
-
-    ~wx_test_new_document_base()
-    {
-        // Normally either close() or close_discard_changes() should be called,
-        // so complain about forgetting to do this if neither was. Except that
-        // we shouldn't do this if we're unwinding due to an exception from a
-        // test failure, as this is not a bug in the test code then.
-        if(opened_)
-            {
-            if(std::uncaught_exception())
-                {
-                // Moreover, in case of exception, try to close the window to
-                // avoid showing message boxes asking the user if it should be
-                // saved: this is undesirable in an unattended test.
-                do_close();
-
-                wxTEST_DIALOG
-                    (wxYield()
-                    ,wxExpectModal<wxMessageDialog>(wxNO).Optional()
-                    );
-                }
-            else
-                {
-                wxSafeShowMessage
-                    ("Programming error"
-                    ,"A document created during unattended test hasn't been 
closed, "
-                     "please report this."
-                    );
-                }
-            }
-    }
-
-    // Close the document window, the document must not be modified.
-    void close()
-    {
-        do_close();
-
-        wxYield();
-    }
-
-    // Close the document window, the document must have been modified and the
-    // changes to it will be discarded.
-    void close_discard_changes()
-    {
-        do_close();
-
-        wxTEST_DIALOG(wxYield()
-                     ,wxExpectModal<wxMessageDialog>(wxNO).
-                        Describe("message box confirming closing modified 
file")
-                     );
-    }
-
-  protected:
-    // This method should be called by the derived classes when the document
-    // window is really opened.
-    void set_opened() { opened_ = true; }
-
-  private:
-    // Common part of different close() methods.
-    void do_close()
-    {
-        // If we started closing the document, we should reset the flag: even
-        // if closing it fails, we shouldn't complain about forgetting to close
-        // it as we clearly didn't forget to do it.
-        opened_ = false;
-
-        wxUIActionSimulator ui;
-        ui.Char('l', wxMOD_CONTROL);    // "File|Close"
-    }
-
-    bool opened_;
-};
-
 /// Represents a new illustration document.
 ///
 /// Instantiating an object of this class simulates creating a new 
illustration.
@@ -143,7 +35,7 @@
 /// to ensure that it doesn't stay open.
 
 class wx_test_new_illustration
-    :public wx_test_new_document_base
+    :public wx_test_document_base
 {
   public:
     // Default constructor creates an illustration with the default parameters.
@@ -182,7 +74,7 @@
 /// destroying it.
 
 class wx_test_new_census
-    :public wx_test_new_document_base
+    :public wx_test_document_base
 {
   public:
     wx_test_new_census()




reply via email to

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