2022-08-19 15:59:36 +02:00
|
|
|
// 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
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
#include "testview.h"
|
|
|
|
|
|
2012-08-06 13:42:46 +02:00
|
|
|
#include <QDebug>
|
2012-10-08 12:53:54 +02:00
|
|
|
#include <QUrl>
|
2010-01-07 12:14:35 +01:00
|
|
|
#include <qtestcase.h>
|
2010-09-23 15:36:39 +02:00
|
|
|
#include <abstractproperty.h>
|
|
|
|
|
#include <bindingproperty.h>
|
|
|
|
|
#include <variantproperty.h>
|
2016-06-08 20:21:24 +02:00
|
|
|
#include <signalhandlerproperty.h>
|
2010-09-23 15:36:39 +02:00
|
|
|
#include <nodelistproperty.h>
|
2010-09-23 15:53:55 +02:00
|
|
|
#include <nodeinstanceview.h>
|
|
|
|
|
#include <model.h>
|
2016-06-08 20:21:24 +02:00
|
|
|
#include <nodeinstanceview.h>
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2010-09-23 15:53:55 +02:00
|
|
|
TestView::TestView(QmlDesigner::Model *model)
|
2016-06-08 20:21:24 +02:00
|
|
|
: QmlDesigner::AbstractView(model)
|
2010-01-07 12:14:35 +01:00
|
|
|
{
|
2016-06-08 20:21:24 +02:00
|
|
|
/*
|
2011-01-18 19:38:01 +01:00
|
|
|
QmlDesigner::NodeInstanceView *nodeInstanceView = new QmlDesigner::NodeInstanceView(model, QmlDesigner::NodeInstanceServerInterface::TestModus);
|
2010-09-23 15:53:55 +02:00
|
|
|
|
2016-06-08 20:21:24 +02:00
|
|
|
if (model)
|
|
|
|
|
model->setNodeInstanceView(nodeInstanceView);
|
|
|
|
|
*/
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::modelAttached(QmlDesigner::Model *model)
|
|
|
|
|
{
|
2016-06-08 20:21:24 +02:00
|
|
|
QmlDesigner::AbstractView::modelAttached(model);
|
2021-07-16 20:21:44 +02:00
|
|
|
m_methodCalls += MethodCall("modelAttached", QStringList() << QString::number(reinterpret_cast<qint64>(model)));
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::modelAboutToBeDetached(QmlDesigner::Model *model)
|
|
|
|
|
{
|
2016-06-08 20:21:24 +02:00
|
|
|
QmlDesigner::AbstractView::modelAboutToBeDetached(model);
|
2021-07-16 20:21:44 +02:00
|
|
|
m_methodCalls += MethodCall("modelAboutToBeDetached", QStringList() << QString::number(reinterpret_cast<qint64>(model)));
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::nodeIdChanged(const QmlDesigner::ModelNode &node, const QString& newId, const QString &oldId)
|
|
|
|
|
{
|
|
|
|
|
m_methodCalls += MethodCall("nodeIdChanged", QStringList() << node.id() << newId << oldId);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-10 13:02:49 +01:00
|
|
|
void TestView::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion)
|
2010-01-07 12:14:35 +01:00
|
|
|
{
|
2010-02-10 13:02:49 +01:00
|
|
|
m_methodCalls += MethodCall("rootNodeTypeChanged", QStringList() << rootModelNode().id() << type << QString::number(majorVersion) << QString::number(minorVersion));
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::fileUrlChanged(const QUrl & oldBaseUrl, const QUrl &newBaseUrl)
|
|
|
|
|
{
|
|
|
|
|
m_methodCalls += MethodCall("fileUrlChanged", QStringList() << oldBaseUrl.toString() << newBaseUrl.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::propertiesAboutToBeRemoved(const QList<QmlDesigner::AbstractProperty>& propertyList)
|
|
|
|
|
{
|
|
|
|
|
QStringList propertyNames;
|
|
|
|
|
foreach (const QmlDesigner::AbstractProperty &property, propertyList)
|
2016-06-08 20:21:24 +02:00
|
|
|
propertyNames += QString::fromUtf8(property.name());
|
2010-01-07 12:14:35 +01:00
|
|
|
m_methodCalls += MethodCall("propertiesAboutToBeRemoved", QStringList() << propertyNames.join(", "));
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-08 20:21:24 +02:00
|
|
|
void TestView::propertiesRemoved(const QList<QmlDesigner::AbstractProperty> &propertyList)
|
|
|
|
|
{
|
|
|
|
|
QStringList propertyNames;
|
|
|
|
|
foreach (const QmlDesigner::AbstractProperty &property, propertyList)
|
|
|
|
|
propertyNames += QString::fromUtf8(property.name());
|
|
|
|
|
m_methodCalls += MethodCall("propertiesRemoved", QStringList() << propertyNames.join(", "));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::signalHandlerPropertiesChanged(const QVector<QmlDesigner::SignalHandlerProperty> &propertyList, PropertyChangeFlags )
|
|
|
|
|
{
|
|
|
|
|
QStringList propertyNames;
|
|
|
|
|
foreach (const QmlDesigner::AbstractProperty &property, propertyList)
|
|
|
|
|
propertyNames += QString::fromUtf8(property.name());
|
|
|
|
|
m_methodCalls += MethodCall("signalHandlerPropertiesChanged", QStringList() << propertyNames.join(", "));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::importsChanged(const QList<QmlDesigner::Import> &, const QList<QmlDesigner::Import> &)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
void TestView::nodeCreated(const QmlDesigner::ModelNode &createdNode)
|
|
|
|
|
{
|
|
|
|
|
m_methodCalls += MethodCall("nodeCreated", QStringList() << createdNode.id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::nodeAboutToBeRemoved(const QmlDesigner::ModelNode &removedNode)
|
|
|
|
|
{
|
|
|
|
|
m_methodCalls += MethodCall("nodeAboutToBeRemoved", QStringList() << removedNode.id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::nodeRemoved(const QmlDesigner::ModelNode &removedNode, const QmlDesigner::NodeAbstractProperty &parentProperty, AbstractView::PropertyChangeFlags propertyChange)
|
|
|
|
|
{
|
2016-06-08 20:21:24 +02:00
|
|
|
const QString parentPropertyName = parentProperty.isValid() ? QString::fromUtf8(parentProperty.name()) : QLatin1String("");
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2016-06-08 20:21:24 +02:00
|
|
|
m_methodCalls += MethodCall("nodeRemoved", QStringList() << QString::number(removedNode.internalId()) << parentPropertyName << serialize(propertyChange));
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TestView::nodeReparented(const QmlDesigner::ModelNode & node, const QmlDesigner::NodeAbstractProperty &newPropertyParent, const QmlDesigner::NodeAbstractProperty & oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange)
|
|
|
|
|
{
|
2016-06-08 20:21:24 +02:00
|
|
|
m_methodCalls += MethodCall("nodeReparented", QStringList() << node.id() << QString::fromUtf8(newPropertyParent.name()) << QString::fromUtf8(oldPropertyParent.name()) << serialize(propertyChange));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::nodeAboutToBeReparented(const QmlDesigner::ModelNode &node, const QmlDesigner::NodeAbstractProperty &newPropertyParent, const QmlDesigner::NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange)
|
|
|
|
|
{
|
|
|
|
|
m_methodCalls += MethodCall("nodeAboutToBeReparented", QStringList() << node.id() << QString::fromUtf8(newPropertyParent.name()) << QString::fromUtf8(oldPropertyParent.name()) << serialize(propertyChange));
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::bindingPropertiesChanged(const QList<QmlDesigner::BindingProperty>& propertyList, PropertyChangeFlags propertyChange)
|
|
|
|
|
{
|
|
|
|
|
QStringList propertyNames;
|
|
|
|
|
foreach (const QmlDesigner::BindingProperty &property, propertyList)
|
2016-06-08 20:21:24 +02:00
|
|
|
propertyNames += QString::fromUtf8(property.name());
|
2010-01-07 12:14:35 +01:00
|
|
|
m_methodCalls += MethodCall("bindingPropertiesChanged", QStringList() << propertyNames.join(", ") << serialize(propertyChange));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::variantPropertiesChanged(const QList<QmlDesigner::VariantProperty>& propertyList, PropertyChangeFlags propertyChange)
|
|
|
|
|
{
|
|
|
|
|
QStringList propertyNames;
|
|
|
|
|
foreach (const QmlDesigner::VariantProperty &property, propertyList)
|
2016-06-08 20:21:24 +02:00
|
|
|
propertyNames += QString::fromUtf8(property.name());
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
m_methodCalls += MethodCall("variantPropertiesChanged", QStringList() << propertyNames.join(", ") << serialize(propertyChange));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::selectedNodesChanged(const QList<QmlDesigner::ModelNode> &selectedNodeList,
|
|
|
|
|
const QList<QmlDesigner::ModelNode> &lastSelectedNodeList)
|
|
|
|
|
{
|
|
|
|
|
QStringList selectedNodes;
|
|
|
|
|
foreach (const QmlDesigner::ModelNode &node, selectedNodeList)
|
|
|
|
|
selectedNodes += node.id();
|
|
|
|
|
QStringList lastSelectedNodes;
|
|
|
|
|
foreach (const QmlDesigner::ModelNode &node, lastSelectedNodeList)
|
|
|
|
|
lastSelectedNodes += node.id();
|
|
|
|
|
m_methodCalls += MethodCall("selectedNodesChanged", QStringList() << selectedNodes.join(", ") << lastSelectedNodes.join(", "));
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 12:37:43 +02:00
|
|
|
void TestView::nodeOrderChanged(const QmlDesigner::NodeListProperty &listProperty)
|
2010-01-07 12:14:35 +01:00
|
|
|
{
|
2021-04-14 12:37:43 +02:00
|
|
|
m_methodCalls += MethodCall("nodeOrderChanged",
|
|
|
|
|
QStringList() << QString::fromUtf8(listProperty.name()));
|
2016-06-08 20:21:24 +02:00
|
|
|
}
|
|
|
|
|
|
2016-11-28 11:19:55 +01:00
|
|
|
void TestView::instancePropertyChanged(const QList<QPair<QmlDesigner::ModelNode, QmlDesigner::PropertyName> > &)
|
2016-06-08 20:21:24 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::instancesCompleted(const QVector<QmlDesigner::ModelNode> &)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 11:19:55 +01:00
|
|
|
void TestView::instanceInformationsChanged(const QMultiHash<QmlDesigner::ModelNode, QmlDesigner::InformationName> &)
|
2016-06-08 20:21:24 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::instancesRenderImageChanged(const QVector<QmlDesigner::ModelNode> &)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::instancesPreviewImageChanged(const QVector<QmlDesigner::ModelNode> &)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::instancesChildrenChanged(const QVector<QmlDesigner::ModelNode> &)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::instancesToken(const QString &, int, const QVector<QmlDesigner::ModelNode> &)
|
|
|
|
|
{
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
2016-06-08 20:21:24 +02:00
|
|
|
void TestView::nodeSourceChanged(const QmlDesigner::ModelNode &, const QString &)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::scriptFunctionsChanged(const QmlDesigner::ModelNode &, const QStringList &)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestView::currentStateChanged(const QmlDesigner::ModelNode &node)
|
2010-01-07 12:14:35 +01:00
|
|
|
{
|
2012-09-03 17:34:28 +02:00
|
|
|
m_methodCalls += MethodCall("actualStateChanged", QStringList() << node.id());
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<TestView::MethodCall> &TestView::methodCalls()
|
|
|
|
|
{
|
|
|
|
|
return m_methodCalls;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString TestView::lastFunction() const
|
|
|
|
|
{
|
|
|
|
|
return m_methodCalls.last().name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlDesigner::NodeInstanceView *TestView::nodeInstanceView() const
|
|
|
|
|
{
|
2016-06-08 20:21:24 +02:00
|
|
|
return QmlDesigner::AbstractView::nodeInstanceView();
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-08 20:21:24 +02:00
|
|
|
QmlDesigner::QmlObjectNode TestView::rootQmlObjectNode() const
|
2010-01-07 12:14:35 +01:00
|
|
|
{
|
2016-06-08 20:21:24 +02:00
|
|
|
return rootModelNode();
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
|
2016-06-08 20:21:24 +02:00
|
|
|
void TestView::setCurrentState(const QmlDesigner::QmlModelState &node)
|
|
|
|
|
{
|
|
|
|
|
setCurrentStateNode(node.modelNode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlDesigner::QmlItemNode TestView::rootQmlItemNode() const { return rootModelNode(); }
|
|
|
|
|
|
|
|
|
|
QmlDesigner::QmlModelState TestView::baseState() const { return rootModelNode(); }
|
|
|
|
|
|
|
|
|
|
QmlDesigner::QmlObjectNode TestView::createQmlObjectNode(const QmlDesigner::TypeName &typeName,
|
|
|
|
|
int majorVersion,
|
|
|
|
|
int minorVersion,
|
|
|
|
|
const QmlDesigner::PropertyListType &propertyList)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
return createModelNode(typeName, majorVersion, minorVersion, propertyList);
|
|
|
|
|
}
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
QString TestView::serialize(AbstractView::PropertyChangeFlags change)
|
|
|
|
|
{
|
|
|
|
|
QStringList tokenList;
|
|
|
|
|
|
|
|
|
|
if (change.testFlag(PropertiesAdded))
|
|
|
|
|
tokenList.append(QLatin1String("PropertiesAdded"));
|
|
|
|
|
|
|
|
|
|
if (change.testFlag(EmptyPropertiesRemoved))
|
|
|
|
|
tokenList.append(QLatin1String("EmptyPropertiesRemoved"));
|
|
|
|
|
|
|
|
|
|
return tokenList.join(" ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool operator==(TestView::MethodCall call1, TestView::MethodCall call2)
|
|
|
|
|
{
|
|
|
|
|
if (call1.name != call2.name)
|
|
|
|
|
return false;
|
|
|
|
|
// if (call1.arguments != call2.arguments)
|
|
|
|
|
// return false;
|
|
|
|
|
if (call1.arguments.size() != call2.arguments.size()) {
|
|
|
|
|
qWarning() << "different method names:" << call1.arguments.size() << call2.arguments.size();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < call1.arguments.size(); ++i)
|
|
|
|
|
if (call1.arguments.at(i) != call2.arguments.at(i)) {
|
|
|
|
|
qDebug() << "different argument values:" << call1.arguments.at(i) << call2.arguments.at(i);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDebug operator<<(QDebug debug, TestView::MethodCall call)
|
|
|
|
|
{
|
|
|
|
|
return debug.nospace() << call.name << "(" << call.arguments.join(", ") << ")";
|
|
|
|
|
}
|
|
|
|
|
|