2 * This file is a part of hildon tests
4 * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved.
6 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 #include <gtk/gtkmain.h>
28 #include <gconf/gconf-client.h>
29 #include "test_suites.h"
30 #include "hildon-system-sound.h"
32 /* This define was copied from the hildon-system-sound.c */
33 #define ALARM_GCONF_PATH "/apps/osso/sound/system_alert_volume"
34 #define DEFAULT_BEEP "/usr/share/sounds/ui-default_beep.wav"
36 /* -------------------- Fixtures -------------------- */
39 fx_setup_default_defines ()
43 gtk_init(&argc, NULL);
47 fx_teardown_default_defines ()
50 /* -------------------- Test cases -------------------- */
52 /* ----- Test case for hildon_play_system_sound -----*/
55 * Purpose: test playing a system sound
57 * - Play /usr/share/sounds/ui-default_beep.wav with default volume
58 * - Play /usr/share/sounds/ui-default_beep.wav with volume = 0
59 * - Play /usr/share/sounds/ui-default_beep.wav with volume = 1
60 * - Play /usr/share/sounds/ui-default_beep.wav with the value given by gconf
62 START_TEST (test_hildon_play_system_sound_regular)
64 GConfClient *client = NULL;
67 /* Get a gconf client */
68 client = gconf_client_get_default();
69 fail_if (client == NULL,
70 "hildon-system-sound: Could not get a GConf client");
72 /* Play a system sound */
73 hildon_play_system_sound (DEFAULT_BEEP);
75 /* Mute the volume and then play */
76 gconf_client_set_int (client, ALARM_GCONF_PATH, 0, &error);
77 hildon_play_system_sound (DEFAULT_BEEP);
79 /* Set the volume to 1 */
80 gconf_client_set_int (client, ALARM_GCONF_PATH, 1, &error);
81 hildon_play_system_sound (DEFAULT_BEEP);
83 /* Unset the value of the key */
84 gconf_client_unset (client, ALARM_GCONF_PATH, &error);
85 hildon_play_system_sound (DEFAULT_BEEP);
90 * Purpose: test playing a sound with invalid parameters
93 * - Play a file that does not exist
95 START_TEST (test_hildon_play_system_sound_invalid)
97 GConfClient *client = NULL;
99 /* Get a gconf client */
100 client = gconf_client_get_default();
101 fail_if (client == NULL,
102 "hildon-system-sound: Could not get a GConf client");
105 hildon_play_system_sound (NULL);
108 hildon_play_system_sound ("file_that_does_not_exist.wav");
112 /* ---------- Suite creation ---------- */
114 Suite *create_hildon_system_sound_suite()
116 /* Create the suite */
117 Suite *s = suite_create("HildonSystemSound");
119 /* Create test cases and add them to the suite */
120 TCase *tc1 = tcase_create("hildon_play_system_sound");
122 tcase_add_checked_fixture(tc1, fx_setup_default_defines, fx_teardown_default_defines);
123 tcase_add_test(tc1, test_hildon_play_system_sound_regular);
124 tcase_add_test(tc1, test_hildon_play_system_sound_invalid);
125 suite_add_tcase (s, tc1);
127 /* Return created suite */