diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2020-08-13 08:34:24 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2020-08-13 06:39:40 +0000 |
commit | 4fe5b923cddc9110094a883b5b7dd3051d8c8d90 (patch) | |
tree | 34e3984ab983882423bc563542a041b99b35f065 /tests/auto | |
parent | 24ca17f714ec133acc2bf0fd93c051ef730d69dc (diff) | |
parent | dc870f538dd3e11464a3ece179edf024161e14ba (diff) |
Merge remote-tracking branch 'origin/qds-1.59' into 4.13
Change-Id: Ic720f3adab305c5ef8cd10e713ccabf510eff0c0
Diffstat (limited to 'tests/auto')
5 files changed, 148 insertions, 11 deletions
diff --git a/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt b/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt index 83f9da98a0..fb22fbf06b 100644 --- a/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt +++ b/tests/auto/qml/qmldesigner/coretests/CMakeLists.txt @@ -17,4 +17,5 @@ add_qtc_test(tst_qml_testcore ../testview.cpp ../testview.h testrewriterview.cpp testrewriterview.h tst_testcore.cpp tst_testcore.h + ../testconnectionmanager.cpp ../testconnectionmanager.h ) diff --git a/tests/auto/qml/qmldesigner/coretests/coretests.pro b/tests/auto/qml/qmldesigner/coretests/coretests.pro index 7afb0fda2e..c179025da5 100644 --- a/tests/auto/qml/qmldesigner/coretests/coretests.pro +++ b/tests/auto/qml/qmldesigner/coretests/coretests.pro @@ -61,11 +61,13 @@ TEMPLATE = app SOURCES += \ ../testview.cpp \ testrewriterview.cpp \ - tst_testcore.cpp + tst_testcore.cpp \ + ../testconnectionmanager.cpp HEADERS += \ ../testview.h \ testrewriterview.h \ - tst_testcore.h + tst_testcore.h \ + ../testconnectionmanager.h RESOURCES += ../data/testfiles.qrc diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp index fc5d9dcfa9..965d9b7aee 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp @@ -46,11 +46,12 @@ #include <stylesheetmerger.h> #include <QDebug> +#include "../testconnectionmanager.h" #include "../testview.h" -#include <variantproperty.h> #include <abstractproperty.h> #include <bindingproperty.h> #include <nodeproperty.h> +#include <variantproperty.h> #include <nodelistproperty.h> #include <nodeabstractproperty.h> @@ -1999,8 +2000,9 @@ void tst_TestCore::testModelRemoveNode() QVERIFY(view.data()); model->attachView(view.data()); - NodeInstanceView *nodeInstanceView = new NodeInstanceView(model.data(), NodeInstanceServerInterface::TestModus); - model->attachView(nodeInstanceView); + TestConnectionManager connectionManager; + NodeInstanceView nodeInstanceView{connectionManager}; + model->attachView(&nodeInstanceView); QCOMPARE(view->rootModelNode().directSubModelNodes().count(), 0); @@ -2051,7 +2053,7 @@ void tst_TestCore::testModelRemoveNode() childNode = view->createModelNode("QtQuick.Item", 1, 1); childNode.destroy(); - model->detachView(nodeInstanceView); + model->detachView(&nodeInstanceView); } void tst_TestCore::reparentingNode() @@ -6140,17 +6142,21 @@ void tst_TestCore::testInstancesAttachToExistingModel() // Attach NodeInstanceView - QScopedPointer<NodeInstanceView> instanceView(new NodeInstanceView(0, NodeInstanceServerInterface::TestModus)); - QVERIFY(instanceView.data()); - model->attachView(instanceView.data()); + TestConnectionManager connectionManager; + + NodeInstanceView instanceView{connectionManager}; - NodeInstance rootInstance = instanceView->instanceForModelNode(rootNode); - NodeInstance rectangleInstance = instanceView->instanceForModelNode(rectangleNode); + model->attachView(&instanceView); + + NodeInstance rootInstance = instanceView.instanceForModelNode(rootNode); + NodeInstance rectangleInstance = instanceView.instanceForModelNode(rectangleNode); QVERIFY(rootInstance.isValid()); QVERIFY(rectangleInstance.isValid()); QCOMPARE(QVariant(100), rectangleInstance.property("width")); QVERIFY(rootInstance.instanceId() >= 0); QVERIFY(rectangleInstance.instanceId() >= 0); + + model->detachView(&instanceView); } void tst_TestCore::testQmlModelAddMultipleStates() diff --git a/tests/auto/qml/qmldesigner/testconnectionmanager.cpp b/tests/auto/qml/qmldesigner/testconnectionmanager.cpp new file mode 100644 index 0000000000..f637fb1f1a --- /dev/null +++ b/tests/auto/qml/qmldesigner/testconnectionmanager.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "testconnectionmanager.h" +#include "synchronizecommand.h" + +#include <QLocalSocket> + +namespace QmlDesigner { + +TestConnectionManager::TestConnectionManager() +{ + m_connections.emplace_back("Editor", "editormode"); +} + +void TestConnectionManager::writeCommand(const QVariant &command) +{ + TestConnectionManager::writeCommand(command); + + m_writeCommandCounter++; + + static int synchronizeId = 0; + synchronizeId++; + SynchronizeCommand synchronizeCommand(synchronizeId); + + QLocalSocket *socket = m_connections.front().socket.get(); + + writeCommandToIODevice(QVariant::fromValue(synchronizeCommand), socket, m_writeCommandCounter); + m_writeCommandCounter++; + + while (socket->waitForReadyRead(100)) { + readDataStream(m_connections.front()); + if (m_synchronizeId == synchronizeId) + return; + } +} + +void TestConnectionManager::dispatchCommand(const QVariant &command, Connection &connection) +{ + static const int synchronizeCommandType = QMetaType::type("SynchronizeCommand"); + + if (command.userType() == synchronizeCommandType) { + SynchronizeCommand synchronizeCommand = command.value<SynchronizeCommand>(); + m_synchronizeId = synchronizeCommand.synchronizeId(); + } else { + ConnectionManager::dispatchCommand(command, connection); + } +} + +} // namespace QmlDesigner diff --git a/tests/auto/qml/qmldesigner/testconnectionmanager.h b/tests/auto/qml/qmldesigner/testconnectionmanager.h new file mode 100644 index 0000000000..6ea44c1c1d --- /dev/null +++ b/tests/auto/qml/qmldesigner/testconnectionmanager.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <connectionmanager.h> + +#include <QFile> +#include <QPointer> +#include <QProcess> +#include <QTimer> + +QT_BEGIN_NAMESPACE +class QLocalServer; +class QLocalSocket; +QT_END_NAMESPACE + +namespace QmlDesigner { + +class TestConnectionManager final : public ConnectionManager +{ +public: + TestConnectionManager(); + + void writeCommand(const QVariant &command) override; + +protected: + void dispatchCommand(const QVariant &command, Connection &connection) override; + +private: + int m_synchronizeId = -1; +}; + +} // namespace QmlDesigner |