[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] [PATCH 4/5] Add GUI test program.
From: |
Václav Slavík |
Subject: |
[lmi] [PATCH 4/5] Add GUI test program. |
Date: |
Tue, 18 Feb 2014 18:15:00 +0100 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
This patch adds GUI test application that doesn't currently do anything.
It uses the wx/testing.h header and so requires wx-3.0.0. A small change
to skeleton.hpp is part of it, but I don't think it's likely to conflict
with anything:
Add GUI test program.
Use derived SkeletonTest app class for the GUI tests. Override OnInit()
to call the test suite (currently empty) when the event loop starts
running and terminate immediately after the tests finish. Use
test_tools.hpp.
---
Makefile.am | 8 +++++
main_wx_test.cpp | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
objects.make | 4 +++
skeleton.hpp | 14 ++++----
workhorse.make | 6 ++++
5 files changed, 131 insertions(+), 7 deletions(-)
create mode 100644 main_wx_test.cpp
diff --git a/Makefile.am b/Makefile.am
index 599588b..93136e0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -112,6 +112,7 @@ TESTS = \
test_input \
test_irc7702a \
test_istream_to_string \
+ test_lmi_wx \
test_loads \
test_map_lookup \
test_materially_equal \
@@ -729,6 +730,13 @@ test_istream_to_string_SOURCES = \
timer.cpp
test_istream_to_string_CXXFLAGS = $(AM_CXXFLAGS)
+test_lmi_wx_SOURCES = \
+ main_wx_test.cpp
+test_lmi_wx_CXXFLAGS = $(AM_CXXFLAGS) $(WX_CXXFLAGS)
+test_lmi_wx_LDADD = \
+ liblmi_wx_lib.la \
+ $(WX_LIBS)
+
test_loads_SOURCES = \
$(common_test_objects) \
expm1.c \
diff --git a/main_wx_test.cpp b/main_wx_test.cpp
new file mode 100644
index 0000000..2478e06
--- /dev/null
+++ b/main_wx_test.cpp
@@ -0,0 +1,106 @@
+// Main file for life insurance illustrations with wx interface.
+//
+// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
2012, 2013, 2014 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$
+
+// Portions of this file are derived from wxWindows files
+// samples/docvwmdi/docview.cpp (C) 1998 Julian Smart and Markus Holzem
+// which is covered by the wxWindows license, and
+// samples/html/printing/printing.cpp
+// which bears no copyright or license notice.
+//
+// GWC used that code as an application skeleton and printing
+// implementation, modifying it in 2002 and the later years given in
+// the copyright notice above.
+
+#ifdef __BORLANDC__
+# include "pchfile.hpp"
+# pragma hdrstop
+#endif
+
+#include "test_tools.hpp"
+
+#include "skeleton.hpp"
+
+#include "fenv_guard.hpp"
+#include "fenv_lmi.hpp"
+#include "handle_exceptions.hpp"
+#include "main_common.hpp"
+#include "msw_workarounds.hpp"
+#include "path_utility.hpp"
+
+#include <wx/defs.h>
+
+class SkeletonTest;
+DECLARE_APP(SkeletonTest)
+
+class application_test
+{
+ public:
+ static void test()
+ {
+ }
+};
+
+
+// Application to drive the tests
+class SkeletonTest : public Skeleton
+{
+public:
+ SkeletonTest() {}
+ virtual bool OnInit();
+
+private:
+ void RunTheTests();
+};
+
+IMPLEMENT_APP_NO_MAIN(SkeletonTest)
+IMPLEMENT_WX_THEME_SUPPORT
+
+bool SkeletonTest::OnInit()
+{
+ if(!Skeleton::OnInit())
+ return false;
+
+ // Run the tests at idle time, when the main loop is running, in order to
+ // do it in as realistic conditions as possible.
+ CallAfter(&SkeletonTest::RunTheTests);
+
+ return true;
+}
+
+void SkeletonTest::RunTheTests()
+{
+ application_test::test();
+ ExitMainLoop();
+}
+
+
+int test_main(int argc, char* argv[])
+{
+ initialize_application();
+ initialize_filesystem();
+#ifdef LMI_MSW
+ MswDllPreloader::instance().PreloadDesignatedDlls();
+#endif
+ return wxEntry(argc, argv);
+}
+
diff --git a/objects.make b/objects.make
index b53a4bd..9d1ab7d 100644
--- a/objects.make
+++ b/objects.make
@@ -346,8 +346,12 @@ lmi_wx_lib_objects := \
lmi_wx_objects := \
main_wx.o \
+lmi_wx_test_objects := \
+ main_wx_test.o \
+
ifneq (,$(RC))
lmi_wx_objects += lmi_msw_res.o
+ lmi_wx_test_objects += lmi_msw_res.o
endif
################################################################################
diff --git a/skeleton.hpp b/skeleton.hpp
index 9598305..5b866f2 100644
--- a/skeleton.hpp
+++ b/skeleton.hpp
@@ -54,7 +54,6 @@ class WXDLLIMPEXP_FWD_CORE wxMenuBar;
class Skeleton
: public wxApp
, private lmi::uncopyable <Skeleton>
- ,virtual private obstruct_slicing<Skeleton>
{
public:
Skeleton();
@@ -63,6 +62,13 @@ class Skeleton
// Called by view classes when they are instantiated.
wxMDIChildFrame* CreateChildFrame(wxDocument*, ViewEx*);
+ protected:
+ // wxApp overrides.
+ virtual bool OnExceptionInMainLoop ();
+ virtual int OnExit ();
+ virtual bool OnInit ();
+ virtual void OnUnhandledException ();
+
private:
wxMenuBar* AdjustMenus(wxMenuBar*);
@@ -111,12 +117,6 @@ class Skeleton
void UponWindowTileHorizontally (wxCommandEvent&);
void UponWindowTileVertically (wxCommandEvent&);
- // wxApp overrides.
- virtual bool OnExceptionInMainLoop ();
- virtual int OnExit ();
- virtual bool OnInit ();
- virtual void OnUnhandledException ();
-
bool ProcessCommandLine(int argc, char* argv[]);
void UpdateViews();
diff --git a/workhorse.make b/workhorse.make
index 426e7a7..faa8fe7 100644
--- a/workhorse.make
+++ b/workhorse.make
@@ -96,6 +96,7 @@ default_targets := \
ifneq (safestdlib,$(findstring safestdlib,$(build_type)))
default_targets += \
lmi_wx_shared$(EXEEXT) \
+ lmi_wx_test$(EXEEXT) \
lmi_wx_lib_shared$(SHREXT) \
wx_new$(SHREXT) \
@@ -832,6 +833,10 @@ lmi_wx_shared$(EXEEXT): lmi_so_attributes := -DLMI_USE_SO
lmi_wx_shared$(EXEEXT): EXTRA_LDFLAGS := $(wx_ldflags)
lmi_wx_shared$(EXEEXT): $(lmi_wx_objects) lmi_wx_lib_shared$(SHREXT)
liblmi$(SHREXT) wx_new$(SHREXT)
+lmi_wx_test$(EXEEXT): lmi_so_attributes := -DLMI_USE_SO
+lmi_wx_test$(EXEEXT): EXTRA_LDFLAGS := $(platform_wx_libraries)
+lmi_wx_test$(EXEEXT): $(lmi_wx_test_objects) lmi_wx_lib_shared$(SHREXT)
liblmi$(SHREXT) wx_new$(SHREXT)
+
lmi_wx_static$(EXEEXT): EXTRA_LDFLAGS := $(wx_ldflags)
lmi_wx_static$(EXEEXT): $(lmi_wx_objects) $(lmi_wx_lib_objects) liblmi.a
wx_new$(SHREXT)
@@ -973,6 +978,7 @@ fardel_binaries := \
$(bin_dir)/liblmi$(SHREXT) \
$(bin_dir)/lmi_cli_shared$(EXEEXT) \
$(bin_dir)/lmi_wx_shared$(EXEEXT) \
+ $(bin_dir)/lmi_wx_test$(EXEEXT) \
$(bin_dir)/wx_new$(SHREXT) \
$(wildcard $(prefix)/local/bin/*$(SHREXT)) \
$(wildcard $(prefix)/local/lib/*$(SHREXT)) \
--
1.8.5.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi] [PATCH 4/5] Add GUI test program.,
Václav Slavík <=