aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-12-19 15:48:23 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-02-08 11:03:23 +0000
commitb2739825454ba7585170d15c83de729b0af6c29a (patch)
tree68faa8db84e9002fdaba7a0dbd5a019be8962d6e /tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
parent8419ff45d4f99e585119fa77a1066d4ddaee827c (diff)
Make XmlListModel work without qml-network
We can still load local files then. In fact we load all local files without network requests now, as that is faster anyway. That means the "progress" for local files is 1.0 right from the start as no real loading takes place, and also no headers are sent. Change-Id: I43f0d5179f8dd09bfdb5c6b3a51a6033226ea59c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp')
-rw-r--r--tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
index 757cb8f513..bcff0c46fb 100644
--- a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
+++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
@@ -354,7 +354,7 @@ void tst_qquickxmllistmodel::xml()
QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)));
QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Loading);
QTRY_COMPARE(spy.count(), 1); spy.clear();
@@ -410,6 +410,13 @@ void tst_qquickxmllistmodel::headers()
QTRY_COMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Ready);
+ // It doesn't do a network request for a local file
+ QCOMPARE(factory.lastSentHeaders.count(), 0);
+
+ model->setProperty("source", QUrl("http://localhost/filethatdoesnotexist.xml"));
+ QTRY_COMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Error);
+
QVariantMap expectedHeaders;
expectedHeaders["Accept"] = "application/xml,*/*";
@@ -433,7 +440,7 @@ void tst_qquickxmllistmodel::source()
QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)));
QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Loading);
QTRY_COMPARE(spy.count(), 1); spy.clear();
@@ -447,7 +454,7 @@ void tst_qquickxmllistmodel::source()
if (model->property("source").toString().isEmpty())
QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Null);
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(model->property("progress").toDouble(), qreal(source.isLocalFile() ? 1.0 : 0.0));
QTRY_COMPARE(spy.count(), 1); spy.clear();
QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Loading);