lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [6094] Use output_pdf_existence_checker helper in PDF crea


From: Greg Chicares
Subject: [lmi-commits] [6094] Use output_pdf_existence_checker helper in PDF creation test
Date: Fri, 23 Jan 2015 02:56:36 +0000

Revision: 6094
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6094
Author:   chicares
Date:     2015-01-23 02:56:35 +0000 (Fri, 23 Jan 2015)
Log Message:
-----------
Use output_pdf_existence_checker helper in PDF creation test

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/wx_test_pdf_create.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2015-01-23 02:46:27 UTC (rev 6093)
+++ lmi/trunk/ChangeLog 2015-01-23 02:56:35 UTC (rev 6094)
@@ -35569,3 +35569,9 @@
 Update PDF output tests to the revised specification. See:
   http://lists.nongnu.org/archive/html/lmi/2014-12/msg00089.html
 
+20150123T0256Z <address@hidden> [516]
+
+  wx_test_pdf_create.cpp
+Use output_pdf_existence_checker helper in PDF creation test. See:
+  http://lists.nongnu.org/archive/html/lmi/2014-12/msg00089.html
+

Modified: lmi/trunk/wx_test_pdf_create.cpp
===================================================================
--- lmi/trunk/wx_test_pdf_create.cpp    2015-01-23 02:46:27 UTC (rev 6093)
+++ lmi/trunk/wx_test_pdf_create.cpp    2015-01-23 02:56:35 UTC (rev 6094)
@@ -53,21 +53,36 @@
     return doc->GetUserReadableName().ToStdString();
 }
 
-// Build the path for the output PDF with the given base name.
-fs::path make_pdf_path(std::string const& base_name)
-{
-    fs::path pdf_path(configurable_settings::instance().print_directory());
-    pdf_path /= base_name + ".pdf";
-
-    return pdf_path;
-}
-
 // Return the suffix used for the FO files created by printing the census.
 std::string fo_suffix(int n)
 {
     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.
+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")
+            )
+        {
+        }
+
+  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;
+        }
+};
+
 } // Unnamed namespace.
 
 /// Test printing an illustration document to PDF.
@@ -83,8 +98,7 @@
     wx_test_new_illustration ill;
 
     // Ensure that the output file doesn't exist in the first place.
-    output_file_existence_checker
-        output_pdf(make_pdf_path(get_current_document_name()));
+    output_pdf_existence_checker output_pdf(get_current_document_name());
 
     wxUIActionSimulator ui;
     ui.Char('i', wxMOD_CONTROL);    // "File | Print to PDF"
@@ -117,11 +131,11 @@
     // already present and not created by the test.
     std::string const name = get_current_document_name();
 
-    output_file_existence_checker
-        composite_pdf(make_pdf_path(name + ".composite" + fo_suffix(0)));
+    output_pdf_existence_checker
+        composite_pdf(name + ".composite" + fo_suffix(0));
 
-    output_file_existence_checker
-        cell_pdf(make_pdf_path(name + fo_suffix(1)));
+    output_pdf_existence_checker
+        cell_pdf(name + fo_suffix(1));
 
     // Print the census to PDF.
     wxUIActionSimulator ui;




reply via email to

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