mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-18 17:30:10 +00:00
Add some tests for GtkWindow
These tests may have some assumptions on reasonable window manager behaviour. For now, we just test that the default size of the window ends up as the allocated size of the content. This test currently fails with client-side decorations, because we are not properly discriminating between overall window size and content size.
This commit is contained in:
parent
d35596fe92
commit
1f17efb81c
@ -176,6 +176,10 @@ TEST_PROGS += objects-finalize
|
||||
objects_finalize_SOURCES = objects-finalize.c
|
||||
objects_finalize_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += window
|
||||
window_SOURCES = window.c
|
||||
window_LDADD = $(progs_ldadd)
|
||||
|
||||
EXTRA_DIST += \
|
||||
file-chooser-test-dir/empty \
|
||||
file-chooser-test-dir/text.txt
|
||||
|
50
gtk/tests/window.c
Normal file
50
gtk/tests/window.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static gboolean
|
||||
stop_main (gpointer data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
test_default_size (void)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *box;
|
||||
gint w, h;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
|
||||
gtk_window_get_default_size (GTK_WINDOW (window), &w, &h);
|
||||
g_assert (w == -1 && h == -1);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
|
||||
|
||||
gtk_window_get_default_size (GTK_WINDOW (window), &w, &h);
|
||||
g_assert (w == 300 && h == 300);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
g_timeout_add (1000, stop_main, NULL);
|
||||
gtk_main ();
|
||||
|
||||
g_assert (gtk_widget_get_allocated_width (window) == 300);
|
||||
g_assert (gtk_widget_get_allocated_height (window) == 300);
|
||||
|
||||
g_assert (gtk_widget_get_allocated_width (box) == 300);
|
||||
g_assert (gtk_widget_get_allocated_height (box) == 300);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv);
|
||||
|
||||
g_test_add_func ("/window/default-size", test_default_size);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user