summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfiledialog
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-09-10 09:40:42 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-09-10 09:44:42 (GMT)
commit9e8abb63ba4609887d988ee15ba6daee0b01380e (patch)
treedeb02261e3a6eae2869c51019bcd4397372af0b1 /tests/auto/qfiledialog
parentb300c3022d285deb3b3203aca0746580ba9f3d91 (diff)
downloadQt-9e8abb63ba4609887d988ee15ba6daee0b01380e.zip
Qt-9e8abb63ba4609887d988ee15ba6daee0b01380e.tar.gz
Qt-9e8abb63ba4609887d988ee15ba6daee0b01380e.tar.bz2
Fix random selection when the order is descending.
This commit fix the random selection that appear when the sort is not ascending. The problem is that sometimes the sort is not yet made (timer is not yet fired) so the visible children list contains both sorted items and non sorted items (at the end). translateVisibleLocation was buggy assuming that the list is always sorted. We have now a dirty index that indicate where the dirty items start. And then when the sort is made the dirty index is reset. I have added auto-test for that and fix one that was broken for Mac. The new version of the auto-test showed a crash because of this broken selection. Task-number:258751 Reviewed-by:thierry
Diffstat (limited to 'tests/auto/qfiledialog')
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index 6890610..18875e7 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -1814,6 +1814,8 @@ void tst_QFiledialog::task228844_ensurePreviousSorting()
current.mkdir("e");
current.mkdir("f");
current.mkdir("g");
+ QTemporaryFile *tempFile = new QTemporaryFile(current.absolutePath() + "/rXXXXXX");
+ tempFile->open();
current.cdUp();
QNonNativeFileDialog fd;
@@ -1825,25 +1827,47 @@ void tst_QFiledialog::task228844_ensurePreviousSorting()
tree->header()->setSortIndicator(3,Qt::DescendingOrder);
QTest::qWait(200);
QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
- QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel);
+ QPushButton *button = buttonBox->button(QDialogButtonBox::Open);
QTest::mouseClick(button, Qt::LeftButton);
QTest::qWait(500);
QNonNativeFileDialog fd2;
+ fd2.setFileMode(QFileDialog::Directory);
fd2.restoreState(fd.saveState());
current.cd("aaaaaaaaaaaaaaaaaa");
fd2.setDirectory(current.absolutePath());
fd2.show();
QTest::qWait(500);
QTreeView *tree2 = qFindChild<QTreeView*>(&fd2, "treeView");
+ tree2->setFocus();
QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath());
QDialogButtonBox *buttonBox2 = qFindChild<QDialogButtonBox*>(&fd2, "buttonBox");
- QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Cancel);
+ QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open);
+ fd2.selectFile("g");
QTest::mouseClick(button2, Qt::LeftButton);
QTest::qWait(500);
+ QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QChar('/') + QLatin1String("g"));
+
+ QNonNativeFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
+ fd3.restoreState(fd.saveState());
+ fd3.setFileMode(QFileDialog::Directory);
+ fd3.show();
+ QTest::qWait(500);
+ QTreeView *tree3 = qFindChild<QTreeView*>(&fd3, "treeView");
+ tree3->setFocus();
+
+ QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath());
+
+ QDialogButtonBox *buttonBox3 = qFindChild<QDialogButtonBox*>(&fd3, "buttonBox");
+ QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open);
+ QTest::mouseClick(button3, Qt::LeftButton);
+ QTest::qWait(500);
+
+ QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName());
+
current.cd("aaaaaaaaaaaaaaaaaa");
current.rmdir("a");
current.rmdir("b");
@@ -1852,6 +1876,8 @@ void tst_QFiledialog::task228844_ensurePreviousSorting()
current.rmdir("e");
current.rmdir("f");
current.rmdir("g");
+ tempFile->close();
+ delete tempFile;
current.cdUp();
current.rmdir("aaaaaaaaaaaaaaaaaa");
}