Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
25
inline
QStringList
testStyles
()
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.
31
if
(QQuickStyle::name().isEmpty() || QQuickStylePrivate::isUsingDefaultStyle())
32
return
QQuickStylePrivate::builtInStyles();
33
return
QStringList(QQuickStyle::name());
34
}
35
36
inline
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) {
47
qmlClearTypeRegistrations();
48
QQuickStyle::setStyle(style);
49
testName = testObjectName +
"::"
+ style.toLocal8Bit();
50
QTestResult::setCurrentTestObject(testName);
51
res += QTest::qRun();
52
}
53
QTestResult::setCurrentTestObject(testObjectName);
54
QTest::qCleanup();
55
return
res;
56
}
57
58
#
define
QTEST_QUICKCONTROLS_MAIN
(
TestCase
)
int
59
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
runTests
int runTests(QObject *testObject, int argc, char *argv[])
Definition
qtest_quickcontrols_p.h:36
testStyles
QStringList testStyles()
Definition
qtest_quickcontrols_p.h:25
qtdeclarative
src
quickcontrolstestutils
qtest_quickcontrols_p.h
Generated on
for Qt by
1.18.0