diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2018-03-01 11:12:21 +0100 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2018-03-09 15:16:28 +0000 |
commit | e2914fa9702ad553494ee05a58dde967bdefe004 (patch) | |
tree | 9c44d6573e53a44369c5a7036c86e1febe276113 /tests | |
parent | ca12be0bcbbf460efdf9ccf7ba5c9eb3fab98564 (diff) | |
download | qtivi-e2914fa9702ad553494ee05a58dde967bdefe004.tar.gz |
Add a reload method to QIviSearchAndBrowseModel
The reload() method will reset the model and fetch the data again
from the backend.
This also fixes some problems, which resulted in duplicated entries
during the initial fetch.
Change-Id: I9741f23165a2da7a1587a2893f891a386d2cbabe
Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp b/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp index d7a2e88..5b90a25 100644 --- a/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp +++ b/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp @@ -357,6 +357,7 @@ private Q_SLOTS: void testFetchMore_data(); void testFetchMore(); void testDataChangedMode(); + void testReload(); void testDataChangedMode_jump(); void testNavigation_data(); void testNavigation(); @@ -607,6 +608,35 @@ void tst_QIviSearchAndBrowseModel::testDataChangedMode() QCOMPARE(fetchDataSpy.at(0).at(2).toInt(), testIndex + 1); } +void tst_QIviSearchAndBrowseModel::testReload() +{ + TestServiceObject *service = new TestServiceObject(); + manager->registerService(service, service->interfaces()); + service->testBackend()->setCapabilities(QIviSearchAndBrowseModel::SupportsGetSize); + service->testBackend()->initializeSimpleData(); + + QIviSearchAndBrowseModel model; + model.setServiceObject(service); + + QVERIFY(model.serviceObject()); + + QVERIFY(model.availableContentTypes().contains("simple")); + QSignalSpy countChangedSpy(&model, SIGNAL(countChanged())); + model.setContentType("simple"); + countChangedSpy.wait(100); + QVERIFY(countChangedSpy.count()); + + QCOMPARE(model.rowCount(), model.chunkSize()); + countChangedSpy.clear(); + + QSignalSpy resetSpy(&model, SIGNAL(modelReset())); + model.reload(); + countChangedSpy.wait(100); + QCOMPARE(resetSpy.count(), 1); + QCOMPARE(countChangedSpy.count(), 2); + QCOMPARE(model.rowCount(), model.chunkSize()); +} + void tst_QIviSearchAndBrowseModel::testDataChangedMode_jump() { TestServiceObject *service = new TestServiceObject(); |