Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
quicktestresult_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QUICKTESTRESULT_P_H
6#define QUICKTESTRESULT_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuickTest/private/quicktestglobal_p.h>
20#include <QtCore/qobject.h>
21#include <QtCore/qstring.h>
22#include <QtCore/qstringlist.h>
23#include <QtCore/qscopedpointer.h>
24#include <QtQuick/qquickitem.h>
25#include <QtQuick/qquickwindow.h>
26
28
29class QUrl;
31
32class Q_QMLTEST_EXPORT QuickTestResult : public QObject
33{
34 Q_OBJECT
35 Q_PROPERTY(QString testCaseName READ testCaseName WRITE setTestCaseName NOTIFY testCaseNameChanged)
36 Q_PROPERTY(QString functionName READ functionName WRITE setFunctionName NOTIFY functionNameChanged)
37 Q_PROPERTY(QString dataTag READ dataTag WRITE setDataTag NOTIFY dataTagChanged)
38 Q_PROPERTY(bool failed READ isFailed)
39 Q_PROPERTY(bool skipped READ isSkipped WRITE setSkipped NOTIFY skippedChanged)
40 Q_PROPERTY(int passCount READ passCount)
41 Q_PROPERTY(int failCount READ failCount)
42 Q_PROPERTY(int skipCount READ skipCount)
43 Q_PROPERTY(QStringList functionsToRun READ functionsToRun)
44 Q_PROPERTY(QStringList tagsToRun READ tagsToRun)
45
46 QML_NAMED_ELEMENT(TestResult)
47 QML_ADDED_IN_VERSION(1, 0)
48
49public:
50 QuickTestResult(QObject *parent = nullptr);
51 ~QuickTestResult() override;
52
53 // Values must match QBenchmarkIterationController::RunMode.
54 enum RunMode
55 {
56 RepeatUntilValidMeasurement,
57 RunOnce
58 };
59 Q_ENUM(RunMode)
60
61 QString testCaseName() const;
62 void setTestCaseName(const QString &name);
63
64 QString functionName() const;
65 void setFunctionName(const QString &name);
66
67 QString dataTag() const;
68 void setDataTag(const QString &tag);
69
70 bool isFailed() const;
71
72 bool isSkipped() const;
73 void setSkipped(bool skip);
74
75 int passCount() const;
76 int failCount() const;
77 int skipCount() const;
78
79 QStringList functionsToRun() const;
80 QStringList tagsToRun() const;
81
82public Q_SLOTS:
83 void reset();
84
85 void startLogging();
86 void stopLogging();
87
88 void initTestTable();
89 void clearTestTable();
90
91 void finishTestData();
92 void finishTestDataCleanup();
93 void finishTestFunction();
94
95 void stringify(QQmlV4FunctionPtr args);
96
97 void fail(const QString &message, const QUrl &location, int line);
98 bool verify(bool success, const QString &message,
99 const QUrl &location, int line);
100 bool compare(bool success, const QString &message,
101 const QVariant &val1, const QVariant &val2,
102 const QUrl &location, int line);
103 bool fuzzyCompare(const QVariant &actual, const QVariant &expected, qreal delta);
104 void skip(const QString &message, const QUrl &location, int line);
105 bool expectFail(const QString &tag, const QString &comment,
106 const QUrl &location, int line);
107 bool expectFailContinue(const QString &tag, const QString &comment,
108 const QUrl &location, int line);
109 void warn(const QString &message, const QUrl &location, int line);
110
111 void ignoreWarning(const QJSValue &message);
112 Q_REVISION(6, 3) void failOnWarning(const QJSValue &message);
113
114 void wait(int ms);
115 void sleep(int ms);
116 bool waitForRendering(QQuickItem *item, int timeout = 5000);
117
118 void startMeasurement();
119 void beginDataRun();
120 void endDataRun();
121 bool measurementAccepted();
122 bool needsMoreMeasurements();
123
124 void startBenchmark(RunMode runMode, const QString &tag);
125 bool isBenchmarkDone() const;
126 void nextBenchmark();
127 void stopBenchmark();
128
129 QObject *grabImage(QQuickItem *item);
130
131 Q_REVISION(1, 1) QObject *findChild(QObject *parent, const QString &objectName);
132
133 Q_REVISION(1, 13) bool isPolishScheduled(QObject *itemOrWindow) const;
134 Q_REVISION(6, 5) bool waitForPolish(QObject *itemOrWindow, int timeout) const;
135
136public:
137 // Helper functions for the C++ main() shell.
138 static void parseArgs(int argc, char *argv[]);
139 static void setProgramName(const char *name);
140 static void setCurrentAppname(const char *appname);
141 static int exitCode();
142
143Q_SIGNALS:
144 void programNameChanged();
145 void testCaseNameChanged();
146 void functionNameChanged();
147 void dataTagChanged();
148 void skippedChanged();
149
150private:
151 QScopedPointer<QuickTestResultPrivate> d_ptr;
152
153 Q_DECLARE_PRIVATE(QuickTestResult)
154 Q_DISABLE_COPY(QuickTestResult)
155};
156
157QT_END_NAMESPACE
158
159#endif
QList< QString > TestCaseList
QList< QQmlError > errors() const
TestCaseList testCases() const
TestCaseCollector(const QFileInfo &fileInfo, QQmlEngine *engine)
bool qWaitForSignal(QObject *obj, const char *signal, int timeout)
static QString stripQuotes(const QString &s)
int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir)
static void handleCompileErrors(const QFileInfo &fi, const QList< QQmlError > &errors, QQmlEngine *engine, QQuickView *view=nullptr)
void maybeInvokeSetupMethod(QObject *setupObject, const char *member, Args &&... args)
int quick_test_main_with_setup(int argc, char **argv, const char *name, const char *sourceDir, QObject *setup)