From ae2b30bda0dc4a7b33f7eddae7e23dbf427bd6a4 Mon Sep 17 00:00:00 2001 From: Bartlomiej Moskal Date: Mon, 31 Mar 2025 16:26:35 +0200 Subject: [PATCH] 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 Fixes: QTBUG-134881 Change-Id: I114d76d6851815e7ee3d94ddc28d677d7c1ccea9 Reviewed-by: Assam Boudjelthia (cherry picked from commit 1a35a560ddcaf03d9e2f5f91cd6bcd006c6d0951) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 95ea70197f967286b151028bf33263e23af8118c) --- tests/manual/android_content_uri/tst_content_uris.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/manual/android_content_uri/tst_content_uris.cpp b/tests/manual/android_content_uri/tst_content_uris.cpp index b9a150a447d..7b63e9d6104 100644 --- a/tests/manual/android_content_uri/tst_content_uris.cpp +++ b/tests/manual/android_content_uri/tst_content_uris.cpp @@ -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()); } }