summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/core/core.pro2
-rw-r--r--tests/auto/core/ivigenerator/custom-template/custom-template.pro7
-rw-r--r--tests/auto/core/ivigenerator/custom-template/custom-test.yaml10
-rw-r--r--tests/auto/core/ivigenerator/custom-template/custom-test/module.pri.tpl49
-rw-r--r--tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.cpp.tpl55
-rw-r--r--tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.h.tpl53
-rw-r--r--tests/auto/core/ivigenerator/ivigenerator.pro8
-rw-r--r--tests/auto/core/ivigenerator/org.example.echo.noannotation.qface130
-rw-r--r--tests/auto/core/ivigenerator/org.example.echo.qface48
-rw-r--r--tests/auto/core/ivigenerator/org.example.echo.qtro.qface72
-rw-r--r--tests/auto/core/ivigenerator/org.example.echo.simulator.qface53
-rw-r--r--tests/auto/core/ivigenerator/org.example.echo.yaml8
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_qtro/backend_qtro.pro15
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_simulator/backend_simulator.pro (renamed from tests/auto/core/ivigenerator/projects/org-example-echo-simulator/backend_simulator/backend_simulator.pro)6
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/frontend/frontend.pro14
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/org-example-echo-noannotation.pro21
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/qmlplugin/qmlplugin.pro11
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/simulation_server_qtro/simulation_server_qtro.pro16
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/test/test.pro (renamed from tests/auto/core/ivigenerator/projects/org-example-echo-simulator/test/test.pro)6
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/validator/validator.pro (renamed from tests/auto/core/ivigenerator/projects/org-example-echo-simulator/validator/validator.pro)6
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro2
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/qmlplugin/qmlplugin.pro12
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/backend_qtro/backend_qtro.pro2
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/frontend/frontend.pro2
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/org-example-echo-qtro.pro2
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp99
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h (renamed from tests/auto/core/qiviproperty/testdata/writeError.qml)36
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.cpp32
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.h11
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.cpp265
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.h141
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.cpp17
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.h6
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server_qtro_test.pro12
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp828
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h6
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/simulation_server_qtro/simulation_server_qtro.pro16
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-simulator/control_panel/control_panel.pro10
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-simulator/frontend/frontend.pro14
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-simulator/org-example-echo-simulator.pro13
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo/org-example-echo.pro2
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo/qmlplugin/qmlplugin.pro11
-rw-r--r--tests/auto/core/ivigenerator/projects/projects.pro5
-rw-r--r--tests/auto/core/qivipagingmodel/tst_qivipagingmodel.cpp15
-rw-r--r--tests/auto/core/qiviproperty/qiviproperty.pro13
-rw-r--r--tests/auto/core/qiviproperty/testdata/readWrite.qml48
-rw-r--r--tests/auto/core/qiviproperty/tst_qiviproperty.cpp491
-rw-r--r--tests/auto/core/qivipropertyattribute/qivipropertyattribute.pro13
-rw-r--r--tests/auto/core/qivipropertyattribute/tst_qivipropertyattribute.cpp159
-rw-r--r--tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp117
-rw-r--r--tests/auto/core/queryparser/tst_queryparser.cpp11
51 files changed, 1850 insertions, 1151 deletions
diff --git a/tests/auto/core/core.pro b/tests/auto/core/core.pro
index 3f687ad..43c91c2 100644
--- a/tests/auto/core/core.pro
+++ b/tests/auto/core/core.pro
@@ -1,8 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = servicemanagertest \
- qivipropertyattribute \
- qiviproperty \
qiviabstractfeature \
qivipendingreply \
queryparser \
diff --git a/tests/auto/core/ivigenerator/custom-template/custom-template.pro b/tests/auto/core/ivigenerator/custom-template/custom-template.pro
new file mode 100644
index 0000000..dcda1ca
--- /dev/null
+++ b/tests/auto/core/ivigenerator/custom-template/custom-template.pro
@@ -0,0 +1,7 @@
+TARGET = tst_custom-template
+
+QT += testlib
+CONFIG += c++11 ivigenerator testcase
+
+QFACE_FORMAT = $$PWD/custom-test
+QFACE_SOURCES = ../org.example.echo.qface
diff --git a/tests/auto/core/ivigenerator/custom-template/custom-test.yaml b/tests/auto/core/ivigenerator/custom-template/custom-test.yaml
new file mode 100644
index 0000000..4c5cd17
--- /dev/null
+++ b/tests/auto/core/ivigenerator/custom-template/custom-test.yaml
@@ -0,0 +1,10 @@
+generate_rules:
+ module_rules:
+ - dest_file: "{{srcBase|lower}}.pri"
+ template_file: "module.pri.tpl"
+ - dest_file: 'tst_custom.cpp'
+ template_file: 'tst_custom.cpp.tpl'
+ - dest_file: 'tst_custom.h'
+ template_file: 'tst_custom.h.tpl'
+ interface_rules:
+ struct_rules:
diff --git a/tests/auto/core/ivigenerator/custom-template/custom-test/module.pri.tpl b/tests/auto/core/ivigenerator/custom-template/custom-test/module.pri.tpl
new file mode 100644
index 0000000..067635e
--- /dev/null
+++ b/tests/auto/core/ivigenerator/custom-template/custom-test/module.pri.tpl
@@ -0,0 +1,49 @@
+{#
+# Copyright (C) 2019 Luxoft Sweden AB
+# Copyright (C) 2018 Pelagicore AG.
+# Contact: https://www.qt.io/licensing/
+#
+# This file is part of the QtIvi module of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL-QTAS$
+# Commercial License Usage
+# Licensees holding valid commercial Qt Automotive Suite 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 Lesser General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU Lesser
+# General Public License version 3 as published by the Free Software
+# Foundation and appearing in the file LICENSE.LGPL3 included in the
+# packaging of this file. Please review the following information to
+# ensure the GNU Lesser General Public License version 3 requirements
+# will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+#
+# GNU General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU
+# General Public License version 2.0 or (at your option) the GNU General
+# Public license version 3 or any later version approved by the KDE Free
+# Qt Foundation. The licenses are as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+# 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-2.0.html and
+# https://www.gnu.org/licenses/gpl-3.0.html.
+#
+# $QT_END_LICENSE$
+#
+# SPDX-License-Identifier: LGPL-3.0
+#}
+#############################################################################
+## This is an auto-generated file.
+## Do not edit! All changes made to it will be lost.
+#############################################################################
+
+HEADERS += \
+ $$PWD/tst_custom.h \
+
+SOURCES += \
+ $$PWD/tst_custom.cpp \
diff --git a/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.cpp.tpl b/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.cpp.tpl
new file mode 100644
index 0000000..0ae002f
--- /dev/null
+++ b/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.cpp.tpl
@@ -0,0 +1,55 @@
+{#
+# Copyright (C) 2019 Luxoft Sweden AB
+# Copyright (C) 2018 Pelagicore AG
+# Contact: https://www.qt.io/licensing/
+#
+# This file is part of the QtIvi module of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL-QTAS$
+# Commercial License Usage
+# Licensees holding valid commercial Qt Automotive Suite 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 Lesser General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU Lesser
+# General Public License version 3 as published by the Free Software
+# Foundation and appearing in the file LICENSE.LGPL3 included in the
+# packaging of this file. Please review the following information to
+# ensure the GNU Lesser General Public License version 3 requirements
+# will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+#
+# GNU General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU
+# General Public License version 2.0 or (at your option) the GNU General
+# Public license version 3 or any later version approved by the KDE Free
+# Qt Foundation. The licenses are as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+# 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-2.0.html and
+# https://www.gnu.org/licenses/gpl-3.0.html.
+#
+# $QT_END_LICENSE$
+#
+# SPDX-License-Identifier: LGPL-3.0
+#}
+{% include "common/generated_comment.cpp.tpl" %}
+
+#include "tst_custom.h"
+
+CustomTest::CustomTest()
+ : QObject()
+{
+}
+
+void CustomTest::initTestCase()
+{
+ QVERIFY(true);
+ qInfo("Test successfully generated from 'custom template'");
+}
+
+QTEST_MAIN(CustomTest)
diff --git a/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.h.tpl b/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.h.tpl
new file mode 100644
index 0000000..f052e87
--- /dev/null
+++ b/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.h.tpl
@@ -0,0 +1,53 @@
+{#
+# Copyright (C) 2019 Luxoft Sweden AB
+# Copyright (C) 2018 Pelagicore AG
+# Contact: https://www.qt.io/licensing/
+#
+# This file is part of the QtIvi module of the Qt Toolkit.
+#
+# $QT_BEGIN_LICENSE:LGPL-QTAS$
+# Commercial License Usage
+# Licensees holding valid commercial Qt Automotive Suite 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 Lesser General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU Lesser
+# General Public License version 3 as published by the Free Software
+# Foundation and appearing in the file LICENSE.LGPL3 included in the
+# packaging of this file. Please review the following information to
+# ensure the GNU Lesser General Public License version 3 requirements
+# will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+#
+# GNU General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU
+# General Public License version 2.0 or (at your option) the GNU General
+# Public license version 3 or any later version approved by the KDE Free
+# Qt Foundation. The licenses are as published by the Free Software
+# Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+# 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-2.0.html and
+# https://www.gnu.org/licenses/gpl-3.0.html.
+#
+# $QT_END_LICENSE$
+#
+# SPDX-License-Identifier: LGPL-3.0
+#}
+{% include "common/generated_comment.cpp.tpl" %}
+
+#include <QTest>
+
+class CustomTest : public QObject
+{
+ Q_OBJECT
+
+public:
+ CustomTest();
+
+private slots:
+ void initTestCase();
+};
diff --git a/tests/auto/core/ivigenerator/ivigenerator.pro b/tests/auto/core/ivigenerator/ivigenerator.pro
index 87b0c0b..00f5307 100644
--- a/tests/auto/core/ivigenerator/ivigenerator.pro
+++ b/tests/auto/core/ivigenerator/ivigenerator.pro
@@ -1,9 +1,9 @@
TEMPLATE = subdirs
-SUBDIRS = projects
+SUBDIRS = projects \
+ custom-template \
OTHER_FILES = org.example.echo.qface \
org.example.echo.yaml \
- org.example.echo.noprivate.qface \
- org.example.echo.qtro.qface \
- org.example.echo.simulator.qface
+ org.example.echo.noannotation.qface \
+ no-private.yaml
diff --git a/tests/auto/core/ivigenerator/org.example.echo.noannotation.qface b/tests/auto/core/ivigenerator/org.example.echo.noannotation.qface
new file mode 100644
index 0000000..263dc16
--- /dev/null
+++ b/tests/auto/core/ivigenerator/org.example.echo.noannotation.qface
@@ -0,0 +1,130 @@
+/**
+ * module
+ */
+module org.example.echo 1.0
+
+/**
+ * \brief the brief
+ * the description
+ * continues \l http://qt.io
+ */
+interface Echo {
+ /**
+ * \brief brief message
+ *
+ * Some more documentation
+ */
+ readonly string lastMessage;
+ int intValue;
+ var varValue;
+ real floatValue1;
+ real floatValue2;
+ string stringValue;
+ model<Contact> contactList;
+ Contact contact;
+ Combo combo;
+ list<int> intList;
+ list<Combo> comboList;
+ WeekDay weekDay;
+ TestEnum testEnum;
+ real UPPERCASEPROPERTY;
+
+ string echo(string msg);
+ string id() const;
+ Combo getCombo();
+ void voidSlot();
+ void voidSlot2(int param);
+ void timer(int interval);
+ signal anotherChanged(AnotherStruct another);
+ signal foobar(string foo);
+ signal somethingHappened();
+ signal newValueAvailable(var newValue);
+}
+
+interface EchoZoned {
+
+ /**
+ * \brief brief message
+ *
+ * Some more documentation
+ */
+ readonly string lastMessage;
+ int intValue;
+ var varValue;
+ string stringValue;
+ string unsupportedValue;
+ bool zonedValue;
+ bool valueWithDefault;
+ bool echoEnabled;
+ AirflowDirection airflowDirection;
+ int rangedValue;
+ int rangedValueWithDefault;
+ Contact contact;
+ Combo combo;
+ list<int> intList;
+ list<Combo> comboList;
+ WeekDay weekDay;
+ TestEnum testEnum;
+ real UPPERCASEPROPERTY;
+
+ string echo(string msg);
+ string id();
+ var varMethod();
+ Combo getCombo();
+ string timer(int interval);
+
+ signal anotherChanged(AnotherStruct another);
+ signal foobar(string foo);
+ signal somethingHappened();
+ signal newValueAvailable(var newValue);
+}
+
+/**
+ * \brief Control where the airflow goes
+ */
+flag AirflowDirection {
+ /**
+ * \brief Airflow to the windshield
+ */
+ Windshield = 1,
+ /**
+ * \brief Airflow to the dashboard
+ */
+ Dashboard = 2,
+ /**
+ * \brief Airflow to the floor
+ */
+ Floor = 4
+}
+
+flag WeekDay {
+ Monday = 1,
+ Tuesday = 2,
+ Wednesday = 3,
+ Thursday = 4,
+ Friday = 5
+}
+
+enum TestEnum {
+ FirstEnumValue = 1,
+ SecondEnumValue = 2
+}
+
+/**
+ * The contact information
+ */
+struct Contact {
+ string name;
+ int age;
+ bool isMarried;
+ var additionalData;
+}
+
+struct Combo {
+ Contact contactInfo;
+ WeekDay day;
+}
+
+struct AnotherStruct {
+ int justANumber;
+}
diff --git a/tests/auto/core/ivigenerator/org.example.echo.qface b/tests/auto/core/ivigenerator/org.example.echo.qface
index 118cf63..6ea92bc 100644
--- a/tests/auto/core/ivigenerator/org.example.echo.qface
+++ b/tests/auto/core/ivigenerator/org.example.echo.qface
@@ -5,26 +5,20 @@
module org.example.echo 1.0
/**
- * @brief the brief
- * @description the description
- * continues {@link http://qt.io}
- * @deprecated
- * @see org.example.echo.Echo
- * @see org.example
- * @see http://qt.io
- * @anything hello
+ * \brief the brief
+ * the description
+ * continues \l http://qt.io
*/
@config: {id: "org.foo.id.1.0", qml_class_name: "UiEcho"}
interface Echo {
/**
- * @brief brief message
- * @details long message
+ * \brief brief message
*
- * @param msg the message
- * @return the echo
+ * Some more documentation
*/
readonly string lastMessage;
int intValue;
+ var varValue;
@config_simulator: {minimum: 10.}
real floatValue1;
@config_simulator: {maximum: 10.}
@@ -36,6 +30,7 @@ interface Echo {
list<int> intList;
list<Combo> comboList;
WeekDay weekDay;
+ TestEnum testEnum;
real UPPERCASEPROPERTY;
string echo(string msg);
@@ -43,22 +38,24 @@ interface Echo {
Combo getCombo();
void voidSlot();
void voidSlot2(int param);
+ void timer(int interval);
signal anotherChanged(AnotherStruct another);
signal foobar(string foo);
signal somethingHappened();
+ signal newValueAvailable(var newValue);
}
@config: {id: "org.foo.idz.1.0", zoned: true}
interface EchoZoned {
+
/**
- * @brief brief message
- * @details long message
+ * \brief brief message
*
- * @param msg the message
- * @return the echo
+ * Some more documentation
*/
readonly string lastMessage;
int intValue;
+ var varValue;
@config_simulator: {domain: ["one", "two", "three"]}
string stringValue;
string unsupportedValue;
@@ -74,31 +71,36 @@ interface EchoZoned {
Combo combo;
list<int> intList;
list<Combo> comboList;
+ WeekDay weekDay;
+ TestEnum testEnum;
real UPPERCASEPROPERTY;
string echo(string msg);
string id();
+ var varMethod();
Combo getCombo();
+ string timer(int interval);
signal anotherChanged(AnotherStruct another);
signal foobar(string foo);
signal somethingHappened();
+ signal newValueAvailable(var newValue);
}
/**
- * @brief Control where the airflow goes
+ * \brief Control where the airflow goes
*/
flag AirflowDirection {
/**
- * @brief Airflow to the windshield
+ * \brief Airflow to the windshield
*/
Windshield = 1,
/**
- * @brief Airflow to the dashboard
+ * \brief Airflow to the dashboard
*/
Dashboard = 2,
/**
- * @brief Airflow to the floor
+ * \brief Airflow to the floor
*/
Floor = 4
}
@@ -112,6 +114,11 @@ flag WeekDay {
Friday = 5
}
+enum TestEnum {
+ FirstEnumValue = 1,
+ SecondEnumValue = 2
+}
+
/**
* The contact information
*/
@@ -119,6 +126,7 @@ struct Contact {
string name;
int age;
bool isMarried;
+ var additionalData;
}
struct Combo {
diff --git a/tests/auto/core/ivigenerator/org.example.echo.qtro.qface b/tests/auto/core/ivigenerator/org.example.echo.qtro.qface
deleted file mode 100644
index 9d4b93b..0000000
--- a/tests/auto/core/ivigenerator/org.example.echo.qtro.qface
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * module
- */
-@config: { interfaceBuilder: "echoInterfaceBuilder" }
-module org.example.echo 1.0
-
-/**
- * @brief the brief
- * @description the description
- * continues {@link http://qt.io}
- * @deprecated
- * @see org.example.echo.Echo
- * @see org.example
- * @see http://qt.io
- * @anything hello
- */
-@config: {id: "org.foo.id.1.0", qml_class_name: "UiEcho"}
-interface Echo {
- /**
- * @brief brief message
- * @details long message
- *
- * @param msg the message
- * @return the echo
- */
- readonly string lastMessage;
- int intValue;
- @config_simulator: {minimum: 10.}
- real floatValue1;
- @config_simulator: {maximum: 10.}
- real floatValue2;
- string stringValue;
- list<Contact> contactList;
- Contact contact;
- WeekDay weekDay;
- real UPPERCASEPROPERTY;
-
- string echo(string msg);
- string id() const;
- Combo getCombo();
- void voidSlot();
- void voidSlot2(int param);
- signal anotherChanged(AnotherStruct another);
- signal foobar(string foo);
- signal somethingHappened();
-}
-
-enum WeekDay {
- Monday = 1,
- Tuesday = 2,
- Wednesday = 3,
- Thursday = 4,
- Friday = 5
-}
-
-/**
- * The contact information
- */
-struct Contact {
- string name;
- int age;
- bool isMarried;
-}
-
-struct Combo {
- Contact contactInfo;
- WeekDay day;
-}
-
-struct AnotherStruct {
- int justANumber;
-}
diff --git a/tests/auto/core/ivigenerator/org.example.echo.simulator.qface b/tests/auto/core/ivigenerator/org.example.echo.simulator.qface
deleted file mode 100644
index 3d77205..0000000
--- a/tests/auto/core/ivigenerator/org.example.echo.simulator.qface
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * module
- */
-module org.example.simulator.echo 1.0
-
-/**
- * @brief the brief
- * @description the description
- * continues {@link http://qt.io}
- * @deprecated
- * @see org.example.echo.Echo
- * @see org.example
- * @see http://qt.io
- * @anything hello
- */
-@config: {"id": "org.foo.id.1.0"}
-interface Echo {
- /**
- * @brief brief message
- * @details long message
- *
- * @param msg the message
- * @return the echo
- */
- readonly string lastMessage;
- int intValue;
- string stringValue;
-
- string echo(string msg);
- string id();
-
- signal valueChanged(int value);
-}
-
-@config: {"id": "org.foo.idz.1.0", "zoned": true}
-interface EchoZoned {
- /**
- * @brief brief message
- * @details long message
- *
- * @param msg the message
- * @return the echo
- */
- readonly string lastMessage;
- int intValue;
- string stringValue;
-
- string echo(string msg);
- string id();
-
- signal valueChanged(int value);
-}
-
diff --git a/tests/auto/core/ivigenerator/org.example.echo.yaml b/tests/auto/core/ivigenerator/org.example.echo.yaml
index f0d1769..10953f0 100644
--- a/tests/auto/core/ivigenerator/org.example.echo.yaml
+++ b/tests/auto/core/ivigenerator/org.example.echo.yaml
@@ -44,12 +44,12 @@ org.example.echo.Echo#intValue:
org.example.echo.EchoZoned#contact:
config_simulator:
zoned: true
- default: [ "foo", 23, true ]
+ default: [ "foo", 23, true, 1234 ]
org.example.echo.EchoZoned#combo:
config_simulator:
zoned: true
- default: [ [ "foo", 23, true ], WeekDay.Monday ]
+ default: [ [ "foo", 23, true, 1234 ], WeekDay.Monday ]
org.example.echo.EchoZoned#intList:
config_simulator:
@@ -57,8 +57,8 @@ org.example.echo.EchoZoned#intList:
org.example.echo.EchoZoned#comboList:
config_simulator:
- default: [[ [ "foo", 23, true ], WeekDay.Monday ], [ [ "bar", 21, false ], WeekDay.Tuesday ]]
+ default: [[ [ "foo", 23, true, 1234 ], WeekDay.Monday ], [ [ "bar", 21, false, "foo" ], WeekDay.Tuesday ]]
org.example.echo.Echo#contactList:
config_simulator:
- default: [[ "foo", 23, true ], [ "bar", 12, false ]]
+ default: [[ "foo", 23, true, WeekDay.Monday ], [ "bar", 12, false, false ]]
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_qtro/backend_qtro.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_qtro/backend_qtro.pro
new file mode 100644
index 0000000..4f13551
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_qtro/backend_qtro.pro
@@ -0,0 +1,15 @@
+TEMPLATE=lib
+TARGET = $$qtLibraryTarget(echo_noannotation_qtro)
+LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_noannotation_frontend)
+DESTDIR = ../qtivi
+
+CONFIG += warn_off ivigenerator plugin
+
+INCLUDEPATH += $$OUT_PWD/../frontend
+PLUGIN_TYPE = qtivi
+PLUGIN_CLASS_NAME = EchoPlugin
+
+QT += core ivicore
+
+QFACE_FORMAT = backend_qtro
+QFACE_SOURCES = ../../../org.example.echo.noannotation.qface
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/backend_simulator/backend_simulator.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_simulator/backend_simulator.pro
index d62c1f2..ffefda0 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/backend_simulator/backend_simulator.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_simulator/backend_simulator.pro
@@ -1,6 +1,6 @@
TEMPLATE=lib
-TARGET = $$qtLibraryTarget(echo_backend_simulator)
-LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_simulator_frontend)
+TARGET = $$qtLibraryTarget(echo_noannotation_simulator)
+LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_noannotation_frontend)
DESTDIR = ../qtivi
CONFIG += warn_off ivigenerator plugin
@@ -12,4 +12,4 @@ PLUGIN_CLASS_NAME = EchoPlugin
QT += core ivicore
QFACE_FORMAT = backend_simulator
-QFACE_SOURCES = ../../../org.example.echo.simulator.qface
+QFACE_SOURCES = ../../../org.example.echo.noannotation.qface
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/frontend/frontend.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/frontend/frontend.pro
new file mode 100644
index 0000000..842b84a
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/frontend/frontend.pro
@@ -0,0 +1,14 @@
+TEMPLATE=lib
+TARGET= $$qtLibraryTarget(echo_noannotation_frontend)
+DESTDIR = ../
+
+CONFIG += ivigenerator
+
+QT += ivicore ivicore-private qml quick
+
+DEFINES += QT_BUILD_ORG_EXAMPLE_ECHO_LIB
+
+macos: QMAKE_SONAME_PREFIX = @rpath
+
+QFACE_SOURCES = ../../../org.example.echo.noannotation.qface
+
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/org-example-echo-noannotation.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/org-example-echo-noannotation.pro
new file mode 100644
index 0000000..993ce2a
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/org-example-echo-noannotation.pro
@@ -0,0 +1,21 @@
+TEMPLATE = subdirs
+
+SUBDIRS = frontend \
+ qmlplugin \
+ backend_simulator \
+ validator \
+ test \
+
+backend_simulator.depends = frontend
+validator.depends = frontend
+test.depends = frontend
+qmlplugin.depends = frontend
+
+QT_FOR_CONFIG += ivicore
+qtConfig(remoteobjects): {
+ SUBDIRS += backend_qtro \
+ simulation_server_qtro \
+
+ backend_qtro.depends = frontend
+ simulation_server_qtro.depends = frontend
+}
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/qmlplugin/qmlplugin.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/qmlplugin/qmlplugin.pro
new file mode 100644
index 0000000..ef896df
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/qmlplugin/qmlplugin.pro
@@ -0,0 +1,11 @@
+TEMPLATE = lib
+QT = ivicore ivivehiclefunctions
+CONFIG += c++11 plugin
+
+INCLUDEPATH += $$OUT_PWD/../frontend
+LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_noannotation_frontend)
+
+QFACE_FORMAT = qmlplugin
+QFACE_SOURCES = ../../../org.example.echo.noannotation.qface
+
+load(ivigenerator)
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/simulation_server_qtro/simulation_server_qtro.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/simulation_server_qtro/simulation_server_qtro.pro
new file mode 100644
index 0000000..fece593
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/simulation_server_qtro/simulation_server_qtro.pro
@@ -0,0 +1,16 @@
+TEMPLATE = app
+TARGET = org-example-echo-noannotation-simulation-server
+QMAKE_PROJECT_NAME = $$TARGET
+LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_noannotation_frontend)
+
+DESTDIR = ..
+
+CONFIG += c++11 ivigenerator
+CONFIG -= app_bundle
+
+INCLUDEPATH += $$OUT_PWD/../frontend
+
+QT += qml quick core ivicore
+
+QFACE_FORMAT = server_qtro_simulator
+QFACE_SOURCES = ../../../org.example.echo.noannotation.qface
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/test/test.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/test/test.pro
index 89887f5..ca4a039 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/test/test.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/test/test.pro
@@ -1,4 +1,4 @@
-TARGET = tst_org-example-echo-simulator
+TARGET = tst_org-example-echo-noannotation
QMAKE_PROJECT_NAME = $$TARGET
DESTDIR = ../
@@ -6,9 +6,9 @@ QT += testlib core ivicore
CONFIG += c++11 ivigenerator testcase
INCLUDEPATH += $$OUT_PWD/../frontend
-LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_simulator_frontend)
+LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_noannotation_frontend)
QMAKE_RPATHDIR += $$OUT_PWD/..
QFACE_FORMAT = test
-QFACE_SOURCES = ../../../org.example.echo.simulator.qface
+QFACE_SOURCES = ../../../org.example.echo.noannotation.qface
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/validator/validator.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/validator/validator.pro
index fccb3c6..09ec4d1 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/validator/validator.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/validator/validator.pro
@@ -1,7 +1,7 @@
TEMPLATE = app
-TARGET = validator_org-example-echo-simulator
+TARGET = validator_org-example-echo-noannotation
QMAKE_PROJECT_NAME = $$TARGET
-LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_simulator_frontend)
+LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_noannotation_frontend)
DESTDIR = ..
@@ -13,4 +13,4 @@ INCLUDEPATH += $$OUT_PWD/../frontend
QT += qml quick core ivicore
QFACE_FORMAT = generation_validator
-QFACE_SOURCES = ../../../org.example.echo.simulator.qface
+QFACE_SOURCES = ../../../org.example.echo.noannotation.qface
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro
index 898a129..c751801 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro
@@ -3,6 +3,7 @@ TEMPLATE = subdirs
QT_FOR_CONFIG += ivicore
SUBDIRS = frontend \
+ qmlplugin \
backend_simulator \
validator \
test
@@ -10,3 +11,4 @@ SUBDIRS = frontend \
backend_simulator.depends = frontend
validator.depends = frontend
test.depends = frontend
+qmlplugin.depends = frontend
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/qmlplugin/qmlplugin.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/qmlplugin/qmlplugin.pro
new file mode 100644
index 0000000..c611d4e
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/qmlplugin/qmlplugin.pro
@@ -0,0 +1,12 @@
+TEMPLATE = lib
+QT = ivicore ivivehiclefunctions
+CONFIG += c++11 plugin
+
+INCLUDEPATH += $$OUT_PWD/../frontend
+LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_noprivate_frontend)
+
+QFACE_FORMAT = qmlplugin
+QFACE_SOURCES = ../../../org.example.echo.qface
+QFACE_ANNOTATIONS += ../../../no-private.yaml
+
+load(ivigenerator)
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/backend_qtro/backend_qtro.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/backend_qtro/backend_qtro.pro
index 0bf0ee3..09efc01 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/backend_qtro/backend_qtro.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/backend_qtro/backend_qtro.pro
@@ -14,4 +14,4 @@ QT += core ivicore
macos: QMAKE_SONAME_PREFIX = @rpath
QFACE_FORMAT = backend_qtro
-QFACE_SOURCES = ../../../org.example.echo.qtro.qface
+QFACE_SOURCES = ../../../org.example.echo.qface
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/frontend/frontend.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/frontend/frontend.pro
index 0754145..ec105e3 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/frontend/frontend.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/frontend/frontend.pro
@@ -10,4 +10,4 @@ DEFINES += QT_BUILD_ORG_EXAMPLE_ECHO_LIB
macos: QMAKE_SONAME_PREFIX = @rpath
-QFACE_SOURCES = ../../../org.example.echo.qtro.qface
+QFACE_SOURCES = ../../../org.example.echo.qface
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/org-example-echo-qtro.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/org-example-echo-qtro.pro
index 0940541..9d56fcb 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/org-example-echo-qtro.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/org-example-echo-qtro.pro
@@ -2,7 +2,9 @@ TEMPLATE = subdirs
SUBDIRS = frontend \
backend_qtro \
+ simulation_server_qtro \
server_qtro_test
backend_qtro.depends = frontend
server_qtro_test.depends = backend_qtro
+simulation_server_qtro.depends = frontend
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp
new file mode 100644
index 0000000..2e7d542
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Luxoft Sweden AB
+** Copyright (C) 2018 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "contactsmodelservice.h"
+
+ContactsModelService::ContactsModelService(QObject* parent)
+ : PagingModelSimpleSource(parent)
+{
+}
+
+void ContactsModelService::registerInstance(const QUuid &identifier)
+{
+ Q_UNUSED(identifier)
+}
+
+void ContactsModelService::unregisterInstance(const QUuid &identifier)
+{
+ Q_UNUSED(identifier)
+}
+
+void ContactsModelService::fetchData(const QUuid &identifier, int start, int count)
+{
+ QVariantList list;
+ int max = qMin(start + count, m_list.count());
+ for (int i=start; i < max; i++)
+ list.append(QVariant::fromValue(m_list.at(i)));
+
+ emit dataFetched(identifier, list, start, max < m_list.count());
+}
+
+void ContactsModelService::insert(int index, const Contact &item)
+{
+ m_list.insert(index, item);
+
+ emit dataChanged(QUuid(), { QVariant::fromValue(item) }, index, 0);
+}
+
+void ContactsModelService::remove(int index)
+{
+ m_list.removeAt(index);
+
+ emit dataChanged(QUuid(), QVariantList(), index, 1);
+}
+
+void ContactsModelService::move(int currentIndex, int newIndex)
+{
+ int min = qMin(currentIndex, newIndex);
+ int max = qMax(currentIndex, newIndex);
+
+ m_list.move(currentIndex, newIndex);
+ QVariantList variantList;
+ for (int i = min; i <= max; i++)
+ variantList.append(QVariant::fromValue(m_list.at(i)));
+
+ emit dataChanged(QUuid(), variantList, min, max - min + 1);
+}
+
+void ContactsModelService::reset()
+{
+ emit dataChanged(QUuid(), QVariantList(), 0, m_list.count());
+ m_list.clear();
+}
+
+void ContactsModelService::update(int index, const Contact &item)
+{
+ m_list[index] = item;
+ emit dataChanged(QUuid(), { QVariant::fromValue(item) }, index, 1);
+}
+
+const Contact &ContactsModelService::at(int index) const
+{
+ return m_list.at(index);
+}
diff --git a/tests/auto/core/qiviproperty/testdata/writeError.qml b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h
index bf975c6..5a257f5 100644
--- a/tests/auto/core/qiviproperty/testdata/writeError.qml
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h
@@ -27,18 +27,32 @@
**
****************************************************************************/
-import QtQuick 2.0
+#ifndef CONTACTSMODELSERVICE_H
+#define CONTACTSMODELSERVICE_H
-Item {
+#include "contact.h"
+#include "rep_pagingmodel_source.h"
- property int intProperty: testObject.intAttributeProperty.value
- property int enumProperty: testObject.enumAttributeProperty.value
+class ContactsModelService : public PagingModelSimpleSource
+{
+public:
+ ContactsModelService(QObject* parent = nullptr);
- function intTest() {
- testObject.intAttributeProperty.value = "foo"
- }
+ void registerInstance(const QUuid &identifier) override;
+ void unregisterInstance(const QUuid &identifier) override;
- function enumTest() {
- testObject.enumAttributeProperty.value = 50
- }
-}
+ void fetchData(const QUuid &identifier, int start, int count) override;
+
+public Q_SLOTS:
+ void insert(int index, const Contact &item);
+ void remove(int index);
+ void move(int currentIndex, int newIndex);
+ void reset();
+ void update(int index, const Contact &item);
+ const Contact &at(int index) const;
+
+private:
+ QList<Contact> m_list;
+};
+
+#endif // CONTACTSMODELSERVICE_H
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.cpp
index f24b359..80a2735 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.cpp
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.cpp
@@ -28,12 +28,14 @@
****************************************************************************/
#include "echoservice.h"
+#include <QtIviRemoteObjectsHelper>
+#include <QTimer>
EchoService::EchoService()
- :m_testCombo(Contact(QStringLiteral("Antti"), 34, true), EchoModule::Friday),
- m_testId(QStringLiteral("id123"))
+ : m_testCombo(Contact(QStringLiteral("Antti"), 34, true, QVariant()), EchoModule::Friday)
+ , m_testId(QStringLiteral("id123"))
{
-
+ setTestEnum(EchoModule::FirstEnumValue);
}
void EchoService::setLastMessage(QString lastMessage)
@@ -41,30 +43,42 @@ void EchoService::setLastMessage(QString lastMessage)
EchoSimpleSource::setLastMessage(lastMessage);
}
-QString EchoService::echo(const QString &msg)
+QVariant EchoService::echo(const QString &msg)
{
emit echoSlotCalled(msg);
return msg;
}
-QString EchoService::id()
+QVariant EchoService::id()
{
emit idSlotCalled();
return m_testId;
}
-Combo EchoService::getCombo()
+QVariant EchoService::getCombo()
{
emit getComboSlotCalled();
- return m_testCombo;
+ return QVariant::fromValue(m_testCombo);
}
-void EchoService::voidSlot()
+QVariant EchoService::voidSlot()
{
emit voidSlotCalled();
+ return QVariant();
}
-void EchoService::voidSlot2(int param)
+QVariant EchoService::voidSlot2(int param)
{
emit voidSlot2Called(param);
+ return QVariant();
+}
+
+QVariant EchoService::timer(int interval)
+{
+ static quint64 counter = 0;
+ QIviRemoteObjectPendingResult pendingResult(counter++, false);
+ QTimer::singleShot(interval, this, [this, pendingResult](){
+ emit pendingResultAvailable(pendingResult.id(), true, QVariant());
+ });
+ return QVariant::fromValue(pendingResult);
}
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.h b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.h
index ad3eba1..2bdbf54 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.h
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.h
@@ -45,11 +45,12 @@ public:
virtual void setLastMessage(QString lastMessage) override;
public Q_SLOTS:
- virtual QString echo(const QString &msg) override;
- virtual QString id() override;
- virtual Combo getCombo() override;
- virtual void voidSlot() override;
- virtual void voidSlot2(int param) override;
+ virtual QVariant echo(const QString &msg) override;
+ virtual QVariant id() override;
+ virtual QVariant getCombo() override;
+ virtual QVariant voidSlot() override;
+ virtual QVariant voidSlot2(int param) override;
+ virtual QVariant timer(int interval) override;
Q_SIGNALS:
void echoSlotCalled(const QString &msg);
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.cpp
new file mode 100644
index 0000000..e5c6634
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.cpp
@@ -0,0 +1,265 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Luxoft Sweden AB
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "echozonedservice.h"
+
+#include <QtIviRemoteObjectsHelper>
+#include <QTimer>
+
+#define SET_VALUE(m_VALUE, VALUE, CHANGED_SIGNAL) \
+ if (m_zoneHash.value(zone).m_VALUE == VALUE) \
+ return; \
+ \
+ m_zoneHash[zone].m_VALUE = VALUE; \
+ emit CHANGED_SIGNAL(VALUE, zone); \
+
+
+EchoZonedService::EchoZonedService(QObject *parent)
+ : EchoZonedSimpleSource(parent)
+ , m_testCombo(Contact(QStringLiteral("Antti"), 34, true, QVariant()), EchoModule::Friday)
+ , m_testId(QStringLiteral("id123"))
+{
+ m_zoneHash.insert(QString(), ZoneObject());
+ m_zoneHash.insert(QStringLiteral("FrontLeft"), ZoneObject());
+}
+
+QString EchoZonedService::lastMessage(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_lastMessage;
+}
+
+int EchoZonedService::intValue(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_intValue;
+}
+
+void EchoZonedService::setIntValue(int intValue, const QString &zone)
+{
+ SET_VALUE(m_intValue, intValue, intValueChanged);
+}
+
+QVariant EchoZonedService::varValue(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_varValue;
+}
+
+void EchoZonedService::setVarValue(const QVariant &varValue, const QString &zone)
+{
+ SET_VALUE(m_varValue, varValue, varValueChanged);
+}
+
+QString EchoZonedService::stringValue(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_stringValue;
+}
+
+void EchoZonedService::setStringValue(const QString &stringValue, const QString &zone)
+{
+ SET_VALUE(m_stringValue, stringValue, stringValueChanged);
+}
+
+QString EchoZonedService::unsupportedValue(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_unsupportedValue;
+}
+
+void EchoZonedService::setUnsupportedValue(const QString &unsupportedValue, const QString &zone)
+{
+ SET_VALUE(m_unsupportedValue, unsupportedValue, unsupportedValueChanged);
+}
+
+bool EchoZonedService::zonedValue(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_zonedValue;
+}
+
+void EchoZonedService::setZonedValue(bool zonedValue, const QString &zone)
+{
+ SET_VALUE(m_zonedValue, zonedValue, zonedValueChanged);
+}
+
+bool EchoZonedService::valueWithDefault(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_valueWithDefault;
+}
+
+void EchoZonedService::setValueWithDefault(bool valueWithDefault, const QString &zone)
+{
+ SET_VALUE(m_valueWithDefault, valueWithDefault, valueWithDefaultChanged);
+}
+
+bool EchoZonedService::isEchoEnabled(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_echoEnabled;
+}
+
+void EchoZonedService::setEchoEnabled(bool echoEnabled, const QString &zone)
+{
+ SET_VALUE(m_echoEnabled, echoEnabled, echoEnabledChanged);
+}
+
+EchoModule::AirflowDirections EchoZonedService::airflowDirection(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_airflowDirection;
+}
+
+void EchoZonedService::setAirflowDirection(EchoModule::AirflowDirections airflowDirection, const QString &zone)
+{
+ SET_VALUE(m_airflowDirection, airflowDirection, airflowDirectionChanged);
+}
+
+int EchoZonedService::rangedValue(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_rangedValue;
+}
+
+void EchoZonedService::setRangedValue(int rangedValue, const QString &zone)
+{
+ SET_VALUE(m_rangedValue, rangedValue, rangedValueChanged);
+}
+
+int EchoZonedService::rangedValueWithDefault(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_rangedValueWithDefault;
+}
+
+void EchoZonedService::setRangedValueWithDefault(int rangedValueWithDefault, const QString &zone)
+{
+ SET_VALUE(m_rangedValueWithDefault, rangedValueWithDefault, rangedValueWithDefaultChanged);
+}
+
+Contact EchoZonedService::contact(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_contact;
+}
+
+void EchoZonedService::setContact(const Contact &contact, const QString &zone)
+{
+ SET_VALUE(m_contact, contact, contactChanged);
+}
+
+Combo EchoZonedService::combo(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_combo;
+}
+
+void EchoZonedService::setCombo(const Combo &combo, const QString &zone)
+{
+ SET_VALUE(m_combo, combo, comboChanged);
+}
+
+QVariantList EchoZonedService::intList(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_intList;
+}
+
+void EchoZonedService::setIntList(const QVariantList &intList, const QString &zone)
+{
+ SET_VALUE(m_intList, intList, intListChanged);
+}
+
+QVariantList EchoZonedService::comboList(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_comboList;
+}
+
+void EchoZonedService::setComboList(const QVariantList &comboList, const QString &zone)
+{
+ SET_VALUE(m_comboList, comboList, comboListChanged);
+}
+
+EchoModule::DaysOfTheWeek EchoZonedService::weekDay(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_weekDay;
+}
+
+void EchoZonedService::setWeekDay(EchoModule::DaysOfTheWeek weekDay, const QString &zone)
+{
+ SET_VALUE(m_weekDay, weekDay, weekDayChanged);
+}
+
+EchoModule::TestEnum EchoZonedService::testEnum(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_testEnum;
+}
+
+void EchoZonedService::setTestEnum(EchoModule::TestEnum testEnum, const QString &zone)
+{
+ SET_VALUE(m_testEnum, testEnum, testEnumChanged);
+}
+
+qreal EchoZonedService::UPPERCASEPROPERTY(const QString &zone)
+{
+ return m_zoneHash.value(zone).m_UPPERCASEPROPERTY;
+}
+
+void EchoZonedService::setUPPERCASEPROPERTY(qreal UPPERCASEPROPERTY, const QString &zone)
+{
+ SET_VALUE(m_UPPERCASEPROPERTY, UPPERCASEPROPERTY, UPPERCASEPROPERTYChanged);
+}
+
+QStringList EchoZonedService::availableZones()
+{
+ auto keys = m_zoneHash.keys();
+ keys.removeAll(QString());
+ return keys;
+}
+
+QVariant EchoZonedService::echo(const QString &msg, const QString &zone)
+{
+ emit echoSlotCalled(msg, zone);
+ return msg;
+}
+
+QVariant EchoZonedService::id(const QString &zone)
+{
+ emit idSlotCalled(zone);
+ return m_testId;
+}
+
+QVariant EchoZonedService::varMethod(const QString &zone)
+{
+ emit varMethodSlotCalled(zone);
+ return QVariant("FOOOO");
+}
+
+QVariant EchoZonedService::getCombo(const QString &zone)
+{
+ emit getComboSlotCalled(zone);
+ return QVariant::fromValue(m_testCombo);
+}
+
+QVariant EchoZonedService::timer(int interval, const QString &zone)
+{
+ static quint64 counter = 0;
+ QIviRemoteObjectPendingResult pendingResult(counter++, false);
+ QTimer::singleShot(interval, this, [this, pendingResult, zone](){
+ emit pendingResultAvailable(pendingResult.id(), true, zone);
+ });
+ return QVariant::fromValue(pendingResult);
+}
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.h b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.h
new file mode 100644
index 0000000..c0b72a9
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.h
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Luxoft Sweden AB
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtIvi module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ECHOZONEDSERVICE_H
+#define ECHOZONEDSERVICE_H
+
+#include "rep_echozoned_source.h"
+
+class EchoZonedService : public EchoZonedSimpleSource
+{
+ Q_OBJECT
+public:
+ explicit EchoZonedService(QObject *parent = nullptr);
+
+public slots:
+ QString lastMessage(const QString &zone) override;
+ int intValue(const QString &zone) override;
+ void setIntValue(int intValue, const QString &zone) override;
+ QVariant varValue(const QString &zone) override;
+ void setVarValue(const QVariant &varValue, const QString &zone) override;
+ QString stringValue(const QString &zone) override;
+ void setStringValue(const QString &stringValue, const QString &zone) override;
+ QString unsupportedValue(const QString &zone) override;
+ void setUnsupportedValue(const QString &unsupportedValue, const QString &zone) override;
+ bool zonedValue(const QString &zone) override;
+ void setZonedValue(bool zonedValue, const QString &zone) override;
+ bool valueWithDefault(const QString &zone) override;
+ void setValueWithDefault(bool valueWithDefault, const QString &zone) override;
+ bool isEchoEnabled(const QString &zone) override;
+ void setEchoEnabled(bool echoEnabled, const QString &zone) override;
+ EchoModule::AirflowDirections airflowDirection(const QString &zone) override;
+ void setAirflowDirection(EchoModule::AirflowDirections airflowDirection, const QString &zone) override;
+ int rangedValue(const QString &zone) override;
+ void setRangedValue(int rangedValue, const QString &zone) override;
+ int rangedValueWithDefault(const QString &zone) override;
+ void setRangedValueWithDefault(int rangedValueWithDefault, const QString &zone) override;
+ Contact contact(const QString &zone) override;
+ void setContact(const Contact &contact, const QString &zone) override;
+ Combo combo(const QString &zone) override;
+ void setCombo(const Combo &combo, const QString &zone) override;
+ QVariantList intList(const QString &zone) override;
+ void setIntList(const QVariantList &intList, const QString &zone) override;
+ QVariantList comboList(const QString &zone) override;
+ void setComboList(const QVariantList &comboList, const QString &zone) override;
+ EchoModule::DaysOfTheWeek weekDay(const QString &zone) override;
+ void setWeekDay(EchoModule::DaysOfTheWeek weekDay, const QString &zone) override;
+ EchoModule::TestEnum testEnum(const QString &zone) override;
+ void setTestEnum(EchoModule::TestEnum testEnum, const QString &zone) override;
+ qreal UPPERCASEPROPERTY(const QString &zone) override;
+ void setUPPERCASEPROPERTY(qreal UPPERCASEPROPERTY, const QString &zone) override;
+ QStringList availableZones() override;
+ QVariant echo(const QString &msg, const QString &zone) override;
+ QVariant id(const QString &zone) override;
+ QVariant varMethod(const QString &zone) override;
+ QVariant getCombo(const QString &zone) override;
+ QVariant timer(int interval, const QString &zone) override;
+
+Q_SIGNALS:
+ void echoSlotCalled(const QString &msg, const QString& zone);
+ void idSlotCalled(const QString& zone);
+ void varMethodSlotCalled(const QString& zone);
+ void getComboSlotCalled(const QString& zone);
+ void voidSlotCalled(const QString& zone);
+ void voidSlot2Called(int param, const QString& zone);
+
+private:
+ struct ZoneObject {
+ ZoneObject()
+ : m_lastMessage(QString())
+ , m_intValue(int(0))
+ , m_varValue(QVariant())
+ , m_stringValue(QString())
+ , m_unsupportedValue(QString())
+ , m_zonedValue(bool(false))
+ , m_valueWithDefault(bool(false))
+ , m_echoEnabled(bool(false))
+ , m_airflowDirection(EchoModule::AirflowDirections())
+ , m_rangedValue(int(0))
+ , m_rangedValueWithDefault(int(0))
+ , m_contact(Contact())
+ , m_combo(Combo())
+ , m_intList(QVariantList())
+ , m_comboList(QVariantList())
+ , m_weekDay(0)
+ , m_testEnum(EchoModule::FirstEnumValue)
+ , m_UPPERCASEPROPERTY(qreal(0.0))
+ {}
+
+ QString m_zone;
+ QString m_lastMessage;
+ int m_intValue;
+ QVariant m_varValue;
+ QString m_stringValue;
+ QString m_unsupportedValue;
+ bool m_zonedValue;
+ bool m_valueWithDefault;
+ bool m_echoEnabled;
+ EchoModule::AirflowDirections m_airflowDirection;
+ int m_rangedValue;
+ int m_rangedValueWithDefault;
+ Contact m_contact;
+ Combo m_combo;
+ QVariantList m_intList;
+ QVariantList m_comboList;
+ EchoModule::DaysOfTheWeek m_weekDay;
+ EchoModule::TestEnum m_testEnum;
+ qreal m_UPPERCASEPROPERTY;
+ QStringList m_propertiesToSync;
+ };
+
+ QHash <QString, ZoneObject> m_zoneHash;
+ Combo m_testCombo;
+ QString m_testId;
+};
+
+#endif // ECHOZONEDSERVICE_H
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.cpp
index 2ee265e..8d989c4 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.cpp
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.cpp
@@ -29,15 +29,28 @@
#include "server.h"
#include "core.h"
+#include <QTest>
bool Server::start()
{
- return Core::instance()->host()->enableRemoting(&m_service, QStringLiteral("org.example.echo.Echo"));
+ bool val = true;
+ val = val && Core::instance()->host()->enableRemoting(&m_echoService, QStringLiteral("org.example.echo.Echo"));
+ val = val && Core::instance()->host()->enableRemoting(&m_contactsModelService, QStringLiteral("org.example.echo.Echo.contactList"));
+ val = val && Core::instance()->host()->enableRemoting(&m_echoZonedService, QStringLiteral("org.example.echo.EchoZoned"));
+ //Give QtRO time to announce the service
+ QTest::qWait(200);
+ return val;
}
bool Server::stop()
{
- return Core::instance()->host()->disableRemoting(&m_service);
+ bool val = true;
+ val = val && Core::instance()->host()->disableRemoting(&m_echoService);
+ val = val && Core::instance()->host()->disableRemoting(&m_contactsModelService);
+ val = val && Core::instance()->host()->disableRemoting(&m_echoZonedService);
+ //Give QtRO time to send the disconnect message to the Replica
+ QTest::qWait(200);
+ return val;
}
Server::~Server()
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.h b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.h
index 03e4696..d5763be 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.h
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server.h
@@ -31,6 +31,8 @@
#define SERVER_H
#include "echoservice.h"
+#include "echozonedservice.h"
+#include "contactsmodelservice.h"
class Server : public QObject
{
@@ -41,7 +43,9 @@ public Q_SLOTS:
bool stop();
public:
- EchoService m_service;
+ EchoService m_echoService;
+ EchoZonedService m_echoZonedService;
+ ContactsModelService m_contactsModelService;
~Server();
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server_qtro_test.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server_qtro_test.pro
index 8a8ee55..bc222d9 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server_qtro_test.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/server_qtro_test.pro
@@ -1,7 +1,7 @@
TARGET = tst_org-example-echo-qtro
QMAKE_PROJECT_NAME = $$TARGET
QT -= gui
-QT += testlib ivicore
+QT += testlib ivicore iviremoteobjects_helper_private
LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_frontend)
DESTDIR = ..
@@ -15,15 +15,19 @@ INCLUDEPATH += $$OUT_PWD/../backend_qtro
SOURCES += main.cpp \
server.cpp \
echoservice.cpp \
- tst_echoqtro.cpp
+ tst_echoqtro.cpp \
+ echozonedservice.cpp \
+ contactsmodelservice.cpp
QFACE_FORMAT = server_qtro
-QFACE_SOURCES = ../../../org.example.echo.qtro.qface
+QFACE_SOURCES = ../../../org.example.echo.qface
HEADERS += \
server.h \
echoservice.h \
- tst_echoqtro.h
+ tst_echoqtro.h \
+ echozonedservice.h \
+ contactsmodelservice.h
QMAKE_RPATHDIR += $$OUT_PWD/..
QMAKE_RPATHDIR += $$OUT_PWD/../qtivi
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp
index 9cb5ef6..7452a3e 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp
@@ -31,6 +31,7 @@
#include "echoplugin.h"
#include "server.h"
#include "echo.h"
+#include "echozoned.h"
#define WAIT_AND_COMPARE(spy, value) \
if (spy.count() == !value) \
@@ -38,6 +39,8 @@ if (spy.count() == !value) \
QCOMPARE(spy.count(), value); \
+static QString frontLeftZone = QStringLiteral("FrontLeft");
+
EchoQtroTest::EchoQtroTest()
:QObject()
{
@@ -51,54 +54,58 @@ void EchoQtroTest::cleanup()
void EchoQtroTest::testInit()
{
Echo client;
- QVERIFY(client.startAutoDiscovery()==QIviAbstractFeature::ProductionBackendLoaded);
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
QCOMPARE(client.lastMessage(), QString());
QCOMPARE(client.intValue(), 0);
QCOMPARE(client.floatValue1(), qreal(0.0));
QCOMPARE(client.floatValue2(), qreal(0.0));
QCOMPARE(client.stringValue(), QString());
- QCOMPARE(client.contactList(), QVariantList());
+ QCOMPARE(client.comboList(), QVariantList());
QCOMPARE(client.contact(), Contact());
QCOMPARE(client.weekDay(), EchoModule::WeekDay());
+ QCOMPARE(client.testEnum(), EchoModule::FirstEnumValue);
Server server;
//test initial values
- QCOMPARE(server.m_service.lastMessage(), QString());
- QCOMPARE(server.m_service.intValue(), 0);
- QCOMPARE(server.m_service.floatValue1(), qreal(0.0));
- QCOMPARE(server.m_service.floatValue2(), qreal(0.0));
- QCOMPARE(server.m_service.stringValue(), QString());
- QCOMPARE(server.m_service.contactList(), QVariantList());
- QCOMPARE(server.m_service.contact(), Contact());
- QCOMPARE(server.m_service.weekDay(), EchoModule::WeekDay());
-
- QString lastMessageTestValue("this is the last message");
+ QCOMPARE(server.m_echoService.lastMessage(), QString());
+ QCOMPARE(server.m_echoService.intValue(), 0);
+ QCOMPARE(server.m_echoService.floatValue1(), qreal(0.0));
+ QCOMPARE(server.m_echoService.floatValue2(), qreal(0.0));
+ QCOMPARE(server.m_echoService.stringValue(), QString());
+ QCOMPARE(server.m_echoService.comboList(), QVariantList());
+ QCOMPARE(server.m_echoService.contact(), Contact());
+ QCOMPARE(server.m_echoService.weekDay(), EchoModule::WeekDay());
+ QCOMPARE(server.m_echoService.testEnum(), EchoModule::FirstEnumValue);
+
+ QLatin1String lastMessageTestValue("this is the last message");
int intValueTestValue(789);
- float floatValue1TestValue(3.14);
- float floatValue2TestValue(2.71);
- QString stringValueTestValue("test string");
- QVariantList contactListTestValue(
- { QVariant::fromValue<Contact>(Contact("Mr A.", 20, false)),
- QVariant::fromValue<Contact>(Contact("Mr B.", 40, true)) });
- Contact contactTestValue("Nemo", 47, true);
+ qreal floatValue1TestValue(3.14);
+ qreal floatValue2TestValue(2.71);
+ QLatin1String stringValueTestValue("test string");
+ QVariantList comboListTestValue(
+ { QVariant::fromValue<Combo>(Combo(Contact("Mr A.", 20, false, "foo"), EchoModule::Monday)),
+ QVariant::fromValue<Combo>(Combo(Contact("Mr B.", 40, true, "bar"), EchoModule::Wednesday)) });
+ Contact contactTestValue(QStringLiteral("Nemo"), 47, true, 1);
EchoModule::WeekDay weekDayTestValue = EchoModule::Wednesday;
-
-
- server.m_service.setLastMessage(lastMessageTestValue);
- server.m_service.setIntValue(intValueTestValue);
- server.m_service.setFloatValue1(floatValue1TestValue);
- server.m_service.setFloatValue2(floatValue2TestValue);
- server.m_service.setStringValue(stringValueTestValue);
- server.m_service.setContactList(contactListTestValue);
- server.m_service.setContact(contactTestValue);
- server.m_service.setWeekDay(weekDayTestValue);
+ EchoModule::TestEnum testEnumTestValue = EchoModule::SecondEnumValue;
+
+ server.m_echoService.setLastMessage(lastMessageTestValue);
+ server.m_echoService.setIntValue(intValueTestValue);
+ server.m_echoService.setFloatValue1(floatValue1TestValue);
+ server.m_echoService.setFloatValue2(floatValue2TestValue);
+ server.m_echoService.setStringValue(stringValueTestValue);
+ server.m_echoService.setComboList(comboListTestValue);
+ server.m_echoService.setContact(contactTestValue);
+ server.m_echoService.setWeekDay(weekDayTestValue);
+ server.m_echoService.setTestEnum(testEnumTestValue);
QVERIFY(!client.isInitialized());
QCOMPARE(client.error(), QIviAbstractFeature::NoError);
//wait until the client has connected and initial values are set
+ QSignalSpy lastMessageChangedSpy(&client, SIGNAL(lastMessageChanged(QString)));
QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
QVERIFY(server.start());
@@ -107,17 +114,150 @@ void EchoQtroTest::testInit()
WAIT_AND_COMPARE(initSpy, 1);
QVERIFY(client.isInitialized());
+ //make sure the change signal is only emitted once with the correct value
+ QCOMPARE(lastMessageChangedSpy.count(), 1);
+ QCOMPARE(lastMessageChangedSpy.at(0).at(0).toString(), lastMessageTestValue);
+
//test that client gets the same values that were set at the server before connection was established
- QCOMPARE(client.lastMessage(),lastMessageTestValue);
+ QCOMPARE(client.lastMessage(), lastMessageTestValue);
QCOMPARE(client.intValue(), intValueTestValue);
QCOMPARE(client.floatValue1(), floatValue1TestValue);
QCOMPARE(client.floatValue2(), floatValue2TestValue);
QCOMPARE(client.stringValue(), stringValueTestValue);
- QVariantList contactList = client.contactList();
- QCOMPARE(contactList[0].value<Contact>(), contactListTestValue[0].value<Contact>());
- QCOMPARE(contactList[1].value<Contact>(), contactListTestValue[1].value<Contact>());
+ QVariantList comboList = client.comboList();
+ QCOMPARE(comboList[0].value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(comboList[1].value<Combo>(), comboListTestValue[1].value<Combo>());
QCOMPARE(client.contact(), contactTestValue);
QCOMPARE(client.weekDay(), weekDayTestValue);
+ QCOMPARE(client.testEnum(), testEnumTestValue);
+
+
+ lastMessageChangedSpy.clear();
+ //test that a second instance is also initialized with the correct values
+ Echo client2;
+
+ QSignalSpy lastMessageChangedSpy2(&client2, SIGNAL(lastMessageChanged(QString)));
+ QSignalSpy initSpy2(&client2, SIGNAL(isInitializedChanged(bool)));
+
+ QVERIFY(client2.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ QVERIFY(initSpy2.isValid());
+ WAIT_AND_COMPARE(initSpy2, 1);
+ QVERIFY(client2.isInitialized());
+
+ //make sure the change signal is only emitted once with the correct value
+ QCOMPARE(lastMessageChangedSpy2.count(), 1);
+ QCOMPARE(lastMessageChangedSpy2.at(0).at(0).toString(), lastMessageTestValue);
+
+ //make sure the first instance doesn't emit the change signal again
+ QCOMPARE(lastMessageChangedSpy.count(), 0);
+}
+
+void EchoQtroTest::testZonedInit()
+{
+ EchoZoned client;
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //Just compare a few of them
+ QCOMPARE(client.intValue(), 0);
+ QCOMPARE(client.varValue(), QVariant());
+ QCOMPARE(client.stringValue(), QString());
+ QCOMPARE(client.airflowDirection(), EchoModule::AirflowDirections());
+ QCOMPARE(client.contact(), Contact());
+ QCOMPARE(client.comboList(), QVariantList());
+ QCOMPARE(client.UPPERCASEPROPERTY(), qreal(0.0));
+ QCOMPARE(client.testEnum(), EchoModule::FirstEnumValue);
+ QCOMPARE(client.availableZones(), QStringList());
+
+ Server server;
+
+ //test initial values
+ QCOMPARE(server.m_echoZonedService.intValue(QString()), 0);
+ QCOMPARE(server.m_echoZonedService.varValue(QString()), QVariant());
+ QCOMPARE(server.m_echoZonedService.stringValue(QString()), QString());
+ QCOMPARE(server.m_echoZonedService.airflowDirection(QString()), EchoModule::AirflowDirections());
+ QCOMPARE(server.m_echoZonedService.contact(QString()), Contact());
+ QCOMPARE(server.m_echoZonedService.comboList(QString()), QVariantList());
+ QCOMPARE(server.m_echoZonedService.UPPERCASEPROPERTY(QString()), qreal(0.0));
+ QCOMPARE(server.m_echoZonedService.testEnum(QString()), EchoModule::FirstEnumValue);
+
+ int intValueTestValue(789);
+ QVariant varValueTestValue(789);
+ qreal floatValueTestValue(3.14);
+ QLatin1String stringValueTestValue("test string");
+ QVariantList comboListTestValue(
+ { QVariant::fromValue<Combo>(Combo(Contact("Mr A.", 20, false, "foo"), EchoModule::Monday)),
+ QVariant::fromValue<Combo>(Combo(Contact("Mr B.", 40, true, "bar"), EchoModule::Wednesday)) });
+ Contact contactTestValue(QStringLiteral("Nemo"), 47, true, 1);
+ EchoModule::AirflowDirections airflowTestValue = EchoModule::Windshield;
+ EchoModule::TestEnum testEnumTestValue = EchoModule::SecondEnumValue;
+
+
+ server.m_echoZonedService.setIntValue(intValueTestValue, QString());
+ server.m_echoZonedService.setVarValue(varValueTestValue, QString());
+ server.m_echoZonedService.setStringValue(stringValueTestValue, QString());
+
+ server.m_echoZonedService.setAirflowDirection(airflowTestValue, frontLeftZone);
+ server.m_echoZonedService.setContact(contactTestValue, frontLeftZone);
+ server.m_echoZonedService.setComboList(comboListTestValue, frontLeftZone);
+ server.m_echoZonedService.setUPPERCASEPROPERTY(floatValueTestValue, frontLeftZone);
+ server.m_echoZonedService.setTestEnum(testEnumTestValue, frontLeftZone);
+
+
+ QVERIFY(!client.isInitialized());
+ QCOMPARE(client.error(), QIviAbstractFeature::NoError);
+
+ //wait until the client has connected and initial values are set
+ QSignalSpy stringValueChangedSpy(&client, SIGNAL(stringValueChanged(QString)));
+ QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
+ QSignalSpy availableZonesSpy(&client, SIGNAL(availableZonesChanged(QStringList)));
+
+ QVERIFY(server.start());
+
+ QVERIFY(initSpy.isValid());
+ WAIT_AND_COMPARE(initSpy, 1);
+ QVERIFY(client.isInitialized());
+ QVERIFY(availableZonesSpy.count());
+ QCOMPARE(client.availableZones(), QStringList({"FrontLeft"}));
+
+ //make sure the change signal is only emitted once with the correct value
+ QCOMPARE(stringValueChangedSpy.count(), 1);
+ QCOMPARE(stringValueChangedSpy.at(0).at(0).toString(), stringValueTestValue);
+
+ //test that client gets the same values that were set at the server before connection was established
+ QCOMPARE(client.intValue(), intValueTestValue);
+ QCOMPARE(client.varValue(), varValueTestValue);
+ QCOMPARE(client.stringValue(), stringValueTestValue);
+
+ EchoZoned *zone = qobject_cast<EchoZoned*>(client.zoneAt(frontLeftZone));
+ QVERIFY(zone);
+ QCOMPARE(zone->airflowDirection(), airflowTestValue);
+ QCOMPARE(zone->contact(), contactTestValue);
+ QVariantList comboList = zone->comboList();
+ QCOMPARE(comboList[0].value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(comboList[1].value<Combo>(), comboListTestValue[1].value<Combo>());
+ QCOMPARE(zone->UPPERCASEPROPERTY(), floatValueTestValue);
+ QCOMPARE(zone->testEnum(), testEnumTestValue);
+
+ stringValueChangedSpy.clear();
+ //test that a second instance is also initialized with the correct values
+ EchoZoned client2;
+
+ QSignalSpy stringValueChangedSpy2(&client2, SIGNAL(stringValueChanged(QString)));
+ QSignalSpy initSpy2(&client2, SIGNAL(isInitializedChanged(bool)));
+
+ QVERIFY(client2.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ QVERIFY(initSpy2.isValid());
+ WAIT_AND_COMPARE(initSpy2, 1);
+ QVERIFY(client2.isInitialized());
+
+ //make sure the change signal is only emitted once with the correct value
+ QCOMPARE(stringValueChangedSpy2.count(), 1);
+ QCOMPARE(stringValueChangedSpy2.at(0).at(0).toString(), stringValueTestValue);
+
+ //make sure the first instance doesn't emit the change signal again
+ QCOMPARE(stringValueChangedSpy.count(), 0);
}
void EchoQtroTest::testReconnect()
@@ -126,36 +266,57 @@ void EchoQtroTest::testReconnect()
QVERIFY(server.start());
Echo client;
- QVERIFY(client.startAutoDiscovery()==QIviAbstractFeature::ProductionBackendLoaded);
-
- //wait until the client has connected and initial values are set
QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
WAIT_AND_COMPARE(initSpy, 1);
QVERIFY(client.isInitialized());
+ EchoZoned zonedClient;
+ QSignalSpy zonedInitSpy(&zonedClient, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(zonedInitSpy.isValid());
+ QVERIFY(zonedClient.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
+ WAIT_AND_COMPARE(zonedInitSpy, 1);
+ QVERIFY(zonedClient.isInitialized());
+
//test disconnection
QCOMPARE(client.error(), QIviAbstractFeature::NoError);
- QSignalSpy disconnectSpy(&client, SIGNAL(errorChanged(QIviAbstractFeature::Error,QString)));
+ QCOMPARE(zonedClient.error(), QIviAbstractFeature::NoError);
+ QSignalSpy disconnectSpy(&client, SIGNAL(errorChanged(QIviAbstractFeature::Error, QString)));
+ QSignalSpy zonedDisconnectSpy(&zonedClient, SIGNAL(errorChanged(QIviAbstractFeature::Error, QString)));
QVERIFY(disconnectSpy.isValid());
+ QVERIFY(zonedDisconnectSpy.isValid());
server.stop();
WAIT_AND_COMPARE(disconnectSpy, 1);
QCOMPARE(client.error(), QIviAbstractFeature::Unknown);
+ WAIT_AND_COMPARE(zonedDisconnectSpy, 1);
+ QCOMPARE(zonedClient.error(), QIviAbstractFeature::Unknown);
//test that a remote call fails on a disconnected replica
QIviPendingReply<QString> idReply = client.id();
QVERIFY(idReply.isResultAvailable() && !idReply.watcher()->isSuccessful());
+ QIviPendingReply<QString> zonedIdReply = zonedClient.id();
+ QVERIFY(zonedIdReply.isResultAvailable() && !zonedIdReply.watcher()->isSuccessful());
+
//test reconnection
- QSignalSpy reconnectSpy(&client, SIGNAL(errorChanged(QIviAbstractFeature::Error,QString)));
+ QSignalSpy reconnectSpy(&client, SIGNAL(errorChanged(QIviAbstractFeature::Error, QString)));
QVERIFY(reconnectSpy.isValid());
+ QSignalSpy zonedReconnectSpy(&zonedClient, SIGNAL(errorChanged(QIviAbstractFeature::Error, QString)));
+ QVERIFY(zonedReconnectSpy.isValid());
server.start();
WAIT_AND_COMPARE(reconnectSpy, 1);
QCOMPARE(client.error(), QIviAbstractFeature::NoError);
+ WAIT_AND_COMPARE(zonedReconnectSpy, 1);
+ QCOMPARE(zonedClient.error(), QIviAbstractFeature::NoError);
}
void EchoQtroTest::testClient2Server()
@@ -164,77 +325,173 @@ void EchoQtroTest::testClient2Server()
QVERIFY(server.start());
Echo client;
- QVERIFY(client.startAutoDiscovery()==QIviAbstractFeature::ProductionBackendLoaded);
-
-
- //wait until the client has connected and initial values are set
QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
WAIT_AND_COMPARE(initSpy, 1);
QVERIFY(client.isInitialized());
//test properties
- QSignalSpy intValueSpy(&server.m_service, SIGNAL(intValueChanged(int)));
+ QSignalSpy intValueSpy(&server.m_echoService, SIGNAL(intValueChanged(int)));
QVERIFY(intValueSpy.isValid());
int intValueTestValue = 12345;
client.setIntValue(intValueTestValue);
WAIT_AND_COMPARE(intValueSpy, 1);
- QCOMPARE(server.m_service.intValue(), intValueTestValue);
+ QCOMPARE(server.m_echoService.intValue(), intValueTestValue);
QCOMPARE(intValueSpy[0][0].toInt(), intValueTestValue);
- QSignalSpy floatValue1Spy(&server.m_service, SIGNAL(floatValue1Changed(qreal)));
+ QSignalSpy floatValue1Spy(&server.m_echoService, SIGNAL(floatValue1Changed(qreal)));
QVERIFY(floatValue1Spy.isValid());
qreal floatValue1TestValue = 1234.5678;
client.setFloatValue1(floatValue1TestValue);
WAIT_AND_COMPARE(floatValue1Spy, 1);
- QCOMPARE(server.m_service.floatValue1(), floatValue1TestValue);
+ QCOMPARE(server.m_echoService.floatValue1(), floatValue1TestValue);
QCOMPARE(floatValue1Spy[0][0].toReal(), floatValue1TestValue);
- QSignalSpy floatValue2Spy(&server.m_service, SIGNAL(floatValue2Changed(qreal)));
+ QSignalSpy floatValue2Spy(&server.m_echoService, SIGNAL(floatValue2Changed(qreal)));
QVERIFY(floatValue2Spy.isValid());
qreal floatValue2TestValue = 3.1415;
client.setFloatValue2(floatValue2TestValue);
WAIT_AND_COMPARE(floatValue2Spy, 1);
- QCOMPARE(server.m_service.floatValue2(), floatValue2TestValue);
+ QCOMPARE(server.m_echoService.floatValue2(), floatValue2TestValue);
QCOMPARE(floatValue2Spy[0][0].toReal(), floatValue2TestValue);
- QSignalSpy stringValueSpy(&server.m_service, SIGNAL(stringValueChanged(QString)));
+ QSignalSpy stringValueSpy(&server.m_echoService, SIGNAL(stringValueChanged(QString)));
QVERIFY(stringValueSpy.isValid());
- QString stringValueTestValue = "hello test";
+ QString stringValueTestValue = QStringLiteral("hello test");
client.setStringValue(stringValueTestValue);
WAIT_AND_COMPARE(stringValueSpy, 1);
- QCOMPARE(server.m_service.stringValue(), stringValueTestValue);
+ QCOMPARE(server.m_echoService.stringValue(), stringValueTestValue);
QCOMPARE(stringValueSpy[0][0].toString(), stringValueTestValue);
- QSignalSpy contactListSpy(&server.m_service, SIGNAL(contactListChanged(QVariantList)));
- QVERIFY(contactListSpy.isValid());
- QVariantList contactListTestValue(
- { QVariant::fromValue<Contact>(Contact("Mr A.", 20, false)),
- QVariant::fromValue<Contact>(Contact("Mr B.", 40, true)) });
- client.setContactList(contactListTestValue);
- WAIT_AND_COMPARE(contactListSpy, 1);
- QCOMPARE(server.m_service.contactList().count(),contactListTestValue.count());
- QCOMPARE(server.m_service.contactList()[0].value<Contact>(), contactListTestValue[0].value<Contact>());
- QCOMPARE(server.m_service.contactList()[1].value<Contact>(), contactListTestValue[1].value<Contact>());
- QVariantList signalArgs = contactListSpy[0][0].toList();
- QCOMPARE(signalArgs[0].value<Contact>(), contactListTestValue[0].value<Contact>());
- QCOMPARE(signalArgs[1].value<Contact>(), contactListTestValue[1].value<Contact>());
-
- QSignalSpy contactSpy(&server.m_service, SIGNAL(contactChanged(Contact)));
+ QSignalSpy comboListSpy(&server.m_echoService, SIGNAL(comboListChanged(QVariantList)));
+ QVERIFY(comboListSpy.isValid());
+ QVariantList comboListTestValue(
+ { QVariant::fromValue<Combo>(Combo(Contact("Mr A.", 20, false, "foo"), EchoModule::Monday)),
+ QVariant::fromValue<Combo>(Combo(Contact("Mr B.", 40, true, "bar"), EchoModule::Wednesday)) });
+ client.setComboList(comboListTestValue);
+ WAIT_AND_COMPARE(comboListSpy, 1);
+ QCOMPARE(server.m_echoService.comboList().count(),comboListTestValue.count());
+ QCOMPARE(server.m_echoService.comboList().at(0).value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(server.m_echoService.comboList().at(1).value<Combo>(), comboListTestValue[1].value<Combo>());
+ QVariantList signalArgs = comboListSpy[0][0].toList();
+ QCOMPARE(signalArgs[0].value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(signalArgs[1].value<Combo>(), comboListTestValue[1].value<Combo>());
+
+ QSignalSpy contactSpy(&server.m_echoService, SIGNAL(contactChanged(Contact)));
QVERIFY(contactSpy.isValid());
- Contact contactTestValue("Nemo", 47, true);
+ Contact contactTestValue(QStringLiteral("Nemo"), 47, true, 1);
client.setContact(contactTestValue);
WAIT_AND_COMPARE(contactSpy, 1);
- QCOMPARE(server.m_service.contact(), contactTestValue);
+ QCOMPARE(server.m_echoService.contact(), contactTestValue);
QCOMPARE(contactSpy[0][0].value<Contact>(), contactTestValue);
- QSignalSpy weekDaySpy(&server.m_service, SIGNAL(weekDayChanged(EchoModule::WeekDay)));
+ QSignalSpy weekDaySpy(&server.m_echoService, SIGNAL(weekDayChanged(EchoModule::DaysOfTheWeek)));
QVERIFY(weekDaySpy.isValid());
- EchoModule::WeekDay weekDayTestValue = EchoModule::Thursday;
+ EchoModule::DaysOfTheWeek weekDayTestValue = EchoModule::Thursday;
client.setWeekDay(weekDayTestValue);
WAIT_AND_COMPARE(weekDaySpy, 1);
- QCOMPARE(server.m_service.weekDay(), weekDayTestValue);
- QCOMPARE(weekDaySpy[0][0].value<EchoModule::WeekDay>(), weekDayTestValue);
+ QCOMPARE(server.m_echoService.weekDay(), weekDayTestValue);
+ QCOMPARE(weekDaySpy[0][0].value<EchoModule::DaysOfTheWeek>(), weekDayTestValue);
+
+ QSignalSpy testEnumSpy(&server.m_echoService, SIGNAL(testEnumChanged(EchoModule::TestEnum)));
+ QVERIFY(testEnumSpy.isValid());
+ EchoModule::TestEnum testEnumTestValue = EchoModule::SecondEnumValue;
+ client.setTestEnum(testEnumTestValue);
+ WAIT_AND_COMPARE(testEnumSpy, 1);
+ QCOMPARE(server.m_echoService.testEnum(), testEnumTestValue);
+ QCOMPARE(testEnumSpy[0][0].value<EchoModule::TestEnum>(), testEnumTestValue);
+}
+
+void EchoQtroTest::testZonedClient2Server()
+{
+ Server server;
+ QVERIFY(server.start());
+
+ EchoZoned client;
+ QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
+ WAIT_AND_COMPARE(initSpy, 1);
+ QVERIFY(client.isInitialized());
+
+ //test properties
+ QSignalSpy intValueSpy(&server.m_echoZonedService, SIGNAL(intValueChanged(int, QString)));
+ QVERIFY(intValueSpy.isValid());
+ int intValueTestValue = 12345;
+ client.setIntValue(intValueTestValue);
+ WAIT_AND_COMPARE(intValueSpy, 1);
+ QCOMPARE(server.m_echoZonedService.intValue(QString()), intValueTestValue);
+ QCOMPARE(intValueSpy[0][0].toInt(), intValueTestValue);
+ QCOMPARE(intValueSpy[0][1].toString(), QString());
+
+ QSignalSpy UPPERCASEPROPERTYSpy(&server.m_echoZonedService, SIGNAL(UPPERCASEPROPERTYChanged(qreal, QString)));
+ QVERIFY(UPPERCASEPROPERTYSpy.isValid());
+ qreal floatValueTestValue = 1234.5678;
+ client.setUPPERCASEPROPERTY(floatValueTestValue);
+ WAIT_AND_COMPARE(UPPERCASEPROPERTYSpy, 1);
+ QCOMPARE(server.m_echoZonedService.UPPERCASEPROPERTY(QString()), floatValueTestValue);
+ QCOMPARE(UPPERCASEPROPERTYSpy[0][0].toReal(), floatValueTestValue);
+ QCOMPARE(UPPERCASEPROPERTYSpy[0][1].toString(), QString());
+
+ EchoZoned *zone = qobject_cast<EchoZoned*>(client.zoneAt(frontLeftZone));
+ QVERIFY(zone);
+
+ QSignalSpy stringValueSpy(&server.m_echoZonedService, SIGNAL(stringValueChanged(QString, QString)));
+ QVERIFY(stringValueSpy.isValid());
+ QString stringValueTestValue = QStringLiteral("hello test");
+ zone->setStringValue(stringValueTestValue);
+ WAIT_AND_COMPARE(stringValueSpy, 1);
+ QCOMPARE(server.m_echoZonedService.stringValue(frontLeftZone), stringValueTestValue);
+ QCOMPARE(stringValueSpy[0][0].toString(), stringValueTestValue);
+ QCOMPARE(stringValueSpy[0][1].toString(), frontLeftZone);
+
+ QSignalSpy comboListSpy(&server.m_echoZonedService, SIGNAL(comboListChanged(QVariantList, QString)));
+ QVERIFY(comboListSpy.isValid());
+ QVariantList comboListTestValue(
+ { QVariant::fromValue<Combo>(Combo(Contact("Mr A.", 20, false, "foo"), EchoModule::Monday)),
+ QVariant::fromValue<Combo>(Combo(Contact("Mr B.", 40, true, "bar"), EchoModule::Wednesday)) });
+ zone->setComboList(comboListTestValue);
+ WAIT_AND_COMPARE(comboListSpy, 1);
+ QVariantList comboList = server.m_echoZonedService.comboList(frontLeftZone);
+ QCOMPARE(comboList.count(),comboListTestValue.count());
+ QCOMPARE(comboList.at(0).value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(comboList.at(1).value<Combo>(), comboListTestValue[1].value<Combo>());
+ QVariantList signalArgs = comboListSpy[0][0].toList();
+ QCOMPARE(signalArgs[0].value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(signalArgs[1].value<Combo>(), comboListTestValue[1].value<Combo>());
+ QCOMPARE(comboListSpy[0][1].toString(), frontLeftZone);
+
+ QSignalSpy contactSpy(&server.m_echoZonedService, SIGNAL(contactChanged(Contact, QString)));
+ QVERIFY(contactSpy.isValid());
+ Contact contactTestValue(QStringLiteral("Nemo"), 47, true, 1);
+ zone->setContact(contactTestValue);
+ WAIT_AND_COMPARE(contactSpy, 1);
+ QCOMPARE(server.m_echoZonedService.contact(frontLeftZone), contactTestValue);
+ QCOMPARE(contactSpy[0][0].value<Contact>(), contactTestValue);
+ QCOMPARE(contactSpy[0][1].toString(), frontLeftZone);
+
+ QSignalSpy airflowSpy(&server.m_echoZonedService, SIGNAL(airflowDirectionChanged(EchoModule::AirflowDirections, QString)));
+ QVERIFY(airflowSpy.isValid());
+ EchoModule::AirflowDirections airflowTestValue = EchoModule::Windshield;
+ zone->setAirflowDirection(airflowTestValue);
+ WAIT_AND_COMPARE(airflowSpy, 1);
+ QCOMPARE(server.m_echoZonedService.airflowDirection(frontLeftZone), airflowTestValue);
+ QCOMPARE(airflowSpy[0][0].value<EchoModule::AirflowDirections>(), airflowTestValue);
+ QCOMPARE(airflowSpy[0][1].toString(), frontLeftZone);
+
+ QSignalSpy testEnumSpy(&server.m_echoZonedService, SIGNAL(testEnumChanged(EchoModule::TestEnum, QString)));
+ QVERIFY(testEnumSpy.isValid());
+ EchoModule::TestEnum testEnumTestValue = EchoModule::SecondEnumValue;
+ zone->setTestEnum(testEnumTestValue);
+ WAIT_AND_COMPARE(testEnumSpy, 1);
+ QCOMPARE(server.m_echoZonedService.testEnum(frontLeftZone), testEnumTestValue);
+ QCOMPARE(testEnumSpy[0][0].value<EchoModule::TestEnum>(), testEnumTestValue);
+ QCOMPARE(testEnumSpy[0][1].toString(), frontLeftZone);
}
void EchoQtroTest::testServer2Client()
@@ -243,12 +500,12 @@ void EchoQtroTest::testServer2Client()
QVERIFY(server.start());
Echo client;
- QVERIFY(client.startAutoDiscovery()==QIviAbstractFeature::ProductionBackendLoaded);
+ QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
//wait until the client has connected and initial values are set
- QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
- QVERIFY(initSpy.isValid());
WAIT_AND_COMPARE(initSpy, 1);
QVERIFY(client.isInitialized());
@@ -256,7 +513,7 @@ void EchoQtroTest::testServer2Client()
QSignalSpy intValueSpy(&client, SIGNAL(intValueChanged(int)));
QVERIFY(intValueSpy.isValid());
int intValueTestValue = 12345;
- server.m_service.setIntValue(intValueTestValue);
+ server.m_echoService.setIntValue(intValueTestValue);
WAIT_AND_COMPARE(intValueSpy, 1);
QCOMPARE(client.intValue(), intValueTestValue);
QCOMPARE(intValueSpy[0][0].toInt(), intValueTestValue);
@@ -264,7 +521,7 @@ void EchoQtroTest::testServer2Client()
QSignalSpy floatValue1Spy(&client, SIGNAL(floatValue1Changed(qreal)));
QVERIFY(floatValue1Spy.isValid());
qreal floatValue1TestValue = 1234.5678;
- server.m_service.setFloatValue1(floatValue1TestValue);
+ server.m_echoService.setFloatValue1(floatValue1TestValue);
WAIT_AND_COMPARE(floatValue1Spy, 1);
QCOMPARE(client.floatValue1(), floatValue1TestValue);
QCOMPARE(floatValue1Spy[0][0].toReal(), floatValue1TestValue);
@@ -272,48 +529,139 @@ void EchoQtroTest::testServer2Client()
QSignalSpy floatValue2Spy(&client, SIGNAL(floatValue2Changed(qreal)));
QVERIFY(floatValue2Spy.isValid());
qreal floatValue2TestValue = 234.678;
- server.m_service.setFloatValue2(floatValue2TestValue);
+ server.m_echoService.setFloatValue2(floatValue2TestValue);
WAIT_AND_COMPARE(floatValue2Spy, 1);
QCOMPARE(client.floatValue2(), floatValue2TestValue);
QCOMPARE(floatValue2Spy[0][0].toReal(), floatValue2TestValue);
QSignalSpy stringValueSpy(&client, SIGNAL(stringValueChanged(QString)));
QVERIFY(stringValueSpy.isValid());
- QString stringValueTestValue = QString("hello test");
- server.m_service.setStringValue(stringValueTestValue);
+ QLatin1String stringValueTestValue("hello test");
+ server.m_echoService.setStringValue(stringValueTestValue);
WAIT_AND_COMPARE(stringValueSpy, 1);
QCOMPARE(client.stringValue(), stringValueTestValue);
QCOMPARE(stringValueSpy[0][0].toString(), stringValueTestValue);
- QSignalSpy contactListSpy(&client, SIGNAL(contactListChanged(QVariantList)));
- QVERIFY(contactListSpy.isValid());
- QVariantList contactListTestValue(
- { QVariant::fromValue<Contact>(Contact("Mr A.", 20, false)),
- QVariant::fromValue<Contact>(Contact("Mr B.", 40, true)) });
- server.m_service.setContactList(contactListTestValue);
- WAIT_AND_COMPARE(contactListSpy, 1);
- QCOMPARE(client.contactList().count(),contactListTestValue.count());
- QCOMPARE(client.contactList()[0].value<Contact>(), contactListTestValue[0].value<Contact>());
- QCOMPARE(client.contactList()[1].value<Contact>(), contactListTestValue[1].value<Contact>());
- QVariantList signalArgs = contactListSpy[0][0].toList();
- QCOMPARE(signalArgs[0].value<Contact>(), contactListTestValue[0].value<Contact>());
- QCOMPARE(signalArgs[1].value<Contact>(), contactListTestValue[1].value<Contact>());
+ QSignalSpy comboListSpy(&client, SIGNAL(comboListChanged(QVariantList)));
+ QVERIFY(comboListSpy.isValid());
+ QVariantList comboListTestValue(
+ { QVariant::fromValue<Combo>(Combo(Contact("Mr A.", 20, false, "foo"), EchoModule::Monday)),
+ QVariant::fromValue<Combo>(Combo(Contact("Mr B.", 40, true, "bar"), EchoModule::Wednesday)) });
+ server.m_echoService.setComboList(comboListTestValue);
+ WAIT_AND_COMPARE(comboListSpy, 1);
+ QCOMPARE(client.comboList().count(),comboListTestValue.count());
+ QCOMPARE(client.comboList().at(0).value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(client.comboList().at(1).value<Combo>(), comboListTestValue[1].value<Combo>());
+ QVariantList signalArgs = comboListSpy[0][0].toList();
+ QCOMPARE(signalArgs[0].value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(signalArgs[1].value<Combo>(), comboListTestValue[1].value<Combo>());
QSignalSpy contactSpy(&client, SIGNAL(contactChanged(Contact)));
QVERIFY(contactSpy.isValid());
- Contact contactTestValue("Nemo", 47, true);
- server.m_service.setContact(contactTestValue);
+ Contact contactTestValue(QStringLiteral("Nemo"), 47, true, 1);
+ server.m_echoService.setContact(contactTestValue);
WAIT_AND_COMPARE(contactSpy, 1);
QCOMPARE(client.contact(), contactTestValue);
QCOMPARE(contactSpy[0][0].value<Contact>(), contactTestValue);
- QSignalSpy weekDaySpy(&client, SIGNAL(weekDayChanged(EchoModule::WeekDay)));
+ QSignalSpy weekDaySpy(&client, SIGNAL(weekDayChanged(EchoModule::DaysOfTheWeek)));
QVERIFY(weekDaySpy.isValid());
EchoModule::WeekDay weekDayTestValue = EchoModule::Friday;
- server.m_service.setWeekDay(weekDayTestValue);
+ server.m_echoService.setWeekDay(weekDayTestValue);
WAIT_AND_COMPARE(weekDaySpy, 1);
+
QCOMPARE(client.weekDay(), weekDayTestValue);
- QCOMPARE(weekDaySpy[0][0].value<EchoModule::WeekDay>(), weekDayTestValue);
+ QCOMPARE(weekDaySpy[0][0].value<EchoModule::DaysOfTheWeek>(), weekDayTestValue);
+
+ QSignalSpy testEnumSpy(&client, SIGNAL(testEnumChanged(EchoModule::TestEnum)));
+ QVERIFY(testEnumSpy.isValid());
+ EchoModule::TestEnum testEnumTestValue = EchoModule::SecondEnumValue;
+ server.m_echoService.setTestEnum(testEnumTestValue);
+ WAIT_AND_COMPARE(testEnumSpy, 1);
+ QCOMPARE(client.testEnum(), testEnumTestValue);
+ QCOMPARE(testEnumSpy[0][0].value<EchoModule::TestEnum>(), testEnumTestValue);
+}
+
+void EchoQtroTest::testZonedServer2Client()
+{
+ Server server;
+ QVERIFY(server.start());
+
+ EchoZoned client;
+ QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
+ WAIT_AND_COMPARE(initSpy, 1);
+ QVERIFY(client.isInitialized());
+
+ //test properties
+ QSignalSpy intValueSpy(&client, SIGNAL(intValueChanged(int)));
+ QVERIFY(intValueSpy.isValid());
+ int intValueTestValue = 12345;
+ server.m_echoZonedService.setIntValue(intValueTestValue, QString());
+ WAIT_AND_COMPARE(intValueSpy, 1);
+ QCOMPARE(client.intValue(), intValueTestValue);
+ QCOMPARE(intValueSpy[0][0].toInt(), intValueTestValue);
+
+ QSignalSpy UPPERCASEPROPERTYSpy(&client, SIGNAL(UPPERCASEPROPERTYChanged(qreal)));
+ QVERIFY(UPPERCASEPROPERTYSpy.isValid());
+ qreal floatValueTestValue = 1234.5678;
+ server.m_echoZonedService.setUPPERCASEPROPERTY(floatValueTestValue, QString());
+ WAIT_AND_COMPARE(UPPERCASEPROPERTYSpy, 1);
+ QCOMPARE(client.UPPERCASEPROPERTY(), floatValueTestValue);
+ QCOMPARE(UPPERCASEPROPERTYSpy[0][0].toReal(), floatValueTestValue);
+
+ EchoZoned *zone = qobject_cast<EchoZoned*>(client.zoneAt(frontLeftZone));
+ QVERIFY(zone);
+
+ QSignalSpy stringValueSpy(zone, SIGNAL(stringValueChanged(QString)));
+ QVERIFY(stringValueSpy.isValid());
+ QString stringValueTestValue = QStringLiteral("hello test");
+ server.m_echoZonedService.setStringValue(stringValueTestValue, frontLeftZone);
+ WAIT_AND_COMPARE(stringValueSpy, 1);
+ QCOMPARE(zone->stringValue(), stringValueTestValue);
+ QCOMPARE(stringValueSpy[0][0].toString(), stringValueTestValue);
+
+ QSignalSpy comboListSpy(zone, SIGNAL(comboListChanged(QVariantList)));
+ QVERIFY(comboListSpy.isValid());
+ QVariantList comboListTestValue(
+ { QVariant::fromValue<Combo>(Combo(Contact("Mr A.", 20, false, "foo"), EchoModule::Thursday)),
+ QVariant::fromValue<Combo>(Combo(Contact("Mr B.", 40, true, "bar"), EchoModule::Tuesday)) });
+ server.m_echoZonedService.setComboList(comboListTestValue, frontLeftZone);
+ WAIT_AND_COMPARE(comboListSpy, 1);
+ QVariantList comboList = zone->comboList();
+ QCOMPARE(comboList.count(), comboListTestValue.count());
+ QCOMPARE(comboList.at(0).value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(comboList.at(1).value<Combo>(), comboListTestValue[1].value<Combo>());
+ QVariantList signalArgs = comboListSpy[0][0].toList();
+ QCOMPARE(signalArgs[0].value<Combo>(), comboListTestValue[0].value<Combo>());
+ QCOMPARE(signalArgs[1].value<Combo>(), comboListTestValue[1].value<Combo>());
+
+ QSignalSpy contactSpy(zone, SIGNAL(contactChanged(Contact)));
+ QVERIFY(contactSpy.isValid());
+ Contact contactTestValue(QStringLiteral("Nemo"), 47, true, 1);
+ server.m_echoZonedService.setContact(contactTestValue, frontLeftZone);
+ WAIT_AND_COMPARE(contactSpy, 1);
+ QCOMPARE(zone->contact(), contactTestValue);
+ QCOMPARE(contactSpy[0][0].value<Contact>(), contactTestValue);
+
+ QSignalSpy airflowSpy(zone, SIGNAL(airflowDirectionChanged(EchoModule::AirflowDirections)));
+ QVERIFY(airflowSpy.isValid());
+ EchoModule::AirflowDirections airflowTestValue = EchoModule::Windshield;
+ server.m_echoZonedService.setAirflowDirection(airflowTestValue, frontLeftZone);
+ WAIT_AND_COMPARE(airflowSpy, 1);
+ QCOMPARE(zone->airflowDirection(), airflowTestValue);
+ QCOMPARE(airflowSpy[0][0].value<EchoModule::AirflowDirections>(), airflowTestValue);
+
+ QSignalSpy testEnumSpy(zone, SIGNAL(testEnumChanged(EchoModule::TestEnum)));
+ QVERIFY(testEnumSpy.isValid());
+ EchoModule::TestEnum testEnumTestValue = EchoModule::SecondEnumValue;
+ server.m_echoZonedService.setTestEnum(testEnumTestValue, frontLeftZone);
+ WAIT_AND_COMPARE(testEnumSpy, 1);
+ QCOMPARE(zone->testEnum(), testEnumTestValue);
+ QCOMPARE(testEnumSpy[0][0].value<EchoModule::TestEnum>(), testEnumTestValue);
}
void EchoQtroTest::testSlots()
@@ -322,78 +670,126 @@ void EchoQtroTest::testSlots()
server.start();
Echo client;
- client.startAutoDiscovery();
+ QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
//wait until the client has connected and initial values are set
- QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
- QVERIFY(initSpy.isValid());
WAIT_AND_COMPARE(initSpy, 1);
QVERIFY(client.isInitialized());
//test slots by calling them on the client
- QSignalSpy echoSpy(&server.m_service, SIGNAL(echoSlotCalled(const QString&)));
+ QSignalSpy echoSpy(&server.m_echoService, SIGNAL(echoSlotCalled(const QString&)));
QVERIFY(echoSpy.isValid());
- QString echoTestValue("this will be echoed");
+ QLatin1String echoTestValue("this will be echoed");
QIviPendingReply<QString> echoReply = client.echo(echoTestValue);
QSignalSpy echoReplySpy(echoReply.watcher(), SIGNAL(replySuccess()));
WAIT_AND_COMPARE(echoReplySpy, 1);
QCOMPARE(echoReply.reply(), echoTestValue);
- QCOMPARE(echoSpy.count(),1);
+ QCOMPARE(echoSpy.count(), 1);
QCOMPARE(echoSpy[0][0].toString(), echoTestValue);
- QSignalSpy idSpy(&server.m_service, SIGNAL(idSlotCalled()));
+ QSignalSpy idSpy(&server.m_echoService, SIGNAL(idSlotCalled()));
QVERIFY(idSpy.isValid());
QIviPendingReply<QString> idReply = client.id();
QSignalSpy idReplySpy(idReply.watcher(), SIGNAL(replySuccess()));
WAIT_AND_COMPARE(idReplySpy, 1);
- QCOMPARE(idReply.reply(), server.m_service.m_testId);
- QCOMPARE(idSpy.count(),1);
+ QCOMPARE(idReply.reply(), server.m_echoService.m_testId);
+ QCOMPARE(idSpy.count(), 1);
- QSignalSpy getComboSpy(&server.m_service, SIGNAL(getComboSlotCalled()));
+ QSignalSpy getComboSpy(&server.m_echoService, SIGNAL(getComboSlotCalled()));
QVERIFY(getComboSpy.isValid());
QIviPendingReply<Combo> comboReply = client.getCombo();
QSignalSpy comboReplySpy(comboReply.watcher(), SIGNAL(replySuccess()));
WAIT_AND_COMPARE(comboReplySpy, 1);
- QCOMPARE(comboReply.reply(), server.m_service.m_testCombo);
- QCOMPARE(getComboSpy.count(),1);
+ QCOMPARE(comboReply.reply(), server.m_echoService.m_testCombo);
+ QCOMPARE(getComboSpy.count(), 1);
- QSignalSpy voidSlotSpy(&server.m_service, SIGNAL(voidSlotCalled()));
+ QSignalSpy voidSlotSpy(&server.m_echoService, SIGNAL(voidSlotCalled()));
QVERIFY(voidSlotSpy.isValid());
client.voidSlot();
WAIT_AND_COMPARE(voidSlotSpy, 1);
- QSignalSpy voidSlot2Spy(&server.m_service, SIGNAL(voidSlot2Called(int)));
+ QSignalSpy voidSlot2Spy(&server.m_echoService, SIGNAL(voidSlot2Called(int)));
int voidSlot2TestValue = 776;
QVERIFY(voidSlot2Spy.isValid());
client.voidSlot2(voidSlot2TestValue);
voidSlot2Spy.wait(1000);
- QCOMPARE(voidSlot2Spy.count(),1);
+ QCOMPARE(voidSlot2Spy.count(), 1);
QCOMPARE(voidSlot2Spy[0][0].toInt(), voidSlot2TestValue);
}
-void EchoQtroTest::testMultipleSlotCalls()
+void EchoQtroTest::testZonedSlots()
{
Server server;
server.start();
- Echo client;
- client.startAutoDiscovery();
+ EchoZoned client;
+ QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
//wait until the client has connected and initial values are set
+ WAIT_AND_COMPARE(initSpy, 1);
+ QVERIFY(client.isInitialized());
+
+ //test slots by calling them on the client
+ QSignalSpy echoSpy(&server.m_echoZonedService, SIGNAL(echoSlotCalled(QString, QString)));
+ QVERIFY(echoSpy.isValid());
+ QLatin1String echoTestValue("this will be echoed");
+ QIviPendingReply<QString> echoReply = client.echo(echoTestValue);
+ QSignalSpy echoReplySpy(echoReply.watcher(), SIGNAL(replySuccess()));
+ WAIT_AND_COMPARE(echoReplySpy, 1);
+ QCOMPARE(echoReply.reply(), echoTestValue);
+ QCOMPARE(echoSpy.count(), 1);
+ QCOMPARE(echoSpy[0][0].toString(), echoTestValue);
+ QCOMPARE(echoSpy[0][1].toString(), QString());
+
+ QSignalSpy idSpy(&server.m_echoZonedService, SIGNAL(idSlotCalled(QString)));
+ QVERIFY(idSpy.isValid());
+ QIviPendingReply<QString> idReply = client.id();
+ QSignalSpy idReplySpy(idReply.watcher(), SIGNAL(replySuccess()));
+ WAIT_AND_COMPARE(idReplySpy, 1);
+ QCOMPARE(idReply.reply(), server.m_echoService.m_testId);
+ QCOMPARE(idSpy.count(), 1);
+ QCOMPARE(idSpy[0][0].toString(), QString());
+
+ EchoZoned *zone = qobject_cast<EchoZoned*>(client.zoneAt(frontLeftZone));
+ QVERIFY(zone);
+
+ QSignalSpy getComboSpy(&server.m_echoZonedService, SIGNAL(getComboSlotCalled(QString)));
+ QVERIFY(getComboSpy.isValid());
+ QIviPendingReply<Combo> comboReply = zone->getCombo();
+ QSignalSpy comboReplySpy(comboReply.watcher(), SIGNAL(replySuccess()));
+ WAIT_AND_COMPARE(comboReplySpy, 1);
+ QCOMPARE(comboReply.reply(), server.m_echoService.m_testCombo);
+ QCOMPARE(getComboSpy.count(), 1);
+}
+
+void EchoQtroTest::testMultipleSlotCalls()
+{
+ Server server;
+ server.start();
+
+ Echo client;
QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+
+ //wait until the client has connected and initial values are set
initSpy.wait(1000);
QCOMPARE(initSpy.count(), 1);
QVERIFY(client.isInitialized());
//test the pending replies by calling the same slot with 3 different values
- QSignalSpy echoSpy(&server.m_service, SIGNAL(echoSlotCalled(const QString&)));
+ QSignalSpy echoSpy(&server.m_echoService, SIGNAL(echoSlotCalled(const QString&)));
QVERIFY(echoSpy.isValid());
- QString echoTestValue("first");
- QString echoTestValue2("second");
- QString echoTestValue3("third");
+ QLatin1String echoTestValue("first");
+ QLatin1String echoTestValue2("second");
+ QLatin1String echoTestValue3("third");
QIviPendingReply<QString> echoReply = client.echo(echoTestValue);
QIviPendingReply<QString> echoReply2 = client.echo(echoTestValue2);
QIviPendingReply<QString> echoReply3 = client.echo(echoTestValue3);
@@ -407,24 +803,124 @@ void EchoQtroTest::testMultipleSlotCalls()
QCOMPARE(echoReply.reply(), echoTestValue);
QCOMPARE(echoReply2.reply(), echoTestValue2);
QCOMPARE(echoReply3.reply(), echoTestValue3);
- QCOMPARE(echoSpy.count(),3);
+ QCOMPARE(echoSpy.count(), 3);
QCOMPARE(echoSpy[0][0].toString(), echoTestValue);
QCOMPARE(echoSpy[1][0].toString(), echoTestValue2);
QCOMPARE(echoSpy[2][0].toString(), echoTestValue3);
+
+ EchoZoned zonedClient;
+ QSignalSpy zonedInitSpy(&zonedClient, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(zonedInitSpy.isValid());
+ QVERIFY(zonedClient.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
+ zonedInitSpy.wait(1000);
+ QCOMPARE(zonedInitSpy.count(), 1);
+ QVERIFY(zonedClient.isInitialized());
+
+ EchoZoned *zone = qobject_cast<EchoZoned*>(zonedClient.zoneAt(frontLeftZone));
+ QVERIFY(zone);
+
+ QSignalSpy echoZonedSpy(&server.m_echoZonedService, SIGNAL(echoSlotCalled(QString, QString)));
+ QVERIFY(echoSpy.isValid());
+ QIviPendingReply<QString> echoZonedReply = zone->echo(echoTestValue);
+ QIviPendingReply<QString> echoZonedReply2 = zone->echo(echoTestValue2);
+ QIviPendingReply<QString> echoZonedReply3 = zone->echo(echoTestValue3);
+ QSignalSpy echoZonedReplySpy(echoZonedReply.watcher(), SIGNAL(replySuccess()));
+ QSignalSpy echoZonedReplySpy2(echoZonedReply2.watcher(), SIGNAL(replySuccess()));
+ QSignalSpy echoZonedReplySpy3(echoZonedReply3.watcher(), SIGNAL(replySuccess()));
+ echoZonedReplySpy3.wait();
+ QCOMPARE(echoZonedReplySpy.count(), 1);
+ QCOMPARE(echoZonedReplySpy2.count(), 1);
+ QCOMPARE(echoZonedReplySpy3.count(), 1);
+ QCOMPARE(echoZonedReply.reply(), echoTestValue);
+ QCOMPARE(echoZonedReply2.reply(), echoTestValue2);
+ QCOMPARE(echoZonedReply3.reply(), echoTestValue3);
+ QCOMPARE(echoZonedSpy.count(),3);
+ QCOMPARE(echoZonedSpy[0][0].toString(), echoTestValue);
+ QCOMPARE(echoZonedSpy[0][1].toString(), frontLeftZone);
+ QCOMPARE(echoZonedSpy[1][0].toString(), echoTestValue2);
+ QCOMPARE(echoZonedSpy[0][1].toString(), frontLeftZone);
+ QCOMPARE(echoZonedSpy[2][0].toString(), echoTestValue3);
+ QCOMPARE(echoZonedSpy[0][1].toString(), frontLeftZone);
}
-void EchoQtroTest::testSignals()
+void EchoQtroTest::testAsyncSlotResults()
{
Server server;
server.start();
Echo client;
- client.startAutoDiscovery();
+ QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
+ initSpy.wait(1000);
+ QCOMPARE(initSpy.count(), 1);
+ QVERIFY(client.isInitialized());
+ // test the timer() function which uses a pendingReply on the server side to return the
+ // function when the timer is finished.
+ QIviPendingReply<void> reply = client.timer(1000);
+ QIviPendingReply<void> reply2 = client.timer(500);
+ QSignalSpy echoReplySpy(reply.watcher(), SIGNAL(replySuccess()));
+ QSignalSpy echoReplySpy2(reply2.watcher(), SIGNAL(replySuccess()));
+
+ //Wait for the second reply to return first. Verify the other reply is not yet ready.
+ echoReplySpy2.wait();
+ QCOMPARE(echoReplySpy2.count(), 1);
+ QCOMPARE(echoReplySpy.count(), 0);
+
+ //Wait for the first reply and verify both replies were sent.
+ echoReplySpy.wait();
+ QCOMPARE(echoReplySpy2.count(), 1);
+ QCOMPARE(echoReplySpy.count(), 1);
+
+ EchoZoned zonedClient;
+ QSignalSpy zonedInitSpy(&zonedClient, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(zonedInitSpy.isValid());
+ QVERIFY(zonedClient.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
//wait until the client has connected and initial values are set
+ zonedInitSpy.wait(1000);
+ QCOMPARE(zonedInitSpy.count(), 1);
+ QVERIFY(zonedClient.isInitialized());
+
+ EchoZoned *zone = qobject_cast<EchoZoned*>(zonedClient.zoneAt(frontLeftZone));
+ QVERIFY(zone);
+
+ // test the timer() function which uses a pendingReply on the server side to return the
+ // function when the timer is finished.
+ QIviPendingReply<QString> zonedReply = zonedClient.timer(1000);
+ QIviPendingReply<QString> zonedReply2 = zone->timer(500);
+ QSignalSpy zonedEchoReplySpy(zonedReply.watcher(), SIGNAL(replySuccess()));
+ QSignalSpy zonedEchoReplySpy2(zonedReply2.watcher(), SIGNAL(replySuccess()));
+
+ //Wait for the second reply to return first. Verify the other reply is not yet ready.
+ zonedEchoReplySpy2.wait();
+ QCOMPARE(zonedEchoReplySpy2.count(), 1);
+ QCOMPARE(zonedEchoReplySpy.count(), 0);
+ QCOMPARE(zonedReply2.value(), frontLeftZone);
+
+ //Wait for the first reply and verify both replies were sent.
+ zonedEchoReplySpy.wait();
+ QCOMPARE(zonedEchoReplySpy2.count(), 1);
+ QCOMPARE(zonedEchoReplySpy.count(), 1);
+ QCOMPARE(zonedReply.value(), QString());
+}
+
+void EchoQtroTest::testSignals()
+{
+ Server server;
+ server.start();
+
+ Echo client;
QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
WAIT_AND_COMPARE(initSpy, 1);
QVERIFY(client.isInitialized());
@@ -432,19 +928,97 @@ void EchoQtroTest::testSignals()
QSignalSpy anotherChangedSpy(&client, SIGNAL(anotherChanged(AnotherStruct)));
QVERIFY(anotherChangedSpy.isValid());
AnotherStruct anotherTestValue(7);
- server.m_service.anotherChanged(anotherTestValue);
+ server.m_echoService.anotherChanged(anotherTestValue);
WAIT_AND_COMPARE(anotherChangedSpy, 1);
QCOMPARE(anotherChangedSpy[0][0].value<AnotherStruct>(), anotherTestValue);
QSignalSpy foobarSpy(&client, SIGNAL(foobar(QString)));
QVERIFY(foobarSpy.isValid());
- QString foobarTestValue("foo and bar");
- server.m_service.foobar(foobarTestValue);
+ QLatin1String foobarTestValue("foo and bar");
+ server.m_echoService.foobar(foobarTestValue);
WAIT_AND_COMPARE(foobarSpy, 1);
QCOMPARE(foobarSpy[0][0].toString(), foobarTestValue);
QSignalSpy somethingSpy(&client, SIGNAL(somethingHappened()));
QVERIFY(somethingSpy.isValid());;
- server.m_service.somethingHappened();
+ server.m_echoService.somethingHappened();
WAIT_AND_COMPARE(somethingSpy, 1);
+
+
+ EchoZoned zonedClient;
+ QSignalSpy zonedInitSpy(&zonedClient, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(zonedInitSpy.isValid());
+ QVERIFY(zonedClient.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
+ zonedInitSpy.wait(1000);
+ QCOMPARE(zonedInitSpy.count(), 1);
+ QVERIFY(zonedClient.isInitialized());
+
+ //test custom signals (other than property notifiers) from server to client
+ QSignalSpy zonedAnotherChangedSpy(&zonedClient, SIGNAL(anotherChanged(AnotherStruct)));
+ QVERIFY(zonedAnotherChangedSpy.isValid());
+ server.m_echoZonedService.anotherChanged(anotherTestValue, QString());
+ WAIT_AND_COMPARE(zonedAnotherChangedSpy, 1);
+ QCOMPARE(zonedAnotherChangedSpy[0][0].value<AnotherStruct>(), anotherTestValue);
+
+ EchoZoned *zone = qobject_cast<EchoZoned*>(zonedClient.zoneAt(frontLeftZone));
+ QVERIFY(zone);
+
+ QSignalSpy zonedFoobarSpy(zone, SIGNAL(foobar(QString)));
+ QVERIFY(zonedFoobarSpy.isValid());
+ server.m_echoZonedService.foobar(foobarTestValue, frontLeftZone);
+ WAIT_AND_COMPARE(zonedFoobarSpy, 1);
+ QCOMPARE(zonedFoobarSpy[0][0].toString(), foobarTestValue);
+
+ QSignalSpy zonedSomethingSpy(zone, SIGNAL(somethingHappened()));
+ QVERIFY(zonedSomethingSpy.isValid());;
+ server.m_echoZonedService.somethingHappened(frontLeftZone);
+ WAIT_AND_COMPARE(zonedSomethingSpy, 1);
+}
+
+void EchoQtroTest::testModel()
+{
+ Server server;
+ server.start();
+
+ Echo client;
+ QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(initSpy.isValid());
+ QVERIFY(client.startAutoDiscovery() == QIviAbstractFeature::ProductionBackendLoaded);
+
+ //wait until the client has connected and initial values are set
+ WAIT_AND_COMPARE(initSpy, 1);
+ QVERIFY(client.isInitialized());
+
+ //Give QtRO time to actually call our server side
+ QTest::qWait(200);
+
+ QIviPagingModel* model = client.contactList();
+ QVERIFY(model->isInitialized());
+ QCOMPARE(model->rowCount(), 0);
+
+ //Test inserting a row
+ Contact testContact(QStringLiteral("Mr A."), 20, false, "foo");
+ QSignalSpy countSpy(model, SIGNAL(countChanged()));
+ server.m_contactsModelService.insert(0, testContact);
+
+ WAIT_AND_COMPARE(countSpy, 1);
+ QCOMPARE(model->rowCount(), 1);
+ QCOMPARE(model->at<Contact>(0), testContact);
+ countSpy.clear();
+
+ //test updating a row
+ QSignalSpy changedSpy(model, SIGNAL(dataChanged( QModelIndex, QModelIndex, QVector<int>)));
+ Contact updatedContact(QStringLiteral("Mr B."), 30, true, QVariant());
+ server.m_contactsModelService.update(0, updatedContact);
+
+ WAIT_AND_COMPARE(changedSpy, 1);
+ QCOMPARE(model->rowCount(), 1);
+ QCOMPARE(model->at<Contact>(0), updatedContact);
+
+ //Test removing a row
+ server.m_contactsModelService.remove(0);
+ WAIT_AND_COMPARE(countSpy, 1);
+ QCOMPARE(model->rowCount(), 0);
}
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h
index f573ab0..5ff3da4 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h
@@ -43,12 +43,18 @@ public:
private slots:
void cleanup();
void testInit();
+ void testZonedInit();
void testReconnect();
void testClient2Server();
+ void testZonedClient2Server();
void testServer2Client();
+ void testZonedServer2Client();
void testSlots();
+ void testZonedSlots();
void testMultipleSlotCalls();
+ void testAsyncSlotResults();
void testSignals();
+ void testModel();
};
#endif // ECHOQTROTEST_H
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/simulation_server_qtro/simulation_server_qtro.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/simulation_server_qtro/simulation_server_qtro.pro
new file mode 100644
index 0000000..75be13e
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/simulation_server_qtro/simulation_server_qtro.pro
@@ -0,0 +1,16 @@
+TEMPLATE = app
+TARGET = org-example-echo-qtro-simulation-server
+QMAKE_PROJECT_NAME = $$TARGET
+LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_frontend)
+
+DESTDIR = ..
+
+CONFIG += c++11 ivigenerator
+CONFIG -= app_bundle
+
+INCLUDEPATH += $$OUT_PWD/../frontend
+
+QT += qml quick core ivicore
+
+QFACE_FORMAT = server_qtro_simulator
+QFACE_SOURCES = ../../../org.example.echo.qface
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/control_panel/control_panel.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/control_panel/control_panel.pro
deleted file mode 100644
index 8521a23..0000000
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/control_panel/control_panel.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE=app
-TARGET= echo_simulator_control_panel
-DESTDIR = ../
-
-CONFIG += ivigenerator
-
-QT += ivicore ivicore-private qml quick
-
-QFACE_FORMAT = control_panel
-QFACE_SOURCES = ../../../org.example.echo.simulator.qface
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/frontend/frontend.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/frontend/frontend.pro
deleted file mode 100644
index 130ea15..0000000
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/frontend/frontend.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TEMPLATE=lib
-TARGET= $$qtLibraryTarget(echo_simulator_frontend)
-DESTDIR = ../
-
-CONFIG += ivigenerator
-
-QT += ivicore ivicore-private qml quick
-
-DEFINES += QT_BUILD_ORG_EXAMPLE_SIMULATOR_ECHO_LIB
-
-macos: QMAKE_SONAME_PREFIX = @rpath
-
-QFACE_SOURCES = ../../../org.example.echo.simulator.qface
-
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/org-example-echo-simulator.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/org-example-echo-simulator.pro
deleted file mode 100644
index eeb5bbb..0000000
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-simulator/org-example-echo-simulator.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = subdirs
-
-QT_FOR_CONFIG += ivicore
-
-SUBDIRS = frontend \
- backend_simulator \
- control_panel \
- validator \
- test
-
-backend_simulator.depends = frontend
-validator.depends = frontend
-test.depends = frontend
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo/org-example-echo.pro b/tests/auto/core/ivigenerator/projects/org-example-echo/org-example-echo.pro
index 2446d17..38be75d 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo/org-example-echo.pro
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo/org-example-echo.pro
@@ -1,6 +1,7 @@
TEMPLATE = subdirs
SUBDIRS = frontend \
+ qmlplugin \
backend_simulator \
validator \
test \
@@ -8,3 +9,4 @@ SUBDIRS = frontend \
backend_simulator.depends = frontend
validator.depends = frontend
test.depends = frontend
+qmlplugin.depends = frontend
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo/qmlplugin/qmlplugin.pro b/tests/auto/core/ivigenerator/projects/org-example-echo/qmlplugin/qmlplugin.pro
new file mode 100644
index 0000000..a015b72
--- /dev/null
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo/qmlplugin/qmlplugin.pro
@@ -0,0 +1,11 @@
+TEMPLATE = lib
+QT = ivicore ivivehiclefunctions
+CONFIG += c++11 plugin
+
+INCLUDEPATH += $$OUT_PWD/../frontend
+LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_frontend)
+
+QFACE_FORMAT = qmlplugin
+QFACE_SOURCES = ../../../org.example.echo.qface
+
+load(ivigenerator)
diff --git a/tests/auto/core/ivigenerator/projects/projects.pro b/tests/auto/core/ivigenerator/projects/projects.pro
index cc11805..bc349a5 100644
--- a/tests/auto/core/ivigenerator/projects/projects.pro
+++ b/tests/auto/core/ivigenerator/projects/projects.pro
@@ -4,11 +4,8 @@ QT_FOR_CONFIG += ivicore
SUBDIRS = org-example-echo \
org-example-echo-noprivate \
+ org-example-echo-noannotation \
qtConfig(remoteobjects) {
SUBDIRS += org-example-echo-qtro
}
-
-qtConfig(simulator) {
- SUBDIRS += org-example-echo-simulator
-}
diff --git a/tests/auto/core/qivipagingmodel/tst_qivipagingmodel.cpp b/tests/auto/core/qivipagingmodel/tst_qivipagingmodel.cpp
index 68239c8..560d2b2 100644
--- a/tests/auto/core/qivipagingmodel/tst_qivipagingmodel.cpp
+++ b/tests/auto/core/qivipagingmodel/tst_qivipagingmodel.cpp
@@ -231,24 +231,33 @@ void tst_QIviPagingModel::testClearServiceObject()
QIviPagingModel model;
model.setServiceObject(service);
- //TODO enable when fixed
- //model.setLoadingType(QIviSearchAndBrowseModel::DataChanged);
+ model.setLoadingType(QIviPagingModel::DataChanged);
model.setChunkSize(20);
model.setFetchMoreThreshold(20);
+ QSignalSpy chunkSizeSpy(&model, &QIviPagingModel::chunkSizeChanged);
QVERIFY(model.chunkSize() != defaultModel.chunkSize());
+ QSignalSpy thresholdSpy(&model, &QIviPagingModel::fetchMoreThresholdChanged);
QVERIFY(model.fetchMoreThreshold() != defaultModel.fetchMoreThreshold());
+ QSignalSpy capabilitiesSpy(&model, &QIviPagingModel::capabilitiesChanged);
QVERIFY(model.capabilities() != defaultModel.capabilities());
- //QVERIFY(model.loadingType() != defaultModel.loadingType());
+ QSignalSpy loadingTypeSpy(&model, &QIviPagingModel::loadingTypeChanged);
+ QVERIFY(model.loadingType() != defaultModel.loadingType());
+ QSignalSpy resetSpy(&model, &QAbstractItemModel::modelReset);
QVERIFY(model.rowCount() != defaultModel.rowCount());
QVERIFY(model.setServiceObject(nullptr));
QVERIFY(model.chunkSize() == defaultModel.chunkSize());
+ QCOMPARE(chunkSizeSpy.count(), 1);
QVERIFY(model.fetchMoreThreshold() == defaultModel.fetchMoreThreshold());
+ QCOMPARE(thresholdSpy.count(), 1);
QVERIFY(model.capabilities() == defaultModel.capabilities());
+ QCOMPARE(capabilitiesSpy.count(), 1);
QVERIFY(model.loadingType() == defaultModel.loadingType());
+ QCOMPARE(loadingTypeSpy.count(), 1);
QVERIFY(model.rowCount() == defaultModel.rowCount());
+ QCOMPARE(resetSpy.count(), 1);
}
void tst_QIviPagingModel::testRegisterInstance()
diff --git a/tests/auto/core/qiviproperty/qiviproperty.pro b/tests/auto/core/qiviproperty/qiviproperty.pro
deleted file mode 100644
index 7105bda..0000000
--- a/tests/auto/core/qiviproperty/qiviproperty.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += testlib ivicore qml
-
-TARGET = tst_qiviproperty
-QMAKE_PROJECT_NAME = $$TARGET
-CONFIG += testcase
-
-TEMPLATE = app
-
-SOURCES += \
- tst_qiviproperty.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD/\\\"
-TESTDATA = testdata/*
diff --git a/tests/auto/core/qiviproperty/testdata/readWrite.qml b/tests/auto/core/qiviproperty/testdata/readWrite.qml
deleted file mode 100644
index 8f84162..0000000
--- a/tests/auto/core/qiviproperty/testdata/readWrite.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 Luxoft Sweden AB
-** Copyright (C) 2018 Pelagicore AG
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtIvi module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT-QTAS$
-** Commercial License Usage
-** Licensees holding valid commercial Qt Automotive Suite 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.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import TestObject 1.0
-
-Item {
-
- property int intProperty: testObject.intAttributeProperty.value
- property int enumProperty: testObject.enumAttributeProperty.value
- property var flagsProperty: testObject.flagsAttributeProperty.value
- property var extendFlag: testObject.flagsAttributeProperty.value
- property bool isFlag2Set: testObject.flagsAttributeProperty.value & TestObject.TestFlag_2
- property bool isFlag3Set: testObject.flagsAttributeProperty.value & TestObject.TestFlag_3
-
- function updateValues() {
- testObject.intAttributeProperty.value = 2.4
- testObject.enumAttributeProperty.value = TestObject.TestValue_2
- testObject.flagsAttributeProperty.value = TestObject.TestFlag_1 | TestObject.TestFlag_2
- extendFlag = testObject.flagsAttributeProperty.value | TestObject.TestFlag_3
- }
-}
diff --git a/tests/auto/core/qiviproperty/tst_qiviproperty.cpp b/tests/auto/core/qiviproperty/tst_qiviproperty.cpp
deleted file mode 100644
index 551bfc2..0000000
--- a/tests/auto/core/qiviproperty/tst_qiviproperty.cpp
+++ /dev/null
@@ -1,491 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 Luxoft Sweden AB
-** Copyright (C) 2018 Pelagicore AG
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtIvi module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT-QTAS$
-** Commercial License Usage
-** Licensees holding valid commercial Qt Automotive Suite 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.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest>
-#include <QQmlEngine>
-#include <QQmlComponent>
-#include <QQmlContext>
-#include <qivipropertyattribute.h>
-#include <qivipropertyfactory.h>
-
-#define QIVIPROPERTY(_type_, _name_) \
-Q_PROPERTY(QIviProperty* _name_##Property READ _name_##Property CONSTANT) \
-QIviProperty *m_##_name_##Property; \
-QIviPropertyAttribute<_type_> m_##_name_; \
-_type_ m_##_name_##Value; \
- \
-public: \
-QIviProperty *_name_##Property() const { return m_##_name_##Property; } \
-QIviPropertyAttribute<_type_> _name_() const { return m_##_name_; } \
-void set##_name_(QIviPropertyAttribute<_type_> attribute) { if (attribute == m_##_name_) return; m_##_name_ = attribute; emit _name_##Changed(attribute); } \
- \
-_type_ _name_##Value() const { return m_##_name_##Value; } \
-void set##_name_##Value(_type_ value) { if (value == m_##_name_##Value) return; m_##_name_##Value = value; emit _name_##ValueChanged(value); } \
- \
-Q_SIGNALS: \
-void _name_##ValueChanged(_type_ value); \
-void _name_##Changed(const QIviPropertyAttribute<_type_> _name_); \
-private:
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
-public:
- enum TestEnum {
- TestValue_1 = 1,
- TestValue_2,
- TestValue_3,
- };
- Q_ENUM(TestEnum)
-
- enum TestFlag {
- TestFlag_1 = 0x1,
- TestFlag_2 = 0x2,
- TestFlag_3 = 0x4,
- };
- Q_DECLARE_FLAGS(TestFlags, TestFlag)
- Q_FLAG(TestFlags)
-
- enum InvalidEnum {
- InvalidValue_1 = 1,
- InvalidValue_2,
- InvalidValue_3,
- };
- Q_ENUMS(InvalidEnum)
-
- QIVIPROPERTY(int, intAttribute)
- QIVIPROPERTY(QString, readOnlyAttribute)
- QIVIPROPERTY(TestObject::TestEnum, enumAttribute)
- QIVIPROPERTY(TestObject::TestFlags, flagsAttribute)
-
-public:
- TestObject(QObject *parent = nullptr)
- : QObject(parent)
- , m_intAttributeProperty(QIviPropertyFactory<int>::create(this,
- &TestObject::intAttribute,
- &TestObject::intAttributeChanged,
- &TestObject::intAttributeValue,
- &TestObject::intAttributeValueChanged,
- &TestObject::setintAttributeValue))
- , m_intAttributeValue(-1)
- , m_readOnlyAttributeProperty(QIviPropertyFactory<QString>::create(this,
- &TestObject::readOnlyAttribute,
- &TestObject::readOnlyAttributeChanged,
- &TestObject::readOnlyAttributeValue,
- &TestObject::readOnlyAttributeValueChanged))
- , m_enumAttributeProperty(QIviPropertyFactory<TestObject::TestEnum>::create(this,
- &TestObject::enumAttribute,
- &TestObject::enumAttributeChanged,
- &TestObject::enumAttributeValue,
- &TestObject::enumAttributeValueChanged,
- &TestObject::setenumAttributeValue))
- , m_enumAttributeValue(TestObject::TestEnum())
- , m_flagsAttributeProperty(QIviPropertyFactory<TestObject::TestFlags>::create(this,
- &TestObject::flagsAttribute,
- &TestObject::flagsAttributeChanged,
- &TestObject::flagsAttributeValue,
- &TestObject::flagsAttributeValueChanged,
- &TestObject::setflagsAttributeValue))
- , m_flagsAttributeValue(TestObject::TestFlags())
- {}
-};
-
-Q_DECLARE_METATYPE(TestObject::TestEnum)
-Q_DECLARE_METATYPE(QIviPropertyAttribute<TestObject::TestEnum>)
-Q_DECLARE_METATYPE(TestObject::TestFlags)
-Q_DECLARE_METATYPE(QIviPropertyAttribute<TestObject::TestFlags>)
-Q_DECLARE_OPERATORS_FOR_FLAGS(TestObject::TestFlags)
-Q_DECLARE_METATYPE(QList<QQmlError>)
-
-class tst_QIviProperty : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QIviProperty();
-
-private Q_SLOTS:
- void selfTest();
- void attribute_data();
- void attribute();
- void setGetValue();
- void setGetValue_flags();
- void setGetValue_qml();
- void setValueError_qml();
- void readOnly();
- void readOnly_qml();
-
-private:
- void initializeEnumAttribute(TestObject *testObject)
- {
- QSignalSpy propertyValueChangedSpy(testObject->enumAttributeProperty(), &QIviProperty::valueChanged);
- QSignalSpy valueChangedSpy(testObject, &TestObject::enumAttributeValueChanged);
-
- //Initialize
- testObject->setenumAttributeValue(TestObject::TestValue_3);
-
- QCOMPARE(propertyValueChangedSpy.count(), 1);
- QCOMPARE(propertyValueChangedSpy.at(0).at(0), QVariant::fromValue<TestObject::TestEnum>(TestObject::TestValue_3));
- QCOMPARE(valueChangedSpy.count(), 1);
- QCOMPARE(valueChangedSpy.at(0).at(0), QVariant::fromValue<TestObject::TestEnum>(TestObject::TestValue_3));
- }
-
- void initializeFlagsAttribute(TestObject *testObject)
- {
- QSignalSpy propertyValueChangedSpy(testObject->flagsAttributeProperty(), &QIviProperty::valueChanged);
- QSignalSpy valueChangedSpy(testObject, &TestObject::flagsAttributeValueChanged);
-
- //Initialize
- testObject->setflagsAttributeValue(TestObject::TestFlag_3);
-
- QCOMPARE(propertyValueChangedSpy.count(), 1);
- QCOMPARE(propertyValueChangedSpy.at(0).at(0), QVariant::fromValue<TestObject::TestFlags>(TestObject::TestFlag_3));
- QCOMPARE(valueChangedSpy.count(), 1);
- QCOMPARE(valueChangedSpy.at(0).at(0), QVariant::fromValue<TestObject::TestFlags>(TestObject::TestFlag_3));
- }
-
- void initializeIntAttribute(TestObject *testObject)
- {
- QSignalSpy propertyValueChangedSpy(testObject->intAttributeProperty(), &QIviProperty::valueChanged);
- QSignalSpy valueChangedSpy(testObject, &TestObject::intAttributeValueChanged);
-
- //Initialize
- testObject->setintAttributeValue(1);
-
- QCOMPARE(propertyValueChangedSpy.count(), 1);
- QCOMPARE(propertyValueChangedSpy.at(0).at(0), QVariant(1));
- QCOMPARE(valueChangedSpy.count(), 1);
- QCOMPARE(valueChangedSpy.at(0).at(0), QVariant(1));
- }
-};
-
-tst_QIviProperty::tst_QIviProperty()
-{
- qRegisterMetaType<QIviPropertyAttribute<int>>();
- qRegisterMetaType<QIviPropertyAttribute<QString>>();
- qRegisterMetaType<TestObject::TestEnum>();
- qRegisterMetaType<QIviPropertyAttribute<TestObject::TestEnum>>();
- qRegisterMetaType<TestObject::TestFlags>();
- qRegisterMetaType<QIviPropertyAttribute<TestObject::TestFlags>>();
- qRegisterMetaType<QList<QQmlError>>();
-}
-
-void tst_QIviProperty::selfTest()
-{
- TestObject *testObject = new TestObject();
-
- QCOMPARE(testObject->intAttributeValue(), -1);
- QCOMPARE(testObject->intAttribute().type(), QIviPropertyAttributeBase::Invalid);
- QVERIFY(testObject->intAttributeProperty());
-
- QCOMPARE(testObject->readOnlyAttributeValue(), QString());
- QCOMPARE(testObject->readOnlyAttribute().type(), QIviPropertyAttributeBase::Invalid);
- QVERIFY(testObject->readOnlyAttributeProperty());
-
- QCOMPARE(testObject->enumAttributeValue(), TestObject::TestEnum());
- QCOMPARE(testObject->enumAttribute().type(), QIviPropertyAttributeBase::Invalid);
- QVERIFY(testObject->enumAttributeProperty());
-
- QCOMPARE(testObject->flagsAttributeValue(), TestObject::TestFlags());
- QCOMPARE(testObject->flagsAttribute().type(), QIviPropertyAttributeBase::Invalid);
- QVERIFY(testObject->flagsAttributeProperty());
-}
-
-void tst_QIviProperty::attribute_data()
-{
- QTest::addColumn<QIviPropertyAttribute<int>>("attribute");
- QTest::addColumn<QVariantList>("exptectedList");
- QTest::newRow("noAttribute") << QIviPropertyAttribute<int>(true) << QVariantList();
- QTest::newRow("minimumMaximum") << QIviPropertyAttribute<int>(0,10) << QVariantList();
- QVector<int> avValues;
- QVariantList avVariant;
- avValues << 0 << 5 << 10;
- avVariant << 0 << 5 << 10;
- QTest::newRow("availableValues") << QIviPropertyAttribute<int>(avValues) << QVariantList(avVariant);
-}
-
-void tst_QIviProperty::attribute()
-{
- QFETCH(QIviPropertyAttribute<int>, attribute);
- QFETCH(QVariantList, exptectedList);
-
- TestObject *testObject = new TestObject();
-
- QSignalSpy maximumChangedSpy(testObject->intAttributeProperty(), &QIviProperty::maximumValueChanged);
- QSignalSpy minimumChangedSpy(testObject->intAttributeProperty(), &QIviProperty::minimumValueChanged);
- QSignalSpy availableValuesChangedSpy(testObject->intAttributeProperty(), &QIviProperty::availableValuesChanged);
- QSignalSpy availableChangedSpy(testObject->intAttributeProperty(), &QIviProperty::availableChanged);
- QSignalSpy noAttChangedSpy(testObject, &TestObject::intAttributeChanged);
-
- testObject->setintAttribute(attribute);
- QVariant attributeVariant = QVariant::fromValue<QIviPropertyAttribute<int>>(attribute);
-
- QCOMPARE(maximumChangedSpy.count(), 1);
- QCOMPARE(maximumChangedSpy.at(0).at(0), QVariant::fromValue<int>(attribute.maximumValue()));
- QCOMPARE(minimumChangedSpy.count(), 1);
- QCOMPARE(minimumChangedSpy.at(0).at(0), QVariant::fromValue<int>(attribute.minimumValue()));
- QCOMPARE(availableValuesChangedSpy.count(), 1);
- QCOMPARE(availableValuesChangedSpy.at(0).at(0), QVariant(exptectedList));
- QCOMPARE(availableChangedSpy.count(), 1);
- QCOMPARE(availableChangedSpy.at(0).at(0), QVariant::fromValue<bool>(attribute.isAvailable()));
- QCOMPARE(noAttChangedSpy.count(), 1);
- QCOMPARE(noAttChangedSpy.at(0).at(0), attributeVariant);
- QCOMPARE(testObject->intAttribute(), attribute);
- QCOMPARE(testObject->intAttributeProperty()->isAvailable(), attribute.isAvailable());
- QCOMPARE(testObject->intAttributeProperty()->minimumValue(), QVariant::fromValue<int>(attribute.minimumValue()));
- QCOMPARE(testObject->intAttributeProperty()->maximumValue(), QVariant::fromValue<int>(attribute.maximumValue()));
- QCOMPARE(testObject->intAttributeProperty()->availableValues(), exptectedList);
-}
-
-void tst_QIviProperty::setGetValue()
-{
- TestObject *testObject = new TestObject();
- QSignalSpy propertyValueChangedSpy(testObject->enumAttributeProperty(), &QIviProperty::valueChanged);
- QSignalSpy valueChangedSpy(testObject, &TestObject::enumAttributeValueChanged);
-
- //Initialize
- testObject->setenumAttributeValue(TestObject::TestValue_3);
-
- QCOMPARE(propertyValueChangedSpy.count(), 1);
- QCOMPARE(propertyValueChangedSpy.at(0).at(0), QVariant::fromValue<TestObject::TestEnum>(TestObject::TestValue_3));
- QCOMPARE(valueChangedSpy.count(), 1);
- QCOMPARE(valueChangedSpy.at(0).at(0), QVariant::fromValue<TestObject::TestEnum>(TestObject::TestValue_3));
-
- //Read value
- QCOMPARE(testObject->enumAttributeValue(), TestObject::TestValue_3);
- QCOMPARE(testObject->enumAttributeProperty()->value(), QVariant::fromValue<TestObject::TestEnum>(TestObject::TestValue_3));
-
- propertyValueChangedSpy.clear();
- valueChangedSpy.clear();
-
- //Set value
- QVariant newValueVariant(TestObject::TestValue_2);
- testObject->enumAttributeProperty()->setValue(newValueVariant);
-
- QCOMPARE(propertyValueChangedSpy.count(), 1);
- QCOMPARE(propertyValueChangedSpy.at(0).at(0), newValueVariant);
- QCOMPARE(valueChangedSpy.count(), 1);
- QCOMPARE(valueChangedSpy.at(0).at(0), newValueVariant);
-
- //Read value
- QCOMPARE(testObject->enumAttributeValue(), TestObject::TestValue_2);
- QCOMPARE(testObject->enumAttributeProperty()->value(), newValueVariant);
-}
-
-void tst_QIviProperty::setGetValue_flags()
-{
- TestObject *testObject = new TestObject();
- QSignalSpy propertyValueChangedSpy(testObject->flagsAttributeProperty(), &QIviProperty::valueChanged);
- QSignalSpy valueChangedSpy(testObject, &TestObject::flagsAttributeValueChanged);
-
- //Initialize
- testObject->setflagsAttributeValue(TestObject::TestFlag_3);
-
- QCOMPARE(propertyValueChangedSpy.count(), 1);
- QCOMPARE(propertyValueChangedSpy.at(0).at(0), QVariant::fromValue<TestObject::TestFlags>(TestObject::TestFlag_3));
- QCOMPARE(valueChangedSpy.count(), 1);
- QCOMPARE(valueChangedSpy.at(0).at(0), QVariant::fromValue<TestObject::TestFlags>(TestObject::TestFlag_3));
-
- //Read value
- QCOMPARE(testObject->flagsAttributeValue(), TestObject::TestFlag_3);
- QCOMPARE(testObject->flagsAttributeProperty()->value(), QVariant::fromValue<TestObject::TestFlags>(TestObject::TestFlag_3));
-
- propertyValueChangedSpy.clear();
- valueChangedSpy.clear();
-
- //Set value
- QVariant newValueVariant = QVariant::fromValue(TestObject::TestFlags(TestObject::TestFlag_1 | TestObject::TestFlag_2));
- testObject->flagsAttributeProperty()->setValue(newValueVariant);
-
- QCOMPARE(propertyValueChangedSpy.count(), 1);
- QCOMPARE(propertyValueChangedSpy.at(0).at(0), newValueVariant);
- QCOMPARE(valueChangedSpy.count(), 1);
- QCOMPARE(valueChangedSpy.at(0).at(0), newValueVariant);
-
- //Read value
- QCOMPARE(testObject->flagsAttributeValue(), TestObject::TestFlag_1 | TestObject::TestFlag_2);
- QCOMPARE(testObject->flagsAttributeProperty()->value(), newValueVariant);
-}
-
-void tst_QIviProperty::setGetValue_qml()
-{
- TestObject *testObject = new TestObject();
-
- initializeEnumAttribute(testObject);
- initializeFlagsAttribute(testObject);
- initializeIntAttribute(testObject);
-
- QQmlEngine engine;
- qmlRegisterType<TestObject>("TestObject", 1, 0, "TestObject");
- engine.rootContext()->setContextProperty(QStringLiteral("testObject"), testObject);
- QQmlComponent component(&engine, QUrl::fromLocalFile(QFINDTESTDATA("testdata/readWrite.qml")));
- QObject *obj = component.create();
-
- QVERIFY(obj);
- QCOMPARE(obj->property("intProperty").toInt(), 1);
- QCOMPARE(obj->property("enumProperty").toInt(), 3);
- QCOMPARE(obj->property("flagsProperty").toInt(), 0x4);
- QCOMPARE(obj->property("extendFlag").toInt(), 0x4);
- QVERIFY(!obj->property("isFlag2Set").toBool());
- QVERIFY(obj->property("isFlag3Set").toBool());
-
- QVERIFY(QMetaObject::invokeMethod(obj, "updateValues"));
- QCOMPARE(obj->property("intProperty").toInt(), 2);
- QCOMPARE(obj->property("enumProperty").toInt(), 2);
- QCOMPARE(obj->property("flagsProperty").toInt(), int(TestObject::TestFlags(TestObject::TestFlag_1 | TestObject::TestFlag_2)));
- QCOMPARE(obj->property("extendFlag").toInt(), int(TestObject::TestFlags(TestObject::TestFlag_1 | TestObject::TestFlag_2 | TestObject::TestFlag_3)));
- QVERIFY(obj->property("isFlag2Set").toBool());
- QVERIFY(!obj->property("isFlag3Set").toBool());
-}
-
-void tst_QIviProperty::setValueError_qml()
-{
- TestObject *testObject = new TestObject();
-
- initializeEnumAttribute(testObject);
- initializeIntAttribute(testObject);
-
- QQmlEngine engine;
- engine.setOutputWarningsToStandardError(false);
- engine.rootContext()->setContextProperty(QStringLiteral("testObject"), testObject);
- QSignalSpy warningsSpy(&engine, &QQmlEngine::warnings);
- QString testData = QFINDTESTDATA("testdata/writeError.qml");
- QQmlComponent component(&engine, QUrl::fromLocalFile(testData));
- QObject *obj = component.create();
-
- QVERIFY(obj);
- QVERIFY(QMetaObject::invokeMethod(obj, "enumTest"));
-
- if (!warningsSpy.count())
- QVERIFY(warningsSpy.wait());
-
- QVERIFY(warningsSpy.count());
- QVERIFY(warningsSpy.at(0).count());
- QList<QQmlError> errorList = warningsSpy.at(0).at(0).value<QList<QQmlError>>();
- QCOMPARE(errorList.count(), 1);
- QCOMPARE(errorList.at(0).toString(), QUrl::fromLocalFile(testData).toString() + ":42: Error: Enum value out of range");
- warningsSpy.clear();
-
- QVERIFY(QMetaObject::invokeMethod(obj, "intTest"));
-
- if (!warningsSpy.count())
- QVERIFY(warningsSpy.wait());
-
- QVERIFY(warningsSpy.count());
- QVERIFY(warningsSpy.at(0).count());
- errorList = warningsSpy.at(0).at(0).value<QList<QQmlError>>();
- QCOMPARE(errorList.count(), 1);
- QCOMPARE(errorList.at(0).toString(), QUrl::fromLocalFile(testData).toString() + ":38: Error: Expected: int but got QString");
-}
-
-void tst_QIviProperty::readOnly()
-{
- TestObject *testObject = new TestObject();
- QSignalSpy propertyValueChangedSpy(testObject->readOnlyAttributeProperty(), &QIviProperty::valueChanged);
- QSignalSpy valueChangedSpy(testObject, &TestObject::readOnlyAttributeValueChanged);
-
- //Initialize
- QString value = QString("foo");
- QVariant valueVariant = QVariant::fromValue<QString>(value);
- testObject->setreadOnlyAttributeValue(value);
-
- QCOMPARE(propertyValueChangedSpy.count(), 1);
- QCOMPARE(propertyValueChangedSpy.at(0).at(0), valueVariant);
- QCOMPARE(valueChangedSpy.count(), 1);
- QCOMPARE(valueChangedSpy.at(0).at(0), valueVariant);
-
- //Read value
- QCOMPARE(testObject->readOnlyAttributeValue(), value);
- QCOMPARE(testObject->readOnlyAttributeProperty()->value(), valueVariant);
-
- propertyValueChangedSpy.clear();
- valueChangedSpy.clear();
-
- //Try to set the value
- QString newValue = QString("bar");
- QVariant newValueVariant(newValue);
- QTest::ignoreMessage(QtWarningMsg, "TypeError: Cannot assign to read-only property \"value\"");
- testObject->readOnlyAttributeProperty()->setValue(newValueVariant);
-
- QCOMPARE(propertyValueChangedSpy.count(), 0);
- QCOMPARE(valueChangedSpy.count(), 0);
-
- //Verify that the value is still the old
- QCOMPARE(testObject->readOnlyAttributeValue(), value);
- QCOMPARE(testObject->readOnlyAttributeProperty()->value(), valueVariant);
-}
-
-void tst_QIviProperty::readOnly_qml()
-{
- TestObject *testObject = new TestObject();
- QSignalSpy propertyValueChangedSpy(testObject->readOnlyAttributeProperty(), &QIviProperty::valueChanged);
- QSignalSpy valueChangedSpy(testObject, &TestObject::readOnlyAttributeValueChanged);
-
- //Initialize
- QString value = QString("foo");
- QVariant valueVariant = QVariant::fromValue<QString>(value);
- testObject->setreadOnlyAttributeValue(value);
-
- QCOMPARE(propertyValueChangedSpy.count(), 1);
- QCOMPARE(propertyValueChangedSpy.at(0).at(0), valueVariant);
- QCOMPARE(valueChangedSpy.count(), 1);
- QCOMPARE(valueChangedSpy.at(0).at(0), valueVariant);
-
- //Read value
- QCOMPARE(testObject->readOnlyAttributeValue(), value);
- QCOMPARE(testObject->readOnlyAttributeProperty()->value(), valueVariant);
-
- propertyValueChangedSpy.clear();
- valueChangedSpy.clear();
-
- QQmlEngine engine;
- engine.setOutputWarningsToStandardError(false);
- QQmlComponent component(&engine);
- QSignalSpy warningsSpy(&engine, &QQmlEngine::warnings);
- engine.rootContext()->setContextProperty(QStringLiteral("testObject"), testObject);
- component.setData("import QtQuick 2.0; Item { Component.onCompleted: testObject.readOnlyAttributeProperty.value = \"bar\"; }", QUrl());
- QObject *obj = component.create();
-
- QVERIFY(obj);
- if (!warningsSpy.count())
- QVERIFY(warningsSpy.wait());
-
- QVERIFY(warningsSpy.count());
- QVERIFY(warningsSpy.at(0).count());
- QList<QQmlError> errorList = warningsSpy.at(0).at(0).value<QList<QQmlError>>();
- QCOMPARE(errorList.count(), 1);
- QCOMPARE(errorList.at(0).toString(), QStringLiteral("<Unknown File>:1: Error: TypeError: Cannot assign to read-only property \"value\""));
-}
-
-QTEST_MAIN(tst_QIviProperty)
-
-#include "tst_qiviproperty.moc"
-
diff --git a/tests/auto/core/qivipropertyattribute/qivipropertyattribute.pro b/tests/auto/core/qivipropertyattribute/qivipropertyattribute.pro
deleted file mode 100644
index 65a8033..0000000
--- a/tests/auto/core/qivipropertyattribute/qivipropertyattribute.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += testlib ivicore
-
-TARGET = tst_qivipropertyattribute
-QMAKE_PROJECT_NAME = $$TARGET
-CONFIG += testcase
-
-TEMPLATE = app
-
-SOURCES += \
- tst_qivipropertyattribute.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD/\\\"
-
diff --git a/tests/auto/core/qivipropertyattribute/tst_qivipropertyattribute.cpp b/tests/auto/core/qivipropertyattribute/tst_qivipropertyattribute.cpp
deleted file mode 100644
index a73c6f3..0000000
--- a/tests/auto/core/qivipropertyattribute/tst_qivipropertyattribute.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 Luxoft Sweden AB
-** Copyright (C) 2018 Pelagicore AG
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtIvi module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT-QTAS$
-** Commercial License Usage
-** Licensees holding valid commercial Qt Automotive Suite 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.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest>
-#include <qivipropertyattribute.h>
-
-struct ComplexType
-{
- ComplexType(bool b = false, const QString &string = QString())
- : m_bool(b)
- , m_string(string)
- {}
-
- bool operator==(const ComplexType &other) const
- {
- return (m_bool == other.m_bool &&
- m_string == other.m_string);
- }
-
- bool m_bool;
- QString m_string;
-};
-Q_DECLARE_METATYPE(ComplexType)
-Q_DECLARE_METATYPE(QIviPropertyAttribute<ComplexType>)
-
-class tst_QIviPropertyAttribute : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QIviPropertyAttribute();
-
-private Q_SLOTS:
- void equal();
- void simple();
- void complex();
-};
-
-tst_QIviPropertyAttribute::tst_QIviPropertyAttribute()
-{
- qRegisterMetaType<ComplexType>();
-}
-
-void tst_QIviPropertyAttribute::equal()
-{
- QIviPropertyAttribute<int> minMax(5, 10);
- QIviPropertyAttribute<int> minMax2(5, 10);
- QCOMPARE(minMax, minMax2);
-
- QIviPropertyAttribute<int> noAtt(false);
- QIviPropertyAttribute<int> noAtt2(false);
- QCOMPARE(noAtt, noAtt2);
-
- QVector<int> list;
- list << 0 << 5 << 10 << 50;
- QIviPropertyAttribute<int> avVal(list);
- QIviPropertyAttribute<int> avVal2(list);
- QCOMPARE(avVal, avVal2);
-}
-
-void tst_QIviPropertyAttribute::simple()
-{
- QIviPropertyAttribute<int> invalid;
- QCOMPARE(invalid.type(), QIviPropertyAttributeBase::Invalid);
- QCOMPARE(invalid.isAvailable(), false);
- QCOMPARE(invalid.minimumValue(), int());
- QCOMPARE(invalid.maximumValue(), int());
- QCOMPARE(invalid.availableValues(), QVector<int>());
-
- QIviPropertyAttribute<int> noAttribute(true);
- QCOMPARE(noAttribute.type(), QIviPropertyAttributeBase::NoAttributes);
- QCOMPARE(noAttribute.isAvailable(), true);
- QCOMPARE(noAttribute.minimumValue(), int());
- QCOMPARE(noAttribute.maximumValue(), int());
- QCOMPARE(noAttribute.availableValues(), QVector<int>());
-
- QIviPropertyAttribute<int> minimumMaximum(5, 10);
- QCOMPARE(minimumMaximum.type(), QIviPropertyAttributeBase::MinimumMaximum);
- QCOMPARE(minimumMaximum.isAvailable(), true);
- QCOMPARE(minimumMaximum.minimumValue(), 5);
- QCOMPARE(minimumMaximum.maximumValue(), 10);
- QCOMPARE(minimumMaximum.availableValues(), QVector<int>());
-
- QVector<int> list;
- list << 0 << 5 << 10 << 50;
- QIviPropertyAttribute<int> availableValues(list);
- QCOMPARE(availableValues.type(), QIviPropertyAttributeBase::AvailableValues);
- QCOMPARE(availableValues.isAvailable(), true);
- QCOMPARE(availableValues.minimumValue(), int());
- QCOMPARE(availableValues.maximumValue(), int());
- QCOMPARE(availableValues.availableValues(), list);
-}
-
-void tst_QIviPropertyAttribute::complex()
-{
- QIviPropertyAttribute<ComplexType> invalid;
- QCOMPARE(invalid.type(), QIviPropertyAttributeBase::Invalid);
- QCOMPARE(invalid.isAvailable(), false);
- QCOMPARE(invalid.minimumValue(), ComplexType());
- QCOMPARE(invalid.maximumValue(), ComplexType());
- QCOMPARE(invalid.availableValues(), QVector<ComplexType>());
-
- QIviPropertyAttribute<ComplexType> noAttribute(true);
- QCOMPARE(noAttribute.type(), QIviPropertyAttributeBase::NoAttributes);
- QCOMPARE(noAttribute.isAvailable(), true);
- QCOMPARE(noAttribute.minimumValue(), ComplexType());
- QCOMPARE(noAttribute.maximumValue(), ComplexType());
- QCOMPARE(noAttribute.availableValues(), QVector<ComplexType>());
-
- ComplexType min(false, QStringLiteral("min"));
- ComplexType max(true, QStringLiteral("max"));
- QIviPropertyAttribute<ComplexType> minimumMaximum(min, max);
- QCOMPARE(minimumMaximum.type(), QIviPropertyAttributeBase::MinimumMaximum);
- QCOMPARE(minimumMaximum.isAvailable(), true);
- QCOMPARE(minimumMaximum.minimumValue(), min);
- QCOMPARE(minimumMaximum.maximumValue(), max);
- QCOMPARE(minimumMaximum.availableValues(), QVector<ComplexType>());
-
- QVector<ComplexType> list;
- list << ComplexType(false, "1") << ComplexType(true, "2") << ComplexType(true, "3") << ComplexType(false, "4");
- QIviPropertyAttribute<ComplexType> availableValues(list);
- QCOMPARE(availableValues.type(), QIviPropertyAttributeBase::AvailableValues);
- QCOMPARE(availableValues.isAvailable(), true);
- QCOMPARE(availableValues.minimumValue(), ComplexType());
- QCOMPARE(availableValues.maximumValue(), ComplexType());
- QCOMPARE(availableValues.availableValues(), list);
-}
-
-QTEST_APPLESS_MAIN(tst_QIviPropertyAttribute)
-
-#include "tst_qivipropertyattribute.moc"
-
diff --git a/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp b/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp
index 1cfc8b4..65882e0 100644
--- a/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp
+++ b/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp
@@ -44,12 +44,6 @@ class TestBackend : public QIviSearchAndBrowseModelInterface
public:
- //Registers the type under the passed names. Can be called more often to fill the availableTypes
- void registerType(const QString &name)
- {
- registerContentType<QIviStandardItem>(name);
- }
-
//Sets the capabilities this instance should report
void setCapabilities(QtIviCoreModule::ModelCapabilities capabilities)
{
@@ -59,7 +53,6 @@ public:
//Adds very simple Data which can be used for most of the unit tests
void initializeSimpleData()
{
- registerType("simple");
m_lists.insert("simple", createItemList("simple"));
}
@@ -67,17 +60,14 @@ public:
void initializeNavigationData()
{
static const QStringList types = { "levelOne", "levelTwo", "levelThree" };
- for (const QString &type : types) {
- registerType(type);
+ for (const QString &type : types)
m_lists.insert(type, createItemList(type));
- }
}
//Adds a data set which can be filtered and sorted
void initializeFilterData()
{
QString type("filter");
- registerType(type);
QList<QIviStandardItem> list;
for (int i=0; i<100; i++) {
@@ -109,6 +99,7 @@ public:
void initialize() override
{
+ emit availableContentTypesChanged(m_lists.keys());
emit initializationDone();
}
@@ -126,6 +117,10 @@ public:
{
Q_UNUSED(identifier)
m_contentType = contentType;
+ if (contentType == "levelTwo" || contentType == "levelThree")
+ emit canGoBackChanged(identifier, true);
+ emit queryIdentifiersChanged(identifier, identifiersFromItem<QIviStandardItem>());
+ emit contentTypeChanged(identifier, contentType);
}
void setupFilter(const QUuid &identifier, QIviAbstractQueryTerm *term, const QList<QIviOrderTerm> &orderTerms) override
@@ -228,56 +223,49 @@ public:
requestedItems.append(QVariant::fromValue(list.at(i)));
emit dataFetched(identifier, requestedItems, start, start + count < list.count());
- }
- virtual bool canGoBack(const QUuid &identifier, const QString &type) override
- {
- Q_UNUSED(identifier)
- return (type == "levelTwo" || type == "levelThree");
+ //All but the first item can go forward
+ if (m_contentType == "levelOne" || m_contentType == "levelTwo")
+ emit canGoForwardChanged(identifier, QVector<bool>(requestedItems.count() - 1, true), start + 1);
}
- virtual QString goBack(const QUuid &identifier, const QString &type) override
+ virtual QIviPendingReply<QString> goBack(const QUuid &identifier) override
{
Q_UNUSED(identifier)
- if (type == "levelThree")
- return "levelTwo";
- else if (type == "levelTwo")
- return "levelOne";
+ if (m_contentType == "levelThree")
+ return QIviPendingReply<QString>("levelTwo");
+ else if (m_contentType == "levelTwo")
+ return QIviPendingReply<QString>("levelOne");
- return "levelOne";
+ return QIviPendingReply<QString>::createFailedReply();
}
- virtual bool canGoForward(const QUuid &identifier, const QString &type, const QString &itemId) override
+ virtual QIviPendingReply<QString> goForward(const QUuid &identifier, int index) override
{
Q_UNUSED(identifier)
- if (itemId.endsWith("0"))
- return false;
+ Q_UNUSED(index)
- return (type == "levelOne" || type == "levelTwo");
- }
-
- virtual QString goForward(const QUuid &identifier, const QString &type, const QString &itemId) override
- {
- Q_UNUSED(identifier)
- Q_UNUSED(itemId)
+ if (m_contentType == "levelOne")
+ return QIviPendingReply<QString>("levelTwo");
+ else if (m_contentType == "levelTwo")
+ return QIviPendingReply<QString>("levelThree");
- if (type == "levelOne")
- return "levelTwo";
- else if (type == "levelTwo")
- return "levelThree";
-
- return "levelOne";
+ return QIviPendingReply<QString>::createFailedReply();
}
- virtual QIviPendingReply<void> insert(const QUuid &identifier, const QString &type, int index, const QIviStandardItem *item) override
+ virtual QIviPendingReply<void> insert(const QUuid &identifier, int index, const QVariant &var) override
{
- QList<QIviStandardItem> list = m_lists.value(type);
+ const QIviStandardItem *item = qtivi_gadgetFromVariant<QIviStandardItem>(this, var);
+ if (!item)
+ return QIviPendingReply<void>::createFailedReply();
+
+ QList<QIviStandardItem> list = m_lists.value(m_contentType);
list.insert(index, *item);
QVariantList variantList = { QVariant::fromValue(*item) };
- m_lists.insert(type, list);
+ m_lists.insert(m_contentType, list);
emit dataChanged(identifier, variantList, index, 0);
@@ -286,12 +274,12 @@ public:
return reply;
}
- virtual QIviPendingReply<void> remove(const QUuid &identifier, const QString &type, int index) override
+ virtual QIviPendingReply<void> remove(const QUuid &identifier, int index) override
{
- QList<QIviStandardItem> list = m_lists.value(type);
+ QList<QIviStandardItem> list = m_lists.value(m_contentType);
list.removeAt(index);
- m_lists.insert(type, list);
+ m_lists.insert(m_contentType, list);
emit dataChanged(identifier, QVariantList(), index, 1);
@@ -300,9 +288,9 @@ public:
return reply;
}
- virtual QIviPendingReply<void> move(const QUuid &identifier, const QString &type, int currentIndex, int newIndex) override
+ virtual QIviPendingReply<void> move(const QUuid &identifier, int currentIndex, int newIndex) override
{
- QList<QIviStandardItem> list = m_lists.value(type);
+ QList<QIviStandardItem> list = m_lists.value(m_contentType);
int min = qMin(currentIndex, newIndex);
int max = qMax(currentIndex, newIndex);
@@ -312,7 +300,7 @@ public:
for (int i = min; i <= max; i++)
variantLIst.append(QVariant::fromValue(list.at(i)));
- m_lists.insert(type, list);
+ m_lists.insert(m_contentType, list);
emit dataChanged(identifier, variantLIst, min, max - min + 1);
@@ -321,10 +309,14 @@ public:
return reply;
}
- virtual QIviPendingReply<int> indexOf(const QUuid &identifier, const QString &type, const QIviStandardItem *item) override
+ virtual QIviPendingReply<int> indexOf(const QUuid &identifier, const QVariant &var) override
{
Q_UNUSED(identifier)
- QList<QIviStandardItem> list = m_lists.value(type);
+ const QIviStandardItem *item = qtivi_gadgetFromVariant<QIviStandardItem>(this, var);
+ if (!item)
+ return QIviPendingReply<int>::createFailedReply();
+
+ QList<QIviStandardItem> list = m_lists.value(m_contentType);
QIviPendingReply<int> reply;
reply.setSuccess(list.indexOf(*item));
@@ -441,7 +433,7 @@ void tst_QIviSearchAndBrowseModel::testWithoutBackend()
QTest::ignoreMessage(QtWarningMsg, "Can't remove items without a connected backend");
model.remove(0);
- QTest::ignoreMessage(QtWarningMsg, "Can't insert itmes without a connected backend");
+ QTest::ignoreMessage(QtWarningMsg, "Can't insert items without a connected backend");
model.insert(0, QVariant::fromValue(QIviStandardItem()));
QTest::ignoreMessage(QtWarningMsg, "Can't get the index without a connected backend");
@@ -463,29 +455,43 @@ void tst_QIviSearchAndBrowseModel::testClearServiceObject()
QIviSearchAndBrowseModel model;
model.setServiceObject(service);
- //TODO enable when fixed
- //model.setLoadingType(QIviSearchAndBrowseModel::DataChanged);
+ model.setLoadingType(QIviSearchAndBrowseModel::DataChanged);
model.setChunkSize(20);
model.setContentType("simple");
model.setFetchMoreThreshold(20);
+ QSignalSpy chunkSizeSpy(&model, &QIviSearchAndBrowseModel::chunkSizeChanged);
QVERIFY(model.chunkSize() != defaultModel.chunkSize());
+ QSignalSpy contentTypeSpy(&model, &QIviSearchAndBrowseModel::contentTypeChanged);
QVERIFY(model.contentType() != defaultModel.contentType());
+ QSignalSpy thresholdSpy(&model, &QIviSearchAndBrowseModel::fetchMoreThresholdChanged);
QVERIFY(model.fetchMoreThreshold() != defaultModel.fetchMoreThreshold());
+ QSignalSpy availableContentTypeSpy(&model, &QIviSearchAndBrowseModel::availableContentTypesChanged);
QVERIFY(model.availableContentTypes() != defaultModel.availableContentTypes());
+ QSignalSpy capabilitiesSpy(&model, &QIviSearchAndBrowseModel::capabilitiesChanged);
QVERIFY(model.capabilities() != defaultModel.capabilities());
- //QVERIFY(model.loadingType() != defaultModel.loadingType());
+ QSignalSpy loadingTypeSpy(&model, &QIviSearchAndBrowseModel::loadingTypeChanged);
+ QVERIFY(model.loadingType() != defaultModel.loadingType());
+ QSignalSpy resetSpy(&model, &QAbstractItemModel::modelReset);
QVERIFY(model.rowCount() != defaultModel.rowCount());
QVERIFY(model.setServiceObject(nullptr));
+
QVERIFY(model.chunkSize() == defaultModel.chunkSize());
+ QCOMPARE(chunkSizeSpy.count(), 1);
QVERIFY(model.contentType() == defaultModel.contentType());
+ QCOMPARE(contentTypeSpy.count(), 1);
QVERIFY(model.fetchMoreThreshold() == defaultModel.fetchMoreThreshold());
+ QCOMPARE(thresholdSpy.count(), 1);
QVERIFY(model.availableContentTypes() == defaultModel.availableContentTypes());
+ QCOMPARE(availableContentTypeSpy.count(), 1);
QVERIFY(model.capabilities() == defaultModel.capabilities());
+ QCOMPARE(capabilitiesSpy.count(), 1);
QVERIFY(model.loadingType() == defaultModel.loadingType());
+ QCOMPARE(loadingTypeSpy.count(), 1);
QVERIFY(model.rowCount() == defaultModel.rowCount());
+ QCOMPARE(resetSpy.count(), 1);
}
void tst_QIviSearchAndBrowseModel::testBasic_qml()
@@ -949,11 +955,6 @@ void tst_QIviSearchAndBrowseModel::testInputErrors()
model.fetchMore(model.index(0,0));
QVERIFY(!countChanged.count());
- // Invalid content Type
- QTest::ignoreMessage(QtWarningMsg, "Unsupported type: \"levelOne\" \n Supported types are: \nsimple\n");
- model.setContentType("levelOne");
- model.setContentType("simple");
-
// Invalid query
QTest::ignoreMessage(QtWarningMsg, "Got end of file but expected on of the following types:\n integer\n float\nid>\n ^");
model.setQuery(QString("id>"));
diff --git a/tests/auto/core/queryparser/tst_queryparser.cpp b/tests/auto/core/queryparser/tst_queryparser.cpp
index bcaade2..fb7f21e 100644
--- a/tests/auto/core/queryparser/tst_queryparser.cpp
+++ b/tests/auto/core/queryparser/tst_queryparser.cpp
@@ -155,6 +155,17 @@ void TestQueryParser::validQueries()
CHECK_ERRORSTRING(term->toString(), representationQuery);
+ //Test the searialize functions
+ QByteArray buffer;
+ QDataStream in(&buffer, QIODevice::WriteOnly);
+ in << term;
+
+ QDataStream out(buffer);
+ QIviAbstractQueryTerm *newTerm = nullptr;
+ out >> &newTerm;
+
+ QCOMPARE(term->toString(), newTerm->toString());
+ delete newTerm;
delete term;
}