Add a test for a flowbox crash

This commit is contained in:
Matthias Clasen 2020-05-13 20:14:43 -04:00
parent 69ab403d78
commit 378cca75ea
2 changed files with 60 additions and 0 deletions

59
testsuite/gtk/flowbox.c Normal file
View File

@ -0,0 +1,59 @@
#include <gtk/gtk.h>
static gboolean
main_loop_quit_cb (gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
return FALSE;
}
static void
show_and_wait (GtkWidget *widget)
{
gboolean done = FALSE;
g_timeout_add (500, main_loop_quit_cb, &done);
gtk_widget_show (widget);
while (!done)
g_main_context_iteration (NULL, FALSE);
}
/* this was triggering a crash in gtk_flow_box_measure(),
* see #2702
*/
static void
test_measure_crash (void)
{
GtkWidget *window, *box, *child;
window = gtk_window_new ();
box = gtk_flow_box_new ();
gtk_widget_set_valign (GTK_WIDGET (box), GTK_ALIGN_START);
child = g_object_new (GTK_TYPE_FLOW_BOX_CHILD,
"css-name", "nopadding",
NULL);
gtk_flow_box_insert (GTK_FLOW_BOX (box), child, -1);
gtk_orientable_set_orientation (GTK_ORIENTABLE (box), GTK_ORIENTATION_VERTICAL);
gtk_flow_box_set_row_spacing (GTK_FLOW_BOX (box), 0);
gtk_window_set_child (GTK_WINDOW (window), box);
show_and_wait (window);
gtk_window_destroy (GTK_WINDOW (window));
}
int
main (int argc, char *argv[])
{
gtk_test_init (&argc, &argv);
g_test_add_func ("/flowbox/measure-crash", test_measure_crash);
return g_test_run ();
}

View File

@ -29,6 +29,7 @@ tests = [
['filterlistmodel'],
['flattenlistmodel'],
['floating'],
['flowbox'],
#['gestures'],
['grid'],
['grid-layout'],