]> Pileus Git - ~andy/gtk/blob - gtk/tests/floating.c
tests/Makefile.am tests/autotestfilechooser.c tests/buildertest.c
[~andy/gtk] / gtk / tests / floating.c
1 /* floatingtest.c - test floating flag uses
2  * Copyright (C) 2005 Tim Janik
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 #undef GTK_DISABLE_DEPRECATED
20 #include "../gtk/gtk.h"
21
22 static gboolean destroyed = FALSE;
23 static void
24 destroy (void)
25 {
26   destroyed = TRUE;
27 }
28
29 static void
30 floating_tests (void)
31 {
32   GtkWidget *widget = g_object_new (GTK_TYPE_LABEL, NULL);
33   g_object_connect (widget, "signal::destroy", destroy, NULL, NULL);
34
35   g_assert (GTK_OBJECT_FLOATING (widget));
36   g_assert (g_object_is_floating (widget));
37
38   GTK_OBJECT_UNSET_FLAGS (widget, GTK_FLOATING);
39   g_assert (!GTK_OBJECT_FLOATING (widget));
40   g_assert (!g_object_is_floating (widget));
41
42   GTK_OBJECT_SET_FLAGS (widget, GTK_FLOATING);
43   g_assert (GTK_OBJECT_FLOATING (widget));
44   g_assert (g_object_is_floating (widget));
45
46   g_object_ref_sink (widget);
47   g_assert (!GTK_OBJECT_FLOATING (widget));
48   g_assert (!g_object_is_floating (widget));
49
50   g_object_force_floating (G_OBJECT (widget));
51   g_assert (GTK_OBJECT_FLOATING (widget));
52   g_assert (g_object_is_floating (widget));
53
54   g_object_ref (widget);
55   gtk_object_sink (GTK_OBJECT (widget));
56   g_assert (!GTK_OBJECT_FLOATING (widget));
57   g_assert (!g_object_is_floating (widget));
58
59   g_assert (!destroyed);
60   g_object_unref (widget);
61   g_assert (destroyed);
62 }
63
64 int
65 main (int   argc,
66       char *argv[])
67 {
68   gtk_test_init (&argc, &argv);
69   g_test_add_func ("/floatingtest", floating_tests);
70   return g_test_run();
71 }