>From 9be66b0db2e99a10554e47dfb0e7df049f95619c Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Sun, 15 Feb 2015 00:17:24 +0100
Subject: [PATCH 7/8] Implement the remaining cases of the census outputs
validation test.
Check that "Census|Print case to PDF" and "Illustration|Copy full illustration
data" commands produce the expected output.
---
wx_test_validate_output.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 91 insertions(+), 2 deletions(-)
diff --git a/wx_test_validate_output.cpp b/wx_test_validate_output.cpp
index 60410ef..63f8fdb 100644
--- a/wx_test_validate_output.cpp
+++ b/wx_test_validate_output.cpp
@@ -34,7 +34,10 @@
#include "wx_test_case.hpp"
#include "wx_test_new.hpp"
#include "wx_test_output.hpp"
+#include "wx_test_output_pdf.hpp"
+#include "wx_utility.hpp"
+#include
#include
#include
@@ -82,6 +85,13 @@ struct enter_comments_in_case_defaults_dialog
wx_test_focus_controller_child(*dialog, "Comments");
wxUIActionSimulator ui;
+
+ // There could be an existing comment in this field, delete it first.
+ // This does assume MSW-like key bindings.
+ ui.Char(WXK_HOME);
+ ui.Char(WXK_END, wxMOD_SHIFT);
+ ui.Char(WXK_BACK);
+
ui.Text(comments_.c_str());
wxYield();
@@ -310,6 +320,84 @@ struct enter_comments_in_case_defaults_dialog
);
}
+void validate_print_case_pdf_output
+ (std::string const& corp_name
+ ,std::string const& insured_name
+ )
+{
+ wxUIActionSimulator ui;
+
+ ui.Char('e', wxMOD_CONTROL | wxMOD_SHIFT); // "Census|Edit case defaults"
+ wxTEST_DIALOG
+ (wxYield()
+ ,enter_comments_in_case_defaults_dialog("idiosyncrasy_spreadsheet")
+ ,wxExpectModal(wxYES).
+ Describe("message box asking whether to apply changes to all cells")
+ );
+
+ ui.Char('s', wxMOD_CONTROL); // "File|Save"
+
+ fs::path values_file(configurable_settings::instance().print_directory());
+ values_file /= "values" + tsv_ext();
+
+ output_file_existence_checker output_values(values_file);
+
+ // We don't really care about these files existence, but we don't want them
+ // to be left over after the end of this test, so use the output existence
+ // checker helper to ensure that they are cleaned up.
+ output_pdf_existence_checker
+ composite_pdf(corp_name + ".composite" + serial_suffix(0))
+ ,first_cell_pdf(corp_name + "." + insured_name + serial_suffix(1))
+ ,second_cell_pdf(corp_name + serial_suffix(2))
+ ;
+
+ ui.Char('i', wxMOD_CONTROL | wxMOD_SHIFT); // "Census|Print case to PDF"
+ wxYield();
+
+ LMI_ASSERT_WITH_MSG
+ (output_values.exists()
+ ,"file \"" << values_file << "\" after print case to PDF"
+ );
+}
+
+void validate_run_cell_and_copy_output
+ (std::string const& corp_name
+ ,std::string const& insured_name
+ )
+{
+ wxUIActionSimulator ui;
+
+ ui.Char(WXK_HOME); // Select the first cell.
+ ui.Char('r', wxMOD_CONTROL); // "Census|Run cell"
+ wxYield();
+
+ std::string const ill_data_file
+ (corp_name + "." + insured_name + serial_suffix(1) + ".ill" + tsv_ext()
+ );
+ output_file_existence_checker output_ill_data(ill_data_file);
+
+ ui.Char('d', wxMOD_CONTROL); // "Illustration|Copy full illustration data"
+ wxYield();
+
+ // Close the illustration window opened by running the cell in any case.
+ ui.Char('l', wxMOD_CONTROL); // "File|Close"
+ wxYield();
+
+ LMI_ASSERT_WITH_MSG
+ (output_ill_data.exists()
+ ,"file \"" << ill_data_file << "\" after copying illustration data"
+ );
+
+ // Also check that the contents of the file was placed on clipboard.
+ wxString contents;
+ LMI_ASSERT(wxFFile(ill_data_file).ReadAll(&contents));
+
+ LMI_ASSERT_EQUAL
+ (wxString(ClipboardEx::GetText())
+ ,contents
+ );
+}
+
} // anonymous namespace
// Consider renaming this file to 'wx_test_spreadsheet_output.cpp'
@@ -371,8 +459,6 @@ struct enter_comments_in_case_defaults_dialog
// ABC.cns.roster.tsv
/// ...and delete all three now.
///
-/// THE TESTS BELOW ARE NOT IMPLEMENTED YET!
-///
/// Census | Edit case defaults
/// Comments: replace contents with "idiosyncrasy_spreadsheet"
/// OK
@@ -479,6 +565,9 @@ struct enter_comments_in_case_defaults_dialog
validate_print_case_output(corp_name, insured_filename);
validate_print_roster_output(corp_name, insured_filename);
+ validate_print_case_pdf_output(corp_name, insured_filename);
+ validate_run_cell_and_copy_output(corp_name, insured_filename);
+
census.close();
}
--
2.1.0