2 * Copyright (C) 2006 Nokia Corporation.
4 * Contact: Luc Pionchon <luc.pionchon@nokia.com>
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.
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.
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
25 #include <gtk/gtkmain.h>
26 #include <gtk/gtkhbox.h>
27 #include <glib/gprintf.h>
29 #include "test_suites.h"
30 #include "check_utils.h"
32 #include "hildon-code-dialog.h"
34 /* -------------------- Fixtures -------------------- */
36 static HildonCodeDialog *code_dialog = NULL;
39 fx_setup_default_code_dialog()
42 gtk_init(&argc, NULL);
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.");
49 show_test_window(GTK_WIDGET(code_dialog));
54 fx_teardown_default_code_dialog()
57 /* Destroy the dialog */
58 gtk_widget_destroy (GTK_WIDGET (code_dialog));
62 /* -------------------- Test cases -------------------- */
64 /* ----- Test case for get_code -----*/
66 * Purpose: Check that the regular code values are get without problems
69 * - Get code from new created dialog.
72 START_TEST (test_get_code_regular)
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");
86 * Purpose: Check that the regular code values are get without problems
89 * - Get code from NULL object
90 * - Get code from object that isn't a code dialog.
93 START_TEST (test_get_code_invalid)
96 GtkWidget *aux_object = NULL;
98 /* Test 1: Get code from NULL object. */
99 code = hildon_code_dialog_get_code (NULL);
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);
105 gtk_widget_destroy (aux_object);
110 /* ---------- Suite creation ---------- */
111 Suite *create_hildon_code_dialog_suite()
113 /* Create the suite */
114 Suite *s = suite_create("HildonCodeDialog");
116 /* Create test cases */
117 TCase *tc1 = tcase_create("get_code");
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);
125 /* Return created suite */