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
|
||||
DEPENDS
|
||||
QmlDesignerUtils DesignSystem
|
||||
SOURCES
|
||||
dsthemegroup-test.cpp
|
||||
dsthememgr-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;
|
||||
|
||||
namespace {
|
||||
constexpr const char testPropertyNameFoo[] = "propFoo";
|
||||
constexpr const char testPropertyNameBar[] = "propBar";
|
||||
QByteArray testPropertyNameFoo = "propFoo";
|
||||
QByteArray testPropertyNameBar = "propBar";
|
||||
|
||||
constexpr QmlDesigner::ThemeId themeId1 = 0;
|
||||
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;
|
||||
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 std::optional<ThemeProperty> prop = group.propertyValue(themeId, themeProp.name);
|
||||
|
@@ -11,8 +11,6 @@
|
||||
|
||||
#include <designsystem/dsthememanager.h>
|
||||
|
||||
#include <format>
|
||||
|
||||
using QmlDesigner::DSThemeManager;
|
||||
using QmlDesigner::GroupType;
|
||||
using QmlDesigner::Import;
|
||||
@@ -30,9 +28,7 @@ MATCHER_P3(HasProperty,
|
||||
themeId,
|
||||
group,
|
||||
themeProp,
|
||||
std::format("Collection {} have a property {}",
|
||||
(negation ? "Does't " : "Does "),
|
||||
PrintToString(themeProp)))
|
||||
std::string(negation ? "hasn't " : "has ") + PrintToString(themeProp))
|
||||
{
|
||||
const DSThemeManager &mgr = arg;
|
||||
const std::optional<ThemeProperty> prop = mgr.property(themeId, group, themeProp.name);
|
||||
|
@@ -13,8 +13,9 @@
|
||||
#include <designsystem/dsthemegroup.h>
|
||||
#include <designsystem/dsthememanager.h>
|
||||
|
||||
#include <format>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
using QmlDesigner::DSThemeManager;
|
||||
using QmlDesigner::GroupType;
|
||||
@@ -22,40 +23,24 @@ using QmlDesigner::Import;
|
||||
using QmlDesigner::ModelNode;
|
||||
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 {
|
||||
|
||||
static std::string formatedPropStr(const char tag[], const char name[], const QVariant &v)
|
||||
std::string formatedPropStr(std::string tag, const QByteArray &name, const QVariant &value)
|
||||
{
|
||||
return std::format("{}Property({}, {})", tag, name, v.toString().toStdString());
|
||||
return tag + "Property(" + name.toStdString() + ", " + value.toString().toStdString() + ")";
|
||||
}
|
||||
|
||||
static auto bindingPropStr = std::bind(&formatedPropStr,
|
||||
"Binding",
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2);
|
||||
static auto variantPropStr = std::bind(&formatedPropStr,
|
||||
"Variant",
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2);
|
||||
auto bindingPropStr = std::bind_front(&formatedPropStr, "Binding");
|
||||
auto variantPropStr = std::bind_front(&formatedPropStr, "Variant");
|
||||
|
||||
constexpr const char testPropertyName1[] = "prop1";
|
||||
constexpr const char darkThemeName[] = "dark";
|
||||
QByteArray testPropertyName1 = "prop1";
|
||||
QByteArray darkThemeName = "dark";
|
||||
constexpr QmlDesigner::ThemeId testThemeId = 1;
|
||||
|
||||
MATCHER_P2(HasNodeProperty,
|
||||
name,
|
||||
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;
|
||||
return n.hasNodeProperty(name) && n.nodeProperty(name).modelNode().isValid()
|
||||
@@ -65,7 +50,7 @@ MATCHER_P2(HasNodeProperty,
|
||||
MATCHER_P2(HasBindingProperty,
|
||||
name,
|
||||
value,
|
||||
std::format("{} have {})", (negation ? "Does't " : "Does "), bindingPropStr(name, value)))
|
||||
std::string(negation ? "hasn't " : "has ") + bindingPropStr(name, value))
|
||||
{
|
||||
ModelNode n = arg;
|
||||
return n.hasBindingProperty(name) && n.bindingProperty(name).expression() == value;
|
||||
@@ -74,7 +59,7 @@ MATCHER_P2(HasBindingProperty,
|
||||
MATCHER_P2(HasVariantProperty,
|
||||
name,
|
||||
value,
|
||||
std::format("{} have {})", (negation ? "Does't " : "Does "), variantPropStr(name, value)))
|
||||
std::string(negation ? "hasn't " : "has ") + variantPropStr(name, value))
|
||||
{
|
||||
ModelNode n = arg;
|
||||
return n.hasVariantProperty(name) && n.variantProperty(name).value() == value;
|
||||
@@ -83,10 +68,8 @@ MATCHER_P2(HasVariantProperty,
|
||||
MATCHER_P2(HasGroupVariantProperty,
|
||||
groupName,
|
||||
themeProp,
|
||||
std::format("{} have node {} with {})",
|
||||
(negation ? "Does't " : "Does "),
|
||||
groupName.constData(),
|
||||
PrintToString(themeProp)))
|
||||
std::string(negation ? "hasn't node " : "has node ") + groupName.toStdString() + " with "
|
||||
+ PrintToString(themeProp))
|
||||
{
|
||||
ModelNode n = arg;
|
||||
|
||||
@@ -99,10 +82,8 @@ MATCHER_P2(HasGroupVariantProperty,
|
||||
MATCHER_P2(HasGroupBindingProperty,
|
||||
groupName,
|
||||
themeProp,
|
||||
std::format("{} have node {} with {})",
|
||||
(negation ? "Does't " : "Does "),
|
||||
groupName.constData(),
|
||||
PrintToString(themeProp)))
|
||||
std::string(negation ? "hasn't node " : "has node ") + groupName.toStdString() + " with "
|
||||
+ PrintToString(themeProp))
|
||||
{
|
||||
ModelNode n = arg;
|
||||
|
||||
|
Reference in New Issue
Block a user