aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2010-03-09 14:37:03 +1100
committerRobert Collins <robertc@robertcollins.net>2010-03-09 14:37:03 +1100
commit69049dd2d6011e9ab96f4f439d00e1de98178449 (patch)
tree07ad629ac1da1d36af68c59afa90966cad0908ce /tests
parent6c2b978f17d48fe212cccb15c23bb1e278ba600f (diff)
downloadayatana-indicator-sound-69049dd2d6011e9ab96f4f439d00e1de98178449.tar.gz
ayatana-indicator-sound-69049dd2d6011e9ab96f4f439d00e1de98178449.tar.bz2
ayatana-indicator-sound-69049dd2d6011e9ab96f4f439d00e1de98178449.zip
Fleshed out mocking needs missing symbols from the service linked in to work now.
Diffstat (limited to 'tests')
-rw-r--r--tests/mockpulse.c32
-rw-r--r--tests/mockpulse.h1
-rw-r--r--tests/test-pulse-manager.c29
3 files changed, 53 insertions, 9 deletions
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 <http://www.gnu.org/licenses/>.
#include <pulse/glib-mainloop.h>
#include <pulse/context.h>
+#include <pulse/operation.h>
+#include <pulse/introspect.h>
+#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);
+}
diff --git a/tests/mockpulse.h b/tests/mockpulse.h
index 327121a..71cd85b 100644
--- a/tests/mockpulse.h
+++ b/tests/mockpulse.h
@@ -23,3 +23,4 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <pulse/glib-mainloop.h>
void set_pa_context_get_state_result(pa_context *, pa_context_state_t state);
+void set_pa_context_get_sink_info(pa_sink_info *info);
diff --git a/tests/test-pulse-manager.c b/tests/test-pulse-manager.c
index f4f7ffc..169acbd 100644
--- a/tests/test-pulse-manager.c
+++ b/tests/test-pulse-manager.c
@@ -40,20 +40,31 @@ static void test_pa_context_exit()
static void test_sink_insert()
{
- sink_info *value;
+ sink_info *sink_details;
pa_context* context = pa_context_new(NULL, "foo");
- value = g_new0(sink_info, 1);
- value->index = 8;
- value->name = "mock_sink";
- value->description = "mock description";
- value->mute = FALSE;
+ sink_details = g_new0(sink_info, 1);
+ sink_details->index = 8;
+ sink_details->name = "mock_sink";
+ sink_details->description = "mock description";
+ sink_details->mute = FALSE;
pa_cvolume volume; // nearly full volume:
pa_cvolume_set(&volume, 1, 30000);
- value->volume = volume;
+ sink_details->volume = volume;
+ pa_sink_info *expected = g_new0(pa_sink_info, 1);
+ expected->name = g_strdup("foo");
+ expected->index = 8;
+ expected->description = g_strdup("more details");
+ // fill it out here more.
+ // hook into our pa_context_get_sink_info_by_index to pass exppected to
+ // update_sink_info
+ set_pa_context_get_sink_info(expected);
// update_sink_info is a static method in pulse-manager.c ?
- pa_context_get_sink_info_by_index(context, value->index, update_sink_info, NULL);
- // the mockinkg lib should then return this mocked up sink_info to the method update_sink_info which tests could be wrote against to make sure everthing is populated correctly.
+ pa_context_get_sink_info_by_index(context, sink_details->index, update_sink_info, NULL);
+ // the mockinkg lib should then return this mocked up sink_info to the
+ // method update_sink_info which tests could be wrote against to make sure
+ // everthing is populated correctly.
pa_context_unref(context);
+ g_free(expected);
}