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 "test_suites.h"
29 #include "check_utils.h"
30 #include "hildon-banner.h"
31 #include "hildon-window.h"
33 /* -------------------- Fixtures -------------------- */
35 static GtkWidget * b_window = NULL;
38 fx_setup_default_banner ()
41 gtk_init(&argc, NULL);
43 b_window = create_test_window();
45 /* Check window object has been created properly */
46 fail_if(!HILDON_IS_WINDOW(b_window),
47 "hildon-banner: Window creation failed.");
53 fx_teardown_default_banner ()
56 gtk_widget_destroy(b_window);
60 /* -------------------- Test cases -------------------- */
62 /* ----- Test case for show_animation -----*/
65 * Purpose: Check creation of new animation banner with regular values
67 * - Create an animation banner with NULL animation name and TEST_STRING text.
68 * - Create an animation banner with qgn_list_mahjong animation name and "" text.
70 START_TEST (test_show_animation_regular)
72 gchar * animation_name=NULL;
75 HildonBanner * hildon_banner = NULL;
78 /*Test 1: Create an animation banner with NULL animation name. */
80 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(b_window,NULL,text));
82 fail_if(!HILDON_IS_BANNER(hildon_banner),
83 "hildon-banner: hildon_banner_show_animation failed creating banner.");
85 hildon_banner_set_text(hildon_banner,text);
87 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
89 /*Test 2: Create an animation banner with animation name set to "qgn_list_mahjong" and text set to "". */
91 animation_name = "qgn_list_mahjong";
92 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(b_window,animation_name,text));
94 fail_if(!HILDON_IS_BANNER(hildon_banner),
95 "hildon-banner: hildon_banner_show_animation failed creating banner.");
97 hildon_banner_set_text(hildon_banner,text);
98 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
104 * Purpose: Check creation of new animation banner with invalid values
106 * - Create an animation banner with NULL text.
107 * - Create an animation banner with NULL window.
109 START_TEST (test_show_animation_invalid)
111 gchar * animation_name=NULL;
114 HildonBanner * hildon_banner = NULL;
116 /*Test 1: Create an animation banner with NULL text. */
118 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(b_window,NULL,NULL));
120 fail_if(HILDON_IS_BANNER(hildon_banner),
121 "hildon-banner: hildon_banner_show_animation failed creating banner.");
123 hildon_banner = NULL;
125 /*Test 2: Create an animation banner with NULL window. */
127 animation_name = "qgn_list_mahjong";
128 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(NULL,animation_name,text));
130 fail_if(!HILDON_IS_BANNER(hildon_banner),
131 "hildon-banner: hildon_banner_show_animation failed creating banner.");
133 hildon_banner_set_text(hildon_banner,text);
134 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
139 /* ----- Test case for show_progress -----*/
141 * Purpose: Check creation of new banner with progress bar with regular values.
143 * - Create new progress banner with standard progress bar and "" as text.
144 * - Create new progress banner with NULL progress bar and TEST_STRING as text.
146 START_TEST (test_show_progress_regular)
150 GtkProgressBar * progress_bar = NULL;
151 HildonBanner * hildon_banner = NULL;
153 progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new());
155 /*Test 1: Create progress banner with TEST_STRING as text and basic progress_bar. */
157 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,progress_bar,text));
159 fail_if(!HILDON_IS_BANNER(hildon_banner),
160 "hildon-banner: hildon_banner_show_progress failed creating banner.");
162 hildon_banner_set_text(hildon_banner,text);
163 hildon_banner_set_fraction(hildon_banner,0.5);
164 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
166 hildon_banner = NULL;
168 /*Test 2: Create progress banner with "" as text and NULL progress_bar. */
170 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,NULL,text));
172 fail_if(!HILDON_IS_BANNER(hildon_banner),
173 "hildon-banner: hildon_banner_show_progress failed creating banner.");
175 hildon_banner_set_text(hildon_banner,text);
176 hildon_banner_set_fraction(hildon_banner,0.2);
177 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
183 * Purpose: Check creation of new banner with progress bar with invalid values
185 * - Create new progress banner with NULL text.
186 * - Create new progress banner with NULL window.
188 START_TEST (test_show_progress_invalid)
192 GtkProgressBar * progress_bar = NULL;
193 HildonBanner * hildon_banner = NULL;
195 progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new());
196 /*Test 1: Create progress banner with TEST_STRING as text and basic progress_bar. */
198 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,progress_bar,NULL));
200 /* NULL text avoid create correct banner. */
201 fail_if(HILDON_IS_BANNER(hildon_banner),
202 "hildon-banner: hildon_banner_show_progress failed creating banner.");
204 /*Test 2: Create progress banner with TEST_STRING as text, NULL progress_bar and NULL window */
206 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(NULL,NULL,text));
208 fail_if(!HILDON_IS_BANNER(hildon_banner),
209 "hildon-banner: hildon_banner_show_progress failed creating banner.");
211 hildon_banner_set_text(hildon_banner,text);
212 hildon_banner_set_fraction(hildon_banner,0.2);
214 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
220 /* ---------- Suite creation ---------- */
221 Suite *create_hildon_banner_suite()
223 /* Create the suite */
224 Suite *s = suite_create("HildonBanner");
226 /* Create test cases */
227 TCase *tc1 = tcase_create("show_animation");
228 TCase *tc2 = tcase_create("show_animation");
230 /* Create unit tests for hildon_banner_show_animation and add it to the suite */
231 tcase_add_checked_fixture(tc1, fx_setup_default_banner, fx_teardown_default_banner);
232 tcase_add_test(tc1, test_show_animation_regular);
233 tcase_add_test(tc1, test_show_animation_invalid);
234 suite_add_tcase (s, tc1);
236 /* Create unit tests for hildon_banner_show_animation and add it to the suite */
237 tcase_add_checked_fixture(tc2, fx_setup_default_banner, fx_teardown_default_banner);
238 tcase_add_test(tc2, test_show_progress_regular);
239 tcase_add_test(tc2, test_show_progress_invalid);
240 suite_add_tcase (s, tc2);
244 /* Return created suite */