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