Adding missing debian changelog. Modyfying hildon-banner to allow creation with null...
[hildon] / tests / check-hildon-code-dialog.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 <check.h>
25 #include <gtk/gtkmain.h>
26 #include <gtk/gtkhbox.h>
27 #include <glib/gprintf.h>
28 #include <string.h>
29 #include "test_suites.h"
30 #include "check_utils.h"
31
32 #include "hildon-code-dialog.h"
33
34 /* -------------------- Fixtures -------------------- */
35
36 static HildonCodeDialog *code_dialog = NULL;
37
38 static void 
39 fx_setup_default_code_dialog()
40 {
41   int argc = 0;
42   gtk_init(&argc, NULL);
43
44   code_dialog = HILDON_CODE_DIALOG(hildon_code_dialog_new());
45   /* Check code_dialog object has been created properly */
46   fail_if(!HILDON_IS_CODE_DIALOG(code_dialog), 
47           "hildon-code-dialog: Creation failed.");
48
49   show_test_window(GTK_WIDGET(code_dialog));
50   
51 }
52
53 static void 
54 fx_teardown_default_code_dialog()
55 {
56   
57   /* Destroy the dialog */
58   gtk_widget_destroy (GTK_WIDGET (code_dialog));
59
60 }
61
62 /* -------------------- Test cases -------------------- */
63
64 /* ----- Test case for get_code -----*/
65 /**
66  * Purpose: Check that the regular code values are get without problems
67  *
68  * Cases considered:
69  *    - Get code from new created dialog.
70  *    
71  */
72 START_TEST (test_get_code_regular)
73 {
74   const gchar * code;
75     
76   /* Test 1: Get code from new created dialog. */
77   /* Check that code is correctly get. */
78   code  = hildon_code_dialog_get_code (code_dialog);
79   fail_if (strcmp (code,"") != 0,
80            "hildon-code-dialog: init code isn't empty");
81
82 }
83 END_TEST
84
85 /**
86  * Purpose: Check that the regular code values are get without problems
87  *
88  * Cases considered:
89  *    - Get code from NULL object
90  *    - Get code from object that isn't a code dialog.
91  *    
92  */
93 START_TEST (test_get_code_invalid)
94 {
95   const gchar * code;
96   GtkWidget *aux_object = NULL;
97     
98   /* Test 1: Get code from NULL object. */
99   code  = hildon_code_dialog_get_code (NULL);
100
101   /* Test 2: Get code from object that it isn't a code dialog. */
102   aux_object = gtk_hbox_new (TRUE, 0);
103   code  = hildon_code_dialog_get_code ((HildonCodeDialog *) aux_object);
104
105   gtk_widget_destroy (aux_object);
106
107 }
108 END_TEST
109
110 /* ---------- Suite creation ---------- */
111 Suite *create_hildon_code_dialog_suite()
112 {
113   /* Create the suite */
114   Suite *s = suite_create("HildonCodeDialog");
115   
116   /* Create test cases */
117   TCase *tc1 = tcase_create("get_code");
118
119   /* Create test case for hildon_code_dialog_get_code and add it to the suite */
120   tcase_add_checked_fixture(tc1, fx_setup_default_code_dialog, fx_teardown_default_code_dialog);
121   tcase_add_test(tc1, test_get_code_regular);
122   tcase_add_test(tc1, test_get_code_invalid);
123   suite_add_tcase (s, tc1);
124
125   /* Return created suite */
126   return s;             
127 }