From 9d0d8eaa8b9c021fbb45368f96489f520aab86e7 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Thu, 4 Mar 2010 21:23:40 +1100 Subject: Put mocking core in place for Connor. --- tests/mockpulse.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/mockpulse.c (limited to 'tests/mockpulse.c') diff --git a/tests/mockpulse.c b/tests/mockpulse.c new file mode 100644 index 0000000..297780b --- /dev/null +++ b/tests/mockpulse.c @@ -0,0 +1,28 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Robert Collins + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include + +pa_glib_mainloop* +pa_glib_mainloop_new(GMainContext *c) +{ + printf("This is reached\n", c); + return NULL; +} + -- cgit v1.2.3 From 364d9362165f9f0d468eadc269c6421f4bf929e3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 8 Mar 2010 20:40:32 +0000 Subject: new pulse manager test beginnings --- tests/mockpulse.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/mockpulse.c') diff --git a/tests/mockpulse.c b/tests/mockpulse.c index 297780b..a931e1d 100644 --- a/tests/mockpulse.c +++ b/tests/mockpulse.c @@ -26,3 +26,4 @@ pa_glib_mainloop_new(GMainContext *c) return NULL; } + -- cgit v1.2.3 From 6c2b978f17d48fe212cccb15c23bb1e278ba600f Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Tue, 9 Mar 2010 13:43:16 +1100 Subject: flesh out test_pa_context_exit --- tests/mockpulse.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'tests/mockpulse.c') diff --git a/tests/mockpulse.c b/tests/mockpulse.c index a931e1d..eec2c03 100644 --- a/tests/mockpulse.c +++ b/tests/mockpulse.c @@ -17,13 +17,51 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #include +#include + +struct pa_context { + int refcount; + pa_context_notify_cb_t cb; + void *cbdata; + pa_context_state_t state; +}; -pa_glib_mainloop* +pa_glib_mainloop * pa_glib_mainloop_new(GMainContext *c) { - printf("This is reached\n", c); return NULL; } +pa_context * +pa_context_new(pa_mainloop_api *loop, char const *name) { + struct pa_context * result = g_new(pa_context, 1); + result->refcount = 1; + return result; +} +void +pa_context_unref(pa_context * context) { + context->refcount--; + if (!context->refcount) + g_free(context); +} + +void +pa_context_set_state_callback(pa_context *c, pa_context_notify_cb_t cb, void *userdata) +{ + c->cb = cb; + c->cbdata = userdata; +} + +void set_pa_context_get_state_result(pa_context *c, pa_context_state_t state) +{ + c->state = state; +} + +pa_context_state_t +pa_context_get_state(pa_context *c) +{ + return c->state; +} -- cgit v1.2.3 From 69049dd2d6011e9ab96f4f439d00e1de98178449 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Tue, 9 Mar 2010 14:37:03 +1100 Subject: Fleshed out mocking needs missing symbols from the service linked in to work now. --- tests/mockpulse.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/mockpulse.c') diff --git a/tests/mockpulse.c b/tests/mockpulse.c index eec2c03..a41de30 100644 --- a/tests/mockpulse.c +++ b/tests/mockpulse.c @@ -20,6 +20,9 @@ with this program. If not, see . #include #include +#include +#include +#include "mockpulse.h" struct pa_context { int refcount; @@ -65,3 +68,32 @@ pa_context_get_state(pa_context *c) { return c->state; } + +struct pa_operation { + int refcount; +}; + +/* Can be made into a list if we need multiple callbacks */ +static pa_sink_info *next_sink_info; + +void +set_pa_context_get_sink_info(pa_sink_info *info) { + next_sink_info = info; +} + +pa_operation * +pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_sink_info_cb_t cb, void * userdata) +{ + pa_operation *result = g_new(pa_operation, 1); + result->refcount = 1; + cb(c, next_sink_info, 0, userdata); + return result; +} + +void +pa_operation_unref(pa_operation * foo) +{ + foo->refcount--; + if (!foo->refcount) + g_free(foo); +} -- cgit v1.2.3 From f02377f77f88106ba1c26cb184a14f33cd1a89fe Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 22 Mar 2010 17:32:57 +0000 Subject: first pulse manager test wrote ... finally --- tests/mockpulse.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/mockpulse.c') diff --git a/tests/mockpulse.c b/tests/mockpulse.c index a41de30..b868e07 100644 --- a/tests/mockpulse.c +++ b/tests/mockpulse.c @@ -73,6 +73,12 @@ struct pa_operation { int refcount; }; + +/*void pa_context_connect(pa_context* c, const char *server, pa_context_flags_t flags, const pa_spawn_api *api)*/ +/*{*/ +/* set_pa_context_get_state_result(c, PA_CONTEXT_CONNECTING);*/ +/*}*/ + /* Can be made into a list if we need multiple callbacks */ static pa_sink_info *next_sink_info; -- cgit v1.2.3