>From 8cdfdd2431ceb86055fc648162ad7b6ad54f6d79 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 10 Mar 2015 19:51:22 +0100 Subject: [PATCH] Complain about unknown field names in the input sequences test. Verify that field names not found in the dialog are simply not shown by the current skin but still exist -- and warn if they do not. This will check the test getting out of sync with the main program if the field names change in the future, before this change the test would be still passing without actually performing any tests if an existing field were removed or renamed. --- wx_test_input_sequences.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/wx_test_input_sequences.cpp b/wx_test_input_sequences.cpp index 26e6f61..6ba5c73 100644 --- a/wx_test_input_sequences.cpp +++ b/wx_test_input_sequences.cpp @@ -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 #include #include +#include // 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 @@ -98,16 +102,32 @@ struct input_sequence_test_data 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, + // it must mean that the input model changed, and so this test + // must be updated, so warn about it. + Input const dummy_input; + std::vector 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; -- 2.1.0