summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2019-06-07 14:39:32 +0200
committerDominik Holland <dominik.holland@pelagicore.com>2019-06-11 10:59:24 +0200
commit18712f14d6fd2809d2c73ede2871e3b0855aa6b6 (patch)
tree2cb51300898a924264769e7008630a7377e12d20 /tests
parent0b9baa982ae430f72150204ad4ee6d7ea78bba2e (diff)
downloadqtivi-18712f14d6fd2809d2c73ede2871e3b0855aa6b6.tar.gz
Correctly emit change signals when clearing the ServiceObject
When the serviceObject of a feature is set to null, the feature is responsible to reset its state to the default again. This commit will make sure that not just the state is fixed, but also reflected to the outside by emitting the change signals. Task-number: AUTOSUITE-1000 Change-Id: I4bc696f0179975a2d719ad420718b574010f5a5e Reviewed-by: Kavindra Palaraja <kpalaraja@luxoft.com> Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/core/qivipagingmodel/tst_qivipagingmodel.cpp15
-rw-r--r--tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp20
2 files changed, 29 insertions, 6 deletions
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/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp b/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp
index 98dcb9d..65882e0 100644
--- a/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp
+++ b/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp
@@ -455,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()