Android tests: Fix for moving file in content URI test

In Android's manual URI content test, there is a test case for moving a
file to another directory. While the function works and the file is
moved correctly, the URI is no longer usable after this operation. The
file must be reopened with a new URI.

This commit updates fileOperations test case to use the new URL after
moving file to another directory

Pick-to: 6.9 6.8
Fixes: QTBUG-134881
Change-Id: I114d76d6851815e7ee3d94ddc28d677d7c1ccea9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Bartlomiej Moskal 2025-03-31 16:26:35 +02:00
parent fc3d0b029b
commit 1a35a560dd

View File

@ -239,12 +239,16 @@ void tst_ContentUris::fileOperations()
QVERIFY(file.rename(destDir + u'/' + fileName));
// NOTE: The uri doesn't seem to stay usable after a rename and it needs to get
// permission again via the SAF picker.
// NOTE: The uri doesn't seem to stay usable after a rename, but the file should
// be already moved to the new path. To check and remove file need to use new url
file.close();
showInstructionsDialog("Choose the file that was moved");
QFileDialog::getOpenFileName(nullptr, tr("Open File"));
const auto url = QFileDialog::getOpenFileName(nullptr, tr("Open File"));
file.setFileName(url);
QVERIFY(file.exists());
QVERIFY(file.remove());
QVERIFY(!file.exists());
}
}