QTestPrivate property tests: don't try to create abstract types
Amends 5743837a26fce1962c0480bc7536b4c2d0e69997, after which Qt Positioning and Qt SCXML failed to build as some properties operate on abstract classes. Check whether we can instantiate the tested class before trying to do so, otherwise return a default-constructed unique_ptr. Pick-to: 6.5 Change-Id: Ida9d4375197a93438062b1e1473b4a2a22cc7054 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit f791570b86ce4a0da45bb6e617701a48ee8189b7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
64cfe7a5d0
commit
24e57ce6ca
@ -108,7 +108,12 @@ void testReadWritePropertyBasics(
|
|||||||
std::function<char *(const PropertyType &)> represent =
|
std::function<char *(const PropertyType &)> represent =
|
||||||
[](const PropertyType &val) { return QTest::toString(val); },
|
[](const PropertyType &val) { return QTest::toString(val); },
|
||||||
std::function<std::unique_ptr<TestedClass>(void)> helperConstructor =
|
std::function<std::unique_ptr<TestedClass>(void)> helperConstructor =
|
||||||
[]() { return std::make_unique<TestedClass>(); })
|
[]() {
|
||||||
|
if constexpr (std::is_default_constructible_v<TestedClass>)
|
||||||
|
return std::make_unique<TestedClass>();
|
||||||
|
else
|
||||||
|
return std::unique_ptr<TestedClass>();
|
||||||
|
})
|
||||||
{
|
{
|
||||||
// get the property
|
// get the property
|
||||||
const QMetaObject *metaObject = instance.metaObject();
|
const QMetaObject *metaObject = instance.metaObject();
|
||||||
@ -281,7 +286,12 @@ void testWriteOncePropertyBasics(
|
|||||||
std::function<char *(const PropertyType &)> represent =
|
std::function<char *(const PropertyType &)> represent =
|
||||||
[](const PropertyType &val) { return QTest::toString(val); },
|
[](const PropertyType &val) { return QTest::toString(val); },
|
||||||
std::function<std::unique_ptr<TestedClass>(void)> helperConstructor =
|
std::function<std::unique_ptr<TestedClass>(void)> helperConstructor =
|
||||||
[]() { return std::make_unique<TestedClass>(); })
|
[]() {
|
||||||
|
if constexpr (std::is_default_constructible_v<TestedClass>)
|
||||||
|
return std::make_unique<TestedClass>();
|
||||||
|
else
|
||||||
|
return std::unique_ptr<TestedClass>();
|
||||||
|
})
|
||||||
{
|
{
|
||||||
Q_UNUSED(helperConstructor);
|
Q_UNUSED(helperConstructor);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user