]> Pileus Git - ~andy/gtk/blob - gtk/tests/expander.c
appchooserdialog: remove redundant checks
[~andy/gtk] / gtk / tests / expander.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
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.
8  *
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.
13  *
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/>.
16  */
17
18 /*
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/. 
23  */
24 #include <gtk/gtk.h>
25
26 static void
27 test_click_expander (void)
28 {
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");
32   gboolean expanded;
33   gboolean simsuccess;
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));
41   g_assert (!expanded);
42   /* check expanding */
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));
48   g_assert (expanded);
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));
55   g_assert (!expanded);
56 }
57
58 static void
59 test_click_content_widget (void)
60 {
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 ();
64   gboolean expanded;
65   gboolean simsuccess;
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);
72
73   /* check click on content with expander open */
74   expanded = gtk_expander_get_expanded (GTK_EXPANDER (expander));
75   g_assert (expanded);
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));
81   g_assert (expanded);
82 }
83
84 int
85 main (int   argc,
86       char *argv[])
87 {
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);
91   return g_test_run();
92 }