1/****************************************************************************
2**
3** Copyright (C) 2018 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
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 The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef ABSTRACTTESTSUITE_H
30#define ABSTRACTTESTSUITE_H
31
32#include <QtCore/qobject.h>
33
34#include <QtCore/qbytearray.h>
35#include <QtCore/qdir.h>
36#include <QtCore/qscopedpointer.h>
37#include <QtCore/qstring.h>
38#include <QtCore/qstringlist.h>
39#include <QtCore/qvector.h>
40#include <QtCore/qtextstream.h>
41
42QT_FORWARD_DECLARE_CLASS(QMetaObjectBuilder)
43
44namespace TestConfig {
45enum Mode {
46 Skip,
47 ExpectFail
48};
49}
50
51// For receiving callbacks from the config parser.
52class TestConfigClientInterface
53{
54public:
55 virtual ~TestConfigClientInterface() {}
56 virtual void configData(TestConfig::Mode mode,
57 const QStringList &parts) = 0;
58 virtual void configError(const QString &path,
59 const QString &message,
60 int lineNumber) = 0;
61};
62
63class AbstractTestSuite : public QObject,
64 public TestConfigClientInterface
65{
66// No Q_OBJECT macro, we implement the meta-object ourselves.
67public:
68 AbstractTestSuite(const QByteArray &className,
69 const QString &defaultTestsPath,
70 const QString &defaultConfigPath);
71 virtual ~AbstractTestSuite();
72
73 virtual const QMetaObject *metaObject() const;
74 virtual void *qt_metacast(const char *);
75 virtual int qt_metacall(QMetaObject::Call, int, void **argv);
76
77 static QString readFile(const QString &);
78 static QString escape(const QString &);
79
80protected:
81 enum DataFunctionCreation {
82 DontCreateDataFunction,
83 CreateDataFunction
84 };
85
86 void addTestFunction(const QString &,
87 DataFunctionCreation = DontCreateDataFunction);
88 void finalizeMetaObject();
89
90 virtual void initTestCase();
91 virtual void cleanupTestCase();
92
93 virtual void writeSkipConfigFile(QTextStream &) = 0;
94 virtual void writeExpectFailConfigFile(QTextStream &) = 0;
95
96 virtual void runTestFunction(int index) = 0;
97
98 virtual void configError(const QString &path, const QString &message, int lineNumber);
99
100 QDir testsDir;
101 bool shouldGenerateExpectedFailures;
102
103private:
104 static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);
105
106 void addPrivateSlot(const QByteArray &signature);
107
108 QMetaObject *dynamicMetaObject;
109 QScopedPointer<QMetaObjectBuilder> metaBuilder;
110 QString skipConfigPath, expectFailConfigPath;
111
112private:
113 void createSkipConfigFile();
114 void createExpectFailConfigFile();
115};
116
117#endif
118

source code of qtscript/tests/auto/qscriptv8testsuite/abstracttestsuite.h