-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WT-10578: WDateEdit: fix updating of calendar when validator is changed
- Made the validatorChanged() function virtual in WFormWidget so it can be overridden in WDateEdit, to update its WCalendar - Added regression tests in WDateEditTest - Added internal documentation for validatorChanged() and WValidator::repaint(). Doxygen will only look at this documentation if INTERNAL_DOCS is set to YES in Doxyfile
- Loading branch information
1 parent
63b1c68
commit 76cc78e
Showing
7 changed files
with
132 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (C) 2022 Emweb bv, Herent, Belgium. | ||
* | ||
* See the LICENSE file for terms of use. | ||
*/ | ||
#include <boost/test/unit_test.hpp> | ||
|
||
#include <Wt/WApplication.h> | ||
#include <Wt/WCalendar.h> | ||
#include <Wt/WDate.h> | ||
#include <Wt/WDateEdit.h> | ||
#include <Wt/WDateValidator.h> | ||
#include <Wt/Test/WTestEnvironment.h> | ||
|
||
BOOST_AUTO_TEST_CASE( dateedit_validator_changed1 ) | ||
{ | ||
// Regression test for issue #10578 | ||
// Changing the bottom and top of the validator should change bottom and top of | ||
// date edit and calendar | ||
Wt::Test::WTestEnvironment environment; | ||
Wt::WApplication app(environment); | ||
|
||
auto dateEdit = std::make_unique<Wt::WDateEdit>(); | ||
auto dv = dateEdit->dateValidator(); | ||
const auto bottom = Wt::WDate(1999, 1, 1); | ||
const auto top = Wt::WDate(2042, 1, 1); | ||
dv->setBottom(bottom); | ||
dv->setTop(top); | ||
|
||
BOOST_REQUIRE(dv->bottom() == bottom); | ||
BOOST_REQUIRE(dv->top() == top); | ||
BOOST_REQUIRE(dateEdit->bottom() == bottom); | ||
BOOST_REQUIRE(dateEdit->top() == top); | ||
|
||
auto calendar = dateEdit->calendar(); | ||
BOOST_REQUIRE(calendar->bottom() == bottom); | ||
BOOST_REQUIRE(calendar->top() == top); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE( dateedit_validator_changed2 ) | ||
{ | ||
// Regression test for issue #10578 | ||
// Changing the bottom and top of the date edit should change bottom and top of | ||
// date validator and calendar | ||
Wt::Test::WTestEnvironment environment; | ||
Wt::WApplication app(environment); | ||
|
||
auto dateEdit = std::make_unique<Wt::WDateEdit>(); | ||
auto dv = dateEdit->dateValidator(); | ||
const auto bottom = Wt::WDate(1999, 1, 1); | ||
const auto top = Wt::WDate(2042, 1, 1); | ||
dateEdit->setBottom(bottom); | ||
dateEdit->setTop(top); | ||
|
||
BOOST_REQUIRE(dv->bottom() == bottom); | ||
BOOST_REQUIRE(dv->top() == top); | ||
BOOST_REQUIRE(dateEdit->bottom() == bottom); | ||
BOOST_REQUIRE(dateEdit->top() == top); | ||
|
||
auto calendar = dateEdit->calendar(); | ||
BOOST_REQUIRE(calendar->bottom() == bottom); | ||
BOOST_REQUIRE(calendar->top() == top); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE( dateedit_validator_changed3 ) | ||
{ | ||
// Regression test for issue #10578 | ||
// Changing the bottom and top of the date edit should change bottom and top of | ||
// the calendar, even if we have no validator | ||
Wt::Test::WTestEnvironment environment; | ||
Wt::WApplication app(environment); | ||
|
||
auto dateEdit = std::make_unique<Wt::WDateEdit>(); | ||
dateEdit->setValidator(nullptr); | ||
const auto bottom = Wt::WDate(1999, 1, 1); | ||
const auto top = Wt::WDate(2042, 1, 1); | ||
dateEdit->setBottom(bottom); | ||
dateEdit->setTop(top); | ||
|
||
BOOST_REQUIRE(dateEdit->bottom() == bottom); | ||
BOOST_REQUIRE(dateEdit->top() == top); | ||
|
||
auto calendar = dateEdit->calendar(); | ||
BOOST_REQUIRE(calendar->bottom() == bottom); | ||
BOOST_REQUIRE(calendar->top() == top); | ||
} |