1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
42 #ifndef QUICKTESTRESULT_P_H
43 #define QUICKTESTRESULT_P_H
45 #include <QtQuickTest/quicktestglobal.h>
46 #include <QtCore/qobject.h>
47 #include <QtCore/qstring.h>
48 #include <QtCore/qstringlist.h>
49 #include <QtCore/qscopedpointer.h>
50 #include <QtQuick/qquickitem.h>
51 #include <QtQml/private/qv8engine_p.h>
56 class QuickTestResultPrivate;
58 class Q_QUICK_TEST_EXPORT QuickTestResult : public QObject
62 Q_PROPERTY(QString testCaseName READ testCaseName WRITE setTestCaseName NOTIFY testCaseNameChanged)
63 Q_PROPERTY(QString functionName READ functionName WRITE setFunctionName NOTIFY functionNameChanged)
64 Q_PROPERTY(QString dataTag READ dataTag WRITE setDataTag NOTIFY dataTagChanged)
65 Q_PROPERTY(bool failed READ isFailed)
66 Q_PROPERTY(bool skipped READ isSkipped WRITE setSkipped NOTIFY skippedChanged)
67 Q_PROPERTY(int passCount READ passCount)
68 Q_PROPERTY(int failCount READ failCount)
69 Q_PROPERTY(int skipCount READ skipCount)
70 Q_PROPERTY(QStringList functionsToRun READ functionsToRun)
72 QuickTestResult(QObject *parent = 0);
75 // Values must match QBenchmarkIterationController::RunMode.
78 RepeatUntilValidMeasurement,
82 QString testCaseName() const;
83 void setTestCaseName(const QString &name);
85 QString functionName() const;
86 void setFunctionName(const QString &name);
88 QString dataTag() const;
89 void setDataTag(const QString &tag);
91 bool isFailed() const;
93 bool isSkipped() const;
94 void setSkipped(bool skip);
96 int passCount() const;
97 int failCount() const;
98 int skipCount() const;
100 QStringList functionsToRun() const;
108 void initTestTable();
109 void clearTestTable();
111 void finishTestData();
112 void finishTestDataCleanup();
113 void finishTestFunction();
115 void stringify(QQmlV8Function *args);
117 void fail(const QString &message, const QUrl &location, int line);
118 bool verify(bool success, const QString &message,
119 const QUrl &location, int line);
120 bool compare(bool success, const QString &message,
121 const QVariant &val1, const QVariant &val2,
122 const QUrl &location, int line);
123 bool fuzzyCompare(const QVariant &actual, const QVariant &expected, qreal delta);
124 void skip(const QString &message, const QUrl &location, int line);
125 bool expectFail(const QString &tag, const QString &comment,
126 const QUrl &location, int line);
127 bool expectFailContinue(const QString &tag, const QString &comment,
128 const QUrl &location, int line);
129 void warn(const QString &message, const QUrl &location, int line);
131 void ignoreWarning(const QString &message);
135 bool waitForRendering(QQuickItem *item, int timeout = 5000);
137 void startMeasurement();
140 bool measurementAccepted();
141 bool needsMoreMeasurements();
143 void startBenchmark(RunMode runMode, const QString &tag);
144 bool isBenchmarkDone() const;
145 void nextBenchmark();
146 void stopBenchmark();
148 QObject *grabImage(QQuickItem *item);
151 // Helper functions for the C++ main() shell.
152 static void parseArgs(int argc, char *argv[]);
153 static void setProgramName(const char *name);
154 static void setCurrentAppname(const char *appname);
155 static int exitCode();
158 void programNameChanged();
159 void testCaseNameChanged();
160 void functionNameChanged();
161 void dataTagChanged();
162 void skippedChanged();
165 QScopedPointer<QuickTestResultPrivate> d_ptr;
167 Q_DECLARE_PRIVATE(QuickTestResult)
168 Q_DISABLE_COPY(QuickTestResult)