From fbc4848f9656d7e1dda66d1fd5164da1074f2bd5 Mon Sep 17 00:00:00 2001 From: Burak Hancerli Date: Tue, 30 May 2023 17:05:26 +0200 Subject: [PATCH] QmlProject: Support QDS. prefix when reading This patch also includes a small update to skip creating 'shaderTool' object in the json container if it doesn't exist in the qmlproject file. Task-number: QDS-9969 Change-Id: I1b8639c5e0a57aa77cbd417b51d57c1f4910613a Reviewed-by: Reviewed-by: Thomas Hartmann --- .../buildsystem/projectitem/converters.cpp | 45 +-- .../buildsystem/projectitem/qmlprojectitem.h | 7 +- .../converter/test-set-2/testfile.jsontoqml | 5 - .../converter/test-set-2/testfile.qmltojson | 2 - .../getter-setter/with_qds_prefix.qmlproject | 96 +++++++ ...lproject => without_qds_prefix.qmlproject} | 6 +- .../qmlprojectmanager/projectitem-test.cpp | 260 ++++++++++++++---- 7 files changed, 338 insertions(+), 83 deletions(-) create mode 100644 tests/unit/unittest/qmlprojectmanager/data/getter-setter/with_qds_prefix.qmlproject rename tests/unit/unittest/qmlprojectmanager/data/getter-setter/{notEmpty.qmlproject => without_qds_prefix.qmlproject} (99%) diff --git a/src/plugins/qmlprojectmanager/buildsystem/projectitem/converters.cpp b/src/plugins/qmlprojectmanager/buildsystem/projectitem/converters.cpp index bbe0a52c33b..98dd4cea983 100644 --- a/src/plugins/qmlprojectmanager/buildsystem/projectitem/converters.cpp +++ b/src/plugins/qmlprojectmanager/buildsystem/projectitem/converters.cpp @@ -10,7 +10,8 @@ namespace QmlProjectManager::Converters { using PropsPair = QPair; struct FileProps { - const PropsPair image{"image", QStringList{"*.jpeg", "*.jpg", "*.png", "*.svg", "*.hdr", ".ktx"}}; + const PropsPair image{"image", + QStringList{"*.jpeg", "*.jpg", "*.png", "*.svg", "*.hdr", ".ktx"}}; const PropsPair qml{"qml", QStringList{"*.qml"}}; const PropsPair qmlDir{"qmldir", QStringList{"qmldir"}}; const PropsPair javaScr{"javaScript", QStringList{"*.js", "*.ts"}}; @@ -153,10 +154,12 @@ QString jsonToQmlProject(const QJsonObject &rootObject) } { // append ShaderTool object - startObject("ShaderTool"); - appendString("args", shaderConfig["args"].toVariant().toStringList().join(" ")); - appendArray("files", shaderConfig["files"].toVariant().toStringList()); - endObject(); + if (!shaderConfig["args"].toVariant().toStringList().isEmpty()) { + startObject("ShaderTool"); + appendString("args", shaderConfig["args"].toVariant().toStringList().join(" ")); + appendArray("files", shaderConfig["files"].toVariant().toStringList()); + endObject(); + } } { // append files objects @@ -216,18 +219,22 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile) // convert the the non-object props for (const QString &propName : rootNode->propertyNames()) { QJsonObject *currentObj = &rootObject; - QString objKey = propName; + QString objKey = QString(propName).remove("QDS.", Qt::CaseInsensitive); QJsonValue value = rootNode->property(propName).value.toJsonValue(); - if (propName.contains("language", Qt::CaseInsensitive)) { + if (propName.startsWith("mcu.", Qt::CaseInsensitive)) { + currentObj = &mcuObject; + objKey = QString(propName).remove("MCU."); + } else if (propName.contains("language", Qt::CaseInsensitive)) { currentObj = &languageObject; - if (propName.toLower() == "multilanguagesupport") // fixing the camelcase + if (propName.contains("multilanguagesupport", Qt::CaseInsensitive)) + // fixing the camelcase objKey = "multiLanguageSupport"; } else if (propName.contains("version", Qt::CaseInsensitive)) { currentObj = &versionObject; - if (propName.toLower() == "qdsversion") + if (propName.contains("qdsversion", Qt::CaseInsensitive)) objKey = "designStudio"; - else if (propName.toLower() == "quickversion") + else if (propName.contains("quickversion", Qt::CaseInsensitive)) objKey = "qtQuick"; } else if (propName.contains("widgetapp", Qt::CaseInsensitive) || propName.contains("fileselector", Qt::CaseInsensitive) @@ -265,7 +272,8 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile) FileProps fileProps; const QString childNodeName = childNode->name().toLower(); const QmlJS::SimpleReaderNode::Property childNodeFilter = childNode->property("filter"); - const QmlJS::SimpleReaderNode::Property childNodeDirectory = childNode->property("directory"); + const QmlJS::SimpleReaderNode::Property childNodeDirectory = childNode->property( + "directory"); const QmlJS::SimpleReaderNode::Property childNodeFiles = childNode->property("files"); const QString childNodeFilterValue = childNodeFilter.value.toString(); @@ -304,12 +312,12 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile) // populate & update filters if (filters.isEmpty()) { - filters = QJsonArray::fromStringList(propsPair.second); // populate the filters with the predefined ones + filters = QJsonArray::fromStringList( + propsPair.second); // populate the filters with the predefined ones } if (childNodeFilter.isValid()) { // append filters from qmlproject (merge) - const QStringList filtersFromProjectFile = childNodeFilterValue.split( - ";"); + const QStringList filtersFromProjectFile = childNodeFilterValue.split(";"); for (const QString &filter : filtersFromProjectFile) { if (!filters.contains(QJsonValue(filter))) { filters.append(QJsonValue(filter)); @@ -337,7 +345,8 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile) targetObject.insert("files", files); fileGroupsObject.insert(propsPair.first, targetObject); } else if (childNode->name().contains("shadertool", Qt::CaseInsensitive)) { - QStringList quotedArgs = childNode->property("args").value.toString().split('\"', Qt::SkipEmptyParts); + QStringList quotedArgs + = childNode->property("args").value.toString().split('\"', Qt::SkipEmptyParts); QStringList args; for (int i = 0; i < quotedArgs.size(); ++i) { // Each odd arg in this list is a single quoted argument, which we should @@ -351,7 +360,8 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile) shaderToolObject.insert("args", QJsonArray::fromStringList(args)); shaderToolObject.insert("files", childNode->property("files").value.toJsonValue()); } else { - rootObject.insert(toCamelCase(childNode->name()), nodeToJsonObject(childNode)); + rootObject.insert(toCamelCase(childNode->name().remove("qds.", Qt::CaseInsensitive)), + nodeToJsonObject(childNode)); } } @@ -361,7 +371,8 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile) rootObject.insert("runConfig", runConfigObject); rootObject.insert("deployment", deploymentObject); rootObject.insert("mcuConfig", mcuObject); - rootObject.insert("shaderTool", shaderToolObject); + if (!shaderToolObject.isEmpty()) + rootObject.insert("shaderTool", shaderToolObject); rootObject.insert("fileVersion", 1); return rootObject; } diff --git a/src/plugins/qmlprojectmanager/buildsystem/projectitem/qmlprojectitem.h b/src/plugins/qmlprojectmanager/buildsystem/projectitem/qmlprojectitem.h index 83ef5ca0000..214614f5365 100644 --- a/src/plugins/qmlprojectmanager/buildsystem/projectitem/qmlprojectitem.h +++ b/src/plugins/qmlprojectmanager/buildsystem/projectitem/qmlprojectitem.h @@ -7,11 +7,11 @@ #include +#include #include #include -#include #include -#include +#include #include #include @@ -30,7 +30,6 @@ public: bool isQt4McuProject() const; - QString versionQt() const; void setVersionQt(const QString &version); @@ -102,7 +101,7 @@ private: // runtime variables Utils::FilePath m_projectFile; // design studio project file - QJsonObject m_project; // root project object + QJsonObject m_project; // root project object const bool m_skipRewrite; // initializing functions diff --git a/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-2/testfile.jsontoqml b/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-2/testfile.jsontoqml index c4cce639a23..a05b24e9e61 100644 --- a/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-2/testfile.jsontoqml +++ b/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-2/testfile.jsontoqml @@ -24,11 +24,6 @@ Project { QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" } - ShaderTool { - args: "" - files: [ ] - } - QmlFiles { directory: "." } diff --git a/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-2/testfile.qmltojson b/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-2/testfile.qmltojson index 5635cf1f638..33a478e2ca4 100644 --- a/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-2/testfile.qmltojson +++ b/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-2/testfile.qmltojson @@ -83,8 +83,6 @@ ], "mainFile": "fileSelectors.qml" }, - "shaderTool": { - }, "versions": { "qt": "5" } diff --git a/tests/unit/unittest/qmlprojectmanager/data/getter-setter/with_qds_prefix.qmlproject b/tests/unit/unittest/qmlprojectmanager/data/getter-setter/with_qds_prefix.qmlproject new file mode 100644 index 00000000000..a8b5b459d65 --- /dev/null +++ b/tests/unit/unittest/qmlprojectmanager/data/getter-setter/with_qds_prefix.qmlproject @@ -0,0 +1,96 @@ +import QmlProject + +Project { + QDS.mainFile: "content/App.qml" + QDS.mainUiFile: "Screen01.ui.qml" + + QDS.qt6Project: true + QDS.widgetApp: true + QDS.qtForMCUs: true + QDS.forceFreeType: true + + QDS.importPaths: [ "imports", "asset_imports" ] + QDS.targetDirectory: "/opt/targetDirectory" + QDS.fileSelectors: [ "WXGA", "darkTheme", "ShowIndicator"] + + QDS.qdsVersion: "3.9" + QDS.quickVersion: "6.2" + + QDS.multilanguageSupport: true + QDS.supportedLanguages: ["en" , "fr"] + QDS.primaryLanguage: "en" + + QDS.QmlFiles { + directory: "content" + } + + QDS.QmlFiles { + directory: "imports" + } + + QDS.JavaScriptFiles { + directory: "content" + } + + QDS.JavaScriptFiles { + directory: "imports" + } + + QDS.ImageFiles { + directory: "content" + } + + QDS.Files { + filter: "*.conf" + files: ["qtquickcontrols2.conf"] + } + + QDS.Files { + filter: "qmldir" + directory: "." + } + + QDS.Files { + filter: "*.ttf;*.otf" + } + + QDS.Files { + filter: "*.wav;*.mp3" + } + + QDS.Files { + filter: "*.mp4" + } + + QDS.Files { + filter: "*.glsl;*.glslv;*.glslf;*.vsh;*.fsh;*.vert;*.frag" + } + + QDS.Files { + filter: "*.mesh" + directory: "asset_imports" + } + + QDS.Files { + filter: "*.mesh" + directory: "content" + } + + QDS.Files { + filter: "*.qml" + directory: "asset_imports" + } + + QDS.ImageFiles { + directory: "asset_imports" + } + + QDS.Environment { + QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" + } + + QDS.ShaderTool { + args: "-s --glsl \"100 es,120,150\" --hlsl 50 --msl 12" + files: [ "content/shaders/*" ] + } +} diff --git a/tests/unit/unittest/qmlprojectmanager/data/getter-setter/notEmpty.qmlproject b/tests/unit/unittest/qmlprojectmanager/data/getter-setter/without_qds_prefix.qmlproject similarity index 99% rename from tests/unit/unittest/qmlprojectmanager/data/getter-setter/notEmpty.qmlproject rename to tests/unit/unittest/qmlprojectmanager/data/getter-setter/without_qds_prefix.qmlproject index ae866ca3974..6bee5999555 100644 --- a/tests/unit/unittest/qmlprojectmanager/data/getter-setter/notEmpty.qmlproject +++ b/tests/unit/unittest/qmlprojectmanager/data/getter-setter/without_qds_prefix.qmlproject @@ -3,12 +3,12 @@ import QmlProject Project { mainFile: "content/App.qml" mainUiFile: "Screen01.ui.qml" - + qt6Project: true widgetApp: true qtForMCUs: true forceFreeType: true - + importPaths: [ "imports", "asset_imports" ] targetDirectory: "/opt/targetDirectory" fileSelectors: [ "WXGA", "darkTheme", "ShowIndicator"] @@ -19,7 +19,7 @@ Project { multilanguageSupport: true supportedLanguages: ["en" , "fr"] primaryLanguage: "en" - + QmlFiles { directory: "content" } diff --git a/tests/unit/unittest/qmlprojectmanager/projectitem-test.cpp b/tests/unit/unittest/qmlprojectmanager/projectitem-test.cpp index e76e905f33c..ea8dcdae707 100644 --- a/tests/unit/unittest/qmlprojectmanager/projectitem-test.cpp +++ b/tests/unit/unittest/qmlprojectmanager/projectitem-test.cpp @@ -1,8 +1,8 @@ // Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -#include "googletest.h" // IWYU pragma: keep #include "google-using-declarations.h" +#include "googletest.h" // IWYU pragma: keep #include @@ -19,28 +19,39 @@ protected: projectItemEmpty = std::make_unique( Utils::FilePath::fromString(localTestDataDir + "/getter-setter/empty.qmlproject"), true); - projectItemNotEmpty = std::make_unique( - Utils::FilePath::fromString(localTestDataDir + "/getter-setter/notEmpty.qmlproject"), + projectItemWithQdsPrefix = std::make_unique( + Utils::FilePath::fromString(localTestDataDir + + "/getter-setter/with_qds_prefix.qmlproject"), + true); + + projectItemWithoutQdsPrefix = std::make_unique( + Utils::FilePath::fromString(localTestDataDir + + "/getter-setter/without_qds_prefix.qmlproject"), true); projectItemFileFilters = std::make_unique( - Utils::FilePath::fromString(localTestDataDir + "/file-filters/MaterialBundle.qmlproject"), + Utils::FilePath::fromString(localTestDataDir + + "/file-filters/MaterialBundle.qmlproject"), true); } static void TearDownTestSuite() { projectItemEmpty.reset(); - projectItemNotEmpty.reset(); + projectItemWithQdsPrefix.reset(); + projectItemWithoutQdsPrefix.reset(); projectItemFileFilters.reset(); } protected: static inline std::unique_ptr projectItemEmpty; - static inline std::unique_ptr projectItemNotEmpty; - std::unique_ptr - projectItemSetters = std::make_unique( - Utils::FilePath::fromString(localTestDataDir + "/getter-setter/empty.qmlproject"), true); + static inline std::unique_ptr projectItemWithQdsPrefix; + static inline std::unique_ptr + projectItemWithoutQdsPrefix; + std::unique_ptr projectItemSetters = std::make_unique< + QmlProjectManager::QmlProjectItem>(Utils::FilePath::fromString( + localTestDataDir + "/getter-setter/empty.qmlproject"), + true); static inline std::unique_ptr projectItemFileFilters; }; @@ -51,111 +62,111 @@ auto createAbsoluteFilePaths(const QStringList &fileList) }); } -TEST_F(QmlProjectItem, GetNotEmptyMainFileProject) +TEST_F(QmlProjectItem, GetWithQdsPrefixMainFileProject) { - auto mainFile = projectItemNotEmpty->mainFile(); + auto mainFile = projectItemWithQdsPrefix->mainFile(); ASSERT_THAT(mainFile, Eq("content/App.qml")); } -TEST_F(QmlProjectItem, GetNotEmptyMainUIFileProject) +TEST_F(QmlProjectItem, GetWithQdsPrefixMainUIFileProject) { - auto mainUiFile = projectItemNotEmpty->mainUiFile(); + auto mainUiFile = projectItemWithQdsPrefix->mainUiFile(); ASSERT_THAT(mainUiFile, Eq("Screen01.ui.qml")); } -TEST_F(QmlProjectItem, GetNotEmptyMcuProject) +TEST_F(QmlProjectItem, GetWithQdsPrefixMcuProject) { - auto isMcuProject = projectItemNotEmpty->isQt4McuProject(); + auto isMcuProject = projectItemWithQdsPrefix->isQt4McuProject(); ASSERT_TRUE(isMcuProject); } -TEST_F(QmlProjectItem, GetNotEmptyQtVersion) +TEST_F(QmlProjectItem, GetWithQdsPrefixQtVersion) { - auto qtVersion = projectItemNotEmpty->versionQt(); + auto qtVersion = projectItemWithQdsPrefix->versionQt(); ASSERT_THAT(qtVersion, Eq("6")); } -TEST_F(QmlProjectItem, GetNotEmptyQtQuickVersion) +TEST_F(QmlProjectItem, GetWithQdsPrefixQtQuickVersion) { - auto qtQuickVersion = projectItemNotEmpty->versionQtQuick(); + auto qtQuickVersion = projectItemWithQdsPrefix->versionQtQuick(); ASSERT_THAT(qtQuickVersion, Eq("6.2")); } -TEST_F(QmlProjectItem, GetNotEmptyDesignStudioVersion) +TEST_F(QmlProjectItem, GetWithQdsPrefixDesignStudioVersion) { - auto designStudioVersion = projectItemNotEmpty->versionDesignStudio(); + auto designStudioVersion = projectItemWithQdsPrefix->versionDesignStudio(); ASSERT_THAT(designStudioVersion, Eq("3.9")); } -TEST_F(QmlProjectItem, GetNotEmptySourceDirectory) +TEST_F(QmlProjectItem, GetWithQdsPrefixSourceDirectory) { - auto sourceDirectory = projectItemNotEmpty->sourceDirectory().path(); + auto sourceDirectory = projectItemWithQdsPrefix->sourceDirectory().path(); auto expectedSourceDir = localTestDataDir + "/getter-setter"; ASSERT_THAT(sourceDirectory, Eq(expectedSourceDir)); } -TEST_F(QmlProjectItem, GetNotEmptyTarGetNotEmptyDirectory) +TEST_F(QmlProjectItem, GetWithQdsPrefixTarGetWithQdsPrefixDirectory) { - auto targetDirectory = projectItemNotEmpty->targetDirectory(); + auto targetDirectory = projectItemWithQdsPrefix->targetDirectory(); ASSERT_THAT(targetDirectory, Eq("/opt/targetDirectory")); } -TEST_F(QmlProjectItem, GetNotEmptyImportPaths) +TEST_F(QmlProjectItem, GetWithQdsPrefixImportPaths) { - auto importPaths = projectItemNotEmpty->importPaths(); + auto importPaths = projectItemWithQdsPrefix->importPaths(); ASSERT_THAT(importPaths, UnorderedElementsAre("imports", "asset_imports")); } -TEST_F(QmlProjectItem, GetNotEmptyFileSelectors) +TEST_F(QmlProjectItem, GetWithQdsPrefixFileSelectors) { - auto fileSelectors = projectItemNotEmpty->fileSelectors(); + auto fileSelectors = projectItemWithQdsPrefix->fileSelectors(); ASSERT_THAT(fileSelectors, UnorderedElementsAre("WXGA", "darkTheme", "ShowIndicator")); } -TEST_F(QmlProjectItem, GetNotEmptyMultiLanguageSupport) +TEST_F(QmlProjectItem, GetWithQdsPrefixMultiLanguageSupport) { - auto multilanguageSupport = projectItemNotEmpty->multilanguageSupport(); + auto multilanguageSupport = projectItemWithQdsPrefix->multilanguageSupport(); ASSERT_TRUE(multilanguageSupport); } -TEST_F(QmlProjectItem, GetNotEmptySupportedLanguages) +TEST_F(QmlProjectItem, GetWithQdsPrefixSupportedLanguages) { - auto supportedLanguages = projectItemNotEmpty->supportedLanguages(); + auto supportedLanguages = projectItemWithQdsPrefix->supportedLanguages(); ASSERT_THAT(supportedLanguages, UnorderedElementsAre("en", "fr")); } -TEST_F(QmlProjectItem, GetNotEmptyPrimaryLanguage) +TEST_F(QmlProjectItem, GetWithQdsPrefixPrimaryLanguage) { - auto primaryLanguage = projectItemNotEmpty->primaryLanguage(); + auto primaryLanguage = projectItemWithQdsPrefix->primaryLanguage(); ; ASSERT_THAT(primaryLanguage, Eq("en")); } -TEST_F(QmlProjectItem, GetNotEmptyWidgetApp) +TEST_F(QmlProjectItem, GetWithQdsPrefixWidgetApp) { - auto widgetApp = projectItemNotEmpty->widgetApp(); + auto widgetApp = projectItemWithQdsPrefix->widgetApp(); ASSERT_TRUE(widgetApp); } -TEST_F(QmlProjectItem, GetNotEmptyFileList) +TEST_F(QmlProjectItem, GetWithQdsPrefixFileList) { QStringList fileList; - for (const auto &file : projectItemNotEmpty->files()) { + for (const auto &file : projectItemWithQdsPrefix->files()) { fileList.append(file.path()); } @@ -164,33 +175,179 @@ TEST_F(QmlProjectItem, GetNotEmptyFileList) ASSERT_THAT(fileList, UnorderedElementsAre(expectedFileList)); } -TEST_F(QmlProjectItem, GetNotEmptyShaderToolArgs) +TEST_F(QmlProjectItem, GetWithQdsPrefixShaderToolArgs) { - auto shaderToolArgs = projectItemNotEmpty->shaderToolArgs(); + auto shaderToolArgs = projectItemWithQdsPrefix->shaderToolArgs(); - ASSERT_THAT(shaderToolArgs, - UnorderedElementsAre("-s", "--glsl", "\"100 es,120,150\"", "--hlsl", "50", "--msl", "12")); + ASSERT_THAT( + shaderToolArgs, + UnorderedElementsAre("-s", "--glsl", "\"100 es,120,150\"", "--hlsl", "50", "--msl", "12")); } -TEST_F(QmlProjectItem, GetNotEmptyShaderToolFiles) +TEST_F(QmlProjectItem, GetWithQdsPrefixShaderToolFiles) { - auto shaderToolFiles = projectItemNotEmpty->shaderToolFiles(); + auto shaderToolFiles = projectItemWithQdsPrefix->shaderToolFiles(); ASSERT_THAT(shaderToolFiles, UnorderedElementsAre("content/shaders/*")); } -TEST_F(QmlProjectItem, GetNotEmptyEnvironment) +TEST_F(QmlProjectItem, GetWithQdsPrefixEnvironment) { - auto env = projectItemNotEmpty->environment(); + auto env = projectItemWithQdsPrefix->environment(); ASSERT_THAT(env, UnorderedElementsAre( Utils::EnvironmentItem("QT_QUICK_CONTROLS_CONF", "qtquickcontrols2.conf"))); } -TEST_F(QmlProjectItem, GetNotEmptyForceFreeType) +TEST_F(QmlProjectItem, GetWithQdsPrefixForceFreeType) { - auto forceFreeType = projectItemNotEmpty->forceFreeType(); + auto forceFreeType = projectItemWithQdsPrefix->forceFreeType(); + + ASSERT_TRUE(forceFreeType); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixMainFileProject) +{ + auto mainFile = projectItemWithoutQdsPrefix->mainFile(); + + ASSERT_THAT(mainFile, Eq("content/App.qml")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixMainUIFileProject) +{ + auto mainUiFile = projectItemWithoutQdsPrefix->mainUiFile(); + + ASSERT_THAT(mainUiFile, Eq("Screen01.ui.qml")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixMcuProject) +{ + auto isMcuProject = projectItemWithoutQdsPrefix->isQt4McuProject(); + + ASSERT_TRUE(isMcuProject); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixQtVersion) +{ + auto qtVersion = projectItemWithoutQdsPrefix->versionQt(); + + ASSERT_THAT(qtVersion, Eq("6")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixQtQuickVersion) +{ + auto qtQuickVersion = projectItemWithoutQdsPrefix->versionQtQuick(); + + ASSERT_THAT(qtQuickVersion, Eq("6.2")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixDesignStudioVersion) +{ + auto designStudioVersion = projectItemWithoutQdsPrefix->versionDesignStudio(); + + ASSERT_THAT(designStudioVersion, Eq("3.9")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixSourceDirectory) +{ + auto sourceDirectory = projectItemWithoutQdsPrefix->sourceDirectory().path(); + + auto expectedSourceDir = localTestDataDir + "/getter-setter"; + + ASSERT_THAT(sourceDirectory, Eq(expectedSourceDir)); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixTarGetWithoutQdsPrefixDirectory) +{ + auto targetDirectory = projectItemWithoutQdsPrefix->targetDirectory(); + + ASSERT_THAT(targetDirectory, Eq("/opt/targetDirectory")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixImportPaths) +{ + auto importPaths = projectItemWithoutQdsPrefix->importPaths(); + + ASSERT_THAT(importPaths, UnorderedElementsAre("imports", "asset_imports")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixFileSelectors) +{ + auto fileSelectors = projectItemWithoutQdsPrefix->fileSelectors(); + + ASSERT_THAT(fileSelectors, UnorderedElementsAre("WXGA", "darkTheme", "ShowIndicator")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixMultiLanguageSupport) +{ + auto multilanguageSupport = projectItemWithoutQdsPrefix->multilanguageSupport(); + + ASSERT_TRUE(multilanguageSupport); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixSupportedLanguages) +{ + auto supportedLanguages = projectItemWithoutQdsPrefix->supportedLanguages(); + + ASSERT_THAT(supportedLanguages, UnorderedElementsAre("en", "fr")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixPrimaryLanguage) +{ + auto primaryLanguage = projectItemWithoutQdsPrefix->primaryLanguage(); + ; + + ASSERT_THAT(primaryLanguage, Eq("en")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixWidgetApp) +{ + auto widgetApp = projectItemWithoutQdsPrefix->widgetApp(); + + ASSERT_TRUE(widgetApp); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixFileList) +{ + QStringList fileList; + for (const auto &file : projectItemWithoutQdsPrefix->files()) { + fileList.append(file.path()); + } + + auto expectedFileList = localTestDataDir + "/getter-setter/qtquickcontrols2.conf"; + + ASSERT_THAT(fileList, UnorderedElementsAre(expectedFileList)); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixShaderToolArgs) +{ + auto shaderToolArgs = projectItemWithoutQdsPrefix->shaderToolArgs(); + + ASSERT_THAT( + shaderToolArgs, + UnorderedElementsAre("-s", "--glsl", "\"100 es,120,150\"", "--hlsl", "50", "--msl", "12")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixShaderToolFiles) +{ + auto shaderToolFiles = projectItemWithoutQdsPrefix->shaderToolFiles(); + + ASSERT_THAT(shaderToolFiles, UnorderedElementsAre("content/shaders/*")); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixEnvironment) +{ + auto env = projectItemWithoutQdsPrefix->environment(); + + ASSERT_THAT(env, + UnorderedElementsAre( + Utils::EnvironmentItem("QT_QUICK_CONTROLS_CONF", "qtquickcontrols2.conf"))); +} + +TEST_F(QmlProjectItem, GetWithoutQdsPrefixForceFreeType) +{ + auto forceFreeType = projectItemWithoutQdsPrefix->forceFreeType(); ASSERT_TRUE(forceFreeType); } @@ -524,9 +681,8 @@ TEST_F(QmlProjectItem, TestFileFilters) { // GIVEN auto fileListPath = Utils::FilePath::fromString(localTestDataDir + "/file-filters/filelist.txt"); - QStringList fileNameList = QString::fromUtf8(fileListPath.fileContents().value()) - .replace("\r\n", "\n") - .split("\n"); + QStringList fileNameList + = QString::fromUtf8(fileListPath.fileContents().value()).replace("\r\n", "\n").split("\n"); auto expectedAbsoluteFilePaths = createAbsoluteFilePaths(fileNameList); // WHEN