diff options
author | charles kerr <charlesk@canonical.com> | 2016-01-01 15:58:55 -0600 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-08-28 10:17:14 +0200 |
commit | a8fd3f49bf6509bd4545aec3292d2fc022d847ca (patch) | |
tree | 303f33fab30a4dea88d8f096b9a4369a0d3bf565 /src/main.c | |
parent | 2b939453598cc1fd8f1c40e5d6cbfd63cb852fb4 (diff) | |
download | ayatana-indicator-power-a8fd3f49bf6509bd4545aec3292d2fc022d847ca.tar.gz ayatana-indicator-power-a8fd3f49bf6509bd4545aec3292d2fc022d847ca.tar.bz2 ayatana-indicator-power-a8fd3f49bf6509bd4545aec3292d2fc022d847ca.zip |
make a SoundPlayer interface so we can mock it in the tests
this requires an annoying amount of scaffolding:
1. implement gst and mock classes to implement the SoundPlayer interface
2. modify notifier to take a SoundPlayer argument in its ctor
3. modify service to take a Notifier argument in its ctor instead of instantiating it on its own
4. change main to update the startup steps for player/notifier/service
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -23,7 +23,9 @@ #include <glib/gi18n.h> #include "device.h" +#include "notifier.h" #include "service.h" +#include "sound-player-gst.h" #include "testing.h" /*** @@ -40,6 +42,8 @@ on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop) int main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED) { + IndicatorPowerSoundPlayer * sound_player; + IndicatorPowerNotifier * notifier; IndicatorPowerService * service; IndicatorPowerTesting * testing; GMainLoop * loop; @@ -50,7 +54,9 @@ main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED) textdomain (GETTEXT_PACKAGE); /* run */ - service = indicator_power_service_new (NULL); + sound_player = indicator_power_sound_player_gst_new (); + notifier = indicator_power_notifier_new (sound_player); + service = indicator_power_service_new(NULL, notifier); testing = indicator_power_testing_new (service); loop = g_main_loop_new (NULL, FALSE); g_signal_connect (service, INDICATOR_POWER_SERVICE_SIGNAL_NAME_LOST, @@ -59,7 +65,9 @@ main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED) /* cleanup */ g_main_loop_unref (loop); - g_clear_object (&service); g_clear_object (&testing); + g_clear_object (&service); + g_clear_object (¬ifier); + g_clear_object (&sound_player); return 0; } |