Merge branch 'appinfo-doc-portal-test' into 'master'

gio: test that launch_uris() exports files with the document portal when launching a flatpak

See merge request GNOME/glib!1111
This commit is contained in:
Philip Withnall 2019-12-17 15:30:11 +00:00
commit 51c3921022
13 changed files with 492 additions and 82 deletions

View File

@ -37,56 +37,47 @@
#define HAVE_O_CLOEXEC 1
#endif
static GXdpDocuments *documents;
static char *documents_mountpoint;
static gboolean
init_document_portal (void)
get_document_portal (GXdpDocuments **documents,
char **documents_mountpoint,
GError **error)
{
static gsize documents_inited = 0;
GDBusConnection *connection = NULL;
if (g_once_init_enter (&documents_inited))
*documents = NULL;
*documents_mountpoint = NULL;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
if (connection == NULL)
{
GError *error = NULL;
GDBusConnection *connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (connection != NULL)
{
documents = gxdp_documents_proxy_new_sync (connection, 0,
"org.freedesktop.portal.Documents",
"/org/freedesktop/portal/documents",
NULL, &error);
if (documents != NULL)
{
gxdp_documents_call_get_mount_point_sync (documents,
&documents_mountpoint,
NULL, &error);
if (error != NULL)
{
g_warning ("Cannot get document portal mount point: %s", error->message);
g_error_free (error);
}
}
else
{
g_warning ("Cannot create document portal proxy: %s", error->message);
g_error_free (error);
}
g_object_unref (connection);
}
else
{
g_warning ("Cannot connect to session bus when initializing document portal: %s",
error->message);
g_error_free (error);
}
g_once_init_leave (&documents_inited, 1);
g_prefix_error (error, "Cannot connect to session bus when initializing document portal: ");
goto out;
}
return (documents != NULL && documents_mountpoint != NULL);
*documents = gxdp_documents_proxy_new_sync (connection,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
"org.freedesktop.portal.Documents",
"/org/freedesktop/portal/documents",
NULL, error);
if (*documents == NULL)
{
g_prefix_error (error, "Cannot create document portal proxy: ");
goto out;
}
if (!gxdp_documents_call_get_mount_point_sync (*documents,
documents_mountpoint,
NULL, error))
{
g_clear_object (documents);
g_prefix_error (error, "Cannot get document portal mount point: ");
goto out;
}
out:
g_clear_object (&connection);
return *documents != NULL;
}
/* Flags accepted by org.freedesktop.portal.Documents.AddFull */
@ -102,6 +93,8 @@ g_document_portal_add_documents (GList *uris,
const char *app_id,
GError **error)
{
GXdpDocuments *documents = NULL;
char *documents_mountpoint = NULL;
int length;
GList *ruris = NULL;
gboolean *as_is;
@ -113,10 +106,8 @@ g_document_portal_add_documents (GList *uris,
char **doc_ids = NULL;
GVariant *extra_out = NULL;
if (!init_document_portal ())
if (!get_document_portal (&documents, &documents_mountpoint, error))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_INITIALIZED,
"Document portal is not available");
return NULL;
}
@ -213,6 +204,8 @@ g_document_portal_add_documents (GList *uris,
}
out:
g_clear_object (&documents);
g_clear_pointer (&documents_mountpoint, g_free);
g_clear_object (&fd_list);
g_clear_pointer (&extra_out, g_variant_unref);
g_clear_pointer (&doc_ids, g_strfreev);

View File

@ -247,16 +247,6 @@ xdp_dbus_generated = custom_target('xdp-dbus',
'--output-directory', '@OUTDIR@',
'--generate-c-code', 'xdp-dbus',
'--c-namespace', 'GXdp',
'--annotate', 'org.freedesktop.portal.Documents.Add()',
'org.gtk.GDBus.C.UnixFD', 'true',
'--annotate', 'org.freedesktop.portal.Documents.AddNamed()',
'org.gtk.GDBus.C.UnixFD', 'true',
'--annotate', 'org.freedesktop.portal.Documents.AddFull()',
'org.gtk.GDBus.C.UnixFD', 'true',
'--annotate', 'org.freedesktop.portal.OpenURI.OpenFile()',
'org.gtk.GDBus.C.UnixFD', 'true',
'--annotate', 'org.freedesktop.portal.Trash.TrashFile()',
'org.gtk.GDBus.C.UnixFD', 'true',
'@INPUT@'])
# Generate gdbus-generated.{c,h}

