diff options
Diffstat (limited to 'tests')
22 files changed, 741 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro new file mode 100644 index 0000000..80475ba --- /dev/null +++ b/tests/auto/auto.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += repc integration cmake diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt new file mode 100644 index 0000000..62fc89a --- /dev/null +++ b/tests/auto/cmake/CMakeLists.txt @@ -0,0 +1,12 @@ + +cmake_minimum_required(VERSION 2.8) + +project(qmake_cmake_files) + +enable_testing() + +find_package(Qt5Core REQUIRED) + +include("${_Qt5CTestMacros}") + +expect_pass(test_qremoteobjects_module) diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro new file mode 100644 index 0000000..bf2dbcb --- /dev/null +++ b/tests/auto/cmake/cmake.pro @@ -0,0 +1,5 @@ + +# Cause make to do nothing. +TEMPLATE = subdirs + +CONFIG += ctest_testcase diff --git a/tests/auto/cmake/test_qremoteobjects_module/CMakeLists.txt b/tests/auto/cmake/test_qremoteobjects_module/CMakeLists.txt new file mode 100644 index 0000000..e4b3b0e --- /dev/null +++ b/tests/auto/cmake/test_qremoteobjects_module/CMakeLists.txt @@ -0,0 +1,32 @@ + +cmake_minimum_required(VERSION 2.8) + +project(test_qremoteobjects_module) + +find_package(Qt5Core REQUIRED) +find_package(Qt5Gui REQUIRED) +find_package(Qt5Network REQUIRED) + +find_package(Qt5RemoteObjects REQUIRED) + +include_directories( + ${Qt5RemoteObjects_INCLUDE_DIRS} + ${Qt5Core_INCLUDE_DIRS} + ${Qt5Network_INCLUDE_DIRS} +) + +add_definitions( + ${Qt5RemoteObjects_DEFINITIONS} + ${QtCore_DEFINITIONS} + ${Qt5Network_DEFINITIONS} +) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS} ${Qt5Network_EXECUTABLE_COMPILE_FLAGS} ${Qt5Replicant_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(mainapp main.cpp) + +target_link_libraries(mainapp + ${Qt5RemoteObjects_LIBRARIES} + ${Qt5Core_LIBRARIES} + ${Qt5Network_LIBRARIES} +) diff --git a/tests/auto/cmake/test_qremoteobjects_module/main.cpp b/tests/auto/cmake/test_qremoteobjects_module/main.cpp new file mode 100644 index 0000000..0887d07 --- /dev/null +++ b/tests/auto/cmake/test_qremoteobjects_module/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QRemoteObjectNode> + +int main(int argc, char **argv) +{ + QRemoteObjectNode node; + + return 0; +} diff --git a/tests/auto/integration/.gitignore b/tests/auto/integration/.gitignore new file mode 100644 index 0000000..151e5e1 --- /dev/null +++ b/tests/auto/integration/.gitignore @@ -0,0 +1 @@ +/integration diff --git a/tests/auto/integration/Engine.cpp b/tests/auto/integration/Engine.cpp new file mode 100644 index 0000000..5beaf5e --- /dev/null +++ b/tests/auto/integration/Engine.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "Engine.h" + +Engine::Engine(QObject *parent) : + EngineSource(parent) +{ + setRpm(0); +} + +Engine::~Engine() +{ +} diff --git a/tests/auto/integration/Engine.h b/tests/auto/integration/Engine.h new file mode 100644 index 0000000..5b068d1 --- /dev/null +++ b/tests/auto/integration/Engine.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TESTS_ENGINE_H +#define TESTS_ENGINE_H + +#include "rep_engine_source.h" + +class Engine : public EngineSource +{ + Q_OBJECT +public: + Engine(QObject *parent=Q_NULLPTR); + virtual ~Engine(); + +private: + int speed; +}; + +#endif diff --git a/tests/auto/integration/RemoteObjectTest.h b/tests/auto/integration/RemoteObjectTest.h new file mode 100644 index 0000000..f82583c --- /dev/null +++ b/tests/auto/integration/RemoteObjectTest.h @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TESTS_REMOTEOBJECTTEST_H +#define TESTS_REMOTEOBJECTTEST_H + +#include <QtTest/QtTest> +#include <QMetaType> +#include <qremoteobjectreplica.h> +#include <QRemoteObjectNode> +#include "Engine.h" +#include "Speedometer.h" +#include "rep_engine_replica.h" +#include "rep_speedometer_replica.h" +#include "rep_localdatacenter_source.h" +#include "rep_tcpdatacenter_source.h" +#include "rep_localdatacenter_replica.h" +#include "rep_tcpdatacenter_replica.h" + +//DUMMY impl for variant comparison +bool operator<(const QVector<int> &lhs, const QVector<int> &rhs) +{ + return lhs.size() < rhs.size(); +} + +class RemoteObjectTest: public QObject +{ + Q_OBJECT + QRemoteObjectNode m_client; + QRemoteObjectNode m_registryClient; + QRemoteObjectNode m_basicServer; + QRemoteObjectNode m_localCentreServer; + QRemoteObjectNode m_tcpCentreServer; + QRemoteObjectNode m_registryServer; +private slots: + + void initTestCase() { + QLoggingCategory::setFilterRules("*.debug=true\n" + "qt.remoteobjects.debug=false\n" + "qt.remoteobjects.warning=false"); + //Setup registry + //Registry needs to be created first until we get the retry mechanism implemented + m_registryServer = QRemoteObjectNode::createRegistryHostNode(); + + m_client = QRemoteObjectNode(); + m_registryClient = QRemoteObjectNode::createNodeConnectedToRegistry(); + //m_client.setObjectName("DirectTestClient"); + //m_registryClient.setObjectName("RegistryTestClient"); + + m_basicServer = QRemoteObjectNode::createHostNode(QUrl("tcp://localhost:9999")); + + engine.reset(new Engine); + speedometer.reset(new Speedometer); + m_basicServer.enableRemoting(engine.data()); + m_basicServer.enableRemoting(speedometer.data()); + + m_client.connect(QUrl("tcp://localhost:9999")); + + //setup servers + qRegisterMetaType<QVector<int> >(); + QMetaType::registerComparators<QVector<int> >(); + qRegisterMetaTypeStreamOperators<QVector<int> >(); + m_localCentreServer = QRemoteObjectNode::createHostNodeConnectedToRegistry(); + dataCenterLocal.reset(new LocalDataCenterSource); + dataCenterLocal->setData1(5); + dataCenterLocal->setData2(5.0); + dataCenterLocal->setData3(QStringLiteral("local")); + dataCenterLocal->setData4(QVector<int>() << 1 << 2 << 3 << 4 << 5); + m_localCentreServer.enableRemoting(dataCenterLocal.data()); + + m_tcpCentreServer = QRemoteObjectNode::createHostNodeConnectedToRegistry(QUrl("tcp://localhost:19999")); + dataCenterTcp.reset(new TcpDataCenterSource); + dataCenterTcp->setData1(5); + dataCenterTcp->setData2(5.0); + dataCenterTcp->setData3(QStringLiteral("tcp")); + dataCenterTcp->setData4(QVector<int>() << 1 << 2 << 3 << 4 << 5); + m_tcpCentreServer.enableRemoting(dataCenterTcp.data()); + + //Setup the client + //QVERIFY(m_registryClient.connect( QStringLiteral("local:replica"))); + } + + void RegistryTest() { + QSharedPointer<TcpDataCenterReplica> tcpCentre(m_registryClient.acquire<TcpDataCenterReplica>()); + QSharedPointer<LocalDataCenterReplica> localCentre(m_registryClient.acquire<LocalDataCenterReplica>()); + tcpCentre->waitForSource(); + localCentre->waitForSource(); + QCOMPARE(m_registryClient.registry()->sourceLocations(), m_registryServer.registry()->sourceLocations()); + QVERIFY(localCentre->isInitialized()); + QVERIFY(tcpCentre->isInitialized()); + + QCOMPARE(tcpCentre->data1(), 5 ); + QCOMPARE(tcpCentre->data2(), 5.0); + QCOMPARE(tcpCentre->data3(), QStringLiteral("tcp")); + QCOMPARE(tcpCentre->data4(), QVector<int>() << 1 << 2 << 3 << 4 << 5); + + QCOMPARE(localCentre->data1(), 5); + QCOMPARE(localCentre->data2(), 5.0); + QCOMPARE(localCentre->data3(), QStringLiteral("local")); + QCOMPARE(localCentre->data4(), QVector<int>() << 1 << 2 << 3 << 4 << 5); + + } + + void basicTest() { + engine->setRpm(1234); + + QSharedPointer<EngineReplica> engine_r(m_client.acquire<EngineReplica>()); + engine_r->waitForSource(); + QCOMPARE(engine_r->rpm(), 1234); + } + + void sequentialReplicaTest() { + engine->setRpm(3456); + + QSharedPointer<EngineReplica> engine_r(m_client.acquire<EngineReplica>()); + engine_r->waitForSource(); + QCOMPARE(engine_r->rpm(), 3456); + + engine_r = QSharedPointer<EngineReplica>(m_client.acquire< EngineReplica >()); + engine_r->waitForSource(); + QCOMPARE(engine_r->rpm(), 3456); + } + + void doubleReplicaTest() { + QSharedPointer<EngineReplica> engine_r1(m_client.acquire< EngineReplica >()); + QSharedPointer<EngineReplica> engine_r2(m_client.acquire< EngineReplica >()); + engine->setRpm(3412); + + engine_r1->waitForSource(); + engine_r2->waitForSource(); + + QCOMPARE(engine_r1->rpm(), 3412); + QCOMPARE(engine_r2->rpm(), 3412); + } + + void twoReplicaTest() { + engine->setRpm(1234); + speedometer->setMph(70); + + QSharedPointer<EngineReplica> engine_r(m_client.acquire<EngineReplica>()); + engine_r->waitForSource(); + QSharedPointer<SpeedometerReplica> speedometer_r(m_client.acquire<SpeedometerReplica>()); + speedometer_r->waitForSource(); + + QCOMPARE(engine_r->rpm(), 1234); + QCOMPARE(speedometer_r->mph(), 70); + } + + void dynamicReplicaTest() { + QRemoteObjectDynamicReplica *rep1 = m_registryClient.acquire("TcpDataCenter"); + QRemoteObjectDynamicReplica *rep2 = m_registryClient.acquire("TcpDataCenter"); + QRemoteObjectDynamicReplica *rep3 = m_registryClient.acquire("LocalDataCenter"); + rep1->waitForSource(); + rep2->waitForSource(); + rep3->waitForSource(); + const QMetaObject *metaTcpRep1 = rep1->metaObject(); + const QMetaObject *metaLocalRep1 = rep3->metaObject(); + const QMetaObject *metaTcpSource = dataCenterTcp->metaObject(); + const QMetaObject *metaLocalSource = dataCenterLocal->metaObject(); + QVERIFY(rep1->isInitialized()); + QVERIFY(rep2->isInitialized()); + QVERIFY(rep3->isInitialized()); + + for (int i = 0; i < metaTcpRep1->propertyCount(); ++i) + { + const QMetaProperty propLhs = metaTcpRep1->property(i); + const QMetaProperty propRhs = metaTcpSource->property(metaTcpSource->indexOfProperty(propLhs.name())); + QCOMPARE(propLhs.notifySignalIndex(), propRhs.notifySignalIndex()); + QCOMPARE(propLhs.read(rep1), propRhs.read(dataCenterTcp.data())); + QCOMPARE(propLhs.read(rep2), propRhs.read(rep1)); + } + for (int i = 0; i < metaLocalRep1->propertyCount(); ++i ) + { + const QMetaProperty propLhs = metaLocalRep1->property(i); + const QMetaProperty propRhs = metaLocalSource->property(metaTcpSource->indexOfProperty(propLhs.name())); + QCOMPARE(propLhs.notifySignalIndex(), propRhs.notifySignalIndex()); + QCOMPARE(propLhs.read(rep3), propRhs.read(dataCenterLocal.data())); + } + + } + +private: + QScopedPointer<Engine> engine; + QScopedPointer<Speedometer> speedometer; + QScopedPointer<TcpDataCenterSource> dataCenterTcp; + QScopedPointer<LocalDataCenterSource> dataCenterLocal; +}; + +QTEST_MAIN(RemoteObjectTest) + +#endif diff --git a/tests/auto/integration/Speedometer.cpp b/tests/auto/integration/Speedometer.cpp new file mode 100644 index 0000000..50a35af --- /dev/null +++ b/tests/auto/integration/Speedometer.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "Speedometer.h" + +Speedometer::Speedometer(QObject *parent) : + SpeedometerSource(parent) +{ +} + +Speedometer::~Speedometer() +{ +} diff --git a/tests/auto/integration/Speedometer.h b/tests/auto/integration/Speedometer.h new file mode 100644 index 0000000..71c8645 --- /dev/null +++ b/tests/auto/integration/Speedometer.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TESTS_SPEEDOMETER_H +#define TESTS_SPEEDOMETER_H + +#include "rep_speedometer_source.h" + +class Speedometer : public SpeedometerSource +{ + Q_OBJECT +public: + Speedometer(QObject *parent=Q_NULLPTR); + virtual ~Speedometer(); + +private: + int speed; +}; + +#endif diff --git a/tests/auto/integration/engine.rep b/tests/auto/integration/engine.rep new file mode 100644 index 0000000..4bdba22 --- /dev/null +++ b/tests/auto/integration/engine.rep @@ -0,0 +1,5 @@ +#include <QtCore> +class Engine +{ + PROP(int rpm); +}; diff --git a/tests/auto/integration/integration.pro b/tests/auto/integration/integration.pro new file mode 100644 index 0000000..977b3f8 --- /dev/null +++ b/tests/auto/integration/integration.pro @@ -0,0 +1,24 @@ +QT += network testlib + +QT -= gui + +OTHER_FILES = engine.rep \ + speedometer.rep \ + ../repfiles/localdatacenter.rep \ + ../repfiles/tcpdatacenter.rep + +REPC_SOURCE += $$OTHER_FILES +REPC_REPLICA += $$OTHER_FILES +QT += remoteobjects + +CONFIG += testcase + +HEADERS += $$PWD/RemoteObjectTest.h \ + $$PWD/Engine.h \ + $$PWD/Speedometer.h + +SOURCES += $$PWD/Engine.cpp \ + $$PWD/Speedometer.cpp + +contains(QT_CONFIG, c++11): CONFIG += c++11 + diff --git a/tests/auto/integration/speedometer.rep b/tests/auto/integration/speedometer.rep new file mode 100644 index 0000000..291adb3 --- /dev/null +++ b/tests/auto/integration/speedometer.rep @@ -0,0 +1,5 @@ +#include <QtCore> +class Speedometer +{ + PROP(int mph); +}; diff --git a/tests/auto/repc/pods/.gitignore b/tests/auto/repc/pods/.gitignore new file mode 100644 index 0000000..ccb20c9 --- /dev/null +++ b/tests/auto/repc/pods/.gitignore @@ -0,0 +1 @@ +tst_pods diff --git a/tests/auto/repc/pods/pods.pro b/tests/auto/repc/pods/pods.pro new file mode 100644 index 0000000..db7188c --- /dev/null +++ b/tests/auto/repc/pods/pods.pro @@ -0,0 +1,13 @@ +CONFIG += testcase parallel_test +TARGET = tst_pods +QT += testlib remoteobjects +QT -= gui + +SOURCES += tst_pods.cpp + +REP_FILES = pods.rep + +#REPC_SOURCE = $$REP_FILES # can't have both source and replica in the same process if PODs are involved... +REPC_REPLICA = $$REP_FILES + +contains(QT_CONFIG, c++11):CONFIG += c++11 diff --git a/tests/auto/repc/pods/pods.rep b/tests/auto/repc/pods/pods.rep new file mode 100644 index 0000000..da9a0ca --- /dev/null +++ b/tests/auto/repc/pods/pods.rep @@ -0,0 +1,6 @@ +#include <QString> + +POD PodI(int i) +POD PodF(float f) +POD PodS(QString s) +POD PodIFS(int i, float f, QString s) diff --git a/tests/auto/repc/pods/tst_pods.cpp b/tests/auto/repc/pods/tst_pods.cpp new file mode 100644 index 0000000..fc3112a --- /dev/null +++ b/tests/auto/repc/pods/tst_pods.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "rep_pods_replica.h" + +#include <QTest> + +#include <QByteArray> +#include <QDataStream> + +class tst_Pods : public QObject { + Q_OBJECT + +private Q_SLOTS: + void testConstructors(); + void testParent(); + void testMarshaling(); +}; + + +void tst_Pods::testConstructors() +{ + PodI pi1; + QCOMPARE(pi1.i(), 0); + + PodI pi2(1); + QCOMPARE(pi2.i(), 1); + + PodI pi3(pi2); + QCOMPARE(pi3.i(), pi2.i()); + + PodI pi4(static_cast<QObject*>(Q_NULLPTR)); + QCOMPARE(pi4.i(), 0); + + PodI pi5(1, static_cast<QObject*>(Q_NULLPTR)); + QCOMPARE(pi5.i(), 1); +} + +void tst_Pods::testParent() +{ + PodI pi; + QVERIFY(!pi.parent()); +} + +void tst_Pods::testMarshaling() +{ + QByteArray ba; + QDataStream ds(&ba, QIODevice::ReadWrite); + + { + PodI i1(1), i2(2), i3(3), iDeadBeef(0xdeadbeef); + Q_SET_OBJECT_NAME(i1); + Q_SET_OBJECT_NAME(i2); + Q_SET_OBJECT_NAME(i3); + Q_SET_OBJECT_NAME(iDeadBeef); + ds << i1 << i2 << i3 << iDeadBeef; + } + + ds.device()->seek(0); + + { + PodI i1, i2, i3, iDeadBeef; + ds >> i1 >> i2 >> i3 >> iDeadBeef; + + QCOMPARE(i1.objectName(), QLatin1String("i1")); + QCOMPARE(i2.objectName(), QLatin1String("i2")); + QCOMPARE(i3.objectName(), QLatin1String("i3")); + QCOMPARE(iDeadBeef.objectName(), QLatin1String("iDeadBeef")); + + QCOMPARE(i1.i(), 1); + QCOMPARE(i2.i(), 2); + QCOMPARE(i3.i(), 3); + QCOMPARE(iDeadBeef.i(), int(0xdeadbeef)); + } +} + +QTEST_APPLESS_MAIN(tst_Pods) + +#include "tst_pods.moc" diff --git a/tests/auto/repc/repc.pro b/tests/auto/repc/repc.pro new file mode 100644 index 0000000..b0bb9e1 --- /dev/null +++ b/tests/auto/repc/repc.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += pods diff --git a/tests/auto/repfiles/localdatacenter.rep b/tests/auto/repfiles/localdatacenter.rep new file mode 100644 index 0000000..6f0f7c9 --- /dev/null +++ b/tests/auto/repfiles/localdatacenter.rep @@ -0,0 +1,8 @@ +#include <QtCore> +class LocalDataCenter +{ + PROP(int data1); + PROP(float data2); + PROP(QString data3); + PROP(QVector<int> data4); +}; diff --git a/tests/auto/repfiles/tcpdatacenter.rep b/tests/auto/repfiles/tcpdatacenter.rep new file mode 100644 index 0000000..bfd26c2 --- /dev/null +++ b/tests/auto/repfiles/tcpdatacenter.rep @@ -0,0 +1,8 @@ +#include <QtCore> +class TcpDataCenter +{ + PROP(int data1); + PROP(float data2); + PROP(QString data3); + PROP(QVector<int> data4); +}; diff --git a/tests/tests.pro b/tests/tests.pro new file mode 100644 index 0000000..568bdf7 --- /dev/null +++ b/tests/tests.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +CONFIG += debug_and_release +SUBDIRS = auto |