Commit Graph

5 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
085deb7697 gio/tests/documentportal: Add tests covering portal failures
In case the portal fails to create what we expect, or we can't read the
files we should fail. Add test cases for this too.
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
a3b99ce554 gio/tests/fake-document-portal: Really create fake files
In order to properly test the document portal, let's also create some
dummy files that are named after the FDs we receive and using the
document-id path as the real portal does
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
eb78cfeeca gio/tests/fake-document-portal: Test that the app-id matches the request
Ensure that the app-id requiring the document matches the one we want,
so that we can actually test the code in GDesktopAppInfo that does the
mapping
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
352cfe600a gio/gdocumentportal: Use the target name when opening a symlink
When an URI to a symlink is added to the portal, we open it and we send
the FD (of the target) to the portal. This one has no clue about the original
symlink and so it mounts a file that is named like the target.

g_document_portal_add_documents(), however returns a path that contains
the original name and that one is what is sent to the applications when
used via GDesktopAppInfo.

Basically, this is the situation:
  - /tmp/symlink -> /tmp/target
  - An application is launched to open file:/tmp/symlink
  - The portal creates file:/$XDG_RUNTIME_DIR/doc/ID/target
  - Gio converts the path to file:/$XDG_RUNTIME_DIR/doc/ID/symlink

Now, since we can't just pass the symlink to the portal without also
changing the logic there, it's just better to do the conversion ourself,
and so, we use the already-opened fd to figure out the real path of the
opened file, and we return a document file URI that uses the target
basename instead
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
d81701de56 gio/tests: Add document portal tests
While this can be tested using desktop apps, adding some unit tests
makes simpler to verify the edge cases
2025-10-16 20:29:32 +02:00