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 "test_suites.h"
27 #include "check_utils.h"
28 #include "hildon-banner.h"
29 #include "hildon-window.h"
31 /* -------------------- Fixtures -------------------- */
33 static GtkWidget * b_window = NULL;
36 fx_setup_default_banner ()
39 gtk_init(&argc, NULL);
41 b_window = create_test_window();
43 /* Check window object has been created properly */
44 fail_if(!HILDON_IS_WINDOW(b_window),
45 "hildon-banner: Window creation failed.");
51 fx_teardown_default_banner ()
54 gtk_widget_destroy(b_window);
58 /* -------------------- Test cases -------------------- */
60 /* ----- Test case for show_animation -----*/
63 * Purpose: Check creation of new animation banner with regular values
65 * - Create an animation banner with NULL animation name and TEST_STRING text.
66 * - Create an animation banner with qgn_list_mahjong animation name and "" text.
68 START_TEST (test_show_animation_regular)
70 gchar * animation_name=NULL;
73 HildonBanner * hildon_banner = NULL;
76 /*Test 1: Create an animation banner with NULL animation name. */
78 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(b_window,NULL,text));
80 fail_if(!HILDON_IS_BANNER(hildon_banner),
81 "hildon-banner: hildon_banner_show_animation failed creating banner.");
83 hildon_banner_set_text(hildon_banner,text);
85 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
87 /*Test 2: Create an animation banner with animation name set to "qgn_list_mahjong" and text set to "". */
89 animation_name = "qgn_list_mahjong";
90 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(b_window,animation_name,text));
92 fail_if(!HILDON_IS_BANNER(hildon_banner),
93 "hildon-banner: hildon_banner_show_animation failed creating banner.");
95 hildon_banner_set_text(hildon_banner,text);
96 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
102 * Purpose: Check creation of new animation banner with invalid values
104 * - Create an animation banner with NULL text.
105 * - Create an animation banner with NULL window.
107 START_TEST (test_show_animation_invalid)
109 gchar * animation_name=NULL;
112 HildonBanner * hildon_banner = NULL;
114 /*Test 1: Create an animation banner with NULL text. */
116 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(b_window,NULL,NULL));
118 fail_if(HILDON_IS_BANNER(hildon_banner),
119 "hildon-banner: hildon_banner_show_animation failed creating banner.");
121 hildon_banner = NULL;
123 /*Test 2: Create an animation banner with NULL window. */
125 animation_name = "qgn_list_mahjong";
126 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(NULL,animation_name,text));
128 fail_if(!HILDON_IS_BANNER(hildon_banner),
129 "hildon-banner: hildon_banner_show_animation failed creating banner.");
131 hildon_banner_set_text(hildon_banner,text);
132 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
137 /* ----- Test case for show_progress -----*/
139 * Purpose: Check creation of new banner with progress bar with regular values.
141 * - Create new progress banner with standard progress bar and "" as text.
142 * - Create new progress banner with NULL progress bar and TEST_STRING as text.
144 START_TEST (test_show_progress_regular)
148 GtkProgressBar * progress_bar = NULL;
149 HildonBanner * hildon_banner = NULL;
151 progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new());
153 /*Test 1: Create progress banner with TEST_STRING as text and basic progress_bar. */
155 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,progress_bar,text));
157 fail_if(!HILDON_IS_BANNER(hildon_banner),
158 "hildon-banner: hildon_banner_show_progress failed creating banner.");
160 hildon_banner_set_text(hildon_banner,text);
161 hildon_banner_set_fraction(hildon_banner,0.5);
162 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
164 hildon_banner = NULL;
166 /*Test 2: Create progress banner with "" as text and NULL progress_bar. */
168 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,NULL,text));
170 fail_if(!HILDON_IS_BANNER(hildon_banner),
171 "hildon-banner: hildon_banner_show_progress failed creating banner.");
173 hildon_banner_set_text(hildon_banner,text);
174 hildon_banner_set_fraction(hildon_banner,0.2);
175 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
181 * Purpose: Check creation of new banner with progress bar with invalid values
183 * - Create new progress banner with NULL text.
184 * - Create new progress banner with NULL window.
186 START_TEST (test_show_progress_invalid)
190 GtkProgressBar * progress_bar = NULL;
191 HildonBanner * hildon_banner = NULL;
193 progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new());
194 /*Test 1: Create progress banner with TEST_STRING as text and basic progress_bar. */
196 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,progress_bar,NULL));
198 /* NULL text avoid create correct banner. */
199 fail_if(HILDON_IS_BANNER(hildon_banner),
200 "hildon-banner: hildon_banner_show_progress failed creating banner.");
202 /*Test 2: Create progress banner with TEST_STRING as text, NULL progress_bar and NULL window */
204 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(NULL,NULL,text));
206 fail_if(!HILDON_IS_BANNER(hildon_banner),
207 "hildon-banner: hildon_banner_show_progress failed creating banner.");
209 hildon_banner_set_text(hildon_banner,text);
210 hildon_banner_set_fraction(hildon_banner,0.2);
212 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
218 /* ---------- Suite creation ---------- */
219 Suite *create_hildon_banner_suite()
221 /* Create the suite */
222 Suite *s = suite_create("HildonBanner");
224 /* Create test cases */
225 TCase *tc1 = tcase_create("show_animation");
226 TCase *tc2 = tcase_create("show_animation");
228 /* Create unit tests for hildon_banner_show_animation and add it to the suite */
229 tcase_add_checked_fixture(tc1, fx_setup_default_banner, fx_teardown_default_banner);
230 tcase_add_test(tc1, test_show_animation_regular);
231 tcase_add_test(tc1, test_show_animation_invalid);
232 suite_add_tcase (s, tc1);
234 /* Create unit tests for hildon_banner_show_animation and add it to the suite */
235 tcase_add_checked_fixture(tc2, fx_setup_default_banner, fx_teardown_default_banner);
236 tcase_add_test(tc2, test_show_progress_regular);
237 tcase_add_test(tc2, test_show_progress_invalid);
238 suite_add_tcase (s, tc2);
242 /* Return created suite */