1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 * Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 test_click_expander (void)
29 GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on expander");
30 GtkWidget *expander = gtk_expander_new ("Test Expander");
31 GtkWidget *label = gtk_label_new ("Test Label");
34 gtk_container_add (GTK_CONTAINER (expander), label);
35 gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
36 gtk_widget_show (expander);
37 gtk_widget_show (label);
38 gtk_widget_show_now (window);
39 /* check initial expander state */
40 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
43 simsuccess = gtk_test_widget_click (expander, 1, 0);
44 g_assert (simsuccess == TRUE);
45 while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
46 gtk_main_iteration ();
47 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
49 /* check collapsing */
50 simsuccess = gtk_test_widget_click (expander, 1, 0);
51 g_assert (simsuccess == TRUE);
52 while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
53 gtk_main_iteration ();
54 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
59 test_click_content_widget (void)
61 GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on content widget");
62 GtkWidget *expander = gtk_expander_new ("Test Expander");
63 GtkWidget *entry = gtk_entry_new ();
66 gtk_container_add (GTK_CONTAINER (expander), entry);
67 gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
68 gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
69 gtk_widget_show (expander);
70 gtk_widget_show (entry);
71 gtk_widget_show_now (window);
73 /* check click on content with expander open */
74 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
76 simsuccess = gtk_test_widget_click (entry, 1, 0);
77 g_assert (simsuccess == TRUE);
78 while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
79 gtk_main_iteration ();
80 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
88 gtk_test_init (&argc, &argv);
89 g_test_add_func ("/expander/click-expander", test_click_expander);
90 g_test_add_func ("/expander/click-content-widget", test_click_content_widget);