summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/itemmodels
diff options
context:
space:
mode:
authorDongmei Wang <dongmei.wang@qt.io>2018-11-09 00:07:58 -0800
committerKarsten Heimrich <karsten.heimrich@qt.io>2021-05-20 15:02:38 +0000
commite253a30238ed1a93877780428c035d3b7a53e22a (patch)
treeda7cdaf99e4f5e6d5b804f3ec876977b4dd1a0c6 /tests/auto/gui/itemmodels
parentc2258e85a32b66cf7cbc59a4789e68c31c9955be (diff)
QFileSystemModel fails to locate a host from root's visible children
In QFileSystemModel, in some cases the hostname in a UNC path is converted to lower case and stored in the root node's visibleChildren. When QFileSystemModel sets the UNC path as the root path, it tries to get the row number for the host, but it didn't convert the hostname to lower case before getting the row number, which resulted in the host not found in the root node's visible children. As a result, it returns -1, an invalid row number. Change the behavior to find the node for the host using the host name case-insensitive and then get the row number. Fixes: QTBUG-71701 Pick-to: 5.15 6.0 6.1 Change-Id: Ib95c7b6d2bc22fd82f2789b7004b6fc82dfcb13b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests/auto/gui/itemmodels')
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
index b9c44aa4c2..b6f6328acd 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -230,6 +230,21 @@ void tst_QFileSystemModel::rootPath()
QCOMPARE(rootChanged.count(), oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), newdir.path());
}
+
+#ifdef Q_OS_WIN
+ // check case insensitive root node on windows, tests QTBUG-71701
+ QModelIndex index = model->setRootPath(uR"(\\localhost\c$)"_qs);
+ QVERIFY(index.isValid());
+ QCOMPARE(model->rootPath(), u"//localhost/c$"_qs);
+
+ index = model->setRootPath(uR"(\\localhost\C$)"_qs);
+ QVERIFY(index.isValid());
+ QCOMPARE(model->rootPath(), u"//localhost/C$"_qs);
+
+ index = model->setRootPath(uR"(\\LOCALHOST\C$)"_qs);
+ QVERIFY(index.isValid());
+ QCOMPARE(model->rootPath(), u"//LOCALHOST/C$"_qs);
+#endif
}
void tst_QFileSystemModel::readOnly()