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
27 #include <gtk/gtkmain.h>
28 #include <gtk/gtkhbox.h>
29 #include <glib/gprintf.h>
31 #include "test_suites.h"
32 #include "check_utils.h"
34 #include "hildon-code-dialog.h"
36 /* -------------------- Fixtures -------------------- */
38 static HildonCodeDialog *code_dialog = NULL;
41 fx_setup_default_code_dialog()
44 gtk_init(&argc, NULL);
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.");
51 show_test_window(GTK_WIDGET(code_dialog));
56 fx_teardown_default_code_dialog()
59 /* Destroy the dialog */
60 gtk_widget_destroy (GTK_WIDGET (code_dialog));
64 /* -------------------- Test cases -------------------- */
66 /* ----- Test case for get_code -----*/
68 * Purpose: Check that the regular code values are get without problems
71 * - Get code from new created dialog.
74 START_TEST (test_get_code_regular)
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");
88 * Purpose: Check that the regular code values are get without problems
91 * - Get code from NULL object
92 * - Get code from object that isn't a code dialog.
95 START_TEST (test_get_code_invalid)
98 GtkWidget *aux_object = NULL;
100 /* Test 1: Get code from NULL object. */
101 code = hildon_code_dialog_get_code (NULL);
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);
107 gtk_widget_destroy (aux_object);
112 /* ---------- Suite creation ---------- */
113 Suite *create_hildon_code_dialog_suite()
115 /* Create the suite */
116 Suite *s = suite_create("HildonCodeDialog");
118 /* Create test cases */
119 TCase *tc1 = tcase_create("get_code");
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);
127 /* Return created suite */