mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
Add basic searchbar set_key_capture_widget tests
Make sure we're correctly resetting the internal key capture widget pointer when the widget goes away.
This commit is contained in:
parent
8f289227aa
commit
5c339f2844
@ -36,6 +36,7 @@ tests = [
|
||||
['recentmanager'],
|
||||
['regression-tests'],
|
||||
['scrolledwindow'],
|
||||
['searchbar'],
|
||||
['spinbutton'],
|
||||
['stylecontext'],
|
||||
['templates'],
|
||||
|
54
testsuite/gtk/searchbar.c
Normal file
54
testsuite/gtk/searchbar.c
Normal file
@ -0,0 +1,54 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
capture_widget_destroy (void)
|
||||
{
|
||||
GtkWidget *searchbar = gtk_search_bar_new ();
|
||||
GtkWidget *button = gtk_button_new ();
|
||||
|
||||
g_object_ref_sink (searchbar);
|
||||
g_object_ref_sink (button);
|
||||
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), button);
|
||||
|
||||
g_assert (gtk_search_bar_get_key_capture_widget (GTK_SEARCH_BAR (searchbar)) == button);
|
||||
|
||||
g_object_unref (button);
|
||||
|
||||
g_assert (gtk_search_bar_get_key_capture_widget (GTK_SEARCH_BAR (searchbar)) == NULL);
|
||||
|
||||
g_object_unref (searchbar);
|
||||
}
|
||||
|
||||
static void
|
||||
capture_widget_unset (void)
|
||||
{
|
||||
GtkWidget *searchbar = gtk_search_bar_new ();
|
||||
GtkWidget *button = gtk_button_new ();
|
||||
|
||||
g_object_ref_sink (searchbar);
|
||||
g_object_ref_sink (button);
|
||||
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), button);
|
||||
|
||||
g_assert (gtk_search_bar_get_key_capture_widget (GTK_SEARCH_BAR (searchbar)) == button);
|
||||
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), NULL);
|
||||
|
||||
g_assert (gtk_search_bar_get_key_capture_widget (GTK_SEARCH_BAR (searchbar)) == NULL);
|
||||
|
||||
g_object_unref (searchbar);
|
||||
g_object_unref (button);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv);
|
||||
|
||||
g_test_add_func ("/searchbar/capture-widget-destroy", capture_widget_destroy);
|
||||
g_test_add_func ("/searchbar/capture-widget-unset", capture_widget_unset);
|
||||
|
||||
return g_test_run();
|
||||
}
|
Loading…
Reference in New Issue
Block a user