8#include <QtTest/qtestcase.h>
9#include <QtTest/qtestsystem.h>
10#include <QtTest/private/qtestblacklist_p.h>
11#include <QtTest/private/qtestresult_p.h>
12#include <QtTest/private/qtesttable_p.h>
13#include <QtTest/private/qtestlog_p.h>
15#include <QtTest/qbenchmark.h>
16#include <QtTest/private/qbenchmark_p.h>
17#include <QtCore/qset.h>
18#include <QtCore/qmap.h>
19#include <QtCore/qbytearray.h>
20#include <QtCore/qcoreapplication.h>
21#include <QtCore/qdatetime.h>
22#include <QtCore/qdebug.h>
25#if QT_CONFIG(regularexpression)
26#include <QtCore/qregularexpression.h>
28#include <QtQuick/qquickwindow.h>
29#include <QtGui/qvector3d.h>
30#include <QtGui/qimagewriter.h>
31#include <QtQml/private/qqmlglobal_p.h>
32#include <QtQml/QQmlEngine>
33#include <QtQml/QQmlContext>
34#include <private/qv4qobjectwrapper_p.h>
85 ||
x >= m_image.width()
86 ||
y >= m_image.height()
89 ||
x *
y >= m_image.width() * m_image.height())
98 return m_image.isNull();
100 return m_image ==
other->m_image;
106 if (!writer.
write(m_image)) {
116 return m_image.width();
121 return m_image.height();
126 return m_image.size();
190 return d->testCaseName;
196 d->testCaseName =
name;
212 return d->functionName;
218 if (!
name.isEmpty()) {
219 if (
d->testCaseName.isEmpty()) {
221 (
d->intern(
name).constData());
231 d->functionName =
name;
252 if (!
tag.isEmpty()) {
406 d->table->addColumn(qMetaTypeId<QString>(),
"qmltest_dummy_data_column");
448 if (!success &&
message.isEmpty()) {
450 (success,
"verify()",
"",
454 (success,
message.toUtf8().constData(),
"",
461 if (actual.
userType() == QMetaType::QColor ||
expected.userType() == QMetaType::QColor) {
497 return (
qAbs(act - exp) <= delta);
514 if (
value->isObject()
519 switch (
v.userType()) {
520 case QMetaType::QVector3D:
526 case QMetaType::QUrl:
532 case QMetaType::QDateTime:
564 (success,
message.toUtf8().constData(),
583 (
tag.toLatin1().constData(),
592 (
tag.toLatin1().constData(),
605#if QT_CONFIG(regularexpression)
616#if QT_CONFIG(regularexpression)
644 delete d->benchmarkData;
648 d->resultsList.clear();
663 if (
d->iterCount > -1)
667 if (
d->iterCount == -1) {
687 return container.at(0);
690 std::sort(containerCopy.
begin(), containerCopy.
end(),
692 return a.first() < b.first();
695 const int middle =
count / 2;
698 return containerCopy.
at(middle);
720 delete d->benchmarkIter;
728 if (
d->benchmarkIter)
729 return d->benchmarkIter->isDone();
737 if (
d->benchmarkIter)
738 d->benchmarkIter->next();
744 delete d->benchmarkIter;
745 d->benchmarkIter =
nullptr;
768bool QuickTestResult::isPolishScheduled(
QObject *itemOrWindow)
const
773 if (
auto window = qobject_cast<QQuickWindow*>(itemOrWindow))
776 qmlWarning(
this) <<
"isPolishScheduled() expects either an Item or Window, but got"
777 << QDebug::toString(itemOrWindow);
781bool QuickTestResult::waitForPolish(
QObject *itemOrWindow,
int timeout)
const
786 if (
auto window = qobject_cast<QQuickWindow*>(itemOrWindow))
789 qmlWarning(
this) <<
"waitForItemPolish() expects either an Item or Window, but got"
790 << QDebug::toString(itemOrWindow);
826#if defined(QTEST_NOEXITCODE)
837#include "quicktestresult.moc"
838#include "moc_quicktestresult_p.cpp"
int adjustMedianIterationCount()
QBenchmarkContext context
QBenchmarkMeasurerBase * measurer
static QBenchmarkGlobalData * current
virtual bool needsWarmupIteration()
static QBenchmarkTestMethodData * current
QList< QBenchmarkResult > results
bool resultsAccepted() const
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
The QColor class provides colors based on RGB, HSV or CMYK values.
static QColor fromRgba(QRgb rgba) noexcept
Static convenience function that returns a QColor constructed from the given QRgb value rgba.
int alpha() const noexcept
Returns the alpha color component of this color.
int red() const noexcept
Returns the red color component of this color.
int blue() const noexcept
Returns the blue color component of this color.
int green() const noexcept
Returns the green color component of this color.
\inmodule QtCore\reentrant
static QString toNativeSeparators(const QString &pathName)
qreal y() const
This convenience function is equivalent to calling pos().y().
QGraphicsWidget * window() const
qreal x() const
This convenience function is equivalent to calling pos().x().
The QImageWriter class provides a format independent interface for writing images to files or other d...
QString errorString() const
Returns a human readable description of the last error that occurred.
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
qreal devicePixelRatio() const
Returns the device pixel ratio for the image.
QV4::ExecutionEngine * handle() const
The QJSValue class acts as a container for Qt/JavaScript data types.
QString toString() const
Returns the string value of this QJSValue, as defined in \l{ECMA-262} section 9.8,...
qsizetype size() const noexcept
bool isEmpty() const noexcept
qsizetype length() const noexcept
const_reference at(qsizetype i) const noexcept
T findChild(const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns the child of this object that can be cast into type T and that is called name,...
QObject * parent() const
Returns a pointer to the parent object.
\inmodule QtCore\reentrant
virtual QVariant colorFromString(const QString &, bool *)
QQmlEngine * engine() const
Return the context's QQmlEngine, or \nullptr if the context has no QQmlEngine or the QQmlEngine was d...
The QQmlEngine class provides an environment for instantiating QML components.
static void setContextForObject(QObject *, QQmlContext *)
Sets the QQmlContext for the object to context.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
QRect toAlignedRect() const noexcept
QRectF intersected(const QRectF &other) const noexcept
iterator insert(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QByteArray toUtf8() const &
static void startLogging()
static void addBenchmarkResults(const QList< QBenchmarkResult > &result)
static void stopLogging()
static void warn(const char *msg, const char *file, int line)
static void ignoreMessage(QtMsgType type, const char *msg)
static void finishedCurrentTestDataCleanup()
This function is called after completing each test function, including test functions that are not da...
static void finishedCurrentTestData()
This function is called after completing each test function, including test functions that are not da...
static bool expectFail(const char *dataIndex, const char *comment, QTest::TestFailMode mode, const char *file, int line)
static bool verify(bool statement, const char *statementStr, const char *extraInfo, const char *file, int line)
static bool currentTestFailed()
static void setSkipCurrentTest(bool value)
static void setCurrentAppName(const char *appName)
static void setCurrentTestFunction(const char *func)
static void setBlacklistCurrentTest(bool b)
static void setCurrentTestObject(const char *name)
static const char * currentDataTag()
static bool compare(bool success, const char *failureMsg, char *val1, char *val2, const char *actual, const char *expected, const char *file, int line)
static void addFailure(const char *message, const char *file=nullptr, int line=0)
static bool skipCurrentTest()
static void finishedCurrentTestFunction()
This function is called after completing each test function, including test functions that are data-d...
static void setCurrentTestData(QTestData *data)
static void addSkip(const char *message, const char *file, int line)
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
float toFloat(bool *ok=nullptr) const
Returns the variant as a float if the variant has userType() \l QMetaType::Double,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
bool canConvert(QMetaType targetType) const
The QVector3D class represents a vector or vertex in 3D space.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr float z() const noexcept
Returns the z coordinate of this point.
bool equals(QuickTestImageObject *other) const
int red(int x, int y) const
QVariant pixel(int x, int y) const
void save(const QString &filePath)
int green(int x, int y) const
QuickTestImageObject(const QImage &img, QObject *parent=nullptr)
int alpha(int x, int y) const
int blue(int x, int y) const
QByteArray intern(const QString &str)
QSet< QByteArray > internedStrings
QList< QList< QBenchmarkResult > > resultsList
QTest::QBenchmarkIterationController * benchmarkIter
~QuickTestResultPrivate()
QBenchmarkTestMethodData * benchmarkData
void warn(const QString &message, const QUrl &location, int line)
void finishTestDataCleanup()
void functionNameChanged()
void setFunctionName(const QString &name)
QStringList functionsToRun
bool verify(bool success, const QString &message, const QUrl &location, int line)
bool isBenchmarkDone() const
bool isSkipped() const
\qmlproperty bool TestResult::skipped
bool measurementAccepted()
void finishTestFunction()
const QString & objectName
bool expectFailContinue(const QString &tag, const QString &comment, const QUrl &location, int line)
void reset()
\qmlmethod TestResult::reset()
void setTestCaseName(const QString &name)
static void setCurrentAppname(const char *appname)
bool compare(bool success, const QString &message, const QVariant &val1, const QVariant &val2, const QUrl &location, int line)
QuickTestResult(QObject *parent=nullptr)
void stopLogging()
\qmlmethod TestResult::stopLogging()
static void setProgramName(const char *name)
bool isFailed() const
\qmlproperty bool TestResult::failed
void ignoreWarning(const QJSValue &message)
void testCaseNameChanged()
bool needsMoreMeasurements()
void startBenchmark(RunMode runMode, const QString &tag)
void startLogging()
\qmlmethod TestResult::startLogging()
void fail(const QString &message, const QUrl &location, int line)
bool expectFail(const QString &tag, const QString &comment, const QUrl &location, int line)
void stringify(QQmlV4Function *args)
~QuickTestResult() override
static void parseArgs(int argc, char *argv[])
bool fuzzyCompare(const QVariant &actual, const QVariant &expected, qreal delta)
bool waitForRendering(QQuickItem *item, int timeout=5000)
void setDataTag(const QString &tag)
QObject * grabImage(QQuickItem *item)
void skip(const QString &message, const QUrl &location, int line)
void setSkipped(bool skip)
Q_QUICK_TEST_EXPORT bool qWaitForPolish(const QQuickItem *item, int timeout=defaultTimeout)
Q_QUICK_TEST_EXPORT bool qIsPolishScheduled(const QQuickItem *item)
Combined button and popup list for selecting options.
void checkBlackLists(const char *slot, const char *data, const char *global)
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Appends a new row to the current test data.
Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool qml)
char * toString(const MyPoint &point)
Q_TESTLIB_EXPORT QStringList testFunctions
Q_CORE_EXPORT void qSleep(int ms)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Q_TESTLIB_EXPORT QStringList testTags
Q_CORE_EXPORT void qWait(int ms)
This is an overloaded member function, provided for convenience. It differs from the above function o...
AudioChannelLayoutTag tag
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLbitfield GLuint64 timeout
[4]
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat alpha
GLenum GLenum GLsizei void * table
QQmlContext * qmlContext(const QObject *obj)
Q_AUTOTEST_EXPORT QQmlColorProvider * QQml_colorProvider(void)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
bool qWaitForSignal(QObject *obj, const char *signal, int timeout)
#define Q_QUICK_TEST_EXPORT
static QBenchmarkGlobalData globalBenchmarkData
static QString qtestFixUrl(const QUrl &location)
static QList< QBenchmarkResult > qMedian(const QList< QList< QBenchmarkResult > > &container)
static bool loggingStarted
static QT_BEGIN_NAMESPACE const char * globalProgramName
QUrl url("example.com")
[constructor-url-reference]
\inmodule QtCore \reentrant
static constexpr ReturnedValue null()
ReturnedValue throwError(const Value &value)
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols=true)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent