1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
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 <QtQuickTestUtils/private/visualtestutils_p.h>
19
20QT_BEGIN_NAMESPACE
21
22class QQmlComponent;
23class QQmlEngine;
24class QQuickApplicationWindow;
25class QQuickAbstractButton;
26
27namespace QQuickControlsTestUtils
28{
29 class QQuickControlsApplicationHelper : public QQuickVisualTestUtils::QQuickApplicationHelper
30 {
31 public:
32 QQuickControlsApplicationHelper(QQmlDataTest *testCase, const QString &testFilePath,
33 const QVariantMap &initialProperties = {},
34 const QStringList &qmlImportPaths = {});
35
36 QQuickApplicationWindow *appWindow = nullptr;
37 };
38
39 struct QQuickStyleHelper
40 {
41 [[nodiscard]] bool updateStyle(const QString &style);
42
43 QString currentStyle;
44 QScopedPointer<QQmlEngine> engine;
45 };
46
47 typedef std::function<void(const QString &/*relativePath*/, const QUrl &/*absoluteUrl*/)> ForEachCallback;
48
49 void forEachControl(QQmlEngine *engine, const QString &qqc2ImportPath, const QString &sourcePath,
50 const QString &targetPath, const QStringList &skipList, ForEachCallback callback);
51 void addTestRowForEachControl(QQmlEngine *engine, const QString &qqc2ImportPath, const QString &sourcePath,
52 const QString &targetPath, const QStringList &skipList = QStringList());
53
54 [[nodiscard]] bool verifyButtonClickable(QQuickAbstractButton *button);
55 [[nodiscard]] bool clickButton(QQuickAbstractButton *button);
56 [[nodiscard]] bool doubleClickButton(QQuickAbstractButton *button);
57
58 class ComponentCreator : public QObject
59 {
60 Q_OBJECT
61 QML_ELEMENT
62 QML_SINGLETON
63 Q_MOC_INCLUDE(<QtQml/qqmlcomponent.h>)
64
65 public:
66 Q_INVOKABLE QQmlComponent *createComponent(const QByteArray &data);
67 };
68
69 class StyleInfo : public QObject
70 {
71 Q_OBJECT
72 Q_PROPERTY(QString styleName READ styleName CONSTANT FINAL)
73 QML_ELEMENT
74 QML_SINGLETON
75
76 public:
77 QString styleName() const;
78 };
79}
80
81QT_END_NAMESPACE
82
83#endif // CONTROLSTESTUTILS_P_H
84

source code of qtdeclarative/src/quickcontrolstestutils/controlstestutils_p.h