View File

@ -8,7 +8,7 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -45,6 +45,12 @@
The permissions that the application has for a document store entry
(see org.freedesktop.portal.Documents.GrantPermissions()) are reflected
in the POSIX mode bits in the fuse filesystem.
The D-Bus interface for the document portal is available under the
bus name org.freedesktop.portal.Documents and the object path
/org/freedesktop/portal/documents.
This documentation describes version 3 of this interface.
-->
<interface name='org.freedesktop.portal.Documents'>
<property name="version" type="u" access="read"/>
@ -72,6 +78,7 @@
access to the file.
-->
<method name="Add">
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type='h' name='o_path_fd' direction='in'/>
<arg type='b' name='reuse_existing' direction='in'/>
<arg type='b' name='persistent' direction='in'/>
@ -89,6 +96,7 @@
Creates an entry in the document store for writing a new file.
-->
<method name="AddNamed">
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type='h' name='o_path_parent_fd' direction='in'/>
<arg type='ay' name='filename' direction='in'/>
<arg type='b' name='reuse_existing' direction='in'/>
@ -99,7 +107,7 @@
<!--
AddFull:
@o_path_fds: open file descriptors for the files to export
@flags: flags, 1 == reuse_existing, 2 == persistent
@flags: flags, 1 == reuse_existing, 2 == persistent, 4 == as-needed-by-app
@app_id: an application ID, or empty string
@permissions: the permissions to grant, possible values are 'read', 'write', 'grant-permissions' and 'delete'
@doc_ids: the IDs of the files in the document store
@ -109,6 +117,11 @@
form of an open file descriptor to prove that the caller has
access to the file.
If the as-needed-by-app flag is given, files will only be added to
the document store if the application does not already have access to them.
For files that are not added to the document store, the doc_ids array will
contain an empty string.
Additionally, if app_id is specified, it will be given the permissions
listed in GrantPermission.
@ -119,6 +132,7 @@
This method was added in version 2 of the org.freedesktop.portal.Documents interface.
-->
<method name="AddFull">
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type='ah' name='o_path_fds' direction='in'/>
<arg type='u' name='flags' direction='in'/>
<arg type='s' name='app_id' direction='in'/>
@ -127,6 +141,43 @@
<arg type='a{sv}' name='extra_out' direction='out'/>
</method>
<!--
AddNamedFull:
@o_path_fds: open file descriptor for the parent directory
@filename: the basename for the file
@flags: flags, 1 == reuse_existing, 2 == persistent, 4 == as-needed-by-app
@app_id: an application ID, or empty string
@permissions: the permissions to grant, possible values are 'read', 'write', 'grant-permissions' and 'delete'
@doc_id: the ID of the file in the document store
@extra_info: Extra info returned
Creates an entry in the document store for writing a new file.
If the as-needed-by-app flag is given, file will only be added to
the document store if the application does not already have access to it.
For file that is not added to the document store, the doc_id will
contain an empty string.
Additionally, if app_id is specified, it will be given the permissions
listed in GrantPermission.
The method also returns some extra info that can be used to avoid
multiple roundtrips. For now it only contains as "mountpoint", the
fuse mountpoint of the document portal.
This method was added in version 3 of the org.freedesktop.portal.Documents interface.
-->
<method name="AddNamedFull">
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type='h' name='o_path_fd' direction='in'/>
<arg type='ay' name='filename' direction='in'/>
<arg type='u' name='flags' direction='in'/>
<arg type='s' name='app_id' direction='in'/>
<arg type='as' name='permissions' direction='in'/>
<arg type='s' name='doc_id' direction='out'/>
<arg type='a{sv}' name='extra_out' direction='out'/>
</method>
<!--
GrantPermissions:
@doc_id: the ID of the file in the document store
@ -148,8 +199,8 @@
<!--
RevokePermissions:
@doc_id: the ID of the file in the document store
@app_id: the ID of the application to which permissions are granted
@permissions: the permissions to grant, possible values are 'read', 'write', 'grant-permissions' and 'delete'
@app_id: the ID of the application from which permissions are revoked
@permissions: the permissions to revoke, possible values are 'read', 'write', 'grant-permissions' and 'delete'
Revokes access permissions for a file in the document store
from an application.
@ -184,7 +235,7 @@
Looks up the document ID for a file.
This call is no not available inside the sandbox.
This call is not available inside the sandbox.
-->
<method name="Lookup">
<arg type='ay' name='filename' direction='in'/>

View File

@ -5,7 +5,7 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -26,25 +26,32 @@
The OpenURI portal allows sandboxed applications to open
URIs (e.g. a http: link to the applications homepage)
under the control of the user.
This documentation describes version 3 of this interface.
-->
<interface name="org.freedesktop.portal.OpenURI">
<!--
OpenURI:
@parent_window: Identifier for the application window
@parent_window: Identifier for the application window, see <link linkend="parent_window">Common Conventions</link>
@uri: The uri to open
@options: Vardict with optional further onformation
@handle: Object path for the #org.freedesktop.portal.Request object representing this call
Asks to open a uri.
The @parent_window identifier must be of the form "x11:$XID" for an X11
window. Support for other window systems may be added in the future.
Note that file:// uris are explicitly not supported by this method.
To request opening local files, use org.freedesktop.portal.OpenFile().
To request opening local files, use org.freedesktop.portal.OpenURI.OpenFile().
Supported keys in the @options vardict include:
<variablelist>
<varlistentry>
<term>handle_token s</term>
<listitem><para>
A string that will be used as the last element of the @handle. Must be a valid
object path element. See the #org.freedesktop.portal.Request documentation for
more information about the @handle.
</para></listitem>
</varlistentry>
<varlistentry>
<term>writable b</term>
<listitem><para>
@ -55,6 +62,15 @@
is sandboxed itself.
</para></listitem>
</varlistentry>
<varlistentry>
<term>ask b</term>
<listitem><para>
Whether to ask the user to choose an app. If this is not passed, or false,
the portal may use a default or pick the last choice.
</para><para>
The ask option was introduced in version 3 of the interface.
</para></listitem>
</varlistentry>
</variablelist>
-->
@ -67,18 +83,23 @@
<!--
OpenFile:
@parent_window: Identifier for the application window
@parent_window: Identifier for the application window, see <link linkend="parent_window">Common Conventions</link>
@fd: File descriptor for the file to open
@options: Vardict with optional further onformation
@handle: Object path for the #org.freedesktop.portal.Request object representing this call
Asks to open a local file.
The @parent_window identifier must be of the form "x11:$XID" for an X11
window. Support for other window systems may be added in the future.
Supported keys in the @options vardict include:
<variablelist>
<varlistentry>
<term>handle_token s</term>
<listitem><para>
A string that will be used as the last element of the @handle. Must be a valid
object path element. See the #org.freedesktop.portal.Request documentation for
more information about the @handle.
</para></listitem>
</varlistentry>
<varlistentry>
<term>writable b</term>
<listitem><para>
@ -89,11 +110,52 @@
is sandboxed itself.
</para></listitem>
</varlistentry>
<varlistentry>
<term>ask b</term>
<listitem><para>
Whether to ask the user to choose an app. If this is not passed, or false,
the portal may use a default or pick the last choice.
</para><para>
The ask option was introduced in version 3 of the interface.
</para></listitem>
</varlistentry>
</variablelist>
The OpenFile method was introduced in version 2 of the OpenURI portal API.
-->
<method name="OpenFile">
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="s" name="parent_window" direction="in"/>
<arg type="h" name="fd" direction="in"/>
<arg type="a{sv}" name="options" direction="in"/>
<arg type="o" name="handle" direction="out"/>
</method>
<!--
OpenDirectory:
@parent_window: Identifier for the application window, see <link linkend="parent_window">Common Conventions</link>
@fd: File descriptor for a file
@options: Vardict with optional further onformation
@handle: Object path for the #org.freedesktop.portal.Request object representing this call
Asks to open the directory containing a local file in the file browser.
Supported keys in the @options vardict include:
<variablelist>
<varlistentry>
<term>handle_token s</term>
<listitem><para>
A string that will be used as the last element of the @handle. Must be a valid
object path element. See the #org.freedesktop.portal.Request documentation for
more information about the @handle.
</para></listitem>
</varlistentry>
</variablelist>
The OpenDirectory method was introduced in version 3 of the OpenURI portal API.
-->
<method name="OpenDirectory">
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="s" name="parent_window" direction="in"/>
<arg type="h" name="fd" direction="in"/>
<arg type="a{sv}" name="options" direction="in"/>

