forked from qt-creator/qt-creator
QmlDesigner: Refactor QmlProjectManager tests
Task-number: QDS-9743 Change-Id: Ia5e788fcebacef59ba12226e2c873f5cbf8954ba Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -6,7 +6,6 @@ add_qtc_plugin(QmlProjectManager
|
||||
SOURCES
|
||||
qmlprojectgen/qmlprojectgenerator.cpp qmlprojectgen/qmlprojectgenerator.h
|
||||
qmlprojectgen/templates.qrc
|
||||
|
||||
projectfilecontenttools.cpp projectfilecontenttools.h
|
||||
qdslandingpage.cpp qdslandingpage.h
|
||||
qdslandingpagetheme.cpp qdslandingpagetheme.h
|
||||
@@ -53,3 +52,17 @@ extend_qtc_plugin(QmlProjectManager
|
||||
generatecmakelistsconstants.h
|
||||
boilerplate.qrc
|
||||
)
|
||||
|
||||
add_qtc_library(QmlProjectManagerLib OBJECT
|
||||
CONDITION Qt6_VERSION VERSION_GREATER_EQUAL 6.4.3
|
||||
EXCLUDE_FROM_INSTALL
|
||||
DEPENDS
|
||||
QmlJS Utils
|
||||
INCLUDES
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/buildsystem
|
||||
SOURCES
|
||||
projectitem/filefilteritems.cpp projectitem/filefilteritems.h
|
||||
projectitem/qmlprojectitem.cpp projectitem/qmlprojectitem.h
|
||||
projectitem/converters.cpp projectitem/converters.h
|
||||
)
|
||||
|
||||
@@ -337,7 +337,7 @@ 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('\"');
|
||||
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
|
||||
|
||||
@@ -18,8 +18,9 @@ namespace QmlProjectManager {
|
||||
|
||||
//#define REWRITE_PROJECT_FILE_IN_JSON_FORMAT
|
||||
|
||||
QmlProjectItem::QmlProjectItem(const Utils::FilePath &filePath)
|
||||
QmlProjectItem::QmlProjectItem(const Utils::FilePath &filePath, const bool skipRewrite)
|
||||
: m_projectFile(filePath)
|
||||
, m_skipRewrite(skipRewrite)
|
||||
{
|
||||
if (initProjectObject())
|
||||
setupFileFilters();
|
||||
@@ -394,9 +395,8 @@ void QmlProjectItem::addShaderToolFile(const QString &file)
|
||||
void QmlProjectItem::insertAndUpdateProjectFile(const QString &key, const QJsonValue &value)
|
||||
{
|
||||
m_project[key] = value;
|
||||
#ifndef TESTS_ENABLED_QMLPROJECTITEM
|
||||
m_projectFile.writeFileContents(Converters::jsonToQmlProject(m_project).toUtf8());
|
||||
#endif
|
||||
if (!m_skipRewrite)
|
||||
m_projectFile.writeFileContents(Converters::jsonToQmlProject(m_project).toUtf8());
|
||||
}
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -26,7 +26,7 @@ class QmlProjectItem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlProjectItem(const Utils::FilePath &filePath);
|
||||
explicit QmlProjectItem(const Utils::FilePath &filePath, const bool skipRewrite = false);
|
||||
|
||||
bool isQt4McuProject() const;
|
||||
|
||||
@@ -103,6 +103,7 @@ private:
|
||||
// runtime variables
|
||||
Utils::FilePath m_projectFile; // design studio project file
|
||||
QJsonObject m_project; // root project object
|
||||
const bool m_skipRewrite;
|
||||
|
||||
// initializing functions
|
||||
bool initProjectObject();
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
add_subdirectory(fileformat)
|
||||
add_subdirectory(projectitem)
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
set(WITH_TESTS ON)
|
||||
|
||||
find_package(Googletest MODULE)
|
||||
|
||||
set(QmlProjectItemDir "${PROJECT_SOURCE_DIR}/src/plugins/qmlprojectmanager/buildsystem/projectitem")
|
||||
|
||||
add_qtc_test(tst_qml_projectitem
|
||||
DEPENDS QmlProjectManager Utils QmlJS Googletest
|
||||
INCLUDES "${QmlProjectItemDir}"
|
||||
DEFINES
|
||||
QT_CREATOR
|
||||
SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
TESTDATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data"
|
||||
TESTS_ENABLED_QMLPROJECTITEM
|
||||
SOURCES
|
||||
tst_projectitem.cpp
|
||||
test-getters.cpp
|
||||
test-setters.cpp
|
||||
test-converters.cpp
|
||||
test-filefilters.cpp
|
||||
common.h
|
||||
"${QmlProjectItemDir}/qmlprojectitem.cpp"
|
||||
"${QmlProjectItemDir}/converters.cpp"
|
||||
"${QmlProjectItemDir}/filefilteritems.cpp"
|
||||
)
|
||||
@@ -1,46 +0,0 @@
|
||||
# QmlProject ProjectItem Tests
|
||||
|
||||
## Content
|
||||
|
||||
This test bundle covers following functionalities of QmlProjectItem class;
|
||||
|
||||
* **Getter Functions**: Tests if getter functions are returning correct types with correct values
|
||||
* **Setter Functions**: Tests if setter functions are updating the internal JSON object as expected
|
||||
* **Converter Functions:** Tests if QmlProjectToJson and JsonToQmlProject functions are working as expected
|
||||
* **File Filter Functions:** Tests if file filters are initialized properly
|
||||
|
||||
## Data set folder structure
|
||||
|
||||
The current folder hierarchy is as following;
|
||||
|
||||
```text
|
||||
| data
|
||||
| -> converter
|
||||
| | -> test-set-1
|
||||
| | | -> testfile.qmlproject
|
||||
| | | -> testfile.qmltojson
|
||||
| | | -> testfile.jsontoqml
|
||||
| | -> test-set-2
|
||||
| | | -> testfile.qmlproject
|
||||
| | | -> testfile.qmltojson
|
||||
| | | -> testfile.jsontoqml
|
||||
| | -> test-set-..
|
||||
| | -> test-set-..
|
||||
| -> getter-setter
|
||||
| | -> testfile-1.qmlproject
|
||||
| | -> testfile-2.qmlproject
|
||||
| -> file-filters
|
||||
| | -> test-set-1
|
||||
| | -> test-set-...
|
||||
```
|
||||
|
||||
## Further information
|
||||
|
||||
Please see [data/README.md](data/README.md) for more information on the test set content.
|
||||
|
||||
## Contribution
|
||||
|
||||
Please update;
|
||||
|
||||
* This README whenever you change the test content
|
||||
* [data/README.md](data/README.md) whenever you update the `data` folder
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include <gtest/gtest-matchers.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
static QDir testDataRootDir(QLatin1String(TESTDATA_DIR));
|
||||
|
||||
inline void PrintTo(const QString &qString, ::std::ostream *os)
|
||||
{
|
||||
*os << qUtf8Printable(qString);
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
\\ prop: json-converted
|
||||
\\ prop: auto-generated
|
||||
|
||||
import QmlProject
|
||||
|
||||
Project {
|
||||
mainFile: "content/App.qml"
|
||||
mainUiFile: "Screen01.ui.qml"
|
||||
targetDirectory: "/opt/MaterialLibrary"
|
||||
widgetApp: true
|
||||
importPaths: [ "imports","asset_imports" ]
|
||||
|
||||
qdsVersion: "3.9"
|
||||
quickVersion: ""
|
||||
qt6Project: true
|
||||
qtForMCUs: true
|
||||
|
||||
multilanguageSupport: true
|
||||
primaryLanguage: "en"
|
||||
supportedLanguages: [ "en" ]
|
||||
|
||||
Environment {
|
||||
QT_AUTO_SCREEN_SCALE_FACTOR: "1"
|
||||
QT_ENABLE_HIGHDPI_SCALING: "0"
|
||||
QT_LOGGING_RULES: "qt.qml.connections=false"
|
||||
QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf"
|
||||
}
|
||||
|
||||
ShaderTool {
|
||||
args: "-s --glsl "100 es,120,150" --hlsl 50 --msl 12"
|
||||
files: [ "content/shaders/*" ]
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "imports"
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "asset_imports"
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "imports"
|
||||
}
|
||||
|
||||
ImageFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
ImageFiles {
|
||||
directory: "asset_imports"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.conf"
|
||||
files: [ "qtquickcontrols2.conf" ]
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "asset_imports"
|
||||
filters: "*.mesh"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "content"
|
||||
filters: "*.mesh"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "qmldir"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.glsl;*.glslv;*.glslf;*.vsh;*.fsh;*.vert;*.frag"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.mp3;*.wav"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.mp4"
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
import QmlProject
|
||||
|
||||
Project {
|
||||
mainFile: "content/App.qml"
|
||||
mainUiFile: "Screen01.ui.qml"
|
||||
|
||||
|
||||
/* Include .qml, .js, and image files from current directory and subdirectories */
|
||||
QmlFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "imports"
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "imports"
|
||||
}
|
||||
|
||||
ImageFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.conf"
|
||||
files: ["qtquickcontrols2.conf"]
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "qmldir"
|
||||
directory: "."
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.wav;*.mp3"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.mp4"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.glsl;*.glslv;*.glslf;*.vsh;*.fsh;*.vert;*.frag"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.mesh"
|
||||
directory: "asset_imports"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.mesh"
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.qml"
|
||||
directory: "asset_imports"
|
||||
}
|
||||
|
||||
ImageFiles {
|
||||
directory: "asset_imports"
|
||||
}
|
||||
|
||||
Environment {
|
||||
QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf"
|
||||
QT_AUTO_SCREEN_SCALE_FACTOR: "1"
|
||||
QT_LOGGING_RULES: "qt.qml.connections=false"
|
||||
QT_ENABLE_HIGHDPI_SCALING: "0"
|
||||
/* Useful for debugging
|
||||
QSG_VISUALIZE=batches
|
||||
QSG_VISUALIZE=clip
|
||||
QSG_VISUALIZE=changes
|
||||
QSG_VISUALIZE=overdraw
|
||||
*/
|
||||
}
|
||||
|
||||
qt6Project: true
|
||||
|
||||
/* List of plugin directories passed to QML runtime */
|
||||
importPaths: [ "imports", "asset_imports" ]
|
||||
|
||||
/* Required for deployment */
|
||||
targetDirectory: "/opt/MaterialLibrary"
|
||||
|
||||
qdsVersion: "3.9"
|
||||
|
||||
/* If any modules the project imports require widgets (e.g. QtCharts), widgetApp must be true */
|
||||
widgetApp: true
|
||||
|
||||
/* args: Specifies command line arguments for qsb tool to generate shaders.
|
||||
files: Specifies target files for qsb tool. If path is included, it must be relative to this file.
|
||||
Wildcard '*' can be used in the file name part of the path.
|
||||
e.g. files: [ "content/shaders/*.vert", "*.frag" ] */
|
||||
ShaderTool {
|
||||
args: "-s --glsl \"100 es,120,150\" --hlsl 50 --msl 12"
|
||||
files: [ "content/shaders/*" ]
|
||||
}
|
||||
|
||||
multilanguageSupport: true
|
||||
supportedLanguages: ["en"]
|
||||
primaryLanguage: "en"
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
{
|
||||
"deployment": {
|
||||
"targetDirectory": "/opt/MaterialLibrary"
|
||||
},
|
||||
"environment": {
|
||||
"QT_AUTO_SCREEN_SCALE_FACTOR": "1",
|
||||
"QT_ENABLE_HIGHDPI_SCALING": "0",
|
||||
"QT_LOGGING_RULES": "qt.qml.connections=false",
|
||||
"QT_QUICK_CONTROLS_CONF": "qtquickcontrols2.conf"
|
||||
},
|
||||
"fileGroups": {
|
||||
"config": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
{
|
||||
"name": "qtquickcontrols2.conf"
|
||||
}
|
||||
],
|
||||
"filters": [
|
||||
"*.conf"
|
||||
]
|
||||
},
|
||||
"font": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.ttf",
|
||||
"*.otf"
|
||||
]
|
||||
},
|
||||
"image": {
|
||||
"directories": [
|
||||
"content",
|
||||
"asset_imports"
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.jpeg",
|
||||
"*.jpg",
|
||||
"*.png",
|
||||
"*.svg",
|
||||
"*.hdr",
|
||||
".ktx"
|
||||
]
|
||||
},
|
||||
"javaScript": {
|
||||
"directories": [
|
||||
"content",
|
||||
"imports"
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.js",
|
||||
"*.ts"
|
||||
]
|
||||
},
|
||||
"meshes": {
|
||||
"directories": [
|
||||
"asset_imports",
|
||||
"content"
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.mesh"
|
||||
]
|
||||
},
|
||||
"qml": {
|
||||
"directories": [
|
||||
"content",
|
||||
"imports",
|
||||
"asset_imports"
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.qml"
|
||||
]
|
||||
},
|
||||
"qmldir": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"qmldir"
|
||||
]
|
||||
},
|
||||
"shader": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.glsl",
|
||||
"*.glslv",
|
||||
"*.glslf",
|
||||
"*.vsh",
|
||||
"*.fsh",
|
||||
"*.vert",
|
||||
"*.frag"
|
||||
]
|
||||
},
|
||||
"sound": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.mp3",
|
||||
"*.wav"
|
||||
]
|
||||
},
|
||||
"video": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.mp4"
|
||||
]
|
||||
}
|
||||
},
|
||||
"fileVersion": 1,
|
||||
"importPaths": [
|
||||
"imports",
|
||||
"asset_imports"
|
||||
],
|
||||
"language": {
|
||||
"multiLanguageSupport": true,
|
||||
"primaryLanguage": "en",
|
||||
"supportedLanguages": [
|
||||
"en"
|
||||
]
|
||||
},
|
||||
"mcuConfig": {
|
||||
},
|
||||
"runConfig": {
|
||||
"fileSelectors": [
|
||||
],
|
||||
"mainFile": "content/App.qml",
|
||||
"mainUiFile": "Screen01.ui.qml",
|
||||
"widgetApp": true
|
||||
},
|
||||
"shaderTool": {
|
||||
"args": [
|
||||
"-s",
|
||||
"--glsl",
|
||||
"\"100 es,120,150\"",
|
||||
"--hlsl",
|
||||
"50",
|
||||
"--msl",
|
||||
"12"
|
||||
],
|
||||
"files": [
|
||||
"content/shaders/*"
|
||||
]
|
||||
},
|
||||
"versions": {
|
||||
"designStudio": "3.9",
|
||||
"qt": "6"
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
\\ prop: json-converted
|
||||
\\ prop: auto-generated
|
||||
|
||||
import QmlProject
|
||||
|
||||
Project {
|
||||
mainFile: "content/App.qml"
|
||||
mainUiFile: "content/MainScreen.ui.qml"
|
||||
targetDirectory: "/opt/RobotArm"
|
||||
widgetApp: true
|
||||
importPaths: [ "imports","asset_imports","backend_mock" ]
|
||||
|
||||
qdsVersion: "3.0"
|
||||
quickVersion: ""
|
||||
qt6Project: true
|
||||
qtForMCUs: true
|
||||
|
||||
multilanguageSupport: true
|
||||
primaryLanguage: "en"
|
||||
supportedLanguages: [ "en" ]
|
||||
|
||||
Environment {
|
||||
QT_AUTO_SCREEN_SCALE_FACTOR: "1"
|
||||
QT_ENABLE_HIGHDPI_SCALING: "0"
|
||||
QT_LOGGING_RULES: "qt.qml.connections=false"
|
||||
QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf"
|
||||
}
|
||||
|
||||
ShaderTool {
|
||||
args: ""
|
||||
files: [ ]
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "imports"
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "backend_mock"
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "imports"
|
||||
}
|
||||
|
||||
ImageFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.conf"
|
||||
files: [ "qtquickcontrols2.conf" ]
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "content"
|
||||
filters: "*.mesh"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "qmldir"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.glsl;*.glslv;*.glslf;*.vsh;*.fsh;*.vert;*.frag"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.mp3;*.wav"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.mp4"
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
import QmlProject
|
||||
|
||||
Project {
|
||||
mainFile: "content/App.qml"
|
||||
mainUiFile: "content/MainScreen.ui.qml"
|
||||
|
||||
/* Include .qml, .js, and image files from current directory and subdirectories */
|
||||
QmlFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "imports"
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "backend_mock"
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "imports"
|
||||
}
|
||||
|
||||
ImageFiles {
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.conf"
|
||||
files: ["qtquickcontrols2.conf"]
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "qmldir"
|
||||
directory: "."
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.wav;*.mp3"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.mp4"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.glsl;*.glslv;*.glslf;*.vsh;*.fsh;*.vert;*.frag"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.mesh"
|
||||
directory: "content"
|
||||
}
|
||||
|
||||
Environment {
|
||||
QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf"
|
||||
QT_AUTO_SCREEN_SCALE_FACTOR: "1"
|
||||
QT_LOGGING_RULES: "qt.qml.connections=false"
|
||||
QT_ENABLE_HIGHDPI_SCALING: "0"
|
||||
/* Useful for debugging
|
||||
QSG_VISUALIZE=batches
|
||||
QSG_VISUALIZE=clip
|
||||
QSG_VISUALIZE=changes
|
||||
QSG_VISUALIZE=overdraw
|
||||
*/
|
||||
}
|
||||
|
||||
qt6Project: true
|
||||
|
||||
/* List of plugin directories passed to QML runtime */
|
||||
importPaths: [ "imports", "asset_imports", "backend_mock" ]
|
||||
|
||||
/* Required for deployment */
|
||||
targetDirectory: "/opt/RobotArm"
|
||||
|
||||
qdsVersion: "3.0"
|
||||
|
||||
/* If any modules the project imports require widgets (e.g. QtCharts), widgetApp must be true */
|
||||
widgetApp: true
|
||||
|
||||
multilanguageSupport: true
|
||||
supportedLanguages: ["en"]
|
||||
primaryLanguage: "en"
|
||||
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
{
|
||||
"deployment": {
|
||||
"targetDirectory": "/opt/RobotArm"
|
||||
},
|
||||
"environment": {
|
||||
"QT_AUTO_SCREEN_SCALE_FACTOR": "1",
|
||||
"QT_ENABLE_HIGHDPI_SCALING": "0",
|
||||
"QT_LOGGING_RULES": "qt.qml.connections=false",
|
||||
"QT_QUICK_CONTROLS_CONF": "qtquickcontrols2.conf"
|
||||
},
|
||||
"fileGroups": {
|
||||
"config": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
{
|
||||
"name": "qtquickcontrols2.conf"
|
||||
}
|
||||
],
|
||||
"filters": [
|
||||
"*.conf"
|
||||
]
|
||||
},
|
||||
"font": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.ttf",
|
||||
"*.otf"
|
||||
]
|
||||
},
|
||||
"image": {
|
||||
"directories": [
|
||||
"content"
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.jpeg",
|
||||
"*.jpg",
|
||||
"*.png",
|
||||
"*.svg",
|
||||
"*.hdr",
|
||||
".ktx"
|
||||
]
|
||||
},
|
||||
"javaScript": {
|
||||
"directories": [
|
||||
"content",
|
||||
"imports"
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.js",
|
||||
"*.ts"
|
||||
]
|
||||
},
|
||||
"meshes": {
|
||||
"directories": [
|
||||
"content"
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.mesh"
|
||||
]
|
||||
},
|
||||
"qml": {
|
||||
"directories": [
|
||||
"content",
|
||||
"imports",
|
||||
"backend_mock"
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.qml"
|
||||
]
|
||||
},
|
||||
"qmldir": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"qmldir"
|
||||
]
|
||||
},
|
||||
"shader": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.glsl",
|
||||
"*.glslv",
|
||||
"*.glslf",
|
||||
"*.vsh",
|
||||
"*.fsh",
|
||||
"*.vert",
|
||||
"*.frag"
|
||||
]
|
||||
},
|
||||
"sound": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.mp3",
|
||||
"*.wav"
|
||||
]
|
||||
},
|
||||
"video": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.mp4"
|
||||
]
|
||||
}
|
||||
},
|
||||
"fileVersion": 1,
|
||||
"importPaths": [
|
||||
"imports",
|
||||
"asset_imports",
|
||||
"backend_mock"
|
||||
],
|
||||
"language": {
|
||||
"multiLanguageSupport": true,
|
||||
"primaryLanguage": "en",
|
||||
"supportedLanguages": [
|
||||
"en"
|
||||
]
|
||||
},
|
||||
"mcuConfig": {
|
||||
},
|
||||
"runConfig": {
|
||||
"fileSelectors": [
|
||||
],
|
||||
"mainFile": "content/App.qml",
|
||||
"mainUiFile": "content/MainScreen.ui.qml",
|
||||
"widgetApp": true
|
||||
},
|
||||
"shaderTool": {
|
||||
},
|
||||
"versions": {
|
||||
"designStudio": "3.0",
|
||||
"qt": "6"
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
\\ prop: json-converted
|
||||
\\ prop: auto-generated
|
||||
|
||||
import QmlProject
|
||||
|
||||
Project {
|
||||
mainFile: "OutrunHVAC.qml"
|
||||
mainUiFile: "Screen01.ui.qml"
|
||||
targetDirectory: "/opt/OutrunHVAC"
|
||||
widgetApp: false
|
||||
importPaths: [ "imports","asset_imports" ]
|
||||
|
||||
qdsVersion: ""
|
||||
quickVersion: ""
|
||||
qt6Project: true
|
||||
qtForMCUs: true
|
||||
|
||||
multilanguageSupport: false
|
||||
primaryLanguage: ""
|
||||
supportedLanguages: [ ]
|
||||
|
||||
Environment {
|
||||
QMLSCENE_CORE_PROFILE: "true"
|
||||
QT_AUTO_SCREEN_SCALE_FACTOR: "1"
|
||||
QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf"
|
||||
}
|
||||
|
||||
ShaderTool {
|
||||
args: ""
|
||||
files: [ ]
|
||||
}
|
||||
|
||||
QmlFiles {
|
||||
directory: "."
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "."
|
||||
}
|
||||
|
||||
ImageFiles {
|
||||
directory: "."
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.conf"
|
||||
files: [ "qtquickcontrols2.conf" ]
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "*.mesh;*.vert;*.frag"
|
||||
}
|
||||
|
||||
Files {
|
||||
directory: "."
|
||||
filters: "qmldir"
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/* File generated by Qt Creator */
|
||||
|
||||
import QmlProject 1.1
|
||||
|
||||
Project {
|
||||
mainFile: "OutrunHVAC.qml"
|
||||
|
||||
/* Include .qml, .js, and image files from current directory and subdirectories */
|
||||
QmlFiles {
|
||||
directory: "."
|
||||
}
|
||||
|
||||
JavaScriptFiles {
|
||||
directory: "."
|
||||
}
|
||||
|
||||
ImageFiles {
|
||||
directory: "."
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.conf"
|
||||
files: ["qtquickcontrols2.conf"]
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "qmldir"
|
||||
directory: "."
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.ttf;*.otf"
|
||||
}
|
||||
|
||||
Files {
|
||||
filter: "*.mesh;*.vert;*.frag"
|
||||
directory: "."
|
||||
}
|
||||
|
||||
Environment {
|
||||
QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf"
|
||||
QT_AUTO_SCREEN_SCALE_FACTOR: "1"
|
||||
QMLSCENE_CORE_PROFILE: "true"
|
||||
}
|
||||
|
||||
qt6Project: true
|
||||
|
||||
/* List of plugin directories passed to QML runtime */
|
||||
importPaths: [ "imports", "asset_imports" ]
|
||||
|
||||
/* Required for deployment */
|
||||
targetDirectory: "/opt/OutrunHVAC"
|
||||
|
||||
mainUiFile: "Screen01.ui.qml"
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
{
|
||||
"deployment": {
|
||||
"targetDirectory": "/opt/OutrunHVAC"
|
||||
},
|
||||
"environment": {
|
||||
"QMLSCENE_CORE_PROFILE": "true",
|
||||
"QT_AUTO_SCREEN_SCALE_FACTOR": "1",
|
||||
"QT_QUICK_CONTROLS_CONF": "qtquickcontrols2.conf"
|
||||
},
|
||||
"fileGroups": {
|
||||
"config": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
{
|
||||
"name": "qtquickcontrols2.conf"
|
||||
}
|
||||
],
|
||||
"filters": [
|
||||
"*.conf"
|
||||
]
|
||||
},
|
||||
"font": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.ttf",
|
||||
"*.otf"
|
||||
]
|
||||
},
|
||||
"image": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.jpeg",
|
||||
"*.jpg",
|
||||
"*.png",
|
||||
"*.svg",
|
||||
"*.hdr",
|
||||
".ktx"
|
||||
]
|
||||
},
|
||||
"javaScript": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.js",
|
||||
"*.ts"
|
||||
]
|
||||
},
|
||||
"meshes": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.mesh",
|
||||
"*.vert",
|
||||
"*.frag"
|
||||
]
|
||||
},
|
||||
"qml": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"*.qml"
|
||||
]
|
||||
},
|
||||
"qmldir": {
|
||||
"directories": [
|
||||
"."
|
||||
],
|
||||
"files": [
|
||||
],
|
||||
"filters": [
|
||||
"qmldir"
|
||||
]
|
||||
}
|
||||
},
|
||||
"fileVersion": 1,
|
||||
"importPaths": [
|
||||
"imports",
|
||||
"asset_imports"
|
||||
],
|
||||
"language": {
|
||||
},
|
||||
"mcuConfig": {
|
||||
},
|
||||
"runConfig": {
|
||||
"fileSelectors": [
|
||||
],
|
||||
"mainFile": "OutrunHVAC.qml",
|
||||
"mainUiFile": "Screen01.ui.qml"
|
||||
},
|
||||
"shaderTool": {
|
||||
},
|
||||
"versions": {
|
||||
"qt": "6"
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "projectitem/converters.h"
|
||||
|
||||
//#define REGENERATE_DATA_SETS
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
|
||||
class DataSet
|
||||
{
|
||||
public:
|
||||
DataSet(const QString &dataSetName)
|
||||
: m_dataSetDirectory(testDataRootDir.path() + "/converter/" + dataSetName)
|
||||
, m_qmlProjectFile(Utils::FilePath::fromString(
|
||||
QString(m_dataSetDirectory.absolutePath()).append("/testfile.qmlproject")))
|
||||
, m_jsonToQmlProjectFile(Utils::FilePath::fromString(
|
||||
QString(m_dataSetDirectory.absolutePath()).append("/testfile.jsontoqml")))
|
||||
, m_qmlProjectToJsonFile(Utils::FilePath::fromString(
|
||||
QString(m_dataSetDirectory.absolutePath()).append("/testfile.qmltojson")))
|
||||
{}
|
||||
|
||||
QString qmlProjectContent() const
|
||||
{
|
||||
return (m_qmlProjectFile.fileContents() ? m_qmlProjectFile.fileContents().value() : QString{});
|
||||
}
|
||||
QString jsonToQmlProjectContent() const
|
||||
{
|
||||
return m_jsonToQmlProjectFile.fileContents() ? m_jsonToQmlProjectFile.fileContents().value()
|
||||
: QString{};
|
||||
}
|
||||
QString qmlProjectToJsonContent() const
|
||||
{
|
||||
return m_qmlProjectToJsonFile.fileContents() ? m_qmlProjectToJsonFile.fileContents().value()
|
||||
: QString{};
|
||||
}
|
||||
|
||||
QString dataSetPath() const { return m_dataSetDirectory.absolutePath(); }
|
||||
QString dataSetName() const { return m_dataSetDirectory.dirName(); }
|
||||
Utils::FilePath qmlProjectFile() const { return m_qmlProjectFile; }
|
||||
Utils::FilePath jsonToQmlProjectFile() const { return m_jsonToQmlProjectFile; }
|
||||
Utils::FilePath qmlProjectToJsonFile() const { return m_qmlProjectToJsonFile; }
|
||||
|
||||
private:
|
||||
QDir m_dataSetDirectory;
|
||||
Utils::FilePath m_qmlProjectFile;
|
||||
Utils::FilePath m_jsonToQmlProjectFile;
|
||||
Utils::FilePath m_qmlProjectToJsonFile;
|
||||
};
|
||||
|
||||
QVector<DataSet> getDataSets()
|
||||
{
|
||||
QVector<DataSet> dataSets;
|
||||
QDir testDataDir(testDataRootDir.path().append("/converter"));
|
||||
testDataDir.setNameFilters({"test-set-*"});
|
||||
foreach (const QString &directory, testDataDir.entryList()) {
|
||||
dataSets.append(DataSet{directory});
|
||||
}
|
||||
return dataSets;
|
||||
}
|
||||
|
||||
#ifndef REGENERATE_DATA_SETS
|
||||
TEST(QmlProjectConverterTests, QmlProjectToJson)
|
||||
{
|
||||
foreach (const DataSet &dataSet, getDataSets()) {
|
||||
qDebug() << "Data set name:" << dataSet.dataSetName();
|
||||
|
||||
QString targetContent = dataSet.qmlProjectToJsonContent().replace("\r\n", "\n");
|
||||
|
||||
QJsonObject jsonObject{
|
||||
QmlProjectManager::Converters::qmlProjectTojson(dataSet.qmlProjectFile())};
|
||||
QString convertedContent{QJsonDocument(jsonObject).toJson()};
|
||||
|
||||
ASSERT_EQ(convertedContent.toStdString(), targetContent.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(QmlProjectConverterTests, JsonToQmlProject)
|
||||
{
|
||||
foreach (const DataSet &dataSet, getDataSets()) {
|
||||
qDebug() << "Data set name:" << dataSet.dataSetName();
|
||||
|
||||
QString targetContent = dataSet.jsonToQmlProjectContent().replace("\r\n", "\n");
|
||||
|
||||
QString jsonContent = dataSet.qmlProjectToJsonContent();
|
||||
QJsonObject jsonObject{QJsonDocument::fromJson(jsonContent.toLatin1()).object()};
|
||||
QString convertedContent = QmlProjectManager::Converters::jsonToQmlProject(jsonObject);
|
||||
|
||||
ASSERT_EQ(convertedContent.toStdString(), targetContent.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
TEST(QmlProjectConverterTests, RegenerateDataSets)
|
||||
{
|
||||
foreach (const DataSet &dataSet, getDataSets()) {
|
||||
qDebug() << "Regenerating data set:" << dataSet.dataSetName();
|
||||
QJsonObject qml2json = Converters::qmlProjectTojson(dataSet.qmlProjectFile());
|
||||
QString json2qml = Converters::jsonToQmlProject(qml2json);
|
||||
|
||||
dataSet.qmlProjectToJsonFile().writeFileContents(QJsonDocument(qml2json).toJson());
|
||||
dataSet.jsonToQmlProjectFile().writeFileContents(json2qml.toUtf8());
|
||||
}
|
||||
SUCCEED();
|
||||
}
|
||||
#endif
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "common.h"
|
||||
#include "projectitem/qmlprojectitem.h"
|
||||
|
||||
const Utils::FilePath testDataDir{
|
||||
Utils::FilePath::fromString(testDataRootDir.path() + "/file-filters")};
|
||||
const Utils::FilePath projectFilePath{testDataDir.pathAppended("/MaterialBundle.qmlproject")};
|
||||
const QmlProjectManager::QmlProjectItem projectItem{projectFilePath};
|
||||
const Utils::FilePath fileListPath{testDataDir.pathAppended("/filelist.txt")};
|
||||
|
||||
TEST(QmlProjectItemFileFilterTests, TestFileFilters)
|
||||
{
|
||||
QStringList fileNameList = QString::fromUtf8(fileListPath.fileContents().value()).replace("\r\n", "\n").split("\n");
|
||||
|
||||
for (const Utils::FilePath &filePath : projectItem.files()) {
|
||||
const QString fileName{filePath.relativePathFrom(testDataDir).path()};
|
||||
const int index = fileNameList.indexOf(fileName);
|
||||
ASSERT_NE(index, -1) << "file_is_missing_in_the_filelist:: " + fileName.toStdString();
|
||||
fileNameList.remove(index);
|
||||
}
|
||||
|
||||
ASSERT_EQ(fileNameList.size(), 0);
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "common.h"
|
||||
#include "projectitem/qmlprojectitem.h"
|
||||
|
||||
static QString testDataDir{testDataRootDir.path() + "/getter-setter"};
|
||||
static QString qmlProjectFilePath1(testDataDir + "/testfile-1.qmlproject");
|
||||
static QString qmlProjectFilePath2(testDataDir + "/testfile-2.qmlproject");
|
||||
|
||||
struct TestDataSet
|
||||
{
|
||||
public:
|
||||
const QmlProjectManager::QmlProjectItem projectItem1{
|
||||
Utils::FilePath::fromString(qmlProjectFilePath1)};
|
||||
QmlProjectManager::QmlProjectItem projectItem2{Utils::FilePath::fromString(qmlProjectFilePath2)};
|
||||
} dataSet;
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetMainFileProject)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.mainFile(), "content/App.qml");
|
||||
ASSERT_EQ(dataSet.projectItem2.mainFile(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetMainUIFileProject)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.mainUiFile(), "Screen01.ui.qml");
|
||||
ASSERT_EQ(dataSet.projectItem2.mainUiFile(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetMcuProject)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.isQt4McuProject(), true);
|
||||
ASSERT_EQ(dataSet.projectItem2.isQt4McuProject(), false);
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetQtVersion)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.versionQt(), "6");
|
||||
ASSERT_EQ(dataSet.projectItem2.versionQt(), "5");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetQtQuickVersion)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.versionQtQuick(), "6.2");
|
||||
ASSERT_EQ(dataSet.projectItem2.versionQtQuick(), QString());
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetDesignStudioVersion)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.versionDesignStudio(), "3.9");
|
||||
ASSERT_EQ(dataSet.projectItem2.versionDesignStudio(), QString());
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetSourceDirectory)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.sourceDirectory().path(), testDataDir);
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetTargetDirectory)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.targetDirectory(), "/opt/targetDirectory");
|
||||
ASSERT_EQ(dataSet.projectItem2.targetDirectory(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetImportPaths)
|
||||
{
|
||||
QString valsToCompare1 = dataSet.projectItem1.importPaths().join(";");
|
||||
QString valsToCompare2 = dataSet.projectItem2.importPaths().join(";");
|
||||
|
||||
ASSERT_EQ(valsToCompare1.toStdString(), "imports;asset_imports");
|
||||
ASSERT_EQ(valsToCompare2.toStdString(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetFileSelectors)
|
||||
{
|
||||
QString valsToCompare1 = dataSet.projectItem1.fileSelectors().join(";");
|
||||
QString valsToCompare2 = dataSet.projectItem2.fileSelectors().join(";");
|
||||
|
||||
ASSERT_EQ(valsToCompare1.toStdString(), "WXGA;darkTheme;ShowIndicator");
|
||||
ASSERT_EQ(valsToCompare2.toStdString(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetMultiLanguageSupport)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.multilanguageSupport(), true);
|
||||
ASSERT_EQ(dataSet.projectItem2.multilanguageSupport(), false);
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetSupportedLanguages)
|
||||
{
|
||||
QString valsToCompare1 = dataSet.projectItem1.supportedLanguages().join(";");
|
||||
QString valsToCompare2 = dataSet.projectItem2.supportedLanguages().join(";");
|
||||
|
||||
ASSERT_EQ(valsToCompare1.toStdString(), "en;fr");
|
||||
ASSERT_EQ(valsToCompare2.toStdString(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetPrimaryLanguage)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.primaryLanguage(), "en");
|
||||
ASSERT_EQ(dataSet.projectItem2.primaryLanguage(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetWidgetApp)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.widgetApp(), true);
|
||||
ASSERT_EQ(dataSet.projectItem2.widgetApp(), false);
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetFileList)
|
||||
{
|
||||
QString valsToCompare1, valsToCompare2;
|
||||
|
||||
for (const auto &file : dataSet.projectItem1.files()) {
|
||||
valsToCompare1.append(file.path()).append(";");
|
||||
}
|
||||
|
||||
for (const auto &file : dataSet.projectItem2.files()) {
|
||||
valsToCompare2.append(file.path()).append(";");
|
||||
}
|
||||
|
||||
valsToCompare1.remove(valsToCompare1.length() - 1, 1);
|
||||
valsToCompare2.remove(valsToCompare2.length() - 1, 1);
|
||||
|
||||
ASSERT_EQ(valsToCompare1.toStdString(),
|
||||
testDataDir.toStdString() + "/qtquickcontrols2.conf");
|
||||
ASSERT_EQ(valsToCompare2.toStdString(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetShaderToolArgs)
|
||||
{
|
||||
QString valsToCompare1 = dataSet.projectItem1.shaderToolArgs().join(";");
|
||||
QString valsToCompare2 = dataSet.projectItem2.shaderToolArgs().join(";");
|
||||
|
||||
ASSERT_EQ(valsToCompare1.toStdString(), "-s;--glsl;\"100 es,120,150\";--hlsl;50;--msl;12");
|
||||
ASSERT_EQ(valsToCompare2.toStdString(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetShaderToolFiles)
|
||||
{
|
||||
QString valsToCompare1 = dataSet.projectItem1.shaderToolFiles().join(";");
|
||||
QString valsToCompare2 = dataSet.projectItem2.shaderToolFiles().join(";");
|
||||
|
||||
ASSERT_EQ(valsToCompare1.toStdString(), "content/shaders/*");
|
||||
ASSERT_EQ(valsToCompare2.toStdString(), "");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetEnvironment)
|
||||
{
|
||||
Utils::EnvironmentItems env1 = dataSet.projectItem1.environment();
|
||||
Utils::EnvironmentItems env2 = dataSet.projectItem2.environment();
|
||||
|
||||
ASSERT_EQ(env1[0].value.toStdString(), "qtquickcontrols2.conf");
|
||||
ASSERT_EQ(env2.isEmpty(), true);
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemGetterTests, GetForceFreeType)
|
||||
{
|
||||
ASSERT_EQ(dataSet.projectItem1.forceFreeType(), true);
|
||||
ASSERT_EQ(dataSet.projectItem2.forceFreeType(), false);
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "common.h"
|
||||
#include "projectitem/qmlprojectitem.h"
|
||||
|
||||
using namespace QmlProjectManager;
|
||||
|
||||
static QString filePath(testDataRootDir.path() + "/getter-setter/testfile-1.qmlproject");
|
||||
static QmlProjectItem projectItem{Utils::FilePath::fromString(filePath)};
|
||||
|
||||
#define call_mem_fn(ptr) ((projectItem).*(ptr))
|
||||
|
||||
template<typename T>
|
||||
void testerTemplate(void (QmlProjectItem::*setterFunc)(const T &),
|
||||
T (QmlProjectItem::*getterFunc)(void) const,
|
||||
const T &testingData)
|
||||
{
|
||||
call_mem_fn(setterFunc)({testingData});
|
||||
ASSERT_EQ(call_mem_fn(getterFunc)(), testingData);
|
||||
}
|
||||
|
||||
template<typename T, typename Y>
|
||||
void testerTemplate(void (QmlProjectItem::*setterFunc)(const T &),
|
||||
T (QmlProjectItem::*getterFunc)(void) const,
|
||||
void (QmlProjectItem::*adderFunc)(const Y &),
|
||||
const Y &testingData)
|
||||
{
|
||||
call_mem_fn(setterFunc)({testingData});
|
||||
ASSERT_EQ(call_mem_fn(getterFunc)(), T{testingData});
|
||||
|
||||
call_mem_fn(setterFunc)({});
|
||||
call_mem_fn(adderFunc)(testingData);
|
||||
ASSERT_EQ(call_mem_fn(getterFunc)(), T{testingData});
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetMainFileProject)
|
||||
{
|
||||
testerTemplate<QString>(&QmlProjectItem::setMainFile, &QmlProjectItem::mainFile, "testing");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetMainUIFileProject)
|
||||
{
|
||||
testerTemplate<QString>(&QmlProjectItem::setMainUiFile, &QmlProjectItem::mainUiFile, "testing");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetImportPaths)
|
||||
{
|
||||
testerTemplate<QStringList, QString>(&QmlProjectItem::setImportPaths,
|
||||
&QmlProjectItem::importPaths,
|
||||
&QmlProjectItem::addImportPath,
|
||||
"testing");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetFileSelectors)
|
||||
{
|
||||
testerTemplate<QStringList, QString>(&QmlProjectItem::setFileSelectors,
|
||||
&QmlProjectItem::fileSelectors,
|
||||
&QmlProjectItem::addFileSelector,
|
||||
"testing");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetMultiLanguageSupport)
|
||||
{
|
||||
testerTemplate<bool>(&QmlProjectItem::setMultilanguageSupport,
|
||||
&QmlProjectItem::multilanguageSupport,
|
||||
true);
|
||||
|
||||
testerTemplate<bool>(&QmlProjectItem::setMultilanguageSupport,
|
||||
&QmlProjectItem::multilanguageSupport,
|
||||
false);
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetSupportedLanguages)
|
||||
{
|
||||
testerTemplate<QStringList, QString>(&QmlProjectItem::setSupportedLanguages,
|
||||
&QmlProjectItem::supportedLanguages,
|
||||
&QmlProjectItem::addSupportedLanguage,
|
||||
"testing");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetPrimaryLanguage)
|
||||
{
|
||||
testerTemplate<QString>(&QmlProjectItem::setPrimaryLanguage,
|
||||
&QmlProjectItem::primaryLanguage,
|
||||
"testing");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetWidgetApp)
|
||||
{
|
||||
testerTemplate<bool>(&QmlProjectItem::setWidgetApp, &QmlProjectItem::widgetApp, true);
|
||||
testerTemplate<bool>(&QmlProjectItem::setWidgetApp, &QmlProjectItem::widgetApp, false);
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetShaderToolArgs)
|
||||
{
|
||||
testerTemplate<QStringList, QString>(&QmlProjectItem::setShaderToolArgs,
|
||||
&QmlProjectItem::shaderToolArgs,
|
||||
&QmlProjectItem::addShaderToolArg,
|
||||
"testing");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetShaderToolFiles)
|
||||
{
|
||||
testerTemplate<QStringList, QString>(&QmlProjectItem::setShaderToolFiles,
|
||||
&QmlProjectItem::shaderToolFiles,
|
||||
&QmlProjectItem::addShaderToolFile,
|
||||
"testing");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetForceFreeType)
|
||||
{
|
||||
testerTemplate<bool>(&QmlProjectItem::setForceFreeType, &QmlProjectItem::forceFreeType, true);
|
||||
testerTemplate<bool>(&QmlProjectItem::setForceFreeType, &QmlProjectItem::forceFreeType, false);
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetQtVersion)
|
||||
{
|
||||
testerTemplate<QString>(&QmlProjectItem::setVersionQt, &QmlProjectItem::versionQt, "6");
|
||||
testerTemplate<QString>(&QmlProjectItem::setVersionQt, &QmlProjectItem::versionQt, "5.3");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetQtQuickVersion)
|
||||
{
|
||||
testerTemplate<QString>(&QmlProjectItem::setVersionQtQuick, &QmlProjectItem::versionQtQuick, "6");
|
||||
testerTemplate<QString>(&QmlProjectItem::setVersionQtQuick, &QmlProjectItem::versionQtQuick, "5.3");
|
||||
}
|
||||
|
||||
TEST(QmlProjectProjectItemSetterTests, SetDesignStudio)
|
||||
{
|
||||
testerTemplate<QString>(&QmlProjectItem::setVersionDesignStudio, &QmlProjectItem::versionDesignStudio, "6");
|
||||
testerTemplate<QString>(&QmlProjectItem::setVersionDesignStudio, &QmlProjectItem::versionDesignStudio, "5.3");
|
||||
}
|
||||
|
||||
/**
|
||||
TEST(QmlProjectProjectItemSetterTests, SetEnvironment)
|
||||
{
|
||||
//FIXME: implement this
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// not available as of now
|
||||
//TEST(QmlProjectProjectItemSetterTests, SetMcuProject)
|
||||
//{
|
||||
// ASSERT_EQ(dataSet.projectItem1.isQt4McuProject(), true);
|
||||
// ASSERT_EQ(dataSet.projectItem2.isQt4McuProject(), false);
|
||||
//}
|
||||
|
||||
// not available as of now
|
||||
//TEST(QmlProjectProjectItemSetterTests, SetSourceDirectory)
|
||||
//{
|
||||
// ASSERT_EQ(dataSet.projectItem1.sourceDirectory(), testDataDir.path());
|
||||
//}
|
||||
|
||||
// not available as of now
|
||||
//TEST(QmlProjectProjectItemSetterTests, SetTargetDirectory)
|
||||
//{
|
||||
// ASSERT_EQ(dataSet.projectItem1.targetDirectory(), "/opt/targetDirectory");
|
||||
// ASSERT_EQ(dataSet.projectItem2.targetDirectory(), "");
|
||||
//}
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
@@ -37,3 +37,4 @@ if (NOT QT_CREATOR_API_DEFINED)
|
||||
endif()
|
||||
|
||||
add_subdirectory(unittest)
|
||||
add_subdirectory(tools)
|
||||
|
||||
49
tests/unit/README.md
Normal file
49
tests/unit/README.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Contribution Guideline
|
||||
|
||||
This document summarizes;
|
||||
|
||||
* Best practices for writing tests
|
||||
* How to add a new test
|
||||
* How to build only specific test
|
||||
|
||||
All tests here depend on the [GoogleTest][1] framework.
|
||||
|
||||
## Best Practices
|
||||
|
||||
We're following those patterns/approaches;
|
||||
|
||||
* The Arrange, Act, and Assert (AAA) Pattern
|
||||
* Given When Then (GWT) Pattern
|
||||
|
||||
## Adding a New Unit Test
|
||||
|
||||
* Please add your tests under `unit/unittest`. No subfolders are needed.
|
||||
* Name your class as `foo-test.cpp`
|
||||
|
||||
* Always include `googletest.h` header. Without that you may get the printer function can be broken because the are not anymore ODR (because of weak linking to printers for example). It is also necessary for nice printers, also adds Qt known matchers.
|
||||
|
||||
## Building Tests
|
||||
|
||||
> Note:
|
||||
> When you're building the application from the terminal, you can set environment variables instead of settings CMake flags.
|
||||
> The corresponding environment variable name is same with CMake variable name but with a 'QTC_' prefix.
|
||||
> CMake Variable: WITH_TESTS
|
||||
> Environment Variable: QTC_WITH_TESTS
|
||||
|
||||
You have to enable tests with the following CMake variable otherwise the default configuration skips them.
|
||||
|
||||
```bash
|
||||
WITH_TESTS=ON
|
||||
```
|
||||
|
||||
## Building Specific Tests
|
||||
|
||||
After enabling tests you can use test-specific CMake flags to customize which tests should be built instead of building all of them at once. Please check the relevant CMake file to see which variable is required to enable that specific test.
|
||||
|
||||
```bash
|
||||
BUILD_TESTS_BY_DEFAULT=OFF
|
||||
BUILD_TEST_UNITTEST=ON
|
||||
BUILD_TEST_TST_QML_TESTCORE=ON
|
||||
```
|
||||
|
||||
[1]: https://github.com/google/googletest
|
||||
1
tests/unit/tools/CMakeLists.txt
Normal file
1
tests/unit/tools/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(qmlprojectmanager)
|
||||
16
tests/unit/tools/qmlprojectmanager/CMakeLists.txt
Normal file
16
tests/unit/tools/qmlprojectmanager/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
project(QmlProjectManagerConverterDataCreator)
|
||||
|
||||
add_compile_definitions(QT_CREATOR)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "dataSetGenerator"
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
QmlJS Utils ProjectExplorer QmlProjectManagerLib
|
||||
)
|
||||
95
tests/unit/tools/qmlprojectmanager/main.cpp
Normal file
95
tests/unit/tools/qmlprojectmanager/main.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <qmlprojectmanager/buildsystem/projectitem/converters.h>
|
||||
|
||||
class DataSet
|
||||
{
|
||||
public:
|
||||
DataSet(const QString &rootDir)
|
||||
: m_rootDir(rootDir)
|
||||
{}
|
||||
void setDataSource(const QString &dataSetName)
|
||||
{
|
||||
m_dataSetDirectory.setPath(m_rootDir.path() + "/" + dataSetName);
|
||||
|
||||
m_qmlProjectFile = Utils::FilePath::fromString(
|
||||
QString(m_dataSetDirectory.absolutePath()).append("/testfile.qmlproject"));
|
||||
m_jsonToQmlProjectFile = Utils::FilePath::fromString(
|
||||
QString(m_dataSetDirectory.absolutePath()).append("/testfile.jsontoqml"));
|
||||
m_qmlProjectToJsonFile = Utils::FilePath::fromString(
|
||||
QString(m_dataSetDirectory.absolutePath()).append("/testfile.qmltojson"));
|
||||
}
|
||||
|
||||
QString qmlProjectContent() const
|
||||
{
|
||||
return (m_qmlProjectFile.fileContents()
|
||||
? QString::fromLatin1(m_qmlProjectFile.fileContents().value())
|
||||
: QString{});
|
||||
}
|
||||
QString jsonToQmlProjectContent() const
|
||||
{
|
||||
return m_jsonToQmlProjectFile.fileContents()
|
||||
? QString::fromLatin1(m_jsonToQmlProjectFile.fileContents().value())
|
||||
: QString{};
|
||||
}
|
||||
QString qmlProjectToJsonContent() const
|
||||
{
|
||||
return m_qmlProjectToJsonFile.fileContents()
|
||||
? QString::fromLatin1(m_qmlProjectToJsonFile.fileContents().value())
|
||||
: QString{};
|
||||
}
|
||||
|
||||
QString dataSetPath() const { return m_dataSetDirectory.absolutePath(); }
|
||||
QString dataSetName() const { return m_dataSetDirectory.dirName(); }
|
||||
Utils::FilePath qmlProjectFile() const { return m_qmlProjectFile; }
|
||||
Utils::FilePath jsonToQmlProjectFile() const { return m_jsonToQmlProjectFile; }
|
||||
Utils::FilePath qmlProjectToJsonFile() const { return m_qmlProjectToJsonFile; }
|
||||
|
||||
private:
|
||||
QDir m_rootDir;
|
||||
QDir m_dataSetDirectory;
|
||||
Utils::FilePath m_qmlProjectFile;
|
||||
Utils::FilePath m_jsonToQmlProjectFile;
|
||||
Utils::FilePath m_qmlProjectToJsonFile;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const QString helpText{"./dataSetGenerator [path]\n"
|
||||
"[path]: Path to the data set folders. The default is current dir.\n"
|
||||
" Folder names should be in the form of test-set-x.\n"};
|
||||
|
||||
QDir dataSetPath{QDir::currentPath()};
|
||||
if (argc >= 2) {
|
||||
dataSetPath.setPath(argv[1]);
|
||||
}
|
||||
|
||||
if (!dataSetPath.exists()) {
|
||||
qDebug() << "Data path does not exist:" << dataSetPath.path() << Qt::endl;
|
||||
qDebug().noquote() << helpText;
|
||||
return -1;
|
||||
}
|
||||
|
||||
QStringList dataSetList{dataSetPath.entryList({"test-set-*"})};
|
||||
if (!dataSetList.size()) {
|
||||
qDebug() << "No test sets are available under" << dataSetPath.path() << Qt::endl;
|
||||
qDebug().noquote() << helpText;
|
||||
return -1;
|
||||
}
|
||||
|
||||
DataSet dataSet(dataSetPath.path());
|
||||
for (const auto &dataSetName : dataSetList) {
|
||||
dataSet.setDataSource(dataSetName);
|
||||
|
||||
qDebug() << "Regenerating data set:" << dataSet.dataSetName();
|
||||
QJsonObject qml2json = QmlProjectManager::Converters::qmlProjectTojson(
|
||||
dataSet.qmlProjectFile());
|
||||
QString json2qml = QmlProjectManager::Converters::jsonToQmlProject(qml2json);
|
||||
|
||||
dataSet.qmlProjectToJsonFile().writeFileContents(QJsonDocument(qml2json).toJson());
|
||||
dataSet.jsonToQmlProjectFile().writeFileContents(json2qml.toUtf8());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -35,7 +35,8 @@ add_qtc_test(unittest GTEST
|
||||
UNIT_TESTS
|
||||
DONT_CHECK_MESSAGE_COUNTER
|
||||
QTC_RESOURCE_DIR="${CMAKE_CURRENT_LIST_DIR}/../../../share/qtcreator"
|
||||
TESTDATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data"
|
||||
TESTDATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data"
|
||||
UNITTEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
TEST_RELATIVE_LIBEXEC_PATH="${TEST_RELATIVE_LIBEXEC_PATH}"
|
||||
QT6_INSTALL_PREFIX="${QT6_INSTALL_PREFIX}"
|
||||
QDS_MODEL_USE_PROJECTSTORAGEINTERFACE
|
||||
@@ -368,3 +369,5 @@ set_property(SOURCE ${PROJECTSTORAGE_EXCLUDED_SOURCES} PROPERTY SKIP_AUTOMOC ON)
|
||||
|
||||
file(GLOB UNITTEST_EXCLUDED_SOURCES *.cpp)
|
||||
set_property(SOURCE ${UNITTEST_EXCLUDED_SOURCES} PROPERTY SKIP_AUTOMOC ON)
|
||||
|
||||
add_subdirectory(qmlprojectmanager)
|
||||
|
||||
@@ -56,5 +56,6 @@ using testing::StrEq;
|
||||
using testing::Throw;
|
||||
using testing::TypedEq;
|
||||
using testing::UnorderedElementsAre;
|
||||
using testing::UnorderedElementsAreArray;
|
||||
using testing::VariantWith;
|
||||
using testing::WithArg;
|
||||
|
||||
@@ -118,6 +118,7 @@ TEST_F(ModuleScanner, Version)
|
||||
scanner.scan(QStringList{TESTDATA_DIR "/modulescanner"});
|
||||
|
||||
ASSERT_THAT(scanner.modules(), ElementsAre(AllOf(UrlProperty("Example"), VersionProperty("1.3"))));
|
||||
|
||||
}
|
||||
|
||||
TEST_F(ModuleScanner, NoVersion)
|
||||
|
||||
7
tests/unit/unittest/qmlprojectmanager/CMakeLists.txt
Normal file
7
tests/unit/unittest/qmlprojectmanager/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
extend_qtc_test(unittest
|
||||
DEPENDS
|
||||
QmlProjectManagerLib
|
||||
SOURCES
|
||||
converters-test.cpp
|
||||
projectitem-test.cpp
|
||||
)
|
||||
94
tests/unit/unittest/qmlprojectmanager/converters-test.cpp
Normal file
94
tests/unit/unittest/qmlprojectmanager/converters-test.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
// 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 <qmlprojectmanager/buildsystem/projectitem/converters.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace {
|
||||
constexpr QLatin1String localTestDataDir{UNITTEST_DIR "/qmlprojectmanager/data"};
|
||||
|
||||
class DataSet : public testing::TestWithParam<QString>
|
||||
{
|
||||
public:
|
||||
void setDataSource(const QString &dataSetName)
|
||||
{
|
||||
m_dataSetDirectory.setPath(localTestDataDir + "/converter/" + dataSetName);
|
||||
|
||||
m_qmlProjectFile = Utils::FilePath::fromString(
|
||||
QString(m_dataSetDirectory.absolutePath()).append("/testfile.qmlproject"));
|
||||
m_jsonToQmlProjectFile = Utils::FilePath::fromString(
|
||||
QString(m_dataSetDirectory.absolutePath()).append("/testfile.jsontoqml"));
|
||||
m_qmlProjectToJsonFile = Utils::FilePath::fromString(
|
||||
QString(m_dataSetDirectory.absolutePath()).append("/testfile.qmltojson"));
|
||||
}
|
||||
|
||||
QString qmlProjectContent() const
|
||||
{
|
||||
return (m_qmlProjectFile.fileContents()
|
||||
? QString::fromLatin1(m_qmlProjectFile.fileContents().value())
|
||||
: QString{});
|
||||
}
|
||||
QString jsonToQmlProjectContent() const
|
||||
{
|
||||
return m_jsonToQmlProjectFile.fileContents()
|
||||
? QString::fromLatin1(m_jsonToQmlProjectFile.fileContents().value())
|
||||
: QString{};
|
||||
}
|
||||
QString qmlProjectToJsonContent() const
|
||||
{
|
||||
return m_qmlProjectToJsonFile.fileContents()
|
||||
? QString::fromLatin1(m_qmlProjectToJsonFile.fileContents().value())
|
||||
: QString{};
|
||||
}
|
||||
|
||||
QString dataSetPath() const { return m_dataSetDirectory.absolutePath(); }
|
||||
QString dataSetName() const { return m_dataSetDirectory.dirName(); }
|
||||
Utils::FilePath qmlProjectFile() const { return m_qmlProjectFile; }
|
||||
Utils::FilePath jsonToQmlProjectFile() const { return m_jsonToQmlProjectFile; }
|
||||
Utils::FilePath qmlProjectToJsonFile() const { return m_qmlProjectToJsonFile; }
|
||||
|
||||
private:
|
||||
QDir m_dataSetDirectory;
|
||||
Utils::FilePath m_qmlProjectFile;
|
||||
Utils::FilePath m_jsonToQmlProjectFile;
|
||||
Utils::FilePath m_qmlProjectToJsonFile;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(ConverterTests,
|
||||
DataSet,
|
||||
::testing::Values(QString("test-set-1"), QString("test-set-2")));
|
||||
|
||||
TEST_P(DataSet, QmlProjectToJson)
|
||||
{
|
||||
// GIVEN
|
||||
setDataSource(GetParam());
|
||||
QString targetContent = qmlProjectToJsonContent().replace("\r\n", "\n");
|
||||
auto qmlFile = qmlProjectFile();
|
||||
|
||||
// WHEN
|
||||
auto jsonObject = QmlProjectManager::Converters::qmlProjectTojson(qmlFile);
|
||||
|
||||
// THEN
|
||||
QString convertedContent{QString::fromLatin1(QJsonDocument(jsonObject).toJson())};
|
||||
ASSERT_THAT(convertedContent, Eq(targetContent));
|
||||
}
|
||||
|
||||
TEST_P(DataSet, JsonToQmlProject)
|
||||
{
|
||||
// GIVEN
|
||||
setDataSource(GetParam());
|
||||
QString targetContent = jsonToQmlProjectContent().replace("\r\n", "\n");
|
||||
auto jsonContent = qmlProjectToJsonContent().toLatin1();
|
||||
|
||||
// WHEN
|
||||
auto jsonObject{QJsonDocument::fromJson(jsonContent).object()};
|
||||
|
||||
// THEN
|
||||
QString convertedContent = QmlProjectManager::Converters::jsonToQmlProject(jsonObject);
|
||||
ASSERT_THAT(convertedContent, Eq(targetContent));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -22,21 +22,6 @@ Test functions iterate over the "test-set-*" folders and run the tests by using
|
||||
|
||||
### test-set-2
|
||||
|
||||
* **purpose**: testing complex qmlproject file convertion
|
||||
* **origin**: material bundle example
|
||||
|
||||
### test-set-3
|
||||
|
||||
* **purpose**: testing complex qmlproject file convertion
|
||||
* **origin**: robot arm example
|
||||
|
||||
### test-set-4
|
||||
|
||||
* **purpose**: testing complex qmlproject file convertion
|
||||
* **origin**: outrun hvac example
|
||||
|
||||
### test-set-5
|
||||
|
||||
* **purpose**: testing fileselectors
|
||||
* **origin**: file selectors example from playground
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user