lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [5988] Add test for creating and saving new files of all t


From: Vadim Zeitlin
Subject: [lmi-commits] [5988] Add test for creating and saving new files of all types.
Date: Tue, 14 Oct 2014 23:26:06 +0000

Revision: 5988
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5988
Author:   zeitlin
Date:     2014-10-14 23:26:05 +0000 (Tue, 14 Oct 2014)
Log Message:
-----------
Add test for creating and saving new files of all types.

Verify that creating a new document of each of the possible types (census,
illustration, database, policy, ...) and saving it does work.

Modified Paths:
--------------
    lmi/trunk/main_wx_test.cpp

Modified: lmi/trunk/main_wx_test.cpp
===================================================================
--- lmi/trunk/main_wx_test.cpp  2014-10-14 23:25:59 UTC (rev 5987)
+++ lmi/trunk/main_wx_test.cpp  2014-10-14 23:26:05 UTC (rev 5988)
@@ -61,12 +61,26 @@
         test_about_dialog_version();
         test_configurable_settings();
         test_default_input();
+        test_new_file_and_save();
         }
 
   private:
     static void test_about_dialog_version();
     static void test_configurable_settings();
     static void test_default_input();
+    static void test_new_file_and_save();
+
+    // Helper of test_new_file_and_save() which tests creating a new file of
+    // the type corresponding to the key argument, used to select this type in
+    // the "New" popup menu.
+    //
+    // The last argument indicates whether a dialog is shown when creating a
+    // new file of this type (e.g. true for illustrations, false for census).
+    // It affects this function behaviour in two ways: first, it needs to be
+    // ready for this dialog appearing and, second, "File|Save" menu command is
+    // disabled for the files created in this way and "File|Save as" needs to
+    // be used instead.
+    static void do_test_new_file_and_save(int key, wxString const& file, bool 
uses_dialog);
 };
 
 void application_test::test_about_dialog_version()
@@ -138,6 +152,57 @@
     wxLogMessage("GeneralAccountRate is \"%s\"", general_account_date.c_str());
 }
 
+void application_test::do_test_new_file_and_save(int key, wxString const& 
file, bool uses_dialog)
+{
+    struct expect_config_dialog : public wxExpectModalBase<wxDialog>
+    {
+        virtual int OnInvoked(wxDialog* d) const
+            {
+            return wxID_OK;
+            }
+    };
+
+    LMI_ASSERT(!wxFileExists(file));
+
+    wxUIActionSimulator z;
+    z.Char('n', wxMOD_CONTROL); // new file
+    z.Char(key               ); // choose document type
+    if (uses_dialog)
+        {
+        wxTEST_DIALOG
+            (wxYield()
+            ,expect_config_dialog()
+            );
+        }
+    wxYield();
+
+    z.Char(uses_dialog ? 'a' : 's', wxMOD_CONTROL); // save or save as
+    wxTEST_DIALOG
+        (wxYield()
+        ,wxExpectModal<wxFileDialog>(file)
+        );
+    wxYield();
+
+    LMI_ASSERT(wxFileExists(file));
+    wxRemoveFile(file);
+
+    z.Char('l', wxMOD_CONTROL); // close document
+    wxYield();
+}
+
+void application_test::test_new_file_and_save()
+{
+    do_test_new_file_and_save('c', "testfile.cns"     , false);
+    do_test_new_file_and_save('i', "testfile.ill"     , true);
+    do_test_new_file_and_save('d', "testfile.database", false);
+    do_test_new_file_and_save('p', "testfile.policy"  , false);
+    do_test_new_file_and_save('r', "testfile.rounding", false);
+    do_test_new_file_and_save('s', "testfile.strata",   false);
+    do_test_new_file_and_save('m', "testfile.mec",      true);
+    do_test_new_file_and_save('g', "testfile.gpt",      true);
+    do_test_new_file_and_save('x', "testfile.txt",      false);
+}
+
 // Application to drive the tests
 class SkeletonTest : public Skeleton
 {




reply via email to

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