summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/modelview/modeltest.cpp4
-rw-r--r--tests/auto/modelview/tst_modelview.cpp2
-rw-r--r--tests/auto/qml/usertypes/data/watcher.qml37
-rw-r--r--tests/auto/qml/usertypes/tst_usertypes.cpp43
-rw-r--r--tests/auto/qml/usertypes/usertypes.rep7
5 files changed, 90 insertions, 3 deletions
diff --git a/tests/auto/modelview/modeltest.cpp b/tests/auto/modelview/modeltest.cpp
index 9abf878..859d883 100644
--- a/tests/auto/modelview/modeltest.cpp
+++ b/tests/auto/modelview/modeltest.cpp
@@ -443,12 +443,12 @@ void ModelTest::data()
}
// General Purpose roles that should return a QColor
- QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole );
+ QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundRole );
if ( colorVariant.isValid() ) {
QVERIFY( colorVariant.canConvert<QColor>() );
}
- colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole );
+ colorVariant = model->data ( model->index ( 0, 0 ), Qt::ForegroundRole );
if ( colorVariant.isValid() ) {
QVERIFY( colorVariant.canConvert<QColor>() );
}
diff --git a/tests/auto/modelview/tst_modelview.cpp b/tests/auto/modelview/tst_modelview.cpp
index da42763..78e75ca 100644
--- a/tests/auto/modelview/tst_modelview.cpp
+++ b/tests/auto/modelview/tst_modelview.cpp
@@ -733,7 +733,7 @@ void TestModelView::testFlags()
for (int i = 10; i < 20; ++i) {
QStandardItem* firstItem = m_sourceModel.item(i, 0);
QStandardItem* secondItem = m_sourceModel.item(i, 1);
- firstItem->setFlags(firstItem->flags() | Qt::ItemIsEnabled | Qt::ItemIsTristate);
+ firstItem->setFlags(firstItem->flags() | Qt::ItemIsEnabled | Qt::ItemIsAutoTristate);
secondItem->setFlags(firstItem->flags() | Qt::ItemIsEnabled);
}
bool signalsReceived = false;
diff --git a/tests/auto/qml/usertypes/data/watcher.qml b/tests/auto/qml/usertypes/data/watcher.qml
new file mode 100644
index 0000000..b49d824
--- /dev/null
+++ b/tests/auto/qml/usertypes/data/watcher.qml
@@ -0,0 +1,37 @@
+import QtQuick 2.0
+import QtRemoteObjects 5.14
+import usertypes 1.0
+
+TypeWithReplyReplica {
+ property variant result
+ property bool hasError
+
+ node: Node {
+ registryUrl: "local:testWatcher"
+ }
+ onStateChanged: function(state) {
+ if (state != TypeWithReplyReplica.Valid)
+ return;
+ QtRemoteObjects.watch(uppercase("hello"), 1000)
+ .then(function(value) { hasError = false; result = value },
+ function(error) { hasError = true })
+ }
+
+ function callSlowFunction() {
+ result = 0
+ hasError = false
+
+ QtRemoteObjects.watch(slowFunction(), 300)
+ .then(function(value) { hasError = false; result = value },
+ function(error) { hasError = true })
+ }
+
+ function callComplexFunction() {
+ result = null
+ hasError = false
+
+ QtRemoteObjects.watch(complexReturnType(), 300)
+ .then(function(value) { hasError = false; result = value },
+ function(error) { hasError = true })
+ }
+}
diff --git a/tests/auto/qml/usertypes/tst_usertypes.cpp b/tests/auto/qml/usertypes/tst_usertypes.cpp
index 7c554a9..07bed59 100644
--- a/tests/auto/qml/usertypes/tst_usertypes.cpp
+++ b/tests/auto/qml/usertypes/tst_usertypes.cpp
@@ -32,6 +32,21 @@
#include <qqmlcomponent.h>
#include "rep_usertypes_merged.h"
+class TypeWithReply : public TypeWithReplySimpleSource
+{
+public:
+ QString uppercase(const QString & input) override {
+ return input.toUpper();
+ }
+ QMap<QString, QString> complexReturnType() override {
+ return QMap<QString, QString>{{"one","1"}};
+ }
+ int slowFunction() override {
+ QTest::qWait(1000);
+ return 15;
+ }
+};
+
class tst_usertypes : public QObject
{
Q_OBJECT
@@ -46,6 +61,7 @@ private Q_SLOTS:
void subObjectInQml();
void complexInQml_data();
void complexInQml();
+ void watcherInQml();
};
tst_usertypes::tst_usertypes()
@@ -192,6 +208,33 @@ void tst_usertypes::complexInQml()
}
}
+void tst_usertypes::watcherInQml()
+{
+ qmlRegisterType<TypeWithReplyReplica>("usertypes", 1, 0, "TypeWithReplyReplica");
+
+ QRemoteObjectRegistryHost host(QUrl("local:testWatcher"));
+ TypeWithReply source;
+ host.enableRemoting(&source);
+
+ QQmlEngine e;
+ QQmlComponent c(&e, SRCDIR "data/watcher.qml");
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QTRY_COMPARE_WITH_TIMEOUT(obj->property("result").value<QString>(), QString::fromLatin1("HELLO"), 300);
+ QCOMPARE(obj->property("hasError").value<bool>(), false);
+
+ QMetaObject::invokeMethod(obj, "callSlowFunction");
+ QTRY_COMPARE_WITH_TIMEOUT(obj->property("hasError").value<bool>(), true, 1000);
+ QVERIFY(obj->property("result").value<int>() != 10);
+
+ QMetaObject::invokeMethod(obj, "callComplexFunction");
+ QTRY_VERIFY_WITH_TIMEOUT(!obj->property("result").isNull(), 300);
+ auto map = obj->property("result").value<QMap<QString,QString>>();
+ QCOMPARE(map.value("one"), QString::fromLatin1("1"));
+ QCOMPARE(obj->property("hasError").value<bool>(), false);
+}
+
QTEST_MAIN(tst_usertypes)
#include "tst_usertypes.moc"
diff --git a/tests/auto/qml/usertypes/usertypes.rep b/tests/auto/qml/usertypes/usertypes.rep
index dff361d..a82d1d9 100644
--- a/tests/auto/qml/usertypes/usertypes.rep
+++ b/tests/auto/qml/usertypes/usertypes.rep
@@ -23,3 +23,10 @@ class ComplexType
CLASS clock(SimpleClock)
PROP(int after = 42)
}
+
+class TypeWithReply
+{
+ SLOT(QString uppercase(const QString &input))
+ SLOT(QMap<QString, QString> complexReturnType())
+ SLOT(int slowFunction())
+};