diff options
author | Andreas Buhr <andreas@andreasbuhr.de> | 2022-04-20 10:05:50 +0200 |
---|---|---|
committer | Andreas Buhr <andreas.buhr@qt.io> | 2022-04-26 21:38:02 +0200 |
commit | 44e83fc2381f42b97054c11a358e621862319bc4 (patch) | |
tree | 58baa6d52257c4fedc0188a6d7f5b570b88252b4 /tests/auto/qml/qqmlxmllistmodel | |
parent | 8f25235482e5fc0b9c890fedb31e4e07c01f4e56 (diff) |
Fix tst_QQmlXmlListModel::threading() on Android
tst_QQmlXmlListModel::threading() tried to create some temporary
files in a qrc: path on Android. This patch changes it to use
a QTemporaryDirectory for it.
Pick-to: 6.2 6.3
Task-number: QTBUG-101865
Change-Id: I66b44344af822edfe86b0007ae56a65d5da46365
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlxmllistmodel')
-rw-r--r-- | tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp b/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp index f46ceb31e0..8b43ac6be2 100644 --- a/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp +++ b/tests/auto/qml/qqmlxmllistmodel/tst_qqmlxmllistmodel.cpp @@ -134,9 +134,9 @@ private: class ScopedFile { public: - ScopedFile(const QUrl &url, const QByteArray &data) : m_fileUrl(url) + ScopedFile(const QString &fileName, const QByteArray &data) : m_fileName(fileName) { - m_file.setFileName(url.toLocalFile()); + m_file.setFileName(fileName); m_created = m_file.open(QIODevice::WriteOnly | QIODevice::Truncate); if (m_created) { const auto written = m_file.write(data); @@ -147,11 +147,11 @@ public: ~ScopedFile() { QFile::remove(m_file.fileName()); } bool isCreated() const { return m_created; } - QUrl fileUrl() const { return m_fileUrl; } + QString fileName() const { return m_fileName; } private: QFile m_file; - const QUrl m_fileUrl; + const QString m_fileName; bool m_created = false; }; @@ -491,6 +491,8 @@ void tst_QQmlXmlListModel::threading() QScopedPointer<QAbstractItemModel> m3(qobject_cast<QAbstractItemModel *>(component.create())); QVERIFY(m3 != nullptr); + QTemporaryDir tempDir; + for (int dataCount = 0; dataCount < xmlDataCount; ++dataCount) { QString data1, data2, data3; for (int i = 0; i < dataCount; ++i) { @@ -502,14 +504,14 @@ void tst_QQmlXmlListModel::threading() + ",sport=Curling;"; } - ScopedFile f1(testFileUrl("file1.xml"), makeItemXmlAndData(data1).toLatin1()); - ScopedFile f2(testFileUrl("file2.xml"), makeItemXmlAndData(data2).toLatin1()); - ScopedFile f3(testFileUrl("file3.xml"), makeItemXmlAndData(data3).toLatin1()); + ScopedFile f1(tempDir.filePath("file1.xml"), makeItemXmlAndData(data1).toLatin1()); + ScopedFile f2(tempDir.filePath("file2.xml"), makeItemXmlAndData(data2).toLatin1()); + ScopedFile f3(tempDir.filePath("file3.xml"), makeItemXmlAndData(data3).toLatin1()); QVERIFY(f1.isCreated() && f2.isCreated() && f3.isCreated()); - m1->setProperty("source", f1.fileUrl()); - m2->setProperty("source", f2.fileUrl()); - m3->setProperty("source", f3.fileUrl()); + m1->setProperty("source", QUrl::fromLocalFile(f1.fileName())); + m2->setProperty("source", QUrl::fromLocalFile(f2.fileName())); + m3->setProperty("source", QUrl::fromLocalFile(f3.fileName())); QCoreApplication::processEvents(); QTRY_VERIFY(m1->rowCount() == dataCount && m2->rowCount() == dataCount |