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.8
Fixes: QTBUG-134881
Change-Id: I114d76d6851815e7ee3d94ddc28d677d7c1ccea9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 1a35a560ddcaf03d9e2f5f91cd6bcd006c6d0951)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Bartlomiej Moskal 2025-03-31 16:26:35 +02:00 committed by Qt Cherry-pick Bot
parent f4c1d51cae
commit 95ea70197f

View File

@ -239,12 +239,16 @@ void tst_ContentUris::fileOperations()
QVERIFY(file.rename(destDir + u'/' + fileName)); QVERIFY(file.rename(destDir + u'/' + fileName));
// NOTE: The uri doesn't seem to stay usable after a rename and it needs to get // NOTE: The uri doesn't seem to stay usable after a rename, but the file should
// permission again via the SAF picker. // 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"); 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.remove());
QVERIFY(!file.exists());
} }
} }