Fix tst_QFileDialog2 for Windows 7.
There are no rights for typical user or even administrator to write directly under c:\ root in windows without rights elevation, so completionOnLevelAfterRoot() test case failed. Changed the test case to use an existing directory. Task-number: QTBUG-24289 Change-Id: I6a8dfc9d1d6ae798b3b9049c542b45fdbdbd9a8c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
parent
79e9076274
commit
656dff47a6
@ -559,9 +559,39 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
|
|||||||
{
|
{
|
||||||
QNonNativeFileDialog fd;
|
QNonNativeFileDialog fd;
|
||||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||||
fd.setDirectory("C:");
|
fd.setDirectory("C:/");
|
||||||
QDir current = fd.directory();
|
QDir current = fd.directory();
|
||||||
current.mkdir("completionOnLevelAfterRootTest");
|
QStringList entryList = current.entryList(QStringList(), QDir::Dirs);
|
||||||
|
// Find a suitable test dir under c:-root:
|
||||||
|
// - At least 6 characters long
|
||||||
|
// - Ascii, letters only
|
||||||
|
// - No another dir with same start
|
||||||
|
QString testDir;
|
||||||
|
foreach (const QString &entry, entryList) {
|
||||||
|
if (entry.size() > 5 && QString(entry.toAscii()).compare(entry) == 0) {
|
||||||
|
bool invalid = false;
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
if (!entry.at(i).isLetter()) {
|
||||||
|
invalid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!invalid) {
|
||||||
|
foreach (const QString &check, entryList) {
|
||||||
|
if (check.startsWith(entry.left(5)) && check != entry) {
|
||||||
|
invalid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!invalid) {
|
||||||
|
testDir = entry;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (testDir.isEmpty())
|
||||||
|
QSKIP("This test requires to have an unique directory of at least six ascii characters under c:/");
|
||||||
#else
|
#else
|
||||||
fd.setFilter(QDir::Hidden | QDir::AllDirs | QDir::Files | QDir::System);
|
fd.setFilter(QDir::Hidden | QDir::AllDirs | QDir::Files | QDir::System);
|
||||||
fd.setDirectory("/");
|
fd.setDirectory("/");
|
||||||
@ -574,11 +604,8 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
|
|||||||
QTest::qWait(2000);
|
QTest::qWait(2000);
|
||||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||||
//I love testlib :D
|
//I love testlib :D
|
||||||
QTest::keyClick(edit, Qt::Key_C);
|
for (int i = 0; i < 5; i++)
|
||||||
QTest::keyClick(edit, Qt::Key_O);
|
QTest::keyClick(edit, testDir.at(i).toLower().toAscii() - 'a' + Qt::Key_A);
|
||||||
QTest::keyClick(edit, Qt::Key_M);
|
|
||||||
QTest::keyClick(edit, Qt::Key_P);
|
|
||||||
QTest::keyClick(edit, Qt::Key_L);
|
|
||||||
#else
|
#else
|
||||||
QTest::keyClick(edit, Qt::Key_E);
|
QTest::keyClick(edit, Qt::Key_E);
|
||||||
QTest::keyClick(edit, Qt::Key_T);
|
QTest::keyClick(edit, Qt::Key_T);
|
||||||
@ -587,8 +614,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
|
|||||||
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
|
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
|
||||||
QTest::qWait(200);
|
QTest::qWait(200);
|
||||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||||
QCOMPARE(edit->text(), QString("completionOnLevelAfterRootTest"));
|
QCOMPARE(edit->text(), testDir);
|
||||||
current.rmdir("completionOnLevelAfterRootTest");
|
|
||||||
#else
|
#else
|
||||||
QTRY_COMPARE(edit->text(), QString("etc"));
|
QTRY_COMPARE(edit->text(), QString("etc"));
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user