diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2022-11-22 14:06:33 +0200 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2022-12-27 14:47:41 +0200 |
commit | fc10f05c5757d5be85923dc1278ff87ace6aa4d6 (patch) | |
tree | b182db0c43f066b350c526ec2558a500ee757f49 /tests | |
parent | 732c6ab2dd3b6c65946b7b6403034fbd37530421 (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.
Task-number: QTBUG-98974
Change-Id: Ibc4973366807dd5284c19912ab04ff90f2a573cb
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
(cherry picked from commit c1fa5d602c541b06e3e2fc2d02f5d62060c84504)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual/android_content_uri/tst_content_uris.cpp | 24 |
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 1fea742af7..e0fb10eb98 100644 --- a/tests/manual/android_content_uri/tst_content_uris.cpp +++ b/tests/manual/android_content_uri/tst_content_uris.cpp @@ -193,6 +193,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()); } |