diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-05-11 18:12:27 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-05-12 08:40:02 +0000 |
commit | 9ca4f2b18696a9fbdd4247c8d509d63d1ad0e35b (patch) | |
tree | def5ed2e66ac419ab0209642e0df57c2e37c1327 /tests/auto/snippets/tst_snippets.cpp | |
parent | 2d11f49ecd48fbf154cf5dc759526bf28fc732b7 (diff) |
tst_snippets: inject the style name to image file names
For example, qtquickcontrols2-label.qml outputs:
- qtquickcontrols2-label.png (Default)
- qtquickcontrols2-material-label.png (Material)
- qtquickcontrols2-universal-label.png (Universal)
This allows us to take screenshots with different styles without
overlapping names and error-prone manual renaming.
Change-Id: Ic475ee0d95539a1122e37780f8cec038e2fc9446
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/snippets/tst_snippets.cpp')
-rw-r--r-- | tests/auto/snippets/tst_snippets.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/auto/snippets/tst_snippets.cpp b/tests/auto/snippets/tst_snippets.cpp index 1185bde9..852c98e9 100644 --- a/tests/auto/snippets/tst_snippets.cpp +++ b/tests/auto/snippets/tst_snippets.cpp @@ -113,11 +113,23 @@ void tst_Snippets::verify() if (takeScreenshots) { const QString currentDataTag = QLatin1String(QTest::currentDataTag()); - static const QString currentStyle = QQuickStyle::name(); + static const QString applicationStyle = QQuickStyle::name().isEmpty() ? "Default" : QQuickStyle::name(); static const QStringList availableStyles = QQuickStyle::availableStyles(); + + bool isStyledSnippet = false; + const QString snippetStyle = currentDataTag.section("-", 1, 1); for (const QString &availableStyle : availableStyles) { - if (currentStyle != availableStyle && currentDataTag.startsWith("qtquickcontrols2-" + availableStyle.toLower() + "-")) - QSKIP(qPrintable(QString("Not running with the %1 style").arg(availableStyle))); + if (!snippetStyle.compare(availableStyle, Qt::CaseInsensitive)) { + if (applicationStyle != availableStyle) + QSKIP(qPrintable(QString("%1 style specific snippet. Running with the %2 style.").arg(availableStyle, applicationStyle))); + isStyledSnippet = true; + } + } + + if (!isStyledSnippet && !applicationStyle.isEmpty()) { + int index = output.indexOf("-", output.lastIndexOf("/")); + if (index != -1) + output.insert(index, "-" + applicationStyle.toLower()); } QQuickWindow *window = qobject_cast<QQuickWindow *>(root); |