2019-12-09 16:35:15 +02:00
|
|
|
/* WirePlumber
|
|
|
|
|
*
|
2020-05-29 09:30:36 +03:00
|
|
|
* Copyright © 2019-2020 Collabora Ltd.
|
2019-12-09 16:35:15 +02:00
|
|
|
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*/
|
|
|
|
|
|
2020-04-22 18:29:40 +03:00
|
|
|
#include "../common/base-test-fixture.h"
|
|
|
|
|
#include <pipewire/extensions/session-manager/keys.h>
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
struct _TestSiEndpoint
|
|
|
|
|
{
|
|
|
|
|
WpSessionItem parent;
|
|
|
|
|
const gchar *name;
|
|
|
|
|
const gchar *media_class;
|
2020-05-29 09:30:36 +03:00
|
|
|
WpNode *node;
|
2020-03-20 14:45:17 +02:00
|
|
|
WpDirection direction;
|
2020-05-29 09:30:36 +03:00
|
|
|
gboolean changed_properties;
|
2020-03-20 14:45:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
G_DECLARE_FINAL_TYPE (TestSiEndpoint, test_si_endpoint,
|
|
|
|
|
TEST, SI_ENDPOINT, WpSessionItem)
|
|
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
|
test_si_endpoint_get_registration_info (WpSiEndpoint * item)
|
|
|
|
|
{
|
|
|
|
|
TestSiEndpoint *self = TEST_SI_ENDPOINT (item);
|
|
|
|
|
GVariantBuilder b;
|
|
|
|
|
|
|
|
|
|
g_variant_builder_init (&b, G_VARIANT_TYPE ("(ssya{ss})"));
|
|
|
|
|
g_variant_builder_add (&b, "s", self->name);
|
|
|
|
|
g_variant_builder_add (&b, "s", self->media_class);
|
|
|
|
|
g_variant_builder_add (&b, "y", (guchar) self->direction);
|
|
|
|
|
g_variant_builder_add (&b, "a{ss}", NULL);
|
|
|
|
|
|
|
|
|
|
return g_variant_builder_end (&b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static WpProperties *
|
|
|
|
|
test_si_endpoint_get_properties (WpSiEndpoint * item)
|
|
|
|
|
{
|
2020-05-29 09:30:36 +03:00
|
|
|
TestSiEndpoint *self = TEST_SI_ENDPOINT (item);
|
|
|
|
|
if (self->changed_properties)
|
|
|
|
|
return wp_properties_new ("test.property", "changed-value", NULL);
|
|
|
|
|
else
|
|
|
|
|
return wp_properties_new ("test.property", "test-value", NULL);
|
2020-03-20 14:45:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static guint
|
|
|
|
|
test_si_endpoint_get_n_streams (WpSiEndpoint * item)
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static WpSiStream *
|
|
|
|
|
test_si_endpoint_get_stream (WpSiEndpoint * item, guint index)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (index == 0, NULL);
|
|
|
|
|
return WP_SI_STREAM (item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_si_endpoint_endpoint_init (WpSiEndpointInterface * iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_registration_info = test_si_endpoint_get_registration_info;
|
|
|
|
|
iface->get_properties = test_si_endpoint_get_properties;
|
|
|
|
|
iface->get_n_streams = test_si_endpoint_get_n_streams;
|
|
|
|
|
iface->get_stream = test_si_endpoint_get_stream;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
|
test_si_endpoint_get_stream_registration_info (WpSiStream * self)
|
|
|
|
|
{
|
|
|
|
|
GVariantBuilder b;
|
|
|
|
|
|
|
|
|
|
g_variant_builder_init (&b, G_VARIANT_TYPE ("(sa{ss})"));
|
|
|
|
|
g_variant_builder_add (&b, "s", "default");
|
|
|
|
|
g_variant_builder_add (&b, "a{ss}", NULL);
|
|
|
|
|
|
|
|
|
|
return g_variant_builder_end (&b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static WpProperties *
|
|
|
|
|
test_si_endpoint_get_stream_properties (WpSiStream * self)
|
|
|
|
|
{
|
|
|
|
|
return wp_properties_new ("stream.property", "test-value-2", NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static WpSiEndpoint *
|
|
|
|
|
test_si_endpoint_get_stream_parent_endpoint (WpSiStream * self)
|
|
|
|
|
{
|
2020-04-28 11:29:15 -04:00
|
|
|
return WP_SI_ENDPOINT (g_object_ref (self));
|
2020-03-20 14:45:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_si_endpoint_stream_init (WpSiStreamInterface * iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_registration_info = test_si_endpoint_get_stream_registration_info;
|
|
|
|
|
iface->get_properties = test_si_endpoint_get_stream_properties;
|
|
|
|
|
iface->get_parent_endpoint = test_si_endpoint_get_stream_parent_endpoint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (TestSiEndpoint, test_si_endpoint, WP_TYPE_SESSION_ITEM,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_ENDPOINT, test_si_endpoint_endpoint_init)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_STREAM, test_si_endpoint_stream_init))
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_si_endpoint_init (TestSiEndpoint * self)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
static gpointer
|
|
|
|
|
wp_si_endpoint_get_associated_proxy (WpSessionItem * item, GType proxy_type)
|
|
|
|
|
{
|
|
|
|
|
TestSiEndpoint * self = TEST_SI_ENDPOINT (item);
|
|
|
|
|
|
|
|
|
|
if (proxy_type == WP_TYPE_NODE && self->node)
|
|
|
|
|
return g_object_ref (self->node);
|
|
|
|
|
|
|
|
|
|
return WP_SESSION_ITEM_CLASS (test_si_endpoint_parent_class)->
|
|
|
|
|
get_associated_proxy (item, proxy_type);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
static void
|
|
|
|
|
test_si_endpoint_class_init (TestSiEndpointClass * klass)
|
|
|
|
|
{
|
2020-05-29 09:30:36 +03:00
|
|
|
WpSessionItemClass *item_class = (WpSessionItemClass *) klass;
|
|
|
|
|
|
|
|
|
|
item_class->get_associated_proxy = wp_si_endpoint_get_associated_proxy;
|
2020-03-20 14:45:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************/
|
|
|
|
|
|
2019-12-09 16:35:15 +02:00
|
|
|
typedef struct {
|
2020-04-22 18:29:40 +03:00
|
|
|
WpBaseTestFixture base;
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
WpObjectManager *export_om;
|
|
|
|
|
WpObjectManager *proxy_om;
|
|
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
WpProxy *impl_endpoint;
|
2019-12-09 16:35:15 +02:00
|
|
|
WpProxy *proxy_endpoint;
|
|
|
|
|
|
|
|
|
|
gint n_events;
|
|
|
|
|
|
|
|
|
|
} TestEndpointFixture;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_endpoint_setup (TestEndpointFixture *self, gconstpointer user_data)
|
|
|
|
|
{
|
2020-04-22 18:29:40 +03:00
|
|
|
wp_base_test_fixture_setup (&self->base, WP_BASE_TEST_FLAG_CLIENT_CORE);
|
2019-12-09 16:35:15 +02:00
|
|
|
self->export_om = wp_object_manager_new ();
|
|
|
|
|
self->proxy_om = wp_object_manager_new ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_endpoint_teardown (TestEndpointFixture *self, gconstpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
g_clear_object (&self->proxy_om);
|
|
|
|
|
g_clear_object (&self->export_om);
|
2020-04-22 18:29:40 +03:00
|
|
|
wp_base_test_fixture_teardown (&self->base);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_impl_object_added (WpObjectManager *om,
|
2019-12-09 16:35:15 +02:00
|
|
|
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
|
|
|
|
{
|
2020-02-12 11:28:07 +02:00
|
|
|
g_debug ("impl object added");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
|
|
|
|
g_assert_cmpstr (G_OBJECT_TYPE_NAME (endpoint), ==, "WpImplEndpoint");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-02-12 11:28:07 +02:00
|
|
|
g_assert_null (fixture->impl_endpoint);
|
2020-03-20 14:45:17 +02:00
|
|
|
fixture->impl_endpoint = WP_PROXY (endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
if (++fixture->n_events == 3)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_impl_object_removed (WpObjectManager *om,
|
2019-12-09 16:35:15 +02:00
|
|
|
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
|
|
|
|
{
|
2020-02-12 11:28:07 +02:00
|
|
|
g_debug ("impl object removed");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
|
|
|
|
g_assert_cmpstr (G_OBJECT_TYPE_NAME (endpoint), ==, "WpImplEndpoint");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-02-12 11:28:07 +02:00
|
|
|
g_assert_nonnull (fixture->impl_endpoint);
|
|
|
|
|
fixture->impl_endpoint = NULL;
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
if (++fixture->n_events == 2)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_proxy_object_added (WpObjectManager *om,
|
2019-12-09 16:35:15 +02:00
|
|
|
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_debug ("proxy object added");
|
|
|
|
|
|
|
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_cmpstr (G_OBJECT_TYPE_NAME (endpoint), ==, "WpEndpoint");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
g_assert_null (fixture->proxy_endpoint);
|
|
|
|
|
fixture->proxy_endpoint = WP_PROXY (endpoint);
|
|
|
|
|
|
|
|
|
|
if (++fixture->n_events == 3)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_proxy_object_removed (WpObjectManager *om,
|
2019-12-09 16:35:15 +02:00
|
|
|
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_debug ("proxy object removed");
|
|
|
|
|
|
|
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_cmpstr (G_OBJECT_TYPE_NAME (endpoint), ==, "WpEndpoint");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
g_assert_nonnull (fixture->proxy_endpoint);
|
|
|
|
|
fixture->proxy_endpoint = NULL;
|
|
|
|
|
|
|
|
|
|
if (++fixture->n_events == 2)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_activate_done (WpSessionItem * item, GAsyncResult * res,
|
2019-12-09 16:35:15 +02:00
|
|
|
TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
g_debug ("activate done");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_true (wp_session_item_activate_finish (item, res, &error));
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_no_error (error);
|
2020-03-20 14:45:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_export_done (WpSessionItem * item, GAsyncResult * res,
|
2020-03-20 14:45:17 +02:00
|
|
|
TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
|
|
|
|
|
|
g_debug ("export done");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_true (wp_session_item_export_finish (item, res, &error));
|
|
|
|
|
g_assert_no_error (error);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
if (++fixture->n_events == 3)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
static void
|
2020-11-13 13:40:11 +02:00
|
|
|
test_endpoint_session_bound (WpObject * session, GAsyncResult * res,
|
2020-03-20 14:45:17 +02:00
|
|
|
TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
|
|
|
|
|
|
g_debug ("session export done");
|
|
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_true (wp_object_activate_finish (session, res, &error));
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
|
|
g_assert_true (WP_IS_IMPL_SESSION (session));
|
|
|
|
|
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2020-03-20 14:45:17 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
// static void
|
|
|
|
|
// test_endpoint_prop_changed (WpProxy * proxy,
|
|
|
|
|
// const gchar * id_name, TestEndpointFixture *fixture)
|
|
|
|
|
// {
|
|
|
|
|
// wp_debug_object (proxy, "prop changed: %s", id_name);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
// if (++fixture->n_events == 3)
|
|
|
|
|
// g_main_loop_quit (fixture->base.loop);
|
|
|
|
|
// }
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_notify_properties (WpEndpoint * endpoint, GParamSpec * param,
|
2019-12-09 16:35:15 +02:00
|
|
|
TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_debug ("properties changed: %s", G_OBJECT_TYPE_NAME (endpoint));
|
|
|
|
|
|
|
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
|
|
|
|
|
|
|
|
|
if (++fixture->n_events == 2)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_no_props (TestEndpointFixture *fixture, gconstpointer data)
|
2019-12-09 16:35:15 +02:00
|
|
|
{
|
2020-03-20 14:45:17 +02:00
|
|
|
g_autoptr (TestSiEndpoint) endpoint = NULL;
|
|
|
|
|
g_autoptr (WpImplSession) session = NULL;
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* set up the export side */
|
|
|
|
|
g_signal_connect (fixture->export_om, "object-added",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_impl_object_added, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_signal_connect (fixture->export_om, "object-removed",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_impl_object_removed, fixture);
|
2020-05-14 16:24:34 +03:00
|
|
|
wp_object_manager_add_interest (fixture->export_om, WP_TYPE_ENDPOINT, NULL);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_manager_request_object_features (fixture->export_om,
|
|
|
|
|
WP_TYPE_ENDPOINT, WP_OBJECT_FEATURES_ALL);
|
2020-04-22 18:29:40 +03:00
|
|
|
wp_core_install_object_manager (fixture->base.core, fixture->export_om);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* set up the proxy side */
|
|
|
|
|
g_signal_connect (fixture->proxy_om, "object-added",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_proxy_object_added, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_signal_connect (fixture->proxy_om, "object-removed",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_proxy_object_removed, fixture);
|
2020-05-14 16:24:34 +03:00
|
|
|
wp_object_manager_add_interest (fixture->proxy_om, WP_TYPE_ENDPOINT, NULL);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_manager_request_object_features (fixture->proxy_om,
|
|
|
|
|
WP_TYPE_ENDPOINT, WP_OBJECT_FEATURES_ALL);
|
2020-04-22 18:29:40 +03:00
|
|
|
wp_core_install_object_manager (fixture->base.client_core, fixture->proxy_om);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
/* create session */
|
2020-04-22 18:29:40 +03:00
|
|
|
session = wp_impl_session_new (fixture->base.core);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_activate (WP_OBJECT (session), WP_PROXY_FEATURE_BOUND, NULL,
|
2020-05-29 09:30:36 +03:00
|
|
|
(GAsyncReadyCallback) test_endpoint_session_bound, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
/* run until session is bound */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmpint (wp_object_get_active_features (WP_OBJECT (session)), &,
|
2020-03-20 14:45:17 +02:00
|
|
|
WP_PROXY_FEATURE_BOUND);
|
|
|
|
|
g_assert_cmpint (wp_proxy_get_bound_id (WP_PROXY (session)), >, 0);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
/* create endpoint */
|
|
|
|
|
endpoint = g_object_new (test_si_endpoint_get_type (), NULL);
|
|
|
|
|
endpoint->name = "test-endpoint";
|
|
|
|
|
endpoint->media_class = "Audio/Source";
|
|
|
|
|
endpoint->direction = WP_DIRECTION_OUTPUT;
|
|
|
|
|
wp_session_item_activate (WP_SESSION_ITEM (endpoint),
|
2020-05-29 09:30:36 +03:00
|
|
|
(GAsyncReadyCallback) test_endpoint_activate_done, fixture);
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_cmpint (wp_session_item_get_flags (WP_SESSION_ITEM (endpoint)),
|
|
|
|
|
&, WP_SI_FLAG_ACTIVE);
|
|
|
|
|
wp_session_item_export (WP_SESSION_ITEM (endpoint), WP_SESSION (session),
|
2020-05-29 09:30:36 +03:00
|
|
|
(GAsyncReadyCallback) test_endpoint_export_done, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* run until objects are created and features are cached */
|
|
|
|
|
fixture->n_events = 0;
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
2020-02-12 11:28:07 +02:00
|
|
|
g_assert_nonnull (fixture->impl_endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_nonnull (fixture->proxy_endpoint);
|
|
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify the values on the proxy */
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmphex (
|
|
|
|
|
wp_object_get_active_features (WP_OBJECT (fixture->proxy_endpoint)), ==,
|
|
|
|
|
wp_object_get_supported_features (WP_OBJECT (fixture->proxy_endpoint)));
|
2020-01-23 18:50:01 +02:00
|
|
|
g_assert_cmpuint (wp_proxy_get_bound_id (fixture->proxy_endpoint), ==,
|
2020-03-20 14:45:17 +02:00
|
|
|
wp_proxy_get_bound_id (fixture->impl_endpoint));
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmpstr (wp_pipewire_object_get_property (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->proxy_endpoint), "test.property"),
|
|
|
|
|
==, "test-value");
|
2020-03-20 14:45:17 +02:00
|
|
|
|
|
|
|
|
{
|
2020-11-13 13:40:11 +02:00
|
|
|
g_autoptr (WpProperties) props = wp_global_proxy_get_global_properties (
|
|
|
|
|
WP_GLOBAL_PROXY (fixture->proxy_endpoint));
|
2020-03-20 14:45:17 +02:00
|
|
|
g_autofree gchar * session_id = g_strdup_printf ("%u",
|
|
|
|
|
wp_proxy_get_bound_id (WP_PROXY (session)));
|
|
|
|
|
|
|
|
|
|
g_assert_cmpstr (wp_properties_get (props, PW_KEY_ENDPOINT_NAME), ==,
|
|
|
|
|
"test-endpoint");
|
|
|
|
|
g_assert_cmpstr (wp_properties_get (props, PW_KEY_MEDIA_CLASS), ==,
|
|
|
|
|
"Audio/Source");
|
|
|
|
|
g_assert_cmpstr (wp_properties_get (props, PW_KEY_SESSION_ID), ==,
|
|
|
|
|
session_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_assert_cmpstr ("test-endpoint", ==,
|
|
|
|
|
wp_endpoint_get_name (WP_ENDPOINT (fixture->proxy_endpoint)));
|
|
|
|
|
g_assert_cmpstr ("Audio/Source", ==,
|
|
|
|
|
wp_endpoint_get_media_class (WP_ENDPOINT (fixture->proxy_endpoint)));
|
|
|
|
|
g_assert_cmpint (WP_DIRECTION_OUTPUT, ==,
|
|
|
|
|
wp_endpoint_get_direction (WP_ENDPOINT (fixture->proxy_endpoint)));
|
|
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* test property changes */
|
2019-12-09 16:35:15 +02:00
|
|
|
g_signal_connect (fixture->proxy_endpoint, "notify::properties",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_notify_properties, fixture);
|
|
|
|
|
g_signal_connect (fixture->impl_endpoint, "notify::properties",
|
|
|
|
|
(GCallback) test_endpoint_notify_properties, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* change a property on the impl */
|
|
|
|
|
fixture->n_events = 0;
|
|
|
|
|
endpoint->changed_properties = TRUE;
|
|
|
|
|
g_signal_emit_by_name (endpoint, "endpoint-properties-changed");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* run until the change is on both sides */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 2);
|
|
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify the property change on both sides */
|
|
|
|
|
{
|
2020-11-13 13:40:11 +02:00
|
|
|
g_autoptr (WpProperties) props = wp_pipewire_object_get_properties (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->impl_endpoint));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpstr (wp_properties_get (props, "test.property"), ==,
|
|
|
|
|
"changed-value");
|
|
|
|
|
}
|
|
|
|
|
{
|
2020-11-13 13:40:11 +02:00
|
|
|
g_autoptr (WpProperties) props = wp_pipewire_object_get_properties (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->proxy_endpoint));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpstr (wp_properties_get (props, "test.property"), ==,
|
|
|
|
|
"changed-value");
|
|
|
|
|
}
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* destroy impl endpoint */
|
2019-12-09 16:35:15 +02:00
|
|
|
fixture->n_events = 0;
|
2020-05-29 09:30:36 +03:00
|
|
|
g_clear_object (&endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* run until objects are destroyed */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 2);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_null (fixture->impl_endpoint);
|
|
|
|
|
g_assert_null (fixture->proxy_endpoint);
|
|
|
|
|
}
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
#if 0
|
2020-05-29 09:30:36 +03:00
|
|
|
static void
|
|
|
|
|
test_endpoint_with_props (TestEndpointFixture *fixture, gconstpointer data)
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (TestSiEndpoint) endpoint = NULL;
|
|
|
|
|
g_autoptr (WpImplSession) session = NULL;
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* load modules */
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpTestServerLocker) lock =
|
|
|
|
|
wp_test_server_locker_new (&fixture->base.server);
|
|
|
|
|
|
|
|
|
|
g_assert_cmpint (pw_context_add_spa_lib (fixture->base.server.context,
|
|
|
|
|
"audiotestsrc", "audiotestsrc/libspa-audiotestsrc"), ==, 0);
|
|
|
|
|
g_assert_nonnull (pw_context_load_module (fixture->base.server.context,
|
|
|
|
|
"libpipewire-module-adapter", NULL, NULL));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set up the export side */
|
|
|
|
|
g_signal_connect (fixture->export_om, "object-added",
|
|
|
|
|
(GCallback) test_endpoint_impl_object_added, fixture);
|
|
|
|
|
g_signal_connect (fixture->export_om, "object-removed",
|
|
|
|
|
(GCallback) test_endpoint_impl_object_removed, fixture);
|
|
|
|
|
wp_object_manager_add_interest (fixture->export_om, WP_TYPE_ENDPOINT, NULL);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_manager_request_object_features (fixture->export_om,
|
|
|
|
|
WP_TYPE_ENDPOINT, WP_OBJECT_FEATURES_ALL);
|
2020-05-29 09:30:36 +03:00
|
|
|
wp_core_install_object_manager (fixture->base.core, fixture->export_om);
|
|
|
|
|
|
|
|
|
|
/* set up the proxy side */
|
|
|
|
|
g_signal_connect (fixture->proxy_om, "object-added",
|
|
|
|
|
(GCallback) test_endpoint_proxy_object_added, fixture);
|
|
|
|
|
g_signal_connect (fixture->proxy_om, "object-removed",
|
|
|
|
|
(GCallback) test_endpoint_proxy_object_removed, fixture);
|
|
|
|
|
wp_object_manager_add_interest (fixture->proxy_om, WP_TYPE_ENDPOINT, NULL);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_manager_request_object_features (fixture->proxy_om,
|
|
|
|
|
WP_TYPE_ENDPOINT, WP_OBJECT_FEATURES_ALL);
|
2020-05-29 09:30:36 +03:00
|
|
|
wp_core_install_object_manager (fixture->base.client_core, fixture->proxy_om);
|
|
|
|
|
|
|
|
|
|
/* create session */
|
|
|
|
|
session = wp_impl_session_new (fixture->base.core);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_activate (WP_PROXY (session), WP_PROXY_FEATURE_BOUND, NULL,
|
2020-05-29 09:30:36 +03:00
|
|
|
(GAsyncReadyCallback) test_endpoint_session_bound, fixture);
|
|
|
|
|
|
|
|
|
|
/* run until session is bound */
|
|
|
|
|
g_main_loop_run (fixture->base.loop);
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmpint (wp_object_get_active_features (WP_PROXY (session)), &,
|
2020-05-29 09:30:36 +03:00
|
|
|
WP_PROXY_FEATURE_BOUND);
|
|
|
|
|
g_assert_cmpint (wp_proxy_get_bound_id (WP_PROXY (session)), >, 0);
|
|
|
|
|
|
|
|
|
|
/* create endpoint */
|
|
|
|
|
endpoint = g_object_new (test_si_endpoint_get_type (), NULL);
|
|
|
|
|
endpoint->name = "test-endpoint";
|
|
|
|
|
endpoint->media_class = "Audio/Source";
|
|
|
|
|
endpoint->direction = WP_DIRECTION_OUTPUT;
|
|
|
|
|
|
|
|
|
|
/* associate a node that has props */
|
|
|
|
|
endpoint->node = wp_node_new_from_factory (fixture->base.core,
|
|
|
|
|
"adapter",
|
|
|
|
|
wp_properties_new (
|
|
|
|
|
"factory.name", "audiotestsrc",
|
|
|
|
|
"node.name", "audiotestsrc.adapter",
|
|
|
|
|
NULL));
|
|
|
|
|
g_assert_nonnull (endpoint->node);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_activate (WP_PROXY (endpoint->node), WP_PROXY_FEATURES_STANDARD, NULL,
|
|
|
|
|
(GAsyncReadyCallback) test_object_activate_finish_cb, fixture);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
|
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmpint (wp_object_get_active_features (WP_PROXY (endpoint->node)), ==,
|
2020-05-29 09:30:36 +03:00
|
|
|
WP_PROXY_FEATURES_STANDARD);
|
|
|
|
|
|
|
|
|
|
/* activate & export the endpoint */
|
|
|
|
|
wp_session_item_activate (WP_SESSION_ITEM (endpoint),
|
|
|
|
|
(GAsyncReadyCallback) test_endpoint_activate_done, fixture);
|
|
|
|
|
g_assert_cmpint (wp_session_item_get_flags (WP_SESSION_ITEM (endpoint)),
|
|
|
|
|
&, WP_SI_FLAG_ACTIVE);
|
|
|
|
|
wp_session_item_export (WP_SESSION_ITEM (endpoint), WP_SESSION (session),
|
|
|
|
|
(GAsyncReadyCallback) test_endpoint_export_done, fixture);
|
|
|
|
|
|
|
|
|
|
/* run until objects are created and features are cached */
|
2019-12-09 16:35:15 +02:00
|
|
|
fixture->n_events = 0;
|
2020-05-29 09:30:36 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
|
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
|
|
|
|
g_assert_nonnull (fixture->impl_endpoint);
|
|
|
|
|
g_assert_nonnull (fixture->proxy_endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify features; the endpoint must have also augmented the node */
|
|
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmpint (wp_object_get_active_features (WP_PROXY (endpoint->node)), ==,
|
2020-05-29 09:30:36 +03:00
|
|
|
WP_PROXY_FEATURES_STANDARD | WP_PROXY_FEATURE_PROPS);
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmphex (wp_object_get_active_features (fixture->proxy_endpoint), ==,
|
2020-05-29 09:30:36 +03:00
|
|
|
WP_PROXY_FEATURES_STANDARD | WP_PROXY_FEATURE_PROPS);
|
|
|
|
|
|
|
|
|
|
/* verify props */
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->proxy_endpoint, "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 1.0f, 0.001);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->proxy_endpoint, "mute");
|
|
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* setup change signals */
|
|
|
|
|
g_signal_connect (fixture->proxy_endpoint, "prop-changed",
|
|
|
|
|
(GCallback) test_endpoint_prop_changed, fixture);
|
|
|
|
|
g_signal_connect (fixture->impl_endpoint, "prop-changed",
|
|
|
|
|
(GCallback) test_endpoint_prop_changed, fixture);
|
|
|
|
|
g_signal_connect (endpoint->node, "prop-changed",
|
|
|
|
|
(GCallback) test_endpoint_prop_changed, fixture);
|
|
|
|
|
|
|
|
|
|
/* change control on the proxy */
|
|
|
|
|
fixture->n_events = 0;
|
|
|
|
|
wp_proxy_set_prop (fixture->proxy_endpoint, "volume",
|
|
|
|
|
wp_spa_pod_new_float (0.7f));
|
|
|
|
|
|
|
|
|
|
/* run until the change is on all sides */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify the value change on all sides */
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->proxy_endpoint, "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->proxy_endpoint, "mute");
|
|
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, FALSE);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->impl_endpoint, "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->impl_endpoint, "mute");
|
|
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, FALSE);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (WP_PROXY (endpoint->node), "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (WP_PROXY (endpoint->node), "mute");
|
|
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* change control on the impl */
|
|
|
|
|
fixture->n_events = 0;
|
|
|
|
|
wp_proxy_set_prop (fixture->impl_endpoint, "mute",
|
|
|
|
|
wp_spa_pod_new_boolean (TRUE));
|
|
|
|
|
|
|
|
|
|
/* run until the change is on all sides */
|
|
|
|
|
g_main_loop_run (fixture->base.loop);
|
|
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify the value change on all sides */
|
2019-12-09 16:35:15 +02:00
|
|
|
{
|
2020-05-29 09:30:36 +03:00
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->proxy_endpoint, "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
{
|
2020-05-29 09:30:36 +03:00
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->proxy_endpoint, "mute");
|
|
|
|
|
gboolean boolean_value = FALSE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->impl_endpoint, "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->impl_endpoint, "mute");
|
|
|
|
|
gboolean boolean_value = FALSE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (WP_PROXY (endpoint->node), "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (WP_PROXY (endpoint->node), "mute");
|
|
|
|
|
gboolean boolean_value = FALSE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* change control on the node */
|
|
|
|
|
fixture->n_events = 0;
|
|
|
|
|
wp_proxy_set_prop (WP_PROXY (endpoint->node), "volume",
|
|
|
|
|
wp_spa_pod_new_float (0.2f));
|
|
|
|
|
|
|
|
|
|
/* run until the change is on all sides */
|
|
|
|
|
g_main_loop_run (fixture->base.loop);
|
|
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
|
|
|
|
|
|
|
|
|
/* verify the value change on all sides */
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->proxy_endpoint, "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.2f, 0.001);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->proxy_endpoint, "mute");
|
|
|
|
|
gboolean boolean_value = FALSE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->impl_endpoint, "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.2f, 0.001);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (fixture->impl_endpoint, "mute");
|
|
|
|
|
gboolean boolean_value = FALSE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (WP_PROXY (endpoint->node), "volume");
|
|
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_float (pod, &float_value));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.2f, 0.001);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpSpaPod) pod =
|
|
|
|
|
wp_proxy_get_prop (WP_PROXY (endpoint->node), "mute");
|
|
|
|
|
gboolean boolean_value = FALSE;
|
|
|
|
|
g_assert_nonnull (pod);
|
|
|
|
|
g_assert_true (wp_spa_pod_get_boolean (pod, &boolean_value));
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-12 11:28:07 +02:00
|
|
|
/* destroy impl endpoint */
|
2019-12-09 16:35:15 +02:00
|
|
|
fixture->n_events = 0;
|
2020-05-29 09:30:36 +03:00
|
|
|
g_clear_object (&endpoint->node);
|
2020-02-12 11:28:07 +02:00
|
|
|
g_clear_object (&endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* run until objects are destroyed */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 2);
|
2020-02-12 11:28:07 +02:00
|
|
|
g_assert_null (fixture->impl_endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_null (fixture->proxy_endpoint);
|
|
|
|
|
}
|
2020-11-13 13:40:11 +02:00
|
|
|
#endif
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
gint
|
|
|
|
|
main (gint argc, gchar *argv[])
|
|
|
|
|
{
|
|
|
|
|
g_test_init (&argc, &argv, NULL);
|
2020-05-11 15:45:09 +03:00
|
|
|
wp_init (WP_INIT_ALL);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
g_test_add ("/wp/endpoint/no-props", TestEndpointFixture, NULL,
|
|
|
|
|
test_endpoint_setup, test_endpoint_no_props, test_endpoint_teardown);
|
2020-11-13 13:40:11 +02:00
|
|
|
// g_test_add ("/wp/endpoint/with-props", TestEndpointFixture, NULL,
|
|
|
|
|
// test_endpoint_setup, test_endpoint_with_props, test_endpoint_teardown);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
return g_test_run ();
|
|
|
|
|
}
|