7ef07544bfb0f0ad7832b89c68be0f1657e2b670
[hildon] / tests / check-hildon-note.c
1 /*
2  * Copyright (C) 2006 Nokia Corporation.
3  *
4  * Contact: Luc Pionchon <luc.pionchon@nokia.com>
5  *
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.
10  *
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.
15  *
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
19  * 02110-1301 USA
20  *
21  */
22
23 #include <stdlib.h>
24 #include <string.h>
25 #include <check.h>
26 #include <gtk/gtkmain.h>
27 #include "test_suites.h"
28 #include "hildon-window.h"
29 #include "hildon-note.h"
30
31 /* -------------------- Fixtures -------------------- */
32
33 static HildonNote *note = NULL;
34 static GtkWindow * n_window = NULL;
35
36 static void 
37 fx_setup_default_note ()
38 {
39   int argc = 0;
40
41   gtk_init(&argc, NULL);
42
43   n_window = GTK_WINDOW(hildon_window_new());
44  /* Check window object has been created properly */
45   fail_if(!HILDON_IS_WINDOW(n_window),
46           "hildon-note: Window creation failed.");
47 }
48
49 static void 
50 fx_teardown_default_note ()
51 {
52     gtk_widget_destroy (GTK_WIDGET (n_window));
53 }
54
55 /* -------------------- Test cases -------------------- */
56
57 /* ----- Test case for new_confirmation -----*/
58 /**
59  * Purpose: Check that note dialog is properly created with description regular values. 
60  * Cases considered:
61  *    - Create new confirmation note with description set to TEST_STRING
62  *    - Create new confirmation note with description set to "".
63  *
64  */
65 START_TEST (test_new_confirmation_regular)
66 {
67   const gchar * description = NULL;
68   const gchar * ret_description = NULL;
69   GValue value={0, };
70   GValue enum_value={0, };
71   HildonNoteType note_type;
72
73   g_value_init (&value, G_TYPE_STRING);
74   g_value_init (&enum_value, G_TYPE_INT);
75
76   /* Test 1: create new confirmation note with description set to TEST_STRING */
77   description = TEST_STRING;
78   note = HILDON_NOTE(hildon_note_new_confirmation(n_window,description));
79   fail_if(!HILDON_IS_NOTE(note),
80           "hildon-note: Creation failed with hildon_note_new_confirmation");
81
82   g_object_get_property(G_OBJECT (note),"description",&value);
83   ret_description = g_value_get_string (&value);
84   fail_if( strcmp (description,ret_description) != 0,
85            "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
86            description,ret_description);
87     
88   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
89   note_type = g_value_get_int(&enum_value);
90   fail_if( note_type != HILDON_NOTE_CONFIRMATION_TYPE,
91            "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
92
93   gtk_widget_destroy (GTK_WIDGET (note));
94   note=NULL;
95
96   /* Test 2: create new confirmation note with description set to "" */
97   description = "";
98   note = HILDON_NOTE(hildon_note_new_confirmation(n_window,description));
99   fail_if(!HILDON_IS_NOTE(note),
100           "hildon-note: Creation failed with hildon_note_new_confirmation");
101
102   g_object_get_property(G_OBJECT (note),"description",&value);
103   ret_description = g_value_get_string (&value);
104   fail_if( strcmp (description,ret_description) != 0,
105            "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
106            description,ret_description);
107
108   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
109   note_type = g_value_get_int(&enum_value);
110   fail_unless( note_type == HILDON_NOTE_CONFIRMATION_TYPE,
111                "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
112
113   gtk_widget_destroy (GTK_WIDGET (note));
114   note=NULL;
115
116
117   g_value_unset(&value);
118   g_value_unset(&enum_value);    
119 }
120 END_TEST
121
122 /**
123  * Purpose: Check that note dialog is properly created with description invalid values. 
124  * Cases considered:
125  *    - Create new confirmation note with window set to NULL.
126  *    - Create new confirmation note with description set to "NULL".
127  *
128  */
129 START_TEST (test_new_confirmation_invalid)
130 {
131   const gchar * ret_description = NULL;
132   GValue value={0, };
133   GValue enum_value={0, };
134   HildonNoteType note_type;
135   HildonNote * invalid_note;
136    
137   g_value_init (&value, G_TYPE_STRING);
138   g_value_init (&enum_value, G_TYPE_INT);
139
140   /* Test 1: create new confirmation note with window set to "NULL" */
141   invalid_note = HILDON_NOTE(hildon_note_new_confirmation(NULL,""));
142   fail_if(!HILDON_IS_NOTE(invalid_note),
143           "hildon-note: Creation failed with hildon_note_new_confirmation");
144
145   g_object_get_property(G_OBJECT (invalid_note),"description",&value);
146   ret_description = g_value_get_string (&value);
147   fail_if( strcmp ("",ret_description) != 0,
148            "hildon-note: Empty description was not set properly on creation. Returned description: %s",
149            ret_description);
150
151   g_object_get_property(G_OBJECT (invalid_note),"note_type",&enum_value);
152   note_type = g_value_get_int(&enum_value);
153   fail_if( note_type != HILDON_NOTE_CONFIRMATION_TYPE,
154            "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
155
156   gtk_widget_destroy (GTK_WIDGET (invalid_note));
157   invalid_note=NULL;
158
159   /* Test 2: create new confirmation note with description set to "NULL" */
160   invalid_note = HILDON_NOTE(hildon_note_new_confirmation(n_window,NULL));
161   fail_if(!HILDON_IS_NOTE(invalid_note),
162           "hildon-note: Creation failed with hildon_note_new_confirmation");
163
164   g_object_get_property(G_OBJECT (invalid_note),"description",&value);
165   ret_description = g_value_get_string (&value);
166   fail_if( ret_description != NULL,
167            "hildon-note: Empty description was not set properly on creation. Returned description: %s",
168            ret_description);
169
170   g_object_get_property(G_OBJECT (invalid_note),"note_type",&enum_value);
171   note_type = g_value_get_int(&enum_value);
172   fail_if( note_type != HILDON_NOTE_CONFIRMATION_TYPE,
173            "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
174
175   gtk_widget_destroy (GTK_WIDGET (invalid_note));
176   note=NULL;
177
178   g_value_unset(&value);
179   g_value_unset(&enum_value);
180 }
181 END_TEST
182
183 /* ----- Test case for new_information -----*/
184 /**
185  * Purpose: Check that note dialog is properly created with description regular values. 
186  * Cases considered:
187  *    - Create new information note with description set to TEST_STRING.
188  *    - Create new information note with description set to "".
189  *
190  */
191 START_TEST (test_new_information_regular)
192 {
193   const gchar * description = NULL;
194   const gchar * ret_description = NULL;
195   GValue value={0, };
196   GValue enum_value={0, };
197   HildonNoteType note_type;
198
199   g_value_init (&value, G_TYPE_STRING);
200   g_value_init (&enum_value, G_TYPE_INT);
201
202   /* Test 1: create new information note with description set to "Standard question?" */
203   description = TEST_STRING;
204   note = HILDON_NOTE(hildon_note_new_information(n_window,description));
205   fail_if(!HILDON_IS_NOTE(note),
206           "hildon-note: Creation failed with hildon_note_new_information");
207
208   g_object_get_property(G_OBJECT (note),"description",&value);
209   ret_description = g_value_get_string (&value);
210   fail_if( strcmp (description,ret_description) != 0,
211            "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
212            description,ret_description);
213
214   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
215   note_type = g_value_get_int(&enum_value);   
216   fail_if( note_type != HILDON_NOTE_INFORMATION_THEME_TYPE,
217            "hildon-note: Type was not set property on creation (HILDON_NOTE_INFORMATION_THEME_TYPE)",note_type);
218
219   gtk_widget_destroy (GTK_WIDGET (note));
220   note=NULL;
221
222   /* Test 2: create new information note with description set to "" */
223   description = "";
224   note = HILDON_NOTE(hildon_note_new_information(n_window,description));
225   fail_if(!HILDON_IS_NOTE(note),
226           "hildon-note: Creation failed with hildon_note_new_information");
227
228   g_object_get_property(G_OBJECT (note),"description",&value);
229   ret_description = g_value_get_string (&value);
230   fail_if( strcmp (description,ret_description) != 0,
231            "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
232            description,ret_description);
233
234   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
235   note_type = g_value_get_int(&enum_value);
236   fail_if( note_type != HILDON_NOTE_INFORMATION_THEME_TYPE,
237            "hildon-note: Type was not set property on creation (HILDON_NOTE_INFORMATION_THEME_TYPE)",note_type);
238
239   gtk_widget_destroy (GTK_WIDGET (note));
240   note=NULL;
241
242   g_value_unset(&value);
243   g_value_unset(&enum_value);       
244 }
245 END_TEST
246
247   
248 /**
249  * Purpose: Check that note dialog is properly created with description invalid values. 
250  * Cases considered:
251  *    - Create new information note with window set to NULL.
252  *    - Create new information note with description set to "NULL".
253  *
254  */
255 START_TEST (test_new_information_invalid)
256 {
257   const gchar * ret_description = NULL;
258   GValue value={0, };
259   GValue enum_value={0, };
260   HildonNoteType note_type;
261   HildonNote * invalid_note;
262    
263   g_value_init (&value, G_TYPE_STRING);
264   g_value_init (&enum_value, G_TYPE_INT);
265
266   /* Test 1: create new information note with window set to "NULL" */
267   invalid_note = HILDON_NOTE(hildon_note_new_information(NULL,""));
268   fail_if(!HILDON_IS_NOTE(invalid_note),
269           "hildon-note: Creation failed with hildon_note_new_information");
270
271   g_object_get_property(G_OBJECT (invalid_note),"description",&value);
272   ret_description = g_value_get_string (&value);
273   fail_if( strcmp ("",ret_description) != 0,
274            "hildon-note: Empty description was not set properly on creation. Returned description: %s",
275            ret_description);
276
277   g_object_get_property(G_OBJECT (invalid_note),"note_type",&enum_value);
278   note_type = g_value_get_int(&enum_value);
279   fail_if( note_type != HILDON_NOTE_INFORMATION_THEME_TYPE,
280            "hildon-note: Type was not set property on creation (HILDON_NOTE_INFORMATION_THEME_TYPE)",note_type);
281     
282   gtk_widget_destroy (GTK_WIDGET (invalid_note));
283   invalid_note=NULL;
284
285   /* Test 2: create new information note with description set to "NULL" */
286   invalid_note = HILDON_NOTE(hildon_note_new_information(n_window,NULL));
287   fail_if(!HILDON_IS_NOTE(invalid_note),
288           "hildon-note: Creation failed with hildon_note_new_information");
289
290   g_object_get_property(G_OBJECT (invalid_note),"description",&value);
291   ret_description = g_value_get_string (&value);
292   fail_if( ret_description != NULL,
293            "hildon-note: Empty description was not set properly on creation. Returned description: %s",
294            ret_description);
295
296   g_object_get_property(G_OBJECT (invalid_note),"note_type",&enum_value);
297   note_type = g_value_get_int(&enum_value);
298   fail_if( note_type != HILDON_NOTE_INFORMATION_THEME_TYPE,
299            "hildon-note: Type was not set property on creation (HILDON_NOTE_INFORMATION_THEME_TYPE)",note_type);
300
301   gtk_widget_destroy (GTK_WIDGET (invalid_note));
302   note=NULL;
303
304   g_value_unset(&value);
305   g_value_unset(&enum_value);
306 }
307 END_TEST
308
309 /* ----- Test case for new_confirmation_with_icon_name -----*/
310 /**
311  * Purpose: Check that note dialog is properly created with description regular values. 
312  * Cases considered:
313  *    - Create new confirmation note with description set to TEST_STRING and icon name "qgn_list_cp_calibration".
314  *    - Create new confirmation note with description set to "" and icon name NULL.
315  *
316  */
317 START_TEST (test_new_confirmation_with_icon_name_regular)
318 {
319   const gchar * description = NULL;
320   const gchar * ret_description = NULL;
321   const gchar *icon_name = NULL;
322   const gchar * ret_icon_name = NULL;
323   GValue value={0, };
324   GValue icon_name_value={0, };
325   GValue enum_value={0, };
326   HildonNoteType note_type;
327
328   g_value_init (&value, G_TYPE_STRING);
329   g_value_init (&icon_name_value, G_TYPE_STRING);
330   g_value_init (&enum_value, G_TYPE_INT);
331
332   /* Test 1: create new confirmation note with description set to TEST_STRING */
333   description = TEST_STRING;
334   icon_name="qgn_list_cp_calibration";
335   note = HILDON_NOTE(hildon_note_new_confirmation_with_icon_name(n_window,description,icon_name));
336   fail_if(!HILDON_IS_NOTE(note),
337           "hildon-note: Creation failed with hildon_note_new_confirmation_with_icon_name");
338
339     g_object_get_property(G_OBJECT (note),"description",&value);
340   ret_description = g_value_get_string (&value);
341   fail_if( strcmp (description,ret_description) != 0,
342            "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
343            description,ret_description);
344   
345   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
346   note_type = g_value_get_int(&enum_value);  
347   fail_if( note_type != HILDON_NOTE_CONFIRMATION_TYPE,
348            "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
349   
350   g_object_get_property(G_OBJECT (note),"icon",&icon_name_value);
351   ret_icon_name = g_value_get_string (&icon_name_value);
352   fail_if( strcmp (icon_name,ret_icon_name) != 0,
353            "hildon-note: icon_name (%s) was not set properly on creation. Returned icon_name: %s",
354            icon_name,ret_icon_name);
355
356   gtk_widget_destroy (GTK_WIDGET (note));
357   note=NULL;
358   
359   /* Test 2: create new confirmation note with description set to "" and icon name set to NULL */
360   description = "";
361   icon_name=NULL;
362   note = HILDON_NOTE(hildon_note_new_confirmation_with_icon_name(n_window,description,icon_name));
363   fail_if(!HILDON_IS_NOTE(note),
364           "hildon-note: Creation failed with hildon_note_new_confirmation_with_icon_name");
365   
366   g_object_get_property(G_OBJECT (note),"description",&value);
367   ret_description = g_value_get_string (&value);
368   fail_if( strcmp (description,ret_description) != 0,
369            "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
370            description,ret_description);
371   
372   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
373   note_type = g_value_get_int(&enum_value);  
374   fail_if( note_type != HILDON_NOTE_CONFIRMATION_TYPE,
375            "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
376   
377   g_object_get_property(G_OBJECT (note),"icon",&icon_name_value);
378   ret_icon_name = g_value_get_string (&icon_name_value);
379   fail_if( ret_icon_name != NULL,
380            "hildon-note: icon_name (%s) was not set properly on creation. Returned icon_name: %s",
381            icon_name,ret_icon_name);
382   
383   gtk_widget_destroy (GTK_WIDGET (note));
384   note=NULL;
385   
386   g_value_unset(&value);
387   g_value_unset(&icon_name_value);
388   g_value_unset(&enum_value);
389   
390 }
391 END_TEST
392
393 /**
394  * Purpose: Check that note dialog is properly created with description invalid values. 
395  * Cases considered:
396  *    - Create new confirmation note with window set to NULL.
397  *    - Create new confirmation note with description set to "NULL".
398  *
399  */
400 START_TEST (test_new_confirmation_with_icon_name_invalid)
401 {
402   const gchar * ret_description = NULL;
403   const gchar * ret_icon_name = NULL;
404   GValue value={0, };
405   GValue enum_value={0, };
406   GValue icon_name_value={0, };
407   HildonNoteType note_type;
408   HildonNote * invalid_note;
409    
410   g_value_init (&value, G_TYPE_STRING);
411   g_value_init (&icon_name_value, G_TYPE_STRING);
412   g_value_init (&enum_value, G_TYPE_INT);
413
414   /* Test 1: create new confirmation note with window set to "NULL" */
415   invalid_note = HILDON_NOTE(hildon_note_new_confirmation_with_icon_name(NULL,"",""));
416   fail_if(!HILDON_IS_NOTE(invalid_note),
417           "hildon-note: Creation failed with hildon_note_new_confirmation_with_icon_name");
418
419   g_object_get_property(G_OBJECT (invalid_note),"description",&value);
420   ret_description = g_value_get_string (&value);
421   fail_if( strcmp ("",ret_description) != 0,
422            "hildon-note: Description "" was not set properly on creation. Returned description: %s",
423            ret_description);
424
425   g_object_get_property(G_OBJECT (invalid_note),"icon",&icon_name_value);
426   ret_icon_name = g_value_get_string (&icon_name_value);
427   fail_if( strcmp ("",ret_icon_name) != 0,
428            "hildon-note: Description "" was not set properly on creation. Returned description: %s",
429            ret_icon_name);
430
431   g_object_get_property(G_OBJECT (invalid_note),"note_type",&enum_value);
432   note_type = g_value_get_int(&enum_value);
433   fail_if( note_type != HILDON_NOTE_CONFIRMATION_TYPE,
434            "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
435
436   gtk_widget_destroy (GTK_WIDGET (invalid_note));
437   invalid_note=NULL;
438
439   /* Test 2: create new confirmation note with description set to "NULL" */
440   invalid_note = HILDON_NOTE(hildon_note_new_confirmation_with_icon_name(n_window,NULL,"qgn_list_cp_calibration"));
441   fail_if(!HILDON_IS_NOTE(invalid_note),
442           "hildon-note: Creation failed with hildon_note_new_confirmation_with_icon_name");
443
444   g_object_get_property(G_OBJECT (invalid_note),"description",&value);
445   ret_description = g_value_get_string (&value);
446   fail_if( ret_description!=NULL,
447            "hildon-note: Description \"\" was not set properly on creation. Returned description: %s",
448            ret_description);
449
450   g_object_get_property(G_OBJECT (invalid_note),"note_type",&enum_value);
451   note_type = g_value_get_int(&enum_value);
452   fail_if( note_type != HILDON_NOTE_CONFIRMATION_TYPE,
453            "hildon-note: Type was not set property on creation (HILDON_NOTE_CONFIRMATION_TYPE)",note_type);
454
455   g_object_get_property(G_OBJECT (invalid_note),"icon",&icon_name_value);
456   ret_icon_name = g_value_get_string (&icon_name_value);
457   fail_if( strcmp ("qgn_list_cp_calibration",ret_icon_name) != 0,
458            "hildon-note: Icon name qgn_list_cp_calibration was not set properly on creation. Returned icon name: %s",
459            ret_icon_name);
460
461   gtk_widget_destroy (GTK_WIDGET (invalid_note));
462   note=NULL;
463
464   g_value_unset(&icon_name_value);
465   g_value_unset(&value);
466   g_value_unset(&enum_value);
467 }
468 END_TEST
469
470 /* ----- Test case for new_cancel_with_progress_bar -----*/
471
472 /**
473  * Purpose: Check that note dialog is properly created with description regular values. 
474  * Cases considered:
475  *    - Create new confirmation note with description set to TEST_STRING and NULL GtkProgressBar.
476  *    - Create new confirmation note with description set to "" and correct GtkProgressBar.
477  *
478  */
479 START_TEST (test_new_cancel_with_progress_bar_regular)
480 {
481   const gchar * description = NULL;
482   const gchar * ret_description = NULL;
483   GValue value={0, };
484   GValue enum_value={0, };
485   GtkProgressBar * progress_bar=NULL;
486    
487   HildonNoteType note_type;
488
489   g_value_init (&value, G_TYPE_STRING);
490   g_value_init (&enum_value, G_TYPE_INT);
491
492   /* Test 1: create new confirmation note with description set to TEST_STRING and NULL GtkProgressBar */
493   description = TEST_STRING;
494   note = HILDON_NOTE(hildon_note_new_cancel_with_progress_bar(n_window,description,progress_bar));
495   fail_if(!HILDON_IS_NOTE(note),
496           "hildon-note: Creation failed with hildon_note_new_cancel_with_progress_bar");
497
498   g_object_get_property(G_OBJECT (note),"description",&value);
499   ret_description = g_value_get_string (&value);
500   fail_if( strcmp (description,ret_description) != 0,
501            "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
502            description,ret_description);
503
504   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
505   note_type = g_value_get_int(&enum_value);   
506   fail_if( note_type != HILDON_NOTE_PROGRESSBAR_TYPE,
507            "hildon-note: Type was not set property on creation (HILDON_NOTE_PROGRESSBAR_TYPE)",note_type);
508
509   gtk_widget_destroy (GTK_WIDGET (note));
510   note=NULL;
511
512   /* Test 2: create new confirmation note with description set to "" */
513   description = "";
514   progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new());
515   fail_if(!GTK_IS_PROGRESS_BAR(progress_bar),
516           "hildon-note: Progress bar creation failed in hildon_note_new_cancel_with_progress_bar");
517
518   gtk_progress_bar_set_fraction(progress_bar,0.5);
519     
520   note = HILDON_NOTE(hildon_note_new_cancel_with_progress_bar(n_window,description,progress_bar));
521   fail_if(!HILDON_IS_NOTE(note),
522           "hildon-note: Creation failed with hildon_note_new_cancel_with_progress_bar");
523
524   g_object_get_property(G_OBJECT (note),"description",&value);
525   ret_description = g_value_get_string (&value);
526   fail_if( strcmp (description,ret_description) != 0,
527            "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
528            description,ret_description);
529
530   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
531   note_type = g_value_get_int(&enum_value);   
532   fail_if( note_type != HILDON_NOTE_PROGRESSBAR_TYPE,
533            "hildon-note: Type was not set property on creation (HILDON_NOTE_PROGRESSBAR_TYPE)",note_type);
534
535   gtk_widget_destroy (GTK_WIDGET (progress_bar));
536   gtk_widget_destroy (GTK_WIDGET (note));
537   note=NULL;
538
539   g_value_unset(&value);
540   g_value_unset(&enum_value);
541 }
542 END_TEST
543
544 /**
545  * Purpose: Check that note dialog is properly created with description invalid values. 
546  * Cases considered:
547  *    - Create new confirmation note with description set to NULL.
548  *    - Create new confirmation note with window set to NULL.
549  *
550  */
551 START_TEST (test_new_cancel_with_progress_bar_invalid)
552 {
553   const gchar * description = NULL;
554   const gchar * ret_description = NULL;
555   GValue value={0, };
556   GValue enum_value={0, };
557    
558   HildonNoteType note_type;
559
560   g_value_init (&value, G_TYPE_STRING);
561   g_value_init (&enum_value, G_TYPE_INT);
562
563   /* Test 1: create new confirmation note with description set to NULL */
564   description = NULL;
565   note = HILDON_NOTE(hildon_note_new_cancel_with_progress_bar(n_window,description,NULL));
566   fail_if(!HILDON_IS_NOTE(note),
567           "hildon-note: Creation failed with hildon_note_new_cancel_with_progress_bar");
568
569   g_object_get_property(G_OBJECT (note),"description",&value);
570   ret_description = g_value_get_string (&value);
571   fail_if( ret_description != NULL,
572            "hildon-note: NULL description was not set properly on creation",
573            description,ret_description);
574
575   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
576   note_type = g_value_get_int(&enum_value);
577   fail_if( note_type != HILDON_NOTE_PROGRESSBAR_TYPE,
578            "hildon-note: Type was not set property on creation (HILDON_NOTE_PROGRESSBAR_TYPE)",note_type);
579
580   gtk_widget_destroy (GTK_WIDGET (note));
581   note=NULL;
582
583
584   /* Test 2: create new confirmation note with window set to NULL */
585   description = "";
586   note = HILDON_NOTE(hildon_note_new_cancel_with_progress_bar(NULL,description,NULL));
587   fail_if(!HILDON_IS_NOTE(note),
588           "hildon-note: Creation failed with hildon_note_new_cancel_with_progress_bar");
589
590   g_object_get_property(G_OBJECT (note),"description",&value);
591   ret_description = g_value_get_string (&value);
592   fail_if( strcmp(description,ret_description) != 0,
593            "hildon-note: Empty description was not set properly on creation",
594            description,ret_description);
595
596   g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
597   note_type = g_value_get_int(&enum_value);
598   fail_if( note_type != HILDON_NOTE_PROGRESSBAR_TYPE,
599            "hildon-note: Type was not set property on creation (HILDON_NOTE_PROGRESSBAR_TYPE)",note_type);
600
601   gtk_widget_destroy (GTK_WIDGET (note));
602   note=NULL;
603
604   g_value_unset(&value);
605   g_value_unset(&enum_value);
606 }
607 END_TEST
608
609   
610   
611 /* ---------- Suite creation ---------- */
612 Suite *create_hildon_note_suite()
613 {
614   /* Create the suite */
615   Suite *s = suite_create("HildonNote");
616
617   /* Create test cases */
618   TCase *tc1 = tcase_create("new_confirmation");
619   TCase *tc2 = tcase_create("new_confirmation_with_icon_name");
620   TCase *tc3 = tcase_create("new_information");
621   TCase *tc4 = tcase_create("new_cancel_with_progress_bar");
622
623   /* Create test case for hildon_note_new_confirmation and add it to the suite */
624   tcase_add_checked_fixture(tc1, fx_setup_default_note, fx_teardown_default_note);
625   tcase_add_test(tc1, test_new_confirmation_regular);
626   tcase_add_test(tc1, test_new_confirmation_invalid);
627   suite_add_tcase (s, tc1);
628
629   /* Create test case for hildon_note_new_confirmation_with_icon_name and add it to the suite */
630   tcase_add_checked_fixture(tc2, fx_setup_default_note, fx_teardown_default_note);
631   tcase_add_test(tc2, test_new_confirmation_with_icon_name_regular);
632   tcase_add_test(tc2, test_new_confirmation_with_icon_name_invalid);
633   suite_add_tcase (s, tc2);
634
635   /* Create test case for hildon_note_new_with_information and add it to the suite */
636   tcase_add_checked_fixture(tc3, fx_setup_default_note, fx_teardown_default_note);
637   tcase_add_test(tc3, test_new_information_regular);
638   tcase_add_test(tc3, test_new_information_invalid);
639   suite_add_tcase (s, tc3);
640
641   /* Create test case for hildon_note_new_with_progress_bar and add it to the suite */
642   tcase_add_checked_fixture(tc4, fx_setup_default_note, fx_teardown_default_note);
643   tcase_add_test(tc4, test_new_cancel_with_progress_bar_regular);
644   tcase_add_test(tc4, test_new_cancel_with_progress_bar_invalid);
645   suite_add_tcase (s, tc4);
646
647   /* Return created suite */
648   return s;
649 }