Skip to content

Commit

Permalink
fixup! tests: switch the test suite over to use pytest properly
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgesStavracas committed Aug 4, 2023
1 parent 4ebe2c0 commit 4758277
Showing 1 changed file with 106 additions and 102 deletions.
208 changes: 106 additions & 102 deletions src/input-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ is_input_capture_session (Session *session)
}

static InputCaptureSession *
input_capture_session_new (GVariant *options,
Request *request,
GError **error)
input_capture_session_new (GVariant *options,
Request *request,
GError **error)
{
Session *session;
GDBusInterfaceSkeleton *interface_skeleton =
Expand Down Expand Up @@ -120,18 +120,18 @@ input_capture_session_new (GVariant *options,
}

static void
create_session_done (GObject *source_object,
create_session_done (GObject *source_object,
GAsyncResult *res,
gpointer data)
gpointer data)
{
g_autoptr(Request) request = data;
Session *session;
guint response = 2;
g_autoptr(GError) error = NULL;
GVariantBuilder results_builder;
GVariant *results;
Session *session;
gboolean should_close_session;
GVariantBuilder results_builder;
g_autoptr(GError) error = NULL;
guint capabilities = 0;
guint response = 2;

REQUEST_AUTOLOCK (request);

Expand Down Expand Up @@ -202,10 +202,10 @@ create_session_done (GObject *source_object,
}

static gboolean
validate_capabilities (const char *key,
GVariant *value,
GVariant *options,
GError **error)
validate_capabilities (const char *key,
GVariant *value,
GVariant *options,
GError **error)
{
guint32 types = g_variant_get_uint32 (value);

Expand All @@ -224,17 +224,17 @@ static XdpOptionKey input_capture_create_session_options[] = {
};

static gboolean
handle_create_session (XdpDbusInputCapture *object,
handle_create_session (XdpDbusInputCapture *object,
GDBusMethodInvocation *invocation,
const char *arg_parent_window,
GVariant *arg_options)
const char *arg_parent_window,
GVariant *arg_options)
{
Request *request = request_from_invocation (invocation);
g_autoptr(GError) error = NULL;
g_autoptr(XdpDbusImplRequest) impl_request = NULL;
Session *session;
g_autoptr(GError) error = NULL;
GVariantBuilder options_builder;
GVariant *options;
Session *session;

REQUEST_AUTOLOCK (request);

Expand Down Expand Up @@ -292,14 +292,18 @@ handle_create_session (XdpDbusInputCapture *object,
}

static void
get_zones_done (GObject *source_object, GAsyncResult *res, gpointer data)
get_zones_done (GObject *source_object,
GAsyncResult *res,
gpointer data)
{
g_autoptr(Request) request = data;
g_autoptr(GVariant) results = NULL;
g_autoptr(Request) request = NULL;
g_autoptr(GError) error = NULL;
Session *session;
guint response = 2;
gboolean should_close_session;
g_autoptr(GError) error = NULL;
g_autoptr(GVariant) results = NULL;
guint response = 2;

request = (Request *)data;

REQUEST_AUTOLOCK (request);

Expand Down Expand Up @@ -343,18 +347,18 @@ static XdpOptionKey input_capture_get_zones_options[] = {
};

static gboolean
handle_get_zones (XdpDbusInputCapture *object,
handle_get_zones (XdpDbusInputCapture *object,
GDBusMethodInvocation *invocation,
const char *arg_session_handle,
GVariant *arg_options)
const char *arg_session_handle,
GVariant *arg_options)
{
Request *request = request_from_invocation (invocation);
Session *session;
g_autoptr(XdpDbusImplRequest) impl_request = NULL;
InputCaptureSession *input_capture_session;
g_autoptr(GError) error = NULL;
g_autoptr(XdpDbusImplRequest) impl_request = NULL;
GVariantBuilder options_builder;
GVariant *options;
Session *session;

REQUEST_AUTOLOCK (request);

Expand Down Expand Up @@ -443,7 +447,9 @@ handle_get_zones (XdpDbusInputCapture *object,
}

static void
set_pointer_barriers_done (GObject *source_object, GAsyncResult *res, gpointer data)
set_pointer_barriers_done (GObject *source_object,
GAsyncResult *res,
gpointer data)
{
g_autoptr(Request) request = data;
Session *session;
Expand Down Expand Up @@ -494,20 +500,20 @@ static XdpOptionKey input_capture_set_pointer_barriers_options[] = {
};

static gboolean
handle_set_pointer_barriers (XdpDbusInputCapture *object,
handle_set_pointer_barriers (XdpDbusInputCapture *object,
GDBusMethodInvocation *invocation,
const char *arg_session_handle,
GVariant *arg_options,
GVariant *arg_barriers,
guint arg_zone_set)
const char *arg_session_handle,
GVariant *arg_options,
GVariant *arg_barriers,
guint arg_zone_set)
{
Request *request = request_from_invocation (invocation);
Session *session;
g_autoptr(XdpDbusImplRequest) impl_request = NULL;
InputCaptureSession *input_capture_session;
g_autoptr(GError) error = NULL;
g_autoptr(XdpDbusImplRequest) impl_request = NULL;
GVariantBuilder options_builder;
GVariant *options;
Session *session;

REQUEST_AUTOLOCK (request);

Expand Down Expand Up @@ -586,7 +592,7 @@ handle_set_pointer_barriers (XdpDbusInputCapture *object,
arg_session_handle,
xdp_app_info_get_id (request->app_info),
options,
g_variant_ref(arg_barriers), /* FIXME: validation? */
g_variant_ref (arg_barriers), /* FIXME: validation? */
arg_zone_set, /* FIXME: validation? */
NULL,
set_pointer_barriers_done,
Expand All @@ -601,16 +607,15 @@ static XdpOptionKey input_capture_enable_options[] = {
};

static gboolean
handle_enable (XdpDbusInputCapture *object,
handle_enable (XdpDbusInputCapture *object,
GDBusMethodInvocation *invocation,
const char *arg_session_handle,
GVariant *arg_options)
const char *arg_session_handle,
GVariant *arg_options)
{
Call *call = call_from_invocation (invocation);
Session *session;
InputCaptureSession *input_capture_session;
g_autoptr(GError) error = NULL;
g_autoptr(XdpDbusImplRequest) impl_request = NULL;
GVariantBuilder options_builder;

session = acquire_session_from_call (arg_session_handle, call);
Expand Down Expand Up @@ -703,16 +708,15 @@ static XdpOptionKey input_capture_disable_options[] = {
};

static gboolean
handle_disable (XdpDbusInputCapture *object,
GDBusMethodInvocation *invocation,
const char *arg_session_handle,
GVariant *arg_options)
handle_disable (XdpDbusInputCapture *object,
GDBusMethodInvocation *invocation,
const char *arg_session_handle,
GVariant *arg_options)
{
Call *call = call_from_invocation (invocation);
Session *session;
InputCaptureSession *input_capture_session;
g_autoptr(GError) error = NULL;
g_autoptr(XdpDbusImplRequest) impl_request = NULL;
GVariantBuilder options_builder;

session = acquire_session_from_call (arg_session_handle, call);
Expand Down Expand Up @@ -805,10 +809,10 @@ static XdpOptionKey input_capture_release_options[] = {
};

static gboolean
handle_release (XdpDbusInputCapture *object,
handle_release (XdpDbusInputCapture *object,
GDBusMethodInvocation *invocation,
const char *arg_session_handle,
GVariant *arg_options)
const char *arg_session_handle,
GVariant *arg_options)
{
Call *call = call_from_invocation (invocation);
Session *session;
Expand Down Expand Up @@ -902,11 +906,11 @@ handle_release (XdpDbusInputCapture *object,
}

static gboolean
handle_connect_to_eis (XdpDbusInputCapture *object,
handle_connect_to_eis (XdpDbusInputCapture *object,
GDBusMethodInvocation *invocation,
GUnixFDList *in_fd_list,
const char *arg_session_handle,
GVariant *arg_options)
GUnixFDList *in_fd_list,
const char *arg_session_handle,
GVariant *arg_options)
{
Call *call = call_from_invocation (invocation);
Session *session;
Expand Down Expand Up @@ -991,33 +995,32 @@ input_capture_iface_init (XdpDbusInputCaptureIface *iface)
iface->handle_enable = handle_enable;
iface->handle_disable = handle_disable;
iface->handle_release = handle_release;

}

static void
pass_signal (XdpDbusImplInputCapture *impl,
const char *signal_name,
const char *session_id,
GVariant *options,
gpointer *data)
const char *signal_name,
const char *session_id,
GVariant *options,
gpointer data)
{
GDBusConnection *connection = g_dbus_proxy_get_connection (G_DBUS_PROXY (impl));
g_autoptr(Session) session = lookup_session (session_id);

g_dbus_connection_emit_signal (connection,
session->sender,
"/org/freedesktop/portal/desktop",
"org.freedesktop.portal.InputCapture",
signal_name,
g_variant_new ("(o@a{sv})", session_id, options),
NULL);
session->sender,
"/org/freedesktop/portal/desktop",
"org.freedesktop.portal.InputCapture",
signal_name,
g_variant_new ("(o@a{sv})", session_id, options),
NULL);
}

static void
on_disabled_cb (XdpDbusImplInputCapture *impl,
const char *session_id,
GVariant *options,
gpointer *data)
const char *session_id,
GVariant *options,
gpointer data)
{
g_autoptr(Session) session = lookup_session (session_id);
InputCaptureSession *input_capture_session;
Expand Down Expand Up @@ -1048,9 +1051,9 @@ on_disabled_cb (XdpDbusImplInputCapture *impl,

static void
on_activated_cb (XdpDbusImplInputCapture *impl,
const char *session_id,
GVariant *options,
gpointer *data)
const char *session_id,
GVariant *options,
gpointer data)
{
g_autoptr(Session) session = lookup_session (session_id);
InputCaptureSession *input_capture_session;
Expand Down Expand Up @@ -1080,9 +1083,9 @@ on_activated_cb (XdpDbusImplInputCapture *impl,

static void
on_deactivated_cb (XdpDbusImplInputCapture *impl,
const char *session_id,
GVariant *options,
gpointer *data)
const char *session_id,
GVariant *options,
gpointer data)
{
g_autoptr(Session) session = lookup_session (session_id);
InputCaptureSession *input_capture_session;
Expand Down Expand Up @@ -1113,13 +1116,14 @@ on_deactivated_cb (XdpDbusImplInputCapture *impl,
static void
input_capture_init (InputCapture *input_capture)
{
xdp_dbus_input_capture_set_version (XDP_DBUS_INPUT_CAPTURE (input_capture), VERSION_1);
unsigned int supported_capabilities;

xdp_dbus_input_capture_set_version (XDP_DBUS_INPUT_CAPTURE (input_capture), VERSION_1);

supported_capabilities =
xdp_dbus_impl_input_capture_get_supported_capabilities (impl);
xdp_dbus_input_capture_set_supported_capabilities (XDP_DBUS_INPUT_CAPTURE (input_capture),
supported_capabilities);
supported_capabilities);

g_signal_connect (impl, "disabled", G_CALLBACK (on_disabled_cb), input_capture);
g_signal_connect (impl, "activated", G_CALLBACK (on_activated_cb), input_capture);
Expand All @@ -1133,33 +1137,6 @@ input_capture_class_init (InputCaptureClass *klass)
g_quark_from_static_string ("-xdp-request-capture-input-session");
}

GDBusInterfaceSkeleton *
input_capture_create (GDBusConnection *connection,
const char *dbus_name)
{
g_autoptr(GError) error = NULL;

impl = xdp_dbus_impl_input_capture_proxy_new_sync (connection,
G_DBUS_PROXY_FLAGS_NONE,
dbus_name,
DESKTOP_PORTAL_OBJECT_PATH,
NULL,
&error);
if (impl == NULL)
{
g_warning ("Failed to create capture input proxy: %s", error->message);
return NULL;
}

impl_version = xdp_dbus_impl_input_capture_get_version (impl);

g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (impl), G_MAXINT);

input_capture = g_object_new (input_capture_get_type (), NULL);

return G_DBUS_INTERFACE_SKELETON (input_capture);
}

static void
input_capture_session_close (Session *session)
{
Expand Down Expand Up @@ -1193,3 +1170,30 @@ input_capture_session_class_init (InputCaptureSessionClass *klass)
session_class = (SessionClass *)klass;
session_class->close = input_capture_session_close;
}

GDBusInterfaceSkeleton *
input_capture_create (GDBusConnection *connection,
const char *dbus_name)
{
g_autoptr(GError) error = NULL;

impl = xdp_dbus_impl_input_capture_proxy_new_sync (connection,
G_DBUS_PROXY_FLAGS_NONE,
dbus_name,
DESKTOP_PORTAL_OBJECT_PATH,
NULL,
&error);
if (impl == NULL)
{
g_warning ("Failed to create capture input proxy: %s", error->message);
return NULL;
}

impl_version = xdp_dbus_impl_input_capture_get_version (impl);

g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (impl), G_MAXINT);

input_capture = g_object_new (input_capture_get_type (), NULL);

return G_DBUS_INTERFACE_SKELETON (input_capture);
}

0 comments on commit 4758277

Please sign in to comment.