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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2001. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
29 test_click_expander (void)
31 GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on expander");
32 GtkWidget *expander = gtk_expander_new ("Test Expander");
33 GtkWidget *label = gtk_label_new ("Test Label");
36 gtk_container_add (GTK_CONTAINER (expander), label);
37 gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), expander);
38 gtk_widget_show (expander);
39 gtk_widget_show (label);
40 gtk_widget_show_now (window);
41 /* check initial expander state */
42 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
45 simsuccess = gtk_test_widget_click (expander, 1, 0);
46 g_assert (simsuccess == TRUE);
47 while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
48 gtk_main_iteration ();
49 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
51 /* check collapsing */
52 simsuccess = gtk_test_widget_click (expander, 1, 0);
53 g_assert (simsuccess == TRUE);
54 while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
55 gtk_main_iteration ();
56 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
61 test_click_content_widget (void)
63 GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test click on content widget");
64 GtkWidget *expander = gtk_expander_new ("Test Expander");
65 GtkWidget *entry = gtk_entry_new ();
68 gtk_container_add (GTK_CONTAINER (expander), entry);
69 gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), expander);
70 gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
71 gtk_widget_show (expander);
72 gtk_widget_show (entry);
73 gtk_widget_show_now (window);
75 /* check click on content with expander open */
76 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
78 simsuccess = gtk_test_widget_click (entry, 1, 0);
79 g_assert (simsuccess == TRUE);
80 while (gtk_events_pending ()) /* let expander timeout/idle handlers update */
81 gtk_main_iteration ();
82 expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
90 gtk_test_init (&argc, &argv);
91 g_test_add_func ("/expander/click-expander", test_click_expander);
92 g_test_add_func ("/expander/click-content-widget", test_click_content_widget);