diff options
author | The Qt Project <gerrit-noreply@qt-project.org> | 2020-08-28 13:37:45 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2020-08-28 13:37:45 +0000 |
commit | 8b748fb5f85d8fa8b1f89d1196b280e8ba8c6282 (patch) | |
tree | ac8b57c744dfb615f27bf3b409d5cabb61c7001a /tests/auto/shared/visualtestutil.h | |
parent | 6c35631dd4a399144e473ffefba2716c7f3f1cca (diff) | |
parent | 2a054d48ef5a412d104aff0389bcaa69ba2c9878 (diff) |
Merge "Merge branch 'dev' into nativestyle" into wip/nativestyle
Diffstat (limited to 'tests/auto/shared/visualtestutil.h')
-rw-r--r-- | tests/auto/shared/visualtestutil.h | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h index e3f4075d..726daa27 100644 --- a/tests/auto/shared/visualtestutil.h +++ b/tests/auto/shared/visualtestutil.h @@ -37,11 +37,12 @@ #ifndef QQUICKVISUALTESTUTIL_H #define QQUICKVISUALTESTUTIL_H +#include <functional> + #include <QtQuick/QQuickItem> #include <QtQml/QQmlExpression> - #include <QtQuick/private/qquickitem_p.h> - +#include <QtQuickControls2/qquickstyle.h> #include <QtQuickTemplates2/private/qquickapplicationwindow_p.h> #include "util.h" @@ -162,7 +163,33 @@ namespace QQuickVisualTestUtil QByteArray errorMessage; }; - void addTestRowForEachControl(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skiplist = QStringList()); + struct QQuickStyleHelper + { + bool updateStyle(const QString &style) + { + // If it's not the first time a style has been set and the new style is not different, do nothing. + if (!currentStyle.isEmpty() && style == currentStyle) + return false; + + engine.reset(new QQmlEngine); + currentStyle = style; + qmlClearTypeRegistrations(); + QQuickStyle::setStyle(style); + + QQmlComponent component(engine.data()); + component.setData(QString("import QtQuick\nimport QtQuick.Controls\n Control { }").toUtf8(), QUrl()); + + return true; + } + + QString currentStyle; + QScopedPointer<QQmlEngine> engine; + }; + + typedef std::function<void(const QString &/*relativePath*/, const QUrl &/*absoluteUrl*/)> ForEachCallback; + + void forEachControl(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skipList, ForEachCallback callback); + void addTestRowForEachControl(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skipList = QStringList()); } #define QQUICK_VERIFY_POLISH(item) \ |