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
24 #ifndef HILDON_DISABLE_DEPRECATED
28 #include <gtk/gtkmain.h>
29 #include "test_suites.h"
30 #include "check_utils.h"
31 #include <hildon/hildon-banner.h>
32 #include <hildon/hildon-window.h>
34 /* -------------------- Fixtures -------------------- */
36 static GtkWidget * b_window = NULL;
39 fx_setup_default_banner ()
42 gtk_init(&argc, NULL);
44 b_window = create_test_window();
46 /* Check window object has been created properly */
47 fail_if(!HILDON_IS_WINDOW(b_window),
48 "hildon-banner: Window creation failed.");
54 fx_teardown_default_banner ()
57 gtk_widget_destroy(b_window);
61 /* -------------------- Test cases -------------------- */
63 /* ----- Test case for show_animation -----*/
66 * Purpose: Check creation of new animation banner with regular values
68 * - Create an animation banner with NULL animation name and TEST_STRING text.
69 * - Create an animation banner with dummy animation name and "" text.
71 START_TEST (test_show_animation_regular)
73 gchar * animation_name=NULL;
76 HildonBanner * hildon_banner = NULL;
79 /*Test 1: Create an animation banner with NULL animation name. */
81 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(b_window,NULL,text));
83 fail_if(!HILDON_IS_BANNER(hildon_banner),
84 "hildon-banner: hildon_banner_show_animation failed creating banner.");
86 hildon_banner_set_text(hildon_banner,text);
88 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
90 /*Test 2: Create an animation banner with animation name set to "dummy" and text set to "". */
92 animation_name = "dummy";
93 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(b_window,animation_name,text));
95 fail_if(!HILDON_IS_BANNER(hildon_banner),
96 "hildon-banner: hildon_banner_show_animation failed creating banner.");
98 hildon_banner_set_text(hildon_banner,text);
99 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
105 * Purpose: Check creation of new animation banner with invalid values
107 * - Create an animation banner with NULL text.
108 * - Create an animation banner with NULL window.
110 START_TEST (test_show_animation_invalid)
112 gchar * animation_name=NULL;
115 HildonBanner * hildon_banner = NULL;
117 /*Test 1: Create an animation banner with NULL text. */
119 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(b_window,NULL,NULL));
121 fail_if(HILDON_IS_BANNER(hildon_banner),
122 "hildon-banner: hildon_banner_show_animation failed creating banner.");
124 hildon_banner = NULL;
126 /*Test 2: Create an animation banner with NULL window. */
128 animation_name = "dummy";
129 hildon_banner = HILDON_BANNER(hildon_banner_show_animation(NULL,animation_name,text));
131 fail_if(!HILDON_IS_BANNER(hildon_banner),
132 "hildon-banner: hildon_banner_show_animation failed creating banner.");
134 hildon_banner_set_text(hildon_banner,text);
135 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
140 /* ----- Test case for show_progress -----*/
142 * Purpose: Check creation of new banner with progress bar with regular values.
144 * - Create new progress banner with standard progress bar and "" as text.
145 * - Create new progress banner with NULL progress bar and TEST_STRING as text.
147 START_TEST (test_show_progress_regular)
151 GtkProgressBar * progress_bar = NULL;
152 HildonBanner * hildon_banner = NULL;
154 progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new());
156 /*Test 1: Create progress banner with TEST_STRING as text and basic progress_bar. */
158 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,progress_bar,text));
160 fail_if(!HILDON_IS_BANNER(hildon_banner),
161 "hildon-banner: hildon_banner_show_progress failed creating banner.");
163 hildon_banner_set_text(hildon_banner,text);
164 hildon_banner_set_fraction(hildon_banner,0.5);
165 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
167 hildon_banner = NULL;
169 /*Test 2: Create progress banner with "" as text and NULL progress_bar. */
171 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,NULL,text));
173 fail_if(!HILDON_IS_BANNER(hildon_banner),
174 "hildon-banner: hildon_banner_show_progress failed creating banner.");
176 hildon_banner_set_text(hildon_banner,text);
177 hildon_banner_set_fraction(hildon_banner,0.2);
178 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
184 * Purpose: Check creation of new banner with progress bar with invalid values
186 * - Create new progress banner with NULL text.
187 * - Create new progress banner with NULL window.
189 START_TEST (test_show_progress_invalid)
193 GtkProgressBar * progress_bar = NULL;
194 HildonBanner * hildon_banner = NULL;
196 progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new());
197 /*Test 1: Create progress banner with TEST_STRING as text and basic progress_bar. */
199 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,progress_bar,NULL));
201 /* NULL text avoid create correct banner. */
202 fail_if(HILDON_IS_BANNER(hildon_banner),
203 "hildon-banner: hildon_banner_show_progress failed creating banner.");
205 /*Test 2: Create progress banner with TEST_STRING as text, NULL progress_bar and NULL window */
207 hildon_banner = HILDON_BANNER(hildon_banner_show_progress(NULL,NULL,text));
209 fail_if(!HILDON_IS_BANNER(hildon_banner),
210 "hildon-banner: hildon_banner_show_progress failed creating banner.");
212 hildon_banner_set_text(hildon_banner,text);
213 hildon_banner_set_fraction(hildon_banner,0.2);
215 gtk_widget_destroy(GTK_WIDGET(hildon_banner));
219 /* ---------- Suite creation ---------- */
220 Suite *create_hildon_banner_suite()
222 /* Create the suite */
223 Suite *s = suite_create("HildonBanner");
225 /* Create test cases */
226 TCase *tc1 = tcase_create("show_animation");
227 TCase *tc2 = tcase_create("show_progress");
229 /* Create unit tests for hildon_banner_show_animation and add it to the suite */
230 tcase_add_checked_fixture(tc1, fx_setup_default_banner, fx_teardown_default_banner);
231 tcase_add_test(tc1, test_show_animation_regular);
232 tcase_add_test(tc1, test_show_animation_invalid);
233 suite_add_tcase (s, tc1);
235 /* Create unit tests for hildon_banner_show_animation and add it to the suite */
236 tcase_add_checked_fixture(tc2, fx_setup_default_banner, fx_teardown_default_banner);
237 tcase_add_test(tc2, test_show_progress_regular);
238 tcase_add_test(tc2, test_show_progress_invalid);
239 suite_add_tcase (s, tc2);
243 /* Return created suite */