[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [6116] Refactor for reuse
From: |
Greg Chicares |
Subject: |
[lmi-commits] [6116] Refactor for reuse |
Date: |
Sun, 01 Mar 2015 23:25:17 +0000 |
Revision: 6116
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6116
Author: chicares
Date: 2015-03-01 23:25:16 +0000 (Sun, 01 Mar 2015)
Log Message:
-----------
Refactor for reuse
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/wx_test_pdf_create.cpp
Added Paths:
-----------
lmi/trunk/wx_test_output_pdf.hpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2015-03-01 22:02:15 UTC (rev 6115)
+++ lmi/trunk/ChangeLog 2015-03-01 23:25:16 UTC (rev 6116)
@@ -35709,3 +35709,10 @@
Add tests to verify existence of spreadsheet output. See:
http://lists.nongnu.org/archive/html/lmi/2015-02/msg00012.html
+20150301T2325Z <address@hidden> [516]
+
+ wx_test_output_pdf.hpp [new file]
+ wx_test_pdf_create.cpp
+Refactor for reuse. See:
+ http://lists.nongnu.org/archive/html/lmi/2015-02/msg00012.html
+
Added: lmi/trunk/wx_test_output_pdf.hpp
===================================================================
--- lmi/trunk/wx_test_output_pdf.hpp (rev 0)
+++ lmi/trunk/wx_test_output_pdf.hpp 2015-03-01 23:25:16 UTC (rev 6116)
@@ -0,0 +1,81 @@
+// Helper class for working with PDF output files in wx test suite.
+//
+// Copyright (C) 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_output_pdf_hpp
+#define wx_test_output_pdf_hpp
+
+#include "config.hpp"
+
+#include "configurable_settings.hpp"
+#include "wx_test_output.hpp"
+
+#include <boost/filesystem/operations.hpp>
+
+/// Specialized version of output_file_existence_checker for the output PDF
+/// files: it takes just the base name of the file, without neither the
+/// directory part nor the .pdf extension, in its ctor and also takes care of
+/// deleting the .fo.xml created as a side effect of PDF generation when the
+/// PDF file itself is removed.
+class output_pdf_existence_checker :public output_file_existence_checker
+{
+ public:
+ explicit output_pdf_existence_checker(std::string const& base_name)
+ :output_file_existence_checker
+ (make_full_print_path(base_name + ".pdf")
+ )
+ ,fo_xml_path_
+ (make_full_print_path(base_name + ".fo.xml")
+ )
+ {
+ // We do not remove .fo.xml file here, this is unnecessary as we don't
+ // particularly care whether it exists or not because we never check
+ // for its existence.
+ }
+
+ ~output_pdf_existence_checker()
+ {
+ // Do remove the .fo.xml file to avoid littering the print directory
+ // with the files generated during the test run.
+ try
+ {
+ fs::remove(fo_xml_path_);
+ }
+ catch(...)
+ {
+ }
+ }
+
+ private:
+ // Return the full path in the print directory for the file with the given
+ // leaf name.
+ static fs::path make_full_print_path(std::string const& leaf)
+ {
+ fs::path p(configurable_settings::instance().print_directory());
+ p /= leaf;
+ return p;
+ }
+
+ fs::path fo_xml_path_;
+};
+
+#endif // wx_test_output_pdf_hpp
Property changes on: lmi/trunk/wx_test_output_pdf.hpp
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: lmi/trunk/wx_test_pdf_create.cpp
===================================================================
--- lmi/trunk/wx_test_pdf_create.cpp 2015-03-01 22:02:15 UTC (rev 6115)
+++ lmi/trunk/wx_test_pdf_create.cpp 2015-03-01 23:25:16 UTC (rev 6116)
@@ -31,13 +31,12 @@
#include "wx_test_case.hpp"
#include "wx_test_new.hpp"
#include "wx_test_output.hpp"
+#include "wx_test_output_pdf.hpp"
#include <wx/docview.h>
#include <wx/testing.h>
#include <wx/uiaction.h>
-#include <boost/filesystem/operations.hpp>
-
namespace
{
@@ -59,53 +58,6 @@
return wxString::Format(".%09d", n).ToStdString();
}
-// Specialized version of output_file_existence_checker for the output PDF
-// files: it takes just the base name of the file, without neither the
-// directory part nor the .pdf extension, in its ctor and also takes care of
-// deleting the .fo.xml created as a side effect of PDF generation when the PDF
-// file itself is removed.
-class output_pdf_existence_checker :public output_file_existence_checker
-{
- public:
- explicit output_pdf_existence_checker(std::string const& base_name)
- :output_file_existence_checker
- (make_full_print_path(base_name + ".pdf")
- )
- ,fo_xml_path_
- (make_full_print_path(base_name + ".fo.xml")
- )
- {
- // We do not remove .fo.xml file here, this is unnecessary as we don't
- // particularly care whether it exists or not because we never check
- // for its existence.
- }
-
- ~output_pdf_existence_checker()
- {
- // Do remove the .fo.xml file to avoid littering the print directory
- // with the files generated during the test run.
- try
- {
- fs::remove(fo_xml_path_);
- }
- catch(...)
- {
- }
- }
-
- private:
- // Return the full path in the print directory for the file with the given
- // leaf name.
- static fs::path make_full_print_path(std::string const& leaf)
- {
- fs::path p(configurable_settings::instance().print_directory());
- p /= leaf;
- return p;
- }
-
- fs::path fo_xml_path_;
-};
-
} // Unnamed namespace.
/// Test printing an illustration document to PDF.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [6116] Refactor for reuse,
Greg Chicares <=