diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-09-11 16:18:50 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-09-24 13:48:58 +0200 |
commit | a0f0b4f65e96aecc9949d3089a283cdfaeefbb3b (patch) | |
tree | 175f986e31860164c000b9a66c09a549b4f5da55 /tests/auto/styleimports/tst_styleimports.cpp | |
parent | 526729cb8a53972b6925cbfd7a5f5cbf124be71c (diff) |
Support compile-time style selection
By allowing importing styles without first importing QtQuick.Controls,
which does runtime style selection.
[ChangeLog][Styles] It's now possible to select a style at compile-time
by importing that style explicitly instead of QtQuick.Controls. This
avoids the need to do run-time style selection and hence deploy the
QtQuick.Controls plugin with the application.
Change-Id: I666d6dc7727fffd2c7b05743855f2086f076465a
Fixes: QTBUG-86284
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/styleimports/tst_styleimports.cpp')
-rw-r--r-- | tests/auto/styleimports/tst_styleimports.cpp | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/tests/auto/styleimports/tst_styleimports.cpp b/tests/auto/styleimports/tst_styleimports.cpp index 408f06c3..5e525b0f 100644 --- a/tests/auto/styleimports/tst_styleimports.cpp +++ b/tests/auto/styleimports/tst_styleimports.cpp @@ -61,9 +61,6 @@ private slots: void platformSelectors(); - void importStyleWithoutControls_data(); - void importStyleWithoutControls(); - void fallbackStyleShouldNotOverwriteTheme_data(); void fallbackStyleShouldNotOverwriteTheme(); }; @@ -208,44 +205,6 @@ void tst_StyleImports::platformSelectors() #endif } -void tst_StyleImports::importStyleWithoutControls_data() -{ - QTest::addColumn<QString>("style"); - - const auto builtInStyles = QQuickStylePrivate::builtInStyles(); - for (const auto &styleName : builtInStyles) - QTest::addRow(qPrintable(styleName)) << styleName; -} - -// Tests that warnings are printed when trying to import a specific style without first importing QtQuick.Controls. -void tst_StyleImports::importStyleWithoutControls() -{ - QFETCH(QString, style); - - QQmlApplicationEngine engine; - const QUrl url(testFileUrl(QString::fromLatin1("import%1StyleWithoutControls.qml").arg(style))); - bool success = false; - - // Account for extra warnings for fallback styles. - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("QtQuick.Controls must be imported before importing.*Basic")); - if (style == QLatin1String("macOS")) - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("QtQuick.Controls must be imported before importing.*Fusion")); - - // Account for the warning for the current style. - if (style != QLatin1String("Basic")) - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("QtQuick.Controls must be imported before importing.*" + style)); - - QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, - this, [url, &success](QObject *obj, const QUrl &objUrl) { - if (url == objUrl) - success = obj; - }, Qt::QueuedConnection); - - engine.load(url); - // It should load, but with warnings. - QTRY_VERIFY(success); -} - void tst_StyleImports::fallbackStyleShouldNotOverwriteTheme_data() { QTest::addColumn<QString>("style"); |