Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wireplumber
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pkg
wireplumber
Commits
a5e86717
Commit
a5e86717
authored
5 years ago
by
George Kiagiadakis
Browse files
Options
Downloads
Patches
Plain Diff
tests: proxy: add unit test for WpProxyNode and enum_params in particular
parent
31a75371
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/proxy.c
+107
-0
107 additions, 0 deletions
tests/proxy.c
with
107 additions
and
0 deletions
tests/proxy.c
+
107
−
0
View file @
a5e86717
...
...
@@ -161,6 +161,111 @@ test_proxy_basic (TestProxyFixture *fixture, gconstpointer data)
g_main_loop_run
(
fixture
->
loop
);
}
typedef
struct
{
TestProxyFixture
*
fixture
;
guint
n_params
;
}
TestProxyNodeParamData
;
static
void
test_proxy_node_param
(
WpProxyNode
*
node
,
int
seq
,
guint
id
,
guint
index
,
guint
next
,
struct
spa_pod
*
param
,
TestProxyNodeParamData
*
data
)
{
data
->
n_params
++
;
}
static
void
test_proxy_node_enum_params_done
(
WpProxyNode
*
node
,
GAsyncResult
*
res
,
TestProxyNodeParamData
*
data
)
{
g_autoptr
(
GPtrArray
)
params
=
NULL
;
g_autoptr
(
GError
)
error
=
NULL
;
guint
i
;
params
=
wp_proxy_node_enum_params_collect_finish
(
node
,
res
,
&
error
);
g_assert_no_error
(
error
);
g_assert_nonnull
(
params
);
/* the param signal must have also been fired for all params */
g_assert_cmpint
(
params
->
len
,
==
,
data
->
n_params
);
for
(
i
=
0
;
i
<
params
->
len
;
i
++
)
{
struct
spa_pod
*
pod
=
g_ptr_array_index
(
params
,
i
);
g_assert_true
(
spa_pod_is_object_type
(
pod
,
SPA_TYPE_OBJECT_PropInfo
));
}
g_main_loop_quit
(
data
->
fixture
->
loop
);
g_free
(
data
);
}
static
void
test_proxy_node_global_added
(
WpRemote
*
remote
,
WpProxy
*
proxy
,
TestProxyFixture
*
fixture
)
{
const
struct
pw_node_info
*
info
;
TestProxyNodeParamData
*
param_data
;
g_assert_nonnull
(
proxy
);
g_assert_true
(
wp_proxy_is_global
(
proxy
));
g_assert_cmpuint
(
wp_proxy_get_interface_type
(
proxy
),
==
,
PW_TYPE_INTERFACE_Node
);
g_assert_cmphex
(
wp_proxy_get_features
(
proxy
),
==
,
WP_PROXY_FEATURE_PW_PROXY
|
WP_PROXY_FEATURE_INFO
);
g_assert_nonnull
(
wp_proxy_get_pw_proxy
(
proxy
));
g_assert_true
(
WP_IS_PROXY_NODE
(
proxy
));
info
=
wp_proxy_node_get_info
(
WP_PROXY_NODE
(
proxy
));
g_assert_nonnull
(
info
);
g_assert_cmpint
(
wp_proxy_get_global_id
(
proxy
),
==
,
info
->
id
);
{
const
char
*
id
;
g_autoptr
(
WpProperties
)
props
=
wp_proxy_node_get_properties
(
WP_PROXY_NODE
(
proxy
));
g_assert_nonnull
(
props
);
g_assert_true
(
wp_properties_peek_dict
(
props
)
==
info
->
props
);
id
=
wp_properties_get
(
props
,
"node.id"
);
g_assert_nonnull
(
id
);
g_assert_cmpint
(
info
->
id
,
==
,
atoi
(
id
));
}
param_data
=
g_new0
(
TestProxyNodeParamData
,
1
);
param_data
->
fixture
=
fixture
;
g_signal_connect
(
proxy
,
"param"
,
(
GCallback
)
test_proxy_node_param
,
param_data
);
wp_proxy_node_enum_params_collect
(
WP_PROXY_NODE
(
proxy
),
SPA_PARAM_PropInfo
,
NULL
,
NULL
,
(
GAsyncReadyCallback
)
test_proxy_node_enum_params_done
,
param_data
);
}
static
void
test_proxy_node
(
TestProxyFixture
*
fixture
,
gconstpointer
data
)
{
/* load audiotestsrc on the server side */
pw_thread_loop_lock
(
fixture
->
server
.
thread_loop
);
pw_core_add_spa_lib
(
fixture
->
server
.
core
,
"audiotestsrc"
,
"audiotestsrc/libspa-audiotestsrc"
);
if
(
!
pw_module_load
(
fixture
->
server
.
core
,
"libpipewire-module-spa-node"
,
"audiotestsrc"
,
NULL
))
{
pw_thread_loop_unlock
(
fixture
->
server
.
thread_loop
);
g_test_skip
(
"audiotestsrc SPA plugin is not installed"
);
return
;
}
pw_thread_loop_unlock
(
fixture
->
server
.
thread_loop
);
/* we should be able to see this exported audiotestsrc node on the client */
g_signal_connect
(
fixture
->
remote
,
"global-added::node"
,
(
GCallback
)
test_proxy_node_global_added
,
fixture
);
/* tell the remote to call global-added only when these features are ready */
wp_remote_pipewire_set_default_features
(
WP_REMOTE_PIPEWIRE
(
fixture
->
remote
),
WP_TYPE_PROXY_NODE
,
WP_PROXY_FEATURE_PW_PROXY
|
WP_PROXY_FEATURE_INFO
);
g_assert_true
(
wp_remote_connect
(
fixture
->
remote
));
g_main_loop_run
(
fixture
->
loop
);
}
gint
main
(
gint
argc
,
gchar
*
argv
[])
{
...
...
@@ -169,6 +274,8 @@ main (gint argc, gchar *argv[])
g_test_add
(
"/wp/proxy/basic"
,
TestProxyFixture
,
NULL
,
test_proxy_setup
,
test_proxy_basic
,
test_proxy_teardown
);
g_test_add
(
"/wp/proxy/node"
,
TestProxyFixture
,
NULL
,
test_proxy_setup
,
test_proxy_node
,
test_proxy_teardown
);
return
g_test_run
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment