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
controlstestutils_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef CONTROLSTESTUTILS_P_H
5#define CONTROLSTESTUTILS_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 <QtGui/qpa/qplatformtheme.h>
19#include <QtQuickTestUtils/private/visualtestutils_p.h>
20
21QT_BEGIN_NAMESPACE
22
23class QQmlComponent;
24class QQmlEngine;
25class QQuickApplicationWindow;
26class QQuickAbstractButton;
27class QQuickControl;
28
30{
32 {
33 public:
34 QQuickControlsApplicationHelper(QQmlDataTest *testCase, const QString &testFilePath,
35 const QVariantMap &initialProperties = {},
36 const QStringList &qmlImportPaths = {});
37
38 QQuickApplicationWindow *appWindow = nullptr;
39 };
40
42 {
43 [[nodiscard]] bool updateStyle(const QString &style);
44
47 };
48
49 typedef std::function<void(const QString &/*relativePath*/, const QUrl &/*absoluteUrl*/)> ForEachCallback;
50
51 void forEachControl(QQmlEngine *engine, const QString &qqc2ImportPath, const QString &sourcePath,
52 const QString &targetPath, const QStringList &skipList, ForEachCallback callback);
53 void addTestRowForEachControl(QQmlEngine *engine, const QString &qqc2ImportPath, const QString &sourcePath,
54 const QString &targetPath, const QStringList &skipList = QStringList());
55
56 [[nodiscard]] bool verifyButtonClickable(QQuickAbstractButton *button);
57 [[nodiscard]] bool clickButton(QQuickAbstractButton *button);
58 [[nodiscard]] bool doubleClickButton(QQuickAbstractButton *button);
59 [[nodiscard]] QString visualFocusFailureMessage(QQuickControl *control);
60
62 {
63 Q_OBJECT
64 QML_ELEMENT
67
68 public:
70 };
71
72 class StyleInfo : public QObject
73 {
74 Q_OBJECT
75 Q_PROPERTY(QString styleName READ styleName CONSTANT FINAL)
78
79 public:
80 QString styleName() const;
81 };
82
84 {
85 Qt::ColorScheme colorScheme() const override
86 {
87 return m_colorScheme;
88 }
89 void requestColorScheme(Qt::ColorScheme theme) override
90 {
91 m_colorScheme = theme;
92 QWindowSystemInterface::handleThemeChange<QWindowSystemInterface::SynchronousDelivery>();
93 }
94
95 private:
96 Qt::ColorScheme m_colorScheme = QGuiApplication::styleHints()->colorScheme();
97 };
98
100 {
101 Q_OBJECT
102 QML_ELEMENT
104
105 public:
107 Q_INVOKABLE bool setValue(const QString &name, const QString &value);
108 };
109
111}
112
113namespace QQuickTest
114{
115namespace Private {
116// Overload of the one in quicktest.h.
117[[nodiscard]] QByteArray qActiveFocusFailureMessage(QQuickPopup *popup);
118} // namespace Private
119} // namespace QQuickTest
120
121#define VERIFY_VISUAL_FOCUS(control) do
122 {
123 QVERIFY2(control->hasVisualFocus(), qUtf8Printable(visualFocusFailureMessage(control))); \
124}while (false)
125
126QT_END_NAMESPACE
127
128#endif // CONTROLSTESTUTILS_P_H
The QQmlComponent class encapsulates a QML component definition.
Qt::ColorScheme colorScheme() const override
void requestColorScheme(Qt::ColorScheme theme) override
QQuickControlsApplicationHelper(QQmlDataTest *testCase, const QString &testFilePath, const QVariantMap &initialProperties={}, const QStringList &qmlImportPaths={})
Q_INVOKABLE bool setValue(const QString &name, const QString &value)
bool verifyButtonClickable(QQuickAbstractButton *button)
void addTestRowForEachControl(QQmlEngine *engine, const QString &qqc2ImportPath, const QString &sourcePath, const QString &targetPath, const QStringList &skipList=QStringList())
void forEachControl(QQmlEngine *engine, const QString &qqc2ImportPath, const QString &sourcePath, const QString &targetPath, const QStringList &skipList, ForEachCallback callback)
bool doubleClickButton(QQuickAbstractButton *button)
QString visualFocusFailureMessage(QQuickControl *control)
bool clickButton(QQuickAbstractButton *button)
std::function< void(const QString &, const QUrl &)> ForEachCallback
QByteArray qActiveFocusFailureMessage(QQuickPopup *popup)