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/gtksignal.h>
29 #include <glib/gprintf.h>
30 #include "test_suites.h"
31 #include "check_utils.h"
34 #include "hildon-dialoghelp.h"
36 /* -------------------- Fixtures -------------------- */
37 static GtkWidget * dialoghelp = NULL;
40 change_help_status (GtkDialog *dialog, gpointer func_data)
42 gboolean * data = func_data;
47 fx_setup_default_dialoghelp ()
50 gtk_init(&argc, NULL);
52 dialoghelp = gtk_dialog_new();
53 /* Check that the dialog help object has been created properly */
54 fail_if(!GTK_IS_DIALOG (dialoghelp), "hildon-dialoghelp: Creation failed");
56 /* Displays the widget */
57 show_all_test_window (dialoghelp);
62 fx_teardown_default_dialoghelp ()
64 gtk_widget_destroy(GTK_WIDGET(dialoghelp));
67 /* -------------------- Test cases -------------------- */
69 /* ----- Test case for enable_dialoghelp -----*/
71 * Purpose: test gtk_dialog_help_enable/gtk_dialog_help_disable connecting help signal
73 * - Test if gtk_dialog_help_enable actually enables help dialog status
74 * - Test if gtk_dialog_help_enable actually adds help atom to atoms' list
75 * - Test if gtk_dialog_help_disable actually removes help atom to atoms' list
77 START_TEST (test_enable_dialoghelp_regular)
79 gboolean help_enabled = FALSE;
80 GdkWindow *window=NULL;
86 gboolean helpAtom = FALSE;
88 gtk_dialog_help_enable(GTK_DIALOG(dialoghelp));
89 gtk_signal_connect(GTK_OBJECT(dialoghelp),"help",GTK_SIGNAL_FUNC(change_help_status),&help_enabled);
90 gtk_signal_emit_by_name(GTK_OBJECT(dialoghelp),"help");
92 /* Test 1: Test if gtk_dialog_help_enable actually enables help dialog status */
93 fail_if(help_enabled!=TRUE,"hildon-dialoghelp: Enable help failed");
95 /* In order to obtain dialog->window. */
96 gtk_widget_realize(GTK_WIDGET(dialoghelp));
97 window = GTK_WIDGET(dialoghelp)->window;
98 display = gdk_drawable_get_display (window);
100 XGetWMProtocols(GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
103 helpatom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
105 /* search if the help_atom is in the atoms' list */
106 for (i=0; i<amount; i++)
108 if (list[i] == helpatom)
116 /* Test 2: Test if gtk_dialog_help_enable actually adds help atom to atoms' list */
117 fail_if(helpAtom!=TRUE,"hildon-dialoghelp: Help atom is not in the atoms' list");
121 gtk_dialog_help_disable(GTK_DIALOG(dialoghelp));
122 XGetWMProtocols(GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
124 helpatom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
126 /* search if the help_atom is in the atoms' list */
127 for (i=0; i<amount; i++)
129 if (list[i] == helpatom)
136 /* Test 3: Test if gtk_dialog_help_disable actually removes help atom to atoms' list */
137 fail_if(helpAtom==TRUE,"hildon-dialoghelp: Help atom is in the atoms' list");
142 * Purpose: test gtk_dialog_help_enable connecting help signal
144 * - Enable help dialog on NULL object.
145 * - Disable help dialog on NULL object.
147 START_TEST (test_enable_dialoghelp_invalid)
149 gtk_dialog_help_enable(NULL);
150 gtk_dialog_help_disable(NULL);
155 /* ---------- Suite creation ---------- */
157 Suite *create_hildon_dialoghelp_suite()
159 /* Create the suite */
160 Suite *s = suite_create("HildonDialogHelp");
162 /* Create test cases */
163 TCase *tc1 = tcase_create("dialog_help_enable");
165 /* Create test case for gtk_dialog_help_enable and add it to the suite */
166 tcase_add_checked_fixture(tc1, fx_setup_default_dialoghelp, fx_teardown_default_dialoghelp);
167 tcase_add_test(tc1, test_enable_dialoghelp_regular);
168 tcase_add_test(tc1, test_enable_dialoghelp_invalid);
169 suite_add_tcase (s, tc1);
171 /* Return created suite */