View File

@ -5,23 +5,45 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
Author: Matthias Clasen <mclasen@redhat.com>
-->
<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd" name="/">
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
<!--
org.freedesktop.portal.ProxyResolver:
@short_description: Proxy information
The ProxyResolver interface provides network proxy information to sandboxed
applications. It is not a portal in the strict sense, since it does not involve
user interaction. Applications are expected to use this interface indirectly,
via a library API such as the GLib GProxyResolver interface.
This documentation describes version 1 of this interface.
-->
<interface name="org.freedesktop.portal.ProxyResolver">
<!--
Lookup:
@uri: Destination to connect to
@proxies: List of proxy uris
Looks up which proxy to use to connect to @uri. The returned
proxy uri are of the form 'protocol://[user[:password]@host:port'.
The protocol can be http, rtsp, socks or another proxying protocol.
'direct://' is used when no proxy is needed.
-->
<method name="Lookup">
<arg type="s" name="uri" direction="in"/>
<arg type="as" name="proxies" direction="out"/>
</method>
<property name="version" type="u" access="read"/>
</interface>
</node>

View File

@ -276,12 +276,95 @@ test_dbus_appinfo (void)
g_object_unref (app);
}
static void
on_flatpak_launch_uris_finish (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GApplication *app = user_data;
GError *error = NULL;
g_app_info_launch_uris_finish (G_APP_INFO (object), result, &error);
g_assert_no_error (error);
g_application_release (app);
}
static void
on_flatpak_activate (GApplication *app,
gpointer user_data)
{
GDesktopAppInfo *flatpak_appinfo = user_data;
char *uri;
GList *uris;
/* The app will be released in on_flatpak_launch_uris_finish */
g_application_hold (app);
uri = g_filename_to_uri (g_desktop_app_info_get_filename (flatpak_appinfo), NULL, NULL);
g_assert_nonnull (uri);
uris = g_list_prepend (NULL, uri);
g_app_info_launch_uris_async (G_APP_INFO (flatpak_appinfo), uris, NULL,
NULL, on_flatpak_launch_uris_finish, app);
g_list_free (uris);
g_free (uri);
}
static void
on_flatpak_open (GApplication *app,
GFile **files,
gint n_files,
const char *hint)
{
GFile *f;
g_assert_cmpint (n_files, ==, 1);
g_test_message ("on_flatpak_open received file '%s'", g_file_peek_path (files[0]));
/* The file has been exported via the document portal */
f = g_file_new_for_uri ("file:///document-portal/document-id/org.gtk.test.dbusappinfo.flatpak.desktop");
g_assert_true (g_file_equal (files[0], f));
g_object_unref (f);
}
static void
test_flatpak_doc_export (void)
{
const gchar *argv[] = { "myapp", NULL };
gchar *desktop_file = NULL;
GDesktopAppInfo *flatpak_appinfo;
GApplication *app;
int status;
g_test_summary ("Test that files launched via Flatpak apps are made available via the document portal.");
desktop_file = g_test_build_filename (G_TEST_DIST,
"org.gtk.test.dbusappinfo.flatpak.desktop",
NULL);
flatpak_appinfo = g_desktop_app_info_new_from_filename (desktop_file);
g_assert_nonnull (flatpak_appinfo);
g_free (desktop_file);
app = g_application_new ("org.gtk.test.dbusappinfo.flatpak",
G_APPLICATION_HANDLES_OPEN);
g_signal_connect (app, "activate", G_CALLBACK (on_flatpak_activate),
flatpak_appinfo);
g_signal_connect (app, "open", G_CALLBACK (on_flatpak_open), NULL);
status = g_application_run (app, 1, (gchar **) argv);
g_assert_cmpint (status, ==, 0);
g_object_unref (app);
g_object_unref (flatpak_appinfo);
}
int
main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/appinfo/dbusappinfo", test_dbus_appinfo);
g_test_add_func ("/appinfo/flatpak-doc-export", test_flatpak_doc_export);
return session_bus_run ();
}

