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>bb10
parent
246fe27187
commit
628d367a9d
|
|
@ -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());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue