Fix a typo in the signal declaration
[hildon] / tests / check-hildon-system-sound.c
1 /*
2  * This file is a part of hildon tests
3  *
4  * Copyright (C) 2006, 2007 Nokia Corporation, all rights reserved.
5  *
6  * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
7  *
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.
12  *
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.
17  *
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
21  * 02110-1301 USA
22  *
23  */
24
25 #include <stdlib.h>
26 #include <check.h>
27 #include <gtk/gtkmain.h>
28 #include <gconf/gconf-client.h>
29 #include "test_suites.h"
30 #include <hildon/hildon-system-sound.h>
31
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"
35
36 /* -------------------- Fixtures -------------------- */
37
38 static void
39 fx_setup_default_defines ()
40 {
41   int argc = 0;
42
43   gtk_init(&argc, NULL);
44 }
45
46 static void
47 fx_teardown_default_defines ()
48 {
49 }
50 /* -------------------- Test cases -------------------- */
51
52 /* ----- Test case for hildon_play_system_sound -----*/
53
54 /**
55  * Purpose: test playing a system sound
56  * Cases considered:
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
61  */
62 START_TEST (test_hildon_play_system_sound_regular)
63 {
64   GConfClient *client = NULL;
65   GError *error = NULL;
66
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");
71
72   /* Play a system sound */
73   hildon_play_system_sound (DEFAULT_BEEP);
74
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);
78
79   /* Set the volume to 1 */
80   gconf_client_set_int (client, ALARM_GCONF_PATH, 1, &error);
81   hildon_play_system_sound (DEFAULT_BEEP);
82
83   /* Unset the value of the key */
84   gconf_client_unset (client, ALARM_GCONF_PATH, &error);
85   hildon_play_system_sound (DEFAULT_BEEP);
86 }
87 END_TEST
88
89 /**
90  * Purpose: test playing a sound with invalid parameters
91  * Cases considered:
92  *    - Play a NULL path
93  *    - Play a file that does not exist
94  */
95 START_TEST (test_hildon_play_system_sound_invalid)
96 {
97   GConfClient *client = NULL;
98
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");
103
104   /* Test 1 */
105   hildon_play_system_sound (NULL);
106
107   /* Test 2 */
108   hildon_play_system_sound ("file_that_does_not_exist.wav");
109 }
110 END_TEST
111
112 /* ---------- Suite creation ---------- */
113
114 Suite *create_hildon_system_sound_suite()
115 {
116   /* Create the suite */
117   Suite *s = suite_create("HildonSystemSound");
118
119   /* Create test cases and add them to the suite */
120   TCase *tc1 = tcase_create("hildon_play_system_sound");
121
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);
126
127   /* Return created suite */
128   return s;
129 }