2 * Copyright (C) 2006 Nokia Corporation.
4 * Contact: Luc Pionchon <luc.pionchon@nokia.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 #include <gtk/gtkmain.h>
26 #include <gconf/gconf-client.h>
27 #include "test_suites.h"
28 #include "hildon-system-sound.h"
30 /* This define was copied from the hildon-system-sound.c */
31 #define ALARM_GCONF_PATH "/apps/osso/sound/system_alert_volume"
32 #define DEFAULT_BEEP "/usr/share/sounds/ui-default_beep.wav"
34 /* -------------------- Fixtures -------------------- */
37 fx_setup_default_defines ()
41 gtk_init(&argc, NULL);
45 fx_teardown_default_defines ()
48 /* -------------------- Test cases -------------------- */
50 /* ----- Test case for hildon_play_system_sound -----*/
53 * Purpose: test playing a system sound
55 * - Play /usr/share/sounds/ui-default_beep.wav with default volume
56 * - Play /usr/share/sounds/ui-default_beep.wav with volume = 0
57 * - Play /usr/share/sounds/ui-default_beep.wav with volume = 1
58 * - Play /usr/share/sounds/ui-default_beep.wav with the value given by gconf
60 START_TEST (test_hildon_play_system_sound_regular)
62 GConfClient *client = NULL;
65 /* Get a gconf client */
66 client = gconf_client_get_default();
67 fail_if (client == NULL,
68 "hildon-system-sound: Could not get a GConf client");
70 /* Play a system sound */
71 hildon_play_system_sound (DEFAULT_BEEP);
73 /* Mute the volume and then play */
74 gconf_client_set_int (client, ALARM_GCONF_PATH, 0, &error);
75 hildon_play_system_sound (DEFAULT_BEEP);
77 /* Set the volume to 1 */
78 gconf_client_set_int (client, ALARM_GCONF_PATH, 1, &error);
79 hildon_play_system_sound (DEFAULT_BEEP);
81 /* Unset the value of the key */
82 gconf_client_unset (client, ALARM_GCONF_PATH, &error);
83 hildon_play_system_sound (DEFAULT_BEEP);
88 * Purpose: test playing a sound with invalid parameters
91 * - Play a file that does not exist
93 START_TEST (test_hildon_play_system_sound_invalid)
95 GConfClient *client = NULL;
97 /* Get a gconf client */
98 client = gconf_client_get_default();
99 fail_if (client == NULL,
100 "hildon-system-sound: Could not get a GConf client");
103 hildon_play_system_sound (NULL);
106 hildon_play_system_sound ("file_that_does_not_exist.wav");
110 /* ---------- Suite creation ---------- */
112 Suite *create_hildon_system_sound_suite()
114 /* Create the suite */
115 Suite *s = suite_create("HildonSystemSound");
117 /* Create test cases and add them to the suite */
118 TCase *tc1 = tcase_create("hildon_play_system_sound");
120 tcase_add_checked_fixture(tc1, fx_setup_default_defines, fx_teardown_default_defines);
121 tcase_add_test(tc1, test_hildon_play_system_sound_regular);
122 tcase_add_test(tc1, test_hildon_play_system_sound_invalid);
123 suite_add_tcase (s, tc1);
125 /* Return created suite */