[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [6123] Implement rectified test specification
From: |
Greg Chicares |
Subject: |
[lmi-commits] [6123] Implement rectified test specification |
Date: |
Sun, 08 Mar 2015 19:08:19 +0000 |
Revision: 6123
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6123
Author: chicares
Date: 2015-03-08 19:08:18 +0000 (Sun, 08 Mar 2015)
Log Message:
-----------
Implement rectified test specification
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/wx_test_default_update.cpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2015-03-08 18:23:21 UTC (rev 6122)
+++ lmi/trunk/ChangeLog 2015-03-08 19:08:18 UTC (rev 6123)
@@ -35749,3 +35749,9 @@
Work around a MinGW defect more tidily. See:
http://lists.nongnu.org/archive/html/lmi/2014-12/msg00036.html
+20150308T1908Z <address@hidden> [516]
+
+ wx_test_default_update.cpp
+Implement rectified test specification. See:
+ http://lists.nongnu.org/archive/html/lmi/2015-03/msg00007.html
+
Modified: lmi/trunk/wx_test_default_update.cpp
===================================================================
--- lmi/trunk/wx_test_default_update.cpp 2015-03-08 18:23:21 UTC (rev
6122)
+++ lmi/trunk/wx_test_default_update.cpp 2015-03-08 19:08:18 UTC (rev
6123)
@@ -30,8 +30,12 @@
#include "configurable_settings.hpp"
#include "mvc_controller.hpp"
#include "wx_test_case.hpp"
+#include "wx_test_new.hpp"
#include "wx_test_statusbar.hpp"
+#include <wx/checkbox.h>
+#include <wx/datectrl.h>
+#include <wx/radiobox.h>
#include <wx/testing.h>
#include <wx/uiaction.h>
@@ -41,8 +45,10 @@
///
/// Load the default input file, using its special command.
///
-/// Change its "MEC avoidance" option. This particular option is used
-/// because it is available for almost any life insurance product.
+/// Change its "DateOfBirth" option. This particular option is used because it
+/// is available for any life insurance product as the date of birth is a field
+/// of such central importance.
+///
/// Save the changed file; make sure the appropriate message appears
/// on the status bar. Make sure the saved file exists in its
/// configured directory.
@@ -51,11 +57,9 @@
{
wxUIActionSimulator ui;
- // Change the "MEC avoidance" option in the first page of the defaults
- // dialog.
ui.Char('t', wxMOD_CONTROL); // "File|Default"
- struct change_mec_avoidance_in_defaults_dialog
+ struct change_dob_in_defaults_dialog
:public wxExpectModalBase<MvcController>
{
virtual int OnInvoked(MvcController* dialog) const
@@ -63,24 +67,49 @@
dialog->Show();
wxYield();
- wxUIActionSimulator ui;
+ wxWindow* const dob_window = wx_test_focus_controller_child
+ (*dialog
+ ,"DateOfBirth"
+ );
- // Go to the first page: as the dialog remembers its last opened
- // page, it might not open on it.
- ui.Char(WXK_HOME);
- wxYield();
+ // We need to ensure that the "Date Of Birth" field is enabled
+ // by triggering the value of "Use Date Of Birth" if necessary.
+ wxWindow* const usedob_window = wx_test_focus_controller_child
+ (*dialog
+ ,"UseDOB"
+ );
- // Select the first button of the "MEC avoidance" radio box.
- ui.Char(WXK_TAB);
- ui.Char(WXK_TAB);
- wxYield();
+ if (!dob_window->IsEnabled())
+ {
+ ToggleUseDOB(usedob_window);
+ }
- // Change its value: it doesn't matter which button is selected,
- // pressing the down arrow will always toggle the selection in a
- // radio box with two buttons.
- ui.Char(WXK_DOWN);
+ // Entering the target date into a wxDatePickerCtrl using
+ // wxUIActionSimulator is too difficult: different sequences of
+ // keys are required depending on the graphical toolkit used and
+ // also depending on the current locale, so just cheat and put the
+ // date directly into the control.
+ wxDatePickerCtrl* const dob = dynamic_cast<wxDatePickerCtrl*>
+ (dob_window
+ );
+ LMI_ASSERT_WITH_MSG
+ (dob
+ ,"\"DateOfBirth\" field is expected to be a wxDatePickerCtrl"
+ );
+
+ dob->SetValue(wxDateTime(13, wxDateTime::Jan, 1956));
wxYield();
+ // We also need to modify some field interactively to make the
+ // dialog "notice" that something has changed and even making
+ // wxDatePickerCtrl dirty is difficult using wxUIActionSimulator as
+ // it has very different keyboard interfaces under MSW and GTK, so
+ // reuse the "UseDOB" check or radio box: we don't actually change
+ // anything by toggling it twice, but doing this updates the value
+ // of the "DateOfBirth" field as a side effect.
+ ToggleUseDOB(usedob_window);
+ ToggleUseDOB(usedob_window);
+
return wxID_OK;
}
@@ -88,11 +117,40 @@
{
return "defaults dialog";
}
+
+ // Helper method toggling the value of the "UseDOB" field which can be
+ // represented by either a check box or a two element radio box
+ // depending on the skin used.
+ static void ToggleUseDOB(wxWindow* usedob_window)
+ {
+ wxUIActionSimulator ui;
+
+ if(dynamic_cast<wxRadioBox*>(usedob_window))
+ {
+ // Just selecting the other button is sufficient to toggle
+ // the value of a 2 element radio box under MSW, but under
+ // GTK we also have to explicitly check it by pressing
+ // Space or Enter and as it doesn't do anything under MSW, we
+ // just do it unconditionally to avoid conditional compilation.
+ ui.Char(WXK_DOWN);
+ ui.Char(WXK_SPACE);
+ }
+ else if(dynamic_cast<wxCheckBox*>(usedob_window))
+ {
+ ui.Char(WXK_SPACE);
+ }
+ else
+ {
+ throw std::runtime_error("\"UseDOB\" field has unknown type");
+ }
+
+ wxYield();
+ }
};
wxTEST_DIALOG
(wxYield()
- ,change_mec_avoidance_in_defaults_dialog()
+ ,change_dob_in_defaults_dialog()
);
// Save the default document.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [6123] Implement rectified test specification,
Greg Chicares <=