Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
Classes | |
class | AppNapDisabler |
Disables App Nap by registering a background activity. More... | |
Enumerations | |
enum | IdentifierPart { TestObject = 0x1 , TestFunction = 0x2 , TestDataTag = 0x4 , AllParts = 0xFFFF } |
Functions | |
bool | testDataGuiRoles (QAbstractItemModelTester *tester) |
void | generateTestIdentifier (QTestCharBuffer *identifier, int parts) |
bool | appendCharBuffer (QTestCharBuffer *accumulator, const QTestCharBuffer &more) |
QByteArray | formatTypeWithCRefImpl (QMetaType type, bool isConst, bool isRef, bool isRvalueRef) |
template<typename T > | |
QByteArray | formatTypeWithCRef () |
template<typename LeftType , typename RightType = LeftType> | |
void | testEqualityOperatorsCompile () |
template<typename LeftType , typename RightType = LeftType> | |
void | testAllComparisonOperatorsCompile () |
template<typename LeftType , typename RightType > | |
void | testEqualityOperators (LeftType lhs, RightType rhs, bool expectedEqual) |
template<typename LeftType , typename RightType , typename OrderingType > | |
void | testAllComparisonOperators (LeftType lhs, RightType rhs, OrderingType expectedOrdering) |
static bool | isRunningArmOnX86 () |
template<typename TestedClass , typename PropertyType > | |
void | testReadWritePropertyBasics (TestedClass &instance, const PropertyType &initial, const PropertyType &changed, const char *propertyName, std::function< bool(const PropertyType &, const PropertyType &)> comparator=[](const PropertyType &lhs, const PropertyType &rhs) { return lhs==rhs;}, std::function< char *(const PropertyType &)> represent=[](const PropertyType &val) { return QTest::toString(val);}, std::function< std::unique_ptr< TestedClass >(void)> helperConstructor=[]() { return std::make_unique< TestedClass >();}) |
template<typename TestedClass , typename PropertyType > | |
void | testReadWritePropertyBasics (TestedClass &instance, const PropertyType &initial, const PropertyType &changed, const char *propertyName, std::function< std::unique_ptr< TestedClass >(void)> helperConstructor) |
template<typename TestedClass , typename PropertyType > | |
void | testWriteOncePropertyBasics (TestedClass &instance, const PropertyType &prior, const PropertyType &changed, const char *propertyName, bool bindingPreservedOnWrite=true, std::function< bool(const PropertyType &, const PropertyType &)> comparator=[](const PropertyType &lhs, const PropertyType &rhs) { return lhs==rhs;}, std::function< char *(const PropertyType &)> represent=[](const PropertyType &val) { return QTest::toString(val);}, std::function< std::unique_ptr< TestedClass >(void)> helperConstructor=[]() { return std::make_unique< TestedClass >();}) |
template<typename TestedClass , typename PropertyType > | |
void | testWriteOncePropertyBasics (TestedClass &instance, const PropertyType &prior, const PropertyType &changed, const char *propertyName, bool bindingPreservedOnWrite, std::function< std::unique_ptr< TestedClass >(void)> helperConstructor) |
template<typename TestedClass , typename PropertyType > | |
void | testReadOnlyPropertyBasics (TestedClass &instance, const PropertyType &initial, const PropertyType &changed, const char *propertyName, std::function< void()> mutator=[]() { QFAIL("Data modifier function must be provided");}, std::function< bool(const PropertyType &, const PropertyType &)> comparator=[](const PropertyType &lhs, const PropertyType &rhs) { return lhs==rhs;}, std::function< char *(const PropertyType &)> represent=[](const PropertyType &val) { return QTest::toString(val);}) |
void | parseBlackList () |
bool | checkBlackLists (const char *slot, const char *data, const char *global) |
static bool | canHandleUnicodeFileNames () |
void | disableWindowRestore () |
bool | macCrashReporterWillShowDialog () |
Variables | |
Q_TESTLIB_EXPORT Qt::MouseButtons | qtestMouseButtons = Qt::NoButton |
Enumerator | |
---|---|
TestObject | |
TestFunction | |
TestDataTag | |
AllParts |
Definition at line 169 of file qabstracttestlogger_p.h.
bool QTestPrivate::appendCharBuffer | ( | QTestCharBuffer * | accumulator, |
const QTestCharBuffer & | more ) |
Definition at line 447 of file qabstracttestlogger.cpp.
References appendCharBuffer(), QTestCharBuffer::data(), oldsize, qstrnlen(), and QTestCharBuffer::resize().
Referenced by QTapTestLogger::addIncident(), QTeamCityLogger::addIncident(), QTapTestLogger::addMessage(), and appendCharBuffer().
|
inlinestatic |
Definition at line 37 of file qtesthelpers_p.h.
References QFile::encodeName(), and QByteArrayLiteral.
Q_TESTLIB_EXPORT bool QTestPrivate::checkBlackLists | ( | const char * | slot, |
const char * | data, | ||
const char * | global ) |
Definition at line 283 of file qtestblacklist.cpp.
References global, ignoreAll, and ignoredTests.
Referenced by QuickTestResult::setDataTag(), and QuickTestResult::setFunctionName().
void QTestPrivate::disableWindowRestore | ( | ) |
Disables restoration of previously saved window state. This causes tests to start with a clean slate and prevents the "previous restore failed" dialog from showing if there was a test crash.
Definition at line 20 of file qtestutil_macos.mm.
Referenced by QTest::qInit().
QByteArray QTestPrivate::formatTypeWithCRef | ( | ) |
Definition at line 39 of file qcomparisontesthelper_p.h.
References formatTypeWithCRefImpl(), and QMetaType::fromType().
Q_TESTLIB_EXPORT QByteArray QTestPrivate::formatTypeWithCRefImpl | ( | QMetaType | type, |
bool | isConst, | ||
bool | isRef, | ||
bool | isRvalueRef ) |
Definition at line 10 of file qcomparisontesthelper.cpp.
Referenced by formatTypeWithCRef().
void Q_TESTLIB_EXPORT QTestPrivate::generateTestIdentifier | ( | QTestCharBuffer * | identifier, |
int | parts ) |
Definition at line 429 of file qabstracttestlogger.cpp.
References QTestResult::currentDataTag(), QTestResult::currentGlobalDataTag(), QTestResult::currentTestFunction(), QTestResult::currentTestObjectName(), generateTestIdentifier(), QTest::qt_asprintf(), TestDataTag, TestFunction, testObject(), and TestObject.
Referenced by QJUnitTestLogger::enterTestData(), and generateTestIdentifier().
|
static |
Definition at line 48 of file qemulationdetector_p.h.
bool QTestPrivate::macCrashReporterWillShowDialog | ( | ) |
Definition at line 27 of file qtestutil_macos.mm.
Q_TESTLIB_EXPORT void QTestPrivate::parseBlackList | ( | ) |
Definition at line 246 of file qtestblacklist.cpp.
References checkCondition(), function, ignoreAll, ignoredTests, QString::indexOf(), QString::isEmpty(), line, QString::mid(), QTest::qFindTestData(), QStringLiteral, QIODeviceBase::ReadOnly, QString::simplified(), QString::size(), QString::startsWith(), and QString::truncate().
Referenced by QTest::qInit(), and QuickTestResult::setProgramName().
void QTestPrivate::testAllComparisonOperators | ( | LeftType | lhs, |
RightType | rhs, | ||
OrderingType | expectedOrdering ) |
Basic testing of equality and relation operators.
The helper function tests all six relation and equality operators (==, !=, <, >, <=, >=) for the lhs operand of type {LeftType}
and the rhs operand of type {RightType}
and all six for the reverse order of the operands.
If compiled in C++20 mode, also checks {operator<=>()}
if that is implemented.
When compiled in C++17 mode, the OrderingType
must be one of Qt::partial_ordering, Qt::strong_ordering, or Qt::weak_ordering. In C++20 mode, also the {std:
:*_ordering} types can be used.
The expectedOrdering parameter provides the expected relation between lhs and rhs.
Definition at line 226 of file qcomparisontesthelper_p.h.
References CHECK_RUNTIME_CREF, CHECK_RUNTIME_LR, Qt::partial_ordering::equivalent, Qt::partial_ordering::less, and Qt::partial_ordering::unordered.
void QTestPrivate::testAllComparisonOperatorsCompile | ( | ) |
This function checks that the types LeftType
and RightType
properly define all comparison operators (==, !=, <, >, <=, >=). The checks are performed for all combinations of cvref-qualified lvalues and rvalues.
If compiled in C++20 mode, also checks {operator<=>()}
if that is implemented.
Definition at line 113 of file qcomparisontesthelper_p.h.
References CHECK_SINGLE_OPERATOR, QTest::currentTestFailed(), and FOR_EACH_CREF.
|
inline |
Definition at line 58 of file qabstractitemmodeltester.h.
References Qt::BackgroundRole, QVariant::canConvert(), QSqlQueryModel::data(), Qt::DecorationRole, Qt::FontRole, Qt::ForegroundRole, QAbstractTableModel::index(), QVariant::isValid(), model, MODELTESTER_VERIFY, Q_ASSERT, Q_UNUSED, and variant.
Referenced by QAbstractItemModelTesterPrivate::data().
void QTestPrivate::testEqualityOperators | ( | LeftType | lhs, |
RightType | rhs, | ||
bool | expectedEqual ) |
Basic testing of equality operators.
The helper function tests {in}equality operators (== and !=) for the lhs operand of type {LeftType}
and the rhs operand of type {RightType}
, plus the reverse order of the operands.
The expectedEqual parameter is an expected result for {operator==()}
.
Definition at line 187 of file qcomparisontesthelper_p.h.
References CHECK_RUNTIME_CREF, and CHECK_RUNTIME_LR.
void QTestPrivate::testEqualityOperatorsCompile | ( | ) |
This function checks that the types LeftType
and RightType
properly define {in}equality operators (== and !=). The checks are performed for all combinations of cvref-qualified lvalues and rvalues.
Definition at line 96 of file qcomparisontesthelper_p.h.
References CHECK_SINGLE_OPERATOR, and FOR_EACH_CREF.
void QTestPrivate::testReadOnlyPropertyBasics | ( | TestedClass & | instance, |
const PropertyType & | initial, | ||
const PropertyType & | changed, | ||
const char * | propertyName, | ||
std::function< void()> | mutator = []() { QFAIL("Data modifier function must be provided"); }, | ||
std::function< bool(const PropertyType &, const PropertyType &)> | comparator = [](const PropertyType &lhs, const PropertyType &rhs) { return lhs == rhs; }, | ||
std::function< char *(const PropertyType &)> | represent = [](const PropertyType &val) { return QTest::toString(val); } ) |
Basic testing of a read-only bindable property.
This helper function tests the behavior of bindable read-only property propertyName, of type PropertyType
, in class TestedClass
. The caller must supply an instance of TestedClass
and two distinct values, initial and changed, of PropertyType
.
When this function is called, the property's value must be initial. The mutator must, when called, cause the property's value to be revised to changed.
By default {operator==()}
is used to compare values of the property and {QTest::toString()}
is used to generate proper error messages.
If such comparison is not supported for PropertyType
, or the comparison it supports is not appropriate to this property, a custom comparator can be supplied.
Apart from that, a custom represent callback can also be specified to generate a string representation of PropertyType
. If supplied, it must allocate its returned string using {new
char[]}, so that it can be used in place of \l {QTest::toString()}.
Definition at line 431 of file qpropertytesthelper_p.h.
References QFAIL.
void QTestPrivate::testReadWritePropertyBasics | ( | TestedClass & | instance, |
const PropertyType & | initial, | ||
const PropertyType & | changed, | ||
const char * | propertyName, | ||
std::function< bool(const PropertyType &, const PropertyType &)> | comparator = [](const PropertyType &lhs, const PropertyType &rhs) { return lhs == rhs; }, | ||
std::function< char *(const PropertyType &)> | represent = [](const PropertyType &val) { return QTest::toString(val); }, | ||
std::function< std::unique_ptr< TestedClass >(void)> | helperConstructor = []() { return std::make_unique<TestedClass>(); } ) |
Basic testing of a bindable property.
This helper function tests the behavior of bindable read/write property propertyName, of type PropertyType
, in class TestedClass
. The caller must supply an instance of TestedClass
and two distinct values, initial and changed, of PropertyType
.
Since the first part of the test sets the property to initial, it {must not} be the default value of the property, or the check that it was set will be vacuous.
By default {operator==()}
is used to compare values of the property and {QTest::toString()}
is used to generate proper error messages.
If such comparison is not supported for PropertyType
, or the comparison it supports is not appropriate to this property, a custom comparator can be supplied.
Apart from that, a custom represent callback can also be specified to generate a string representation of PropertyType
. If supplied, it must allocate its returned string using {new
char[]}, so that it can be used in place of \l {QTest::toString()}.
The helperConstructor method is used to create another instance of TestedClass
. This instance is used to test for binding loops. By default, the method returns a default-constructed TestedClass
. A custom helperConstructor should be provided if TestedClass
is not default-constructible. Some very specific properties cannot be tested for binding loops. Pass a lambda that returns an {std::nullptr}
as helperConstructor in such case.
Definition at line 105 of file qpropertytesthelper_p.h.
void QTestPrivate::testReadWritePropertyBasics | ( | TestedClass & | instance, |
const PropertyType & | initial, | ||
const PropertyType & | changed, | ||
const char * | propertyName, | ||
std::function< std::unique_ptr< TestedClass >(void)> | helperConstructor ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This overload supports the case where the caller only needs to override the default for helperConstructor. It uses the defaults for all the other parameters.
Definition at line 231 of file qpropertytesthelper_p.h.
References QTest::toString().
void QTestPrivate::testWriteOncePropertyBasics | ( | TestedClass & | instance, |
const PropertyType & | prior, | ||
const PropertyType & | changed, | ||
const char * | propertyName, | ||
bool | bindingPreservedOnWrite, | ||
std::function< std::unique_ptr< TestedClass >(void)> | helperConstructor ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This overload supports the case where the caller only needs to override the default for helperConstructor. It uses the defaults for all the other parameters.
Definition at line 383 of file qpropertytesthelper_p.h.
References QTest::toString().
void QTestPrivate::testWriteOncePropertyBasics | ( | TestedClass & | instance, |
const PropertyType & | prior, | ||
const PropertyType & | changed, | ||
const char * | propertyName, | ||
bool | bindingPreservedOnWrite = true, | ||
std::function< bool(const PropertyType &, const PropertyType &)> | comparator = [](const PropertyType &lhs, const PropertyType &rhs) { return lhs == rhs; }, | ||
std::function< char *(const PropertyType &)> | represent = [](const PropertyType &val) { return QTest::toString(val); }, | ||
std::function< std::unique_ptr< TestedClass >(void)> | helperConstructor = []() { return std::make_unique<TestedClass>(); } ) |
Basic testing of a bindable property that is writable only once.
The write-once properties are writable properties which accept only one valid setting of the value ("write"), after which later attempts are ignored.
This helper function tests the behavior of bindable write-once property propertyName, of type PropertyType
, in class TestedClass
. The caller must supply an instance of TestedClass
and two distinct values, initial and changed, of PropertyType
.
The property of instance must not yet have been set when this function is called. The value it has before being set should be passed as prior and a distinct value, that this test can set it to, as changed.
The bindingPreservedOnWrite parameter controls whether this function expects the binding set by this function to be preserved when setting a value directly. The default value is 'true'.
By default {operator==()}
is used to compare values of the property and {QTest::toString()}
is used to generate proper error messages.
If such comparison is not supported for PropertyType
, or the comparison it supports is not appropriate to this property, a custom comparator can be supplied.
Apart from that, a custom represent callback can also be specified to generate a string representation of PropertyType
. If supplied, it must allocate its returned string using {new
char[]}, so that it can be used in place of \l {QTest::toString()}.
The helperConstructor method is used to create another instance of TestedClass
. This instance is used to test for binding loops. By default, the method returns a default-constructed TestedClass
. A custom helperConstructor should be provided if TestedClass
is not default-constructible. Some very specific properties cannot be tested for binding loops. Pass a lambda that returns an {std::nullptr}
as helperConstructor in such case.
Definition at line 295 of file qpropertytesthelper_p.h.
Q_TESTLIB_EXPORT Qt::MouseButtons QTestPrivate::qtestMouseButtons = Qt::NoButton |
Definition at line 167 of file qtestcase.cpp.