testsuite: add hide-titlebar-when-maximized test for GtkWindow

This commit adds a test that checks whether or not
hide-titlebar-when-maximized can be set before the window is
realized.

https://bugzilla.gnome.org/show_bug.cgi?id=740287
This commit is contained in:
Ray Strode 2014-11-21 14:17:06 -05:00 committed by Matthias Clasen
parent c1ca7986ee
commit 3a5d15358e

View File

@ -1,5 +1,10 @@
#include <gtk/gtk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#include <X11/Xatom.h>
#endif
static gboolean interactive = FALSE;
static gboolean
@ -336,6 +341,73 @@ test_show_hide3 (void)
gtk_widget_destroy (window);
}
static gboolean
on_map_event (GtkWidget *window)
{
gtk_main_quit ();
return FALSE;
}
static void
test_hide_titlebar_when_maximized (void)
{
GtkWidget *window;
g_test_bug ("740287");
/* test that hide-titlebar-when-maximized gets set appropriately
* on the window, if it's set before the window is realized.
*/
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window,
"map-event",
G_CALLBACK (on_map_event),
NULL);
gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (window), TRUE);
gtk_widget_show (window);
g_timeout_add (100, stop_main, NULL);
gtk_main ();
#ifdef GDK_WINDOWING_X11
{
Atom type;
gint format;
gulong nitems;
gulong bytes_after;
gulong *hide = NULL;
XGetWindowProperty (gdk_x11_get_default_xdisplay (),
GDK_WINDOW_XID (gtk_widget_get_window (window)),
gdk_x11_get_xatom_by_name ("_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"),
0,
G_MAXLONG,
False,
XA_CARDINAL,
&type,
&format,
&nitems,
&bytes_after,
(guchar **) &hide);
g_assert_cmpint (type, !=, None);
g_assert_cmpint (type, ==, XA_CARDINAL);
g_assert_cmpint (format, ==, 32);
g_assert_cmpint (nitems, ==, 1);
g_assert_cmpint (hide[0], ==, 1);
XFree (hide);
}
#endif
gtk_widget_destroy (window);
}
int
main (int argc, char *argv[])
{
@ -356,6 +428,7 @@ main (int argc, char *argv[])
g_test_add_func ("/window/show-hide", test_show_hide);
g_test_add_func ("/window/show-hide2", test_show_hide2);
g_test_add_func ("/window/show-hide3", test_show_hide3);
g_test_add_func ("/window/hide-titlebar-when-maximized", test_hide_titlebar_when_maximized);
return g_test_run ();
}