From 839ceb00b00561d9030bb5304edbc37bad84a522 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 2 Oct 2014 17:12:05 +0200 Subject: tst_QFiledialog::completer(): Avoid directories starting with 'c'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently, this causes problems with the completer due to the fact that it matches the root drive "C:\" on Windows. Task-number: QTBUG-41681 Change-Id: Iaf96675067e22e679371139a1a2fbf011a5edbdc Reviewed-by: Tony Sarajärvi --- .../widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 71299e0e5d..92200618d6 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -509,10 +509,20 @@ void tst_QFiledialog::completer() QCOMPARE(model->index(fd.directory().path()), model->index(startPath)); if (input.isEmpty()) { - QModelIndex r = model->index(model->rootPath()); - QVERIFY(model->rowCount(r) > 0); - QModelIndex idx = model->index(0, 0, r); - input = idx.data().toString().at(0); + // Try to find a suitable directory under root that does not + // start with 'C' to avoid issues with completing to "C:" drives on Windows. + const QString rootPath = model->rootPath(); + const QChar rootPathFirstChar = rootPath.at(0).toLower(); + QModelIndex rootIndex = model->index(rootPath); + const int rowCount = model->rowCount(rootIndex); + QVERIFY(rowCount > 0); + for (int row = 0; row < rowCount && input.isEmpty(); ++row) { + const QString name = model->index(row, 0, rootIndex).data().toString(); + const QChar firstChar = name.at(0); + if (firstChar.isLetter() && firstChar.toLower() != rootPathFirstChar) + input = firstChar; + } + QVERIFY2(!input.isEmpty(), "Unable to find a suitable input directory"); } // press 'keys' for the input -- cgit v1.2.3