[gtk/wip/matthiasc/popup5: 96/115] Add a testcase for size allocation



commit ae360ec045f4f271aa9738c9104c3ae7a9c74e1c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun May 5 22:10:16 2019 +0000

    Add a testcase for size allocation
    
    This triggers a critical warning in gtk_widget_snapshot.

 testsuite/gtk/meson.build |  1 +
 testsuite/gtk/popover.c   | 63 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
---
diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build
index 246078c400..a83218c921 100644
--- a/testsuite/gtk/meson.build
+++ b/testsuite/gtk/meson.build
@@ -8,6 +8,7 @@ if cc.get_id() != 'msvc'
 endif
 
 tests = [
+  ['popover'],
   ['accel'],
   ['accessible'],
   ['adjustment'],
diff --git a/testsuite/gtk/popover.c b/testsuite/gtk/popover.c
new file mode 100644
index 0000000000..acd14e062e
--- /dev/null
+++ b/testsuite/gtk/popover.c
@@ -0,0 +1,63 @@
+#include <gtk/gtk.h>
+#include <locale.h>
+#include "gdk/gdkeventsprivate.h"
+
+static gboolean
+pop_up (gpointer data)
+{
+  gtk_popover_popup (GTK_POPOVER (data));
+
+  return G_SOURCE_REMOVE;
+}
+
+static gboolean
+tickle (gpointer data)
+{
+  GtkWidget *label;
+
+  label = gtk_widget_get_first_child (GTK_WIDGET (data));
+  gtk_widget_set_valign (label, GTK_ALIGN_START);
+
+  return G_SOURCE_REMOVE;
+}
+
+static gboolean
+stop (gpointer data)
+{
+  gtk_main_quit ();
+
+  return G_SOURCE_REMOVE;
+}
+
+static void
+test_show_popover (void)
+{
+  GtkWidget *window;
+  GtkWidget *button;
+  GtkWidget *popover;
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  button = gtk_menu_button_new ();
+  popover = gtk_popover_new (NULL);
+  gtk_container_add (GTK_CONTAINER (popover), gtk_label_new ("Nu?"));
+  gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover);
+  gtk_container_add (GTK_CONTAINER (window), button);
+
+  gtk_window_present (GTK_WINDOW (window));
+
+  g_timeout_add (1000, pop_up, popover);
+  g_timeout_add (2000, tickle, popover);
+  g_timeout_add (3000, stop, NULL);
+
+  gtk_main ();
+}
+
+int
+main (int argc, char *argv[])
+{
+  gtk_test_init (&argc, &argv);
+
+  g_test_add_func ("/popover/show", test_show_popover);
+
+  return g_test_run ();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]