summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-10-02 17:12:05 +0200
committerFriedemann Kleint <Friedemann.Kleint@digia.com>2014-10-03 19:01:43 +0200
commit839ceb00b00561d9030bb5304edbc37bad84a522 (patch)
tree236dfc2f3b0b1661e5e817ada5b707fc96bf5a5e
parent1126efed7d2d75d90ff16046d5c1cc7ead2390f2 (diff)
downloadqtbase-839ceb00b00561d9030bb5304edbc37bad84a522.tar.gz
qtbase-839ceb00b00561d9030bb5304edbc37bad84a522.tar.bz2
qtbase-839ceb00b00561d9030bb5304edbc37bad84a522.zip
tst_QFiledialog::completer(): Avoid directories starting with 'c'.
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 <tony.sarajarvi@digia.com>
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp18
1 files changed, 14 insertions, 4 deletions
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