forked from qt-creator/qt-creator
QmlDesigner: Fix build
The design system tests introduced a dpendency to QmlDesignerCore. But that is not working. Only if designer core will use only the project storage, we can use it in the tests. Change-Id: I0fdec9eac8f417593aa4f201177749c69dbf384f Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -1,8 +1,18 @@
|
|||||||
extend_qtc_test(unittest
|
extend_qtc_test(unittest
|
||||||
DEPENDS
|
|
||||||
QmlDesignerUtils DesignSystem
|
|
||||||
SOURCES
|
SOURCES
|
||||||
dsthemegroup-test.cpp
|
dsthemegroup-test.cpp
|
||||||
dsthememgr-test.cpp
|
dsthememgr-test.cpp
|
||||||
dsthemeqml-test.cpp
|
dsthemeqml-test.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
extend_qtc_test(unittest
|
||||||
|
SOURCES_PREFIX "${QML_DESIGNER_DIRECTORY}/libs/designsystem"
|
||||||
|
INCLUDES "${QML_DESIGNER_DIRECTORY}/libs/designsystem"
|
||||||
|
DEFINES DESIGNSYSTEM_STATIC_LIBRARY
|
||||||
|
DEPENDS
|
||||||
|
Qt::Core Qt::Widgets QmlDesignerUtils TestDesignerCore
|
||||||
|
SOURCES
|
||||||
|
dsconstants.h
|
||||||
|
dsthemegroup.h dsthemegroup.cpp
|
||||||
|
dsthememanager.h dsthememanager.cpp
|
||||||
|
)
|
||||||
|
@@ -12,19 +12,28 @@ using QmlDesigner::DSThemeGroup;
|
|||||||
using QmlDesigner::ThemeProperty;
|
using QmlDesigner::ThemeProperty;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr const char testPropertyNameFoo[] = "propFoo";
|
QByteArray testPropertyNameFoo = "propFoo";
|
||||||
constexpr const char testPropertyNameBar[] = "propBar";
|
QByteArray testPropertyNameBar = "propBar";
|
||||||
|
|
||||||
constexpr QmlDesigner::ThemeId themeId1 = 0;
|
constexpr QmlDesigner::ThemeId themeId1 = 0;
|
||||||
constexpr QmlDesigner::ThemeId themeId2 = 1;
|
constexpr QmlDesigner::ThemeId themeId2 = 1;
|
||||||
|
|
||||||
MATCHER_P3(HasPropertyCount, themeId, themePropCount, totalPropsCount, "")
|
MATCHER_P3(HasPropertyCount,
|
||||||
|
themeId,
|
||||||
|
themePropCount,
|
||||||
|
totalPropsCount,
|
||||||
|
std::string(negation ? "hasn't " : "has ") + "total property count "
|
||||||
|
+ PrintToString(totalPropsCount) + " and theme property count "
|
||||||
|
+ PrintToString(themePropCount))
|
||||||
{
|
{
|
||||||
const DSThemeGroup &group = arg;
|
const DSThemeGroup &group = arg;
|
||||||
return group.count() == totalPropsCount && group.count(themeId) == themePropCount;
|
return group.count() == totalPropsCount && group.count(themeId) == themePropCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
MATCHER_P2(HasThemeProperty, themeId, themeProp, "")
|
MATCHER_P2(HasThemeProperty,
|
||||||
|
themeId,
|
||||||
|
themeProp,
|
||||||
|
std::string(negation ? "hasn't " : "has ") + PrintToString(themeProp))
|
||||||
{
|
{
|
||||||
const DSThemeGroup &group = arg;
|
const DSThemeGroup &group = arg;
|
||||||
const std::optional<ThemeProperty> prop = group.propertyValue(themeId, themeProp.name);
|
const std::optional<ThemeProperty> prop = group.propertyValue(themeId, themeProp.name);
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
#include <designsystem/dsthememanager.h>
|
#include <designsystem/dsthememanager.h>
|
||||||
|
|
||||||
#include <format>
|
|
||||||
|
|
||||||
using QmlDesigner::DSThemeManager;
|
using QmlDesigner::DSThemeManager;
|
||||||
using QmlDesigner::GroupType;
|
using QmlDesigner::GroupType;
|
||||||
using QmlDesigner::Import;
|
using QmlDesigner::Import;
|
||||||
@@ -30,9 +28,7 @@ MATCHER_P3(HasProperty,
|
|||||||
themeId,
|
themeId,
|
||||||
group,
|
group,
|
||||||
themeProp,
|
themeProp,
|
||||||
std::format("Collection {} have a property {}",
|
std::string(negation ? "hasn't " : "has ") + PrintToString(themeProp))
|
||||||
(negation ? "Does't " : "Does "),
|
|
||||||
PrintToString(themeProp)))
|
|
||||||
{
|
{
|
||||||
const DSThemeManager &mgr = arg;
|
const DSThemeManager &mgr = arg;
|
||||||
const std::optional<ThemeProperty> prop = mgr.property(themeId, group, themeProp.name);
|
const std::optional<ThemeProperty> prop = mgr.property(themeId, group, themeProp.name);
|
||||||
|
@@ -13,8 +13,9 @@
|
|||||||
#include <designsystem/dsthemegroup.h>
|
#include <designsystem/dsthemegroup.h>
|
||||||
#include <designsystem/dsthememanager.h>
|
#include <designsystem/dsthememanager.h>
|
||||||
|
|
||||||
#include <format>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
using QmlDesigner::DSThemeManager;
|
using QmlDesigner::DSThemeManager;
|
||||||
using QmlDesigner::GroupType;
|
using QmlDesigner::GroupType;
|
||||||
@@ -22,40 +23,24 @@ using QmlDesigner::Import;
|
|||||||
using QmlDesigner::ModelNode;
|
using QmlDesigner::ModelNode;
|
||||||
using QmlDesigner::ThemeProperty;
|
using QmlDesigner::ThemeProperty;
|
||||||
|
|
||||||
template<>
|
|
||||||
struct std::formatter<QByteArray> : std::formatter<std::string>
|
|
||||||
{
|
|
||||||
template<typename FormatContext>
|
|
||||||
auto format(const QByteArray &ba, FormatContext &ctx) const
|
|
||||||
{
|
|
||||||
return std::formatter<std::string>::format(ba.toStdString(), ctx);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
std::string formatedPropStr(std::string tag, const QByteArray &name, const QVariant &value)
|
||||||
static std::string formatedPropStr(const char tag[], const char name[], const QVariant &v)
|
|
||||||
{
|
{
|
||||||
return std::format("{}Property({}, {})", tag, name, v.toString().toStdString());
|
return tag + "Property(" + name.toStdString() + ", " + value.toString().toStdString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto bindingPropStr = std::bind(&formatedPropStr,
|
auto bindingPropStr = std::bind_front(&formatedPropStr, "Binding");
|
||||||
"Binding",
|
auto variantPropStr = std::bind_front(&formatedPropStr, "Variant");
|
||||||
std::placeholders::_1,
|
|
||||||
std::placeholders::_2);
|
|
||||||
static auto variantPropStr = std::bind(&formatedPropStr,
|
|
||||||
"Variant",
|
|
||||||
std::placeholders::_1,
|
|
||||||
std::placeholders::_2);
|
|
||||||
|
|
||||||
constexpr const char testPropertyName1[] = "prop1";
|
QByteArray testPropertyName1 = "prop1";
|
||||||
constexpr const char darkThemeName[] = "dark";
|
QByteArray darkThemeName = "dark";
|
||||||
constexpr QmlDesigner::ThemeId testThemeId = 1;
|
constexpr QmlDesigner::ThemeId testThemeId = 1;
|
||||||
|
|
||||||
MATCHER_P2(HasNodeProperty,
|
MATCHER_P2(HasNodeProperty,
|
||||||
name,
|
name,
|
||||||
typeName,
|
typeName,
|
||||||
std::format("{} have node {} with type {})", (negation ? "Does't " : "Does "), name, typeName))
|
std::string(negation ? "hasn't node " : "has node ") + name.toStdString()
|
||||||
|
+ std::string(" with type ") + typeName)
|
||||||
{
|
{
|
||||||
ModelNode n = arg;
|
ModelNode n = arg;
|
||||||
return n.hasNodeProperty(name) && n.nodeProperty(name).modelNode().isValid()
|
return n.hasNodeProperty(name) && n.nodeProperty(name).modelNode().isValid()
|
||||||
@@ -65,7 +50,7 @@ MATCHER_P2(HasNodeProperty,
|
|||||||
MATCHER_P2(HasBindingProperty,
|
MATCHER_P2(HasBindingProperty,
|
||||||
name,
|
name,
|
||||||
value,
|
value,
|
||||||
std::format("{} have {})", (negation ? "Does't " : "Does "), bindingPropStr(name, value)))
|
std::string(negation ? "hasn't " : "has ") + bindingPropStr(name, value))
|
||||||
{
|
{
|
||||||
ModelNode n = arg;
|
ModelNode n = arg;
|
||||||
return n.hasBindingProperty(name) && n.bindingProperty(name).expression() == value;
|
return n.hasBindingProperty(name) && n.bindingProperty(name).expression() == value;
|
||||||
@@ -74,7 +59,7 @@ MATCHER_P2(HasBindingProperty,
|
|||||||
MATCHER_P2(HasVariantProperty,
|
MATCHER_P2(HasVariantProperty,
|
||||||
name,
|
name,
|
||||||
value,
|
value,
|
||||||
std::format("{} have {})", (negation ? "Does't " : "Does "), variantPropStr(name, value)))
|
std::string(negation ? "hasn't " : "has ") + variantPropStr(name, value))
|
||||||
{
|
{
|
||||||
ModelNode n = arg;
|
ModelNode n = arg;
|
||||||
return n.hasVariantProperty(name) && n.variantProperty(name).value() == value;
|
return n.hasVariantProperty(name) && n.variantProperty(name).value() == value;
|
||||||
@@ -83,10 +68,8 @@ MATCHER_P2(HasVariantProperty,
|
|||||||
MATCHER_P2(HasGroupVariantProperty,
|
MATCHER_P2(HasGroupVariantProperty,
|
||||||
groupName,
|
groupName,
|
||||||
themeProp,
|
themeProp,
|
||||||
std::format("{} have node {} with {})",
|
std::string(negation ? "hasn't node " : "has node ") + groupName.toStdString() + " with "
|
||||||
(negation ? "Does't " : "Does "),
|
+ PrintToString(themeProp))
|
||||||
groupName.constData(),
|
|
||||||
PrintToString(themeProp)))
|
|
||||||
{
|
{
|
||||||
ModelNode n = arg;
|
ModelNode n = arg;
|
||||||
|
|
||||||
@@ -99,10 +82,8 @@ MATCHER_P2(HasGroupVariantProperty,
|
|||||||
MATCHER_P2(HasGroupBindingProperty,
|
MATCHER_P2(HasGroupBindingProperty,
|
||||||
groupName,
|
groupName,
|
||||||
themeProp,
|
themeProp,
|
||||||
std::format("{} have node {} with {})",
|
std::string(negation ? "hasn't node " : "has node ") + groupName.toStdString() + " with "
|
||||||
(negation ? "Does't " : "Does "),
|
+ PrintToString(themeProp))
|
||||||
groupName.constData(),
|
|
||||||
PrintToString(themeProp)))
|
|
||||||
{
|
{
|
||||||
ModelNode n = arg;
|
ModelNode n = arg;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user