summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@digia.com>2013-11-01 15:40:11 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-06 13:02:32 +0100
commit3a5ae1b8fe3dae3be59d064177c468242657e78e (patch)
tree183ee1c84a1f55ce333a6451218e8491c6b0f985 /tests/auto
parenta46a13cb4f79edc009b3e8863727776e41535782 (diff)
downloadqtenginio-3a5ae1b8fe3dae3be59d064177c468242657e78e.tar.gz
Fix some crashes in EnginioQmlModel
Change-Id: I172819f1c16b21c904a00edcc94e2a07d162dfe7 Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qmltests/tst_model.qml62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/qmltests/tst_model.qml b/tests/auto/qmltests/tst_model.qml
index 2abfd77..f63dcbc 100644
--- a/tests/auto/qmltests/tst_model.qml
+++ b/tests/auto/qmltests/tst_model.qml
@@ -55,6 +55,68 @@ Item {
}
TestCase {
+ name: "EnginioModel: without client"
+ EnginioModel {
+ id: modelMissingClient
+ }
+ function test_append()
+ {
+ ignoreWarning("EnginioQmlModel::append(): Enginio client is not set")
+ compare(modelMissingClient.append(null), null)
+ ignoreWarning("EnginioQmlModel::append(): Enginio client is not set")
+ compare(modelMissingClient.append({"objectType": "objects.todos", "title": "no go"}), null)
+ }
+ function test_remove()
+ {
+ ignoreWarning("EnginioQmlModel::remove(): Enginio client is not set")
+ compare(modelMissingClient.remove(0), null)
+ }
+ function test_setProperty()
+ {
+ ignoreWarning("EnginioQmlModel::setProperty(): Enginio client is not set")
+ compare(modelMissingClient.setProperty(0, "title", "foo"), null)
+ }
+ function rowCount()
+ {
+ compare(rowCount(), 0)
+ }
+ }
+
+ TestCase {
+ name: "EnginioModel: invalid row number"
+
+ EnginioModel {
+ id: modelInvalidRow
+ enginio: Enginio {
+ serviceUrl: AppConfig.backendData.serviceUrl
+ backendId: AppConfig.backendData.id
+ }
+ query: {
+ "objectType": AppConfig.testObjectType,
+ "query": {"testCase": "EnginioModel: invalid row"}
+ }
+
+ property int resetCounter: 0
+ onModelReset: ++resetCounter
+ }
+
+ function test_remove()
+ {
+ tryCompare(modelInvalidRow, "resetCounter", 2)
+ var reply = modelInvalidRow.remove(modelInvalidRow.rowCount)
+ tryCompare(reply, "isError", true)
+ verify(reply, "isError", true)
+ }
+ function test_setProperty()
+ {
+ tryCompare(modelInvalidRow, "resetCounter", 2)
+ var reply = modelInvalidRow.setProperty(modelInvalidRow.rowCount, "title", "foo")
+ tryCompare(reply, "isError", true)
+ verify(reply, "isError", true)
+ }
+ }
+
+ TestCase {
name: "EnginioModel: create"
Enginio {