summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs/qfiledialog2
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-11-15 10:44:37 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2016-11-15 09:56:31 +0000
commit628d367a9d618568167d43195c1118b7d7979da0 (patch)
tree5f68b81dd3c48134461b68b571f5261dadf77c47 /tests/auto/widgets/dialogs/qfiledialog2
parent246fe271878dbe586b5f3222a78d67dfecd1ca83 (diff)
Stabilize tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
The test relied on the file created being automatically selected, which sometimes does not happen when executing the entire test. Explicitly select the file and check the selection. Use the temporary directory for testing. Change-Id: Ia58641c1ac32ba21effa8a5ace9623eb5d48a1c2 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'tests/auto/widgets/dialogs/qfiledialog2')
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index b457558879..656d4d46de 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -372,8 +372,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
// test based on task233037_selectingDirectory
struct TestContext {
- TestContext()
- : current(QDir::current()) {}
+ explicit TestContext(const QString &path) : current(path) {}
~TestContext() {
file.remove();
current.rmdir(test.dirName());
@@ -381,7 +380,9 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
QDir current;
QDir test;
QFile file;
- } ctx;
+ };
+
+ TestContext ctx(tempDir.path());
// setup testbed
QVERIFY(ctx.current.mkdir("task143519_deleteAndRenameActionBehavior_test")); // ensure at least one item
@@ -395,6 +396,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
QNonNativeFileDialog fd;
fd.setViewMode(QFileDialog::List);
fd.setDirectory(ctx.test.absolutePath());
+ fd.selectFile(ctx.file.fileName());
fd.show();
QTest::qWaitForWindowActive(&fd);
@@ -409,7 +411,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
// defaults
QVERIFY(openContextMenu(fd));
- QCOMPARE(fd.selectedFiles().size(), 1);
+ QCOMPARE(fd.selectedFiles(), QStringList(ctx.file.fileName()));
QCOMPARE(rm->isEnabled(), !fd.isReadOnly());
QCOMPARE(mv->isEnabled(), !fd.isReadOnly());