View File

@ -0,0 +1,136 @@
/*
* Copyright (C) 2019 Canonical Limited
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Authors: James Henstridge <james.henstridge@canonical.com>
*/
/* A stub implementation of xdg-document-portal covering enough to
* support g_document_portal_add_documents */
#include "fake-document-portal-generated.h"
static gboolean
on_handle_get_mount_point (FakeDocuments *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
fake_documents_complete_get_mount_point (object,
invocation,
"/document-portal");
return TRUE;
}
static gboolean
on_handle_add_full (FakeDocuments *object,
GDBusMethodInvocation *invocation,
GVariant *o_path_fds,
guint flags,
const gchar *app_id,
const gchar *permissions,
gpointer user_data)
{
const gchar **doc_ids = NULL;
GVariant *extra_out = NULL;
gsize length, i;
length = g_variant_get_size (o_path_fds);
doc_ids = g_new0 (const gchar *, length);
for (i = 0; i < length; i++)
{
doc_ids[i] = "document-id";
}
extra_out = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0);
fake_documents_complete_add_full (object,
invocation,
NULL,
doc_ids,
extra_out);
g_free (doc_ids);
return TRUE;
}
static void
on_bus_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
FakeDocuments *interface;
GError *error = NULL;
g_test_message ("Acquired a message bus connection");
interface = fake_documents_skeleton_new ();
g_signal_connect (interface,
"handle-get-mount-point",
G_CALLBACK (on_handle_get_mount_point),
NULL);
g_signal_connect (interface,
"handle-add-full",
G_CALLBACK (on_handle_add_full),
NULL);
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (interface),
connection,
"/org/freedesktop/portal/documents",
&error);
g_assert_no_error (error);
}
static void
on_name_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
g_test_message ("Acquired the name %s", name);
}
static void
on_name_lost (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
g_test_message ("Lost the name %s", name);
}
gint
main (gint argc, gchar *argv[])
{
GMainLoop *loop;
guint id;
loop = g_main_loop_new (NULL, FALSE);
id = g_bus_own_name (G_BUS_TYPE_SESSION,
"org.freedesktop.portal.Documents",
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
on_bus_acquired,
on_name_acquired,
on_name_lost,
loop,
NULL);
g_main_loop_run (loop);
g_bus_unown_name (id);
g_main_loop_unref (loop);
return 0;
}

View File

@ -25,8 +25,21 @@ static GTestDBus *singleton = NULL;
void
session_bus_up (void)
{
gchar *relative, *servicesdir;
g_assert (singleton == NULL);
singleton = g_test_dbus_new (G_TEST_DBUS_NONE);
/* We ignore deprecations here so that gdbus-test-codegen-old can
* build successfully despite these two functions not being
* available in GLib 2.36 */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
relative = g_test_build_filename (G_TEST_BUILT, "services", NULL);
servicesdir = g_canonicalize_filename (relative, NULL);
G_GNUC_END_IGNORE_DEPRECATIONS
g_free (relative);
g_test_dbus_add_service_dir (singleton, servicesdir);
g_free (servicesdir);
g_test_dbus_up (singleton);
}

