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>.
Loading...
Searching...
No Matches
qtest_quickcontrols_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QTEST_QUICKCONTROLS_P_H
5#define QTEST_QUICKCONTROLS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtTest/qtest.h>
19#include <QtTest/private/qtestresult_p.h>
20#include <QtGui/qguiapplication.h>
21#include <QtQml/qqml.h>
22#include <QtQuickControls2/qquickstyle.h>
23#include <QtQuickControls2/private/qquickstyle_p.h>
24
26{
27 // It's not enough to check if the name is empty, because since Qt 6
28 // we set an appropriate style for the platform if no style was specified.
29 // Also, we need the name check to come first, as isUsingDefaultStyle() does not do any resolving,
30 // and so its return value wouldn't be correct otherwise.
34}
35
36inline int runTests(QObject *testObject, int argc, char *argv[])
37{
38 int res = 0;
39 QTest::qInit(testObject, argc, argv);
40 const QByteArray testObjectName = QTestResult::currentTestObjectName();
41 // setCurrentTestObject() takes a C string, which means we must ensure
42 // that the string we pass in lives long enough (i.e until the next call
43 // to setCurrentTestObject()), so store the name outside of the loop.
44 QByteArray testName;
45 const QStringList styles = testStyles();
46 for (const QString &style : styles) {
49 testName = testObjectName + "::" + style.toLocal8Bit();
51 res += QTest::qRun();
52 }
55 return res;
56}
57
58#define QTEST_QUICKCONTROLS_MAIN(TestCase) \
59int main(int argc, char *argv[]) \
60{ \
61 qputenv("QML_NO_TOUCH_COMPRESSION", "1"); \
62 QGuiApplication app(argc, argv); \
63 TestCase tc; \
64 QTEST_SET_MAIN_SOURCE_PATH \
65 return runTests(&tc, argc, argv); \
66}
67
68#endif // QTEST_QUICKCONTROLS_P_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qobject.h:103
static QStringList builtInStyles()
static bool isUsingDefaultStyle()
static void setStyle(const QString &style)
Sets the application style to style.
static QString name()
Returns the name of the application style.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static const char * currentTestObjectName()
static void setCurrentTestObject(const char *name)
Q_TESTLIB_EXPORT int qRun()
Q_TESTLIB_EXPORT void qInit(QObject *testObject, int argc=0, char **argv=nullptr)
Q_TESTLIB_EXPORT void qCleanup()
QList< QString > QStringList
Constructs a string list that contains the given string, str.
GLuint res
void qmlClearTypeRegistrations()
Definition qqml.cpp:230
int runTests(QObject *testObject, int argc, char *argv[])
QStringList testStyles()
void testObject()
[11]