lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [6150] Guard against future changes in field names


From: Greg Chicares
Subject: [lmi-commits] [6150] Guard against future changes in field names
Date: Thu, 26 Mar 2015 23:49:19 +0000

Revision: 6150
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6150
Author:   chicares
Date:     2015-03-26 23:49:19 +0000 (Thu, 26 Mar 2015)
Log Message:
-----------
Guard against future changes in field names

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

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2015-03-26 23:27:16 UTC (rev 6149)
+++ lmi/trunk/ChangeLog 2015-03-26 23:49:19 UTC (rev 6150)
@@ -35936,3 +35936,9 @@
 Flush wxLog after each individual GUI test. See:
   http://lists.nongnu.org/archive/html/lmi/2015-03/msg00026.html
 
+20150326T2349Z <address@hidden> [516]
+
+  wx_test_input_sequences.cpp
+Guard against future changes in field names. See:
+  http://lists.nongnu.org/archive/html/lmi/2015-03/msg00032.html
+

Modified: lmi/trunk/wx_test_input_sequences.cpp
===================================================================
--- lmi/trunk/wx_test_input_sequences.cpp       2015-03-26 23:27:16 UTC (rev 
6149)
+++ lmi/trunk/wx_test_input_sequences.cpp       2015-03-26 23:49:19 UTC (rev 
6150)
@@ -28,12 +28,16 @@
 
 #include "assert_lmi.hpp"
 #include "configurable_settings.hpp"
+#include "input.hpp"
 #include "wx_test_case.hpp"
 #include "wx_test_new.hpp"
 
+#include <wx/crt.h>
 #include <wx/testing.h>
 #include <wx/uiaction.h>
 
+#include <algorithm>                    // std::find()
+
 /// Validate a variety of input sequences in the GUI input dialog.
 ///
 /// Test a broad variety of input sequences. For now, use the set in
@@ -64,7 +68,7 @@
 
 input_sequence_test_data const test_cases[] =
 {
-    // These sequences correspond to the examples from the manual.
+    // These sequences correspond to the examples from the user manual.
     { "SpecifiedAmount" ,"sevenpay 7; 250000 retirement; 100000 #10; 75000 
@95; 50000" },
     { "SpecifiedAmount" ,"100000; 110000; 120000; 130000; 140000; 150000"      
        },
     { "PaymentMode"     ,"annual; monthly"                                     
        },
@@ -77,7 +81,7 @@
     { "Withdrawal"      ,"0 retirement; 5000 #10; 0"                           
        },
     { "Withdrawal"      ,"0,[0,retirement);10000,[retirement,#10);0"           
        },
 
-    // This is an additional sequence used solely for testing.
+    // This is an additional sequence used solely in the present TU.
     { "ProjectedSalary" ,"100000; 105000; 110000 retirement; 0"                
        },
 };
 
@@ -98,16 +102,32 @@
             dialog->Show();
             wxYield();
 
-            if(!wxWindow::FindWindowByName(test_data_.field, dialog))
+            char const* const field_name = test_data_.field;
+            if(!wxWindow::FindWindowByName(field_name, dialog))
                 {
-                // If the field for this input sequence doesn't exist in the
-                // currently used skin at all, skip this particular sequence
-                // silently -- but continue testing the other ones.
+                // Check whether the field name is valid at all. If it
+                // isn't, then the input model must have changed, so
+                // warn that this test must be updated.
+                Input const dummy_input;
+                std::vector<std::string> const& names = 
dummy_input.member_names();
+                if(std::find(names.begin(), names.end(), field_name) == 
names.end())
+                    {
+                    wxPrintf
+                        ("WARNING: unknown field name \"%s\", \"test_cases\" "
+                         "array probably needs to be updated.\n"
+                        ,field_name
+                        );
+                    }
+
+                // However, it is not an error if the field used by
+                // this input sequence doesn't exist in the currently-
+                // used skin--not all skins have all the fields--so
+                // just skip it and continue testing the other ones.
                 return wxID_CANCEL;
                 }
 
             // Focus the field in which the sequence should be entered.
-            wx_test_focus_controller_child(*dialog, test_data_.field);
+            wx_test_focus_controller_child(*dialog, field_name);
 
             // Type the sequence into it.
             wxUIActionSimulator ui;




reply via email to

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