View File

@ -15,16 +15,20 @@ static void
fixture_setup (TestFixture *fixture, gconstpointer unused)
{
GError *error = NULL;
gchar *relative, *servicesdir;
/* Create the global dbus-daemon for this test suite
*/
fixture->dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
/* Add the private directory with our in-tree service files,
* TEST_SERVICES is defined by the build system to point
* to the right directory.
/* Add the private directory with our in-tree service files.
*/
g_test_dbus_add_service_dir (fixture->dbus, TEST_SERVICES);
relative = g_test_build_filename (G_TEST_BUILT, "services", NULL);
servicesdir = g_canonicalize_filename (relative, NULL);
g_free (relative);
g_test_dbus_add_service_dir (fixture->dbus, servicesdir);
g_free (servicesdir);
/* Start the private D-Bus daemon
*/

View File

@ -7,7 +7,6 @@ common_gio_tests_deps = [
test_c_args = [
'-DG_LOG_DOMAIN="GLib-GIO"',
'-DTEST_SERVICES="@0@/gio/tests/services"'.format(meson.build_root()),
'-DGLIB_MKENUMS="@0@"'.format(glib_mkenums),
'-DGLIB_COMPILE_SCHEMAS="@0@"'.format(glib_compile_schemas.full_path()),
'-UG_DISABLE_ASSERT',
@ -311,6 +310,24 @@ if host_machine.system() != 'windows'
},
}
endif
fake_document_portal_generated = custom_target('fake-document-portal-generated',
input : ['../org.freedesktop.portal.Documents.xml'],
output : ['fake-document-portal-generated.h',
'fake-document-portal-generated.c'],
depend_files : gdbus_codegen_built_files,
command : [python, gdbus_codegen,
'--interface-prefix', 'org.freedesktop.portal.',
'--output-directory', '@OUTDIR@',
'--generate-c-code', 'fake-document-portal-generated',
'--c-namespace', 'Fake',
'@INPUT@'])
test_extra_programs += {
'fake-document-portal' : {
'extra_sources': fake_document_portal_generated,
},
}
endif # have_dbus_daemon
# This test is currently unreliable
@ -457,6 +474,7 @@ if installed_tests_enabled
'appinfo-test-static.desktop',
'file.c',
'org.gtk.test.dbusappinfo.desktop',
'org.gtk.test.dbusappinfo.flatpak.desktop',
'test1.overlay',
install_dir : installed_tests_execdir,
)
@ -781,5 +799,5 @@ if installed_tests_enabled
)
endif
# FIXME: subdir('services')
subdir('services')
subdir('modules')

View File

@ -0,0 +1,5 @@
[Desktop Entry]
Type=Application
Name=Test
DBusActivatable=true
X-Flatpak=org.gtk.test.dbusappinfo.flatpak

View File

@ -0,0 +1,30 @@
dbus_service_files = [
'org.freedesktop.portal.Documents.service',
]
srcdir_cdata = configuration_data()
srcdir_cdata.set('installed_tests_dir', meson.current_build_dir() / '..')
installed_cdata = configuration_data()
installed_cdata.set('installed_tests_dir', installed_tests_execdir)
foreach service_file : dbus_service_files
configure_file(
input: service_file + '.in',
output: service_file,
configuration: srcdir_cdata,
)
if installed_tests_enabled
# Build a second copy of the service file for the installed
# version of the tests.
configure_file(
input: service_file + '.in',
output: service_file + '.to-install',
configuration: installed_cdata,
)
install_data(meson.current_build_dir() / service_file + '.to-install',
install_dir: installed_tests_execdir / 'services',
rename: [service_file],
)
endif
endforeach

View File

@ -0,0 +1,3 @@
[D-BUS Service]
Name=org.freedesktop.portal.Documents
Exec=@installed_tests_dir@/fake-document-portal