summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2022-11-22 14:06:33 +0200
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2022-12-20 12:42:31 +0000
commitc1fa5d602c541b06e3e2fc2d02f5d62060c84504 (patch)
tree446e88c7271e9c30e5eacbf8e8d997fd92cf42f8 /tests/manual
parent30efb24d45e61f3329484c8dd416ee6cde25739b (diff)
Android: handle rename() operation with content uris
Allow renaming content uris if the destination is provided as a direct fileName (i.e. not full content scheme path), and if the destination has the same trailing path (or parent) which means a rename in the same folder structure. Pick-to: 6.5 6.4 6.2 Task-number: QTBUG-98974 Change-Id: Ibc4973366807dd5284c19912ab04ff90f2a573cb Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/android_content_uri/tst_content_uris.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/manual/android_content_uri/tst_content_uris.cpp b/tests/manual/android_content_uri/tst_content_uris.cpp
index 6795415229..4f8b9a9971 100644
--- a/tests/manual/android_content_uri/tst_content_uris.cpp
+++ b/tests/manual/android_content_uri/tst_content_uris.cpp
@@ -195,6 +195,30 @@ void tst_ContentUris::fileOperations()
QFile file(url);
QVERIFY(file.exists());
+ // Rename
+ const QString renamedFileName = "renamed_new_file.txt";
+ QVERIFY(file.rename(renamedFileName));
+ const auto renamedUrl = url.replace(fileName, renamedFileName);
+ QVERIFY(file.fileName() == renamedUrl);
+
+ // NOTE: The uri doesn't seem to stay usable after a rename and it needs to get
+ // permission again via the SAF picker.
+ showInstructionsDialog("Choose the file that was renamed");
+ QFileDialog::getOpenFileName(nullptr, tr("Open File"));
+ QVERIFY(file.exists());
+
+ // rename now with full content uri
+ const auto secondRenamedUrl = url.replace(renamedFileName, "second_nenamed_file.txt");
+ QVERIFY(file.rename(secondRenamedUrl));
+ QVERIFY(file.fileName() == secondRenamedUrl);
+
+ // NOTE: The uri doesn't seem to stay usable after a rename and it needs to get
+ // permission again via the SAF picker.
+ showInstructionsDialog("Choose the file that was renamed");
+ QFileDialog::getOpenFileName(nullptr, tr("Open File"));
+ QVERIFY(file.exists());
+
+ // Remove
QVERIFY(file.remove());
QVERIFY(!file.exists());
}