tests/Makefile.am tests/autotestfilechooser.c tests/buildertest.c
2008-06-18 Michael Natterer <mitch@imendio.com> * tests/Makefile.am * tests/autotestfilechooser.c * tests/buildertest.c * tests/defaultvaluetest.c * tests/floatingtest.c * tests/objecttests.c * tests/pixbuf-init.c * tests/textbuffertest.c: remove unit tests here... * gtk/tests/Makefile.am * gtk/tests/builder.c * gtk/tests/defaultvalue.c * gtk/tests/filechooser.c * gtk/tests/floating.c * gtk/tests/object.c * gtk/tests/pixbuf-init.c * gtk/tests/textbuffer.c: ...and add them here. svn path=/trunk/; revision=20450
This commit is contained in:
committed by
Michael Natterer
parent
67c6c28fe0
commit
d5565f5b63
@ -1,42 +1,73 @@
|
||||
include $(top_srcdir)/Makefile.decl
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)/gdk \
|
||||
-I$(top_srcdir)/gdk \
|
||||
-DGDK_PIXBUF_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGTK_DISABLE_DEPRECATED \
|
||||
$(GTK_DEBUG_FLAGS) \
|
||||
$(GTK_DEP_CFLAGS)
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)/gdk \
|
||||
-I$(top_srcdir)/gdk \
|
||||
-DGDK_PIXBUF_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGTK_DISABLE_DEPRECATED \
|
||||
$(GTK_DEBUG_FLAGS) \
|
||||
$(GTK_DEP_CFLAGS)
|
||||
|
||||
DEPS = $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
||||
$(top_builddir)/gdk/$(gdktargetlib) \
|
||||
$(top_builddir)/gtk/$(gtktargetlib)
|
||||
DEPS = \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
||||
$(top_builddir)/gdk/$(gdktargetlib) \
|
||||
$(top_builddir)/gtk/$(gtktargetlib)
|
||||
|
||||
progs_ldadd = $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
||||
$(top_builddir)/gdk/$(gdktargetlib) \
|
||||
$(top_builddir)/gtk/$(gtktargetlib)
|
||||
progs_ldadd = \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
||||
$(top_builddir)/gdk/$(gdktargetlib) \
|
||||
$(top_builddir)/gtk/$(gtktargetlib)
|
||||
|
||||
noinst_PROGRAMS = $(TEST_PROGS)
|
||||
|
||||
|
||||
TEST_PROGS += testing
|
||||
testing_SOURCES = testing.c
|
||||
testing_LDADD = $(progs_ldadd)
|
||||
TEST_PROGS += testing
|
||||
testing_SOURCES = testing.c
|
||||
testing_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += liststore
|
||||
liststore_SOURCES = liststore.c
|
||||
liststore_LDADD = $(progs_ldadd)
|
||||
TEST_PROGS += liststore
|
||||
liststore_SOURCES = liststore.c
|
||||
liststore_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += treestore
|
||||
treestore_SOURCES = treestore.c
|
||||
treestore_LDADD = $(progs_ldadd)
|
||||
TEST_PROGS += treestore
|
||||
treestore_SOURCES = treestore.c
|
||||
treestore_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += treeview-scrolling
|
||||
treeview_scrolling_SOURCES = treeview-scrolling.c
|
||||
treeview_scrolling_LDADD = $(progs_ldadd)
|
||||
TEST_PROGS += treeview-scrolling
|
||||
treeview_scrolling_SOURCES = treeview-scrolling.c
|
||||
treeview_scrolling_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += recentmanager
|
||||
recentmanager_SOURCES = recentmanager.c
|
||||
recentmanager_LDADD = $(progs_ldadd)
|
||||
TEST_PROGS += recentmanager
|
||||
recentmanager_SOURCES = recentmanager.c
|
||||
recentmanager_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += floating
|
||||
floating_SOURCES = floating.c
|
||||
floating_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += object
|
||||
object_SOURCES = object.c pixbuf-init.c
|
||||
object_LDADD = $(progs_ldadd)
|
||||
|
||||
# this doesn't work in make distcheck, since it doesn't
|
||||
# find file-chooser-test-dir
|
||||
# TEST_PROGS += filechooser
|
||||
filechooser_SOURCES = filechooser.c pixbuf-init.c
|
||||
filechooser_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += builder
|
||||
builder_SOURCES = builder.c
|
||||
builder_LDADD = $(progs_ldadd)
|
||||
builder_LDFLAGS = -export-dynamic
|
||||
|
||||
if OS_UNIX
|
||||
TEST_PROGS += defaultvalue
|
||||
endif
|
||||
defaultvalue_SOURCES = defaultvalue.c pixbuf-init.c
|
||||
defaultvalue_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += textbuffer
|
||||
textbuffer_SOURCES = textbuffer.c pixbuf-init.c
|
||||
textbuffer_LDADD = $(progs_ldadd)
|
||||
|
||||
2213
gtk/tests/builder.c
Normal file
2213
gtk/tests/builder.c
Normal file
File diff suppressed because it is too large
Load Diff
341
gtk/tests/defaultvalue.c
Normal file
341
gtk/tests/defaultvalue.c
Normal file
@ -0,0 +1,341 @@
|
||||
/* Gtk+ default value tests
|
||||
* Copyright (C) 2007 Christian Persch
|
||||
* 2007 Johan Dahlin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
#define GTK_ENABLE_BROKEN
|
||||
#include <string.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkunixprint.h>
|
||||
|
||||
static void
|
||||
check_property (const char *output,
|
||||
GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
GValue default_value = { 0, };
|
||||
char *v, *dv, *msg;
|
||||
|
||||
if (g_param_value_defaults (pspec, value))
|
||||
return;
|
||||
|
||||
g_value_init (&default_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
g_param_value_set_default (pspec, &default_value);
|
||||
|
||||
v = g_strdup_value_contents (value);
|
||||
dv = g_strdup_value_contents (&default_value);
|
||||
|
||||
msg = g_strdup_printf ("%s %s.%s: %s != %s\n",
|
||||
output,
|
||||
g_type_name (pspec->owner_type),
|
||||
pspec->name,
|
||||
dv, v);
|
||||
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__,
|
||||
G_STRFUNC, msg);
|
||||
g_free (msg);
|
||||
|
||||
g_free (v);
|
||||
g_free (dv);
|
||||
g_value_unset (&default_value);
|
||||
}
|
||||
|
||||
static void
|
||||
test_type (gconstpointer data)
|
||||
{
|
||||
GObjectClass *klass;
|
||||
GObject *instance;
|
||||
GParamSpec **pspecs;
|
||||
guint n_pspecs, i;
|
||||
GType type;
|
||||
|
||||
type = * (GType *) data;
|
||||
|
||||
if (!G_TYPE_IS_CLASSED (type))
|
||||
return;
|
||||
|
||||
if (G_TYPE_IS_ABSTRACT (type))
|
||||
return;
|
||||
|
||||
if (!g_type_is_a (type, G_TYPE_OBJECT))
|
||||
return;
|
||||
|
||||
/* These can't be freely constructed/destroyed */
|
||||
if (g_type_is_a (type, GTK_TYPE_PRINT_JOB) ||
|
||||
g_type_is_a (type, GDK_TYPE_PIXBUF_LOADER) ||
|
||||
g_type_is_a (type, gdk_pixbuf_simple_anim_iter_get_type ()))
|
||||
return;
|
||||
|
||||
/* The gtk_arg compat wrappers can't set up default values */
|
||||
if (g_type_is_a (type, GTK_TYPE_CLIST) ||
|
||||
g_type_is_a (type, GTK_TYPE_CTREE) ||
|
||||
g_type_is_a (type, GTK_TYPE_LIST) ||
|
||||
g_type_is_a (type, GTK_TYPE_TIPS_QUERY))
|
||||
return;
|
||||
|
||||
klass = g_type_class_ref (type);
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_SETTINGS))
|
||||
instance = g_object_ref (gtk_settings_get_default ());
|
||||
else if (g_type_is_a (type, GDK_TYPE_PANGO_RENDERER))
|
||||
instance = g_object_ref (gdk_pango_renderer_get_default (gdk_screen_get_default ()));
|
||||
else if (g_type_is_a (type, GDK_TYPE_PIXMAP))
|
||||
instance = g_object_ref (gdk_pixmap_new (NULL, 1, 1, 1));
|
||||
else if (g_type_is_a (type, GDK_TYPE_COLORMAP))
|
||||
instance = g_object_ref (gdk_colormap_new (gdk_visual_get_best (), TRUE));
|
||||
else if (g_type_is_a (type, GDK_TYPE_WINDOW))
|
||||
{
|
||||
GdkWindowAttr attributes;
|
||||
attributes.window_type = GDK_WINDOW_TEMP;
|
||||
instance = g_object_ref (gdk_window_new (NULL, &attributes, 0));
|
||||
}
|
||||
else
|
||||
instance = g_object_new (type, NULL);
|
||||
|
||||
if (g_type_is_a (type, G_TYPE_INITIALLY_UNOWNED))
|
||||
g_object_ref_sink (instance);
|
||||
|
||||
pspecs = g_object_class_list_properties (klass, &n_pspecs);
|
||||
for (i = 0; i < n_pspecs; ++i)
|
||||
{
|
||||
GParamSpec *pspec = pspecs[i];
|
||||
GValue value = { 0, };
|
||||
|
||||
if (pspec->owner_type != type)
|
||||
continue;
|
||||
|
||||
if ((pspec->flags & G_PARAM_READABLE) == 0)
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GDK_TYPE_DISPLAY_MANAGER) &&
|
||||
(strcmp (pspec->name, "default-display") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GDK_TYPE_PANGO_RENDERER) &&
|
||||
(strcmp (pspec->name, "screen") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_ABOUT_DIALOG) &&
|
||||
(strcmp (pspec->name, "program-name") == 0))
|
||||
continue;
|
||||
|
||||
/* These are set to the current date */
|
||||
if (g_type_is_a (type, GTK_TYPE_CALENDAR) &&
|
||||
(strcmp (pspec->name, "year") == 0 ||
|
||||
strcmp (pspec->name, "month") == 0 ||
|
||||
strcmp (pspec->name, "day") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_CELL_RENDERER_TEXT) &&
|
||||
(strcmp (pspec->name, "background-gdk") == 0 ||
|
||||
strcmp (pspec->name, "foreground-gdk") == 0 ||
|
||||
strcmp (pspec->name, "font") == 0 ||
|
||||
strcmp (pspec->name, "font-desc") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_CELL_VIEW) &&
|
||||
(strcmp (pspec->name, "background-gdk") == 0 ||
|
||||
strcmp (pspec->name, "foreground-gdk") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_COLOR_BUTTON) &&
|
||||
strcmp (pspec->name, "color") == 0)
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_COLOR_SELECTION) &&
|
||||
strcmp (pspec->name, "current-color") == 0)
|
||||
continue;
|
||||
|
||||
/* Gets set to the cwd */
|
||||
if (g_type_is_a (type, GTK_TYPE_FILE_SELECTION) &&
|
||||
strcmp (pspec->name, "filename") == 0)
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_FONT_SELECTION) &&
|
||||
strcmp (pspec->name, "font") == 0)
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_LAYOUT) &&
|
||||
(strcmp (pspec->name, "hadjustment") == 0 ||
|
||||
strcmp (pspec->name, "vadjustment") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_MESSAGE_DIALOG) &&
|
||||
strcmp (pspec->name, "image") == 0)
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_PRINT_OPERATION) &&
|
||||
strcmp (pspec->name, "job-name") == 0)
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_PRINT_UNIX_DIALOG) &&
|
||||
(strcmp (pspec->name, "page-setup") == 0 ||
|
||||
strcmp (pspec->name, "print-settings") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_PROGRESS_BAR) &&
|
||||
strcmp (pspec->name, "adjustment") == 0)
|
||||
continue;
|
||||
|
||||
/* filename value depends on $HOME */
|
||||
if (g_type_is_a (type, GTK_TYPE_RECENT_MANAGER) &&
|
||||
(strcmp (pspec->name, "filename") == 0 ||
|
||||
strcmp (pspec->name, "size") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_SCALE_BUTTON) &&
|
||||
strcmp (pspec->name, "adjustment") == 0)
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_SCROLLED_WINDOW) &&
|
||||
(strcmp (pspec->name, "hadjustment") == 0 ||
|
||||
strcmp (pspec->name, "vadjustment") == 0))
|
||||
continue;
|
||||
|
||||
/* these defaults come from XResources */
|
||||
if (g_type_is_a (type, GTK_TYPE_SETTINGS) &&
|
||||
strncmp (pspec->name, "gtk-xft-", 8) == 0)
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_SETTINGS) &&
|
||||
(strcmp (pspec->name, "color-hash") == 0 ||
|
||||
strcmp (pspec->name, "gtk-cursor-theme-name") == 0 ||
|
||||
strcmp (pspec->name, "gtk-cursor-theme-size") == 0 ||
|
||||
strcmp (pspec->name, "gtk-double-click-time") == 0 ||
|
||||
strcmp (pspec->name, "gtk-file-chooser-backend") == 0 ||
|
||||
strcmp (pspec->name, "gtk-icon-theme-name") == 0 ||
|
||||
strcmp (pspec->name, "gtk-fallback-icon-theme") == 0 ||
|
||||
strcmp (pspec->name, "gtk-key-theme-name") == 0 ||
|
||||
strcmp (pspec->name, "gtk-theme-name") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_SPIN_BUTTON) &&
|
||||
(strcmp (pspec->name, "adjustment") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_STATUS_ICON) &&
|
||||
(strcmp (pspec->name, "size") == 0 ||
|
||||
strcmp (pspec->name, "screen") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_TEXT_BUFFER) &&
|
||||
(strcmp (pspec->name, "tag-table") == 0 ||
|
||||
strcmp (pspec->name, "copy-target-list") == 0 ||
|
||||
strcmp (pspec->name, "paste-target-list") == 0))
|
||||
continue;
|
||||
|
||||
/* language depends on the current locale */
|
||||
if (g_type_is_a (type, GTK_TYPE_TEXT_TAG) &&
|
||||
(strcmp (pspec->name, "background-gdk") == 0 ||
|
||||
strcmp (pspec->name, "foreground-gdk") == 0 ||
|
||||
strcmp (pspec->name, "language") == 0 ||
|
||||
strcmp (pspec->name, "font") == 0 ||
|
||||
strcmp (pspec->name, "font-desc") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_TEXT) &&
|
||||
(strcmp (pspec->name, "hadjustment") == 0 ||
|
||||
strcmp (pspec->name, "vadjustment") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_TEXT_VIEW) &&
|
||||
strcmp (pspec->name, "buffer") == 0)
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_TREE_VIEW) &&
|
||||
(strcmp (pspec->name, "hadjustment") == 0 ||
|
||||
strcmp (pspec->name, "vadjustment") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_VIEWPORT) &&
|
||||
(strcmp (pspec->name, "hadjustment") == 0 ||
|
||||
strcmp (pspec->name, "vadjustment") == 0))
|
||||
continue;
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_WIDGET) &&
|
||||
(strcmp (pspec->name, "name") == 0 ||
|
||||
strcmp (pspec->name, "screen") == 0 ||
|
||||
strcmp (pspec->name, "style") == 0))
|
||||
continue;
|
||||
|
||||
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
g_object_get_property (instance, pspec->name, &value);
|
||||
check_property ("Property", pspec, &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
g_free (pspecs);
|
||||
|
||||
if (g_type_is_a (type, GTK_TYPE_WIDGET))
|
||||
{
|
||||
pspecs = gtk_widget_class_list_style_properties (GTK_WIDGET_CLASS (klass), &n_pspecs);
|
||||
|
||||
for (i = 0; i < n_pspecs; ++i)
|
||||
{
|
||||
GParamSpec *pspec = pspecs[i];
|
||||
GValue value = { 0, };
|
||||
|
||||
if (pspec->owner_type != type)
|
||||
continue;
|
||||
|
||||
if ((pspec->flags & G_PARAM_READABLE) == 0)
|
||||
continue;
|
||||
|
||||
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
gtk_widget_style_get_property (GTK_WIDGET (instance), pspec->name, &value);
|
||||
check_property ("Style property", pspec, &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
g_free (pspecs);
|
||||
}
|
||||
|
||||
if (g_type_is_a (type, GDK_TYPE_WINDOW))
|
||||
gdk_window_destroy (GDK_WINDOW (instance));
|
||||
else
|
||||
g_object_unref (instance);
|
||||
|
||||
g_type_class_unref (klass);
|
||||
}
|
||||
|
||||
extern void pixbuf_init (void);
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
const GType *otypes;
|
||||
guint i;
|
||||
|
||||
gtk_test_init (&argc, &argv);
|
||||
pixbuf_init ();
|
||||
gtk_test_register_all_types();
|
||||
|
||||
otypes = gtk_test_list_all_types (NULL);
|
||||
for (i = 0; otypes[i]; i++)
|
||||
{
|
||||
gchar *testname;
|
||||
|
||||
testname = g_strdup_printf ("/Default Values/%s",
|
||||
g_type_name (otypes[i]));
|
||||
g_test_add_data_func (testname,
|
||||
&otypes[i],
|
||||
test_type);
|
||||
g_free (testname);
|
||||
}
|
||||
|
||||
return g_test_run();
|
||||
}
|
||||
1093
gtk/tests/filechooser.c
Normal file
1093
gtk/tests/filechooser.c
Normal file
File diff suppressed because it is too large
Load Diff
71
gtk/tests/floating.c
Normal file
71
gtk/tests/floating.c
Normal file
@ -0,0 +1,71 @@
|
||||
/* floatingtest.c - test floating flag uses
|
||||
* Copyright (C) 2005 Tim Janik
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
#include "../gtk/gtk.h"
|
||||
|
||||
static gboolean destroyed = FALSE;
|
||||
static void
|
||||
destroy (void)
|
||||
{
|
||||
destroyed = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
floating_tests (void)
|
||||
{
|
||||
GtkWidget *widget = g_object_new (GTK_TYPE_LABEL, NULL);
|
||||
g_object_connect (widget, "signal::destroy", destroy, NULL, NULL);
|
||||
|
||||
g_assert (GTK_OBJECT_FLOATING (widget));
|
||||
g_assert (g_object_is_floating (widget));
|
||||
|
||||
GTK_OBJECT_UNSET_FLAGS (widget, GTK_FLOATING);
|
||||
g_assert (!GTK_OBJECT_FLOATING (widget));
|
||||
g_assert (!g_object_is_floating (widget));
|
||||
|
||||
GTK_OBJECT_SET_FLAGS (widget, GTK_FLOATING);
|
||||
g_assert (GTK_OBJECT_FLOATING (widget));
|
||||
g_assert (g_object_is_floating (widget));
|
||||
|
||||
g_object_ref_sink (widget);
|
||||
g_assert (!GTK_OBJECT_FLOATING (widget));
|
||||
g_assert (!g_object_is_floating (widget));
|
||||
|
||||
g_object_force_floating (G_OBJECT (widget));
|
||||
g_assert (GTK_OBJECT_FLOATING (widget));
|
||||
g_assert (g_object_is_floating (widget));
|
||||
|
||||
g_object_ref (widget);
|
||||
gtk_object_sink (GTK_OBJECT (widget));
|
||||
g_assert (!GTK_OBJECT_FLOATING (widget));
|
||||
g_assert (!g_object_is_floating (widget));
|
||||
|
||||
g_assert (!destroyed);
|
||||
g_object_unref (widget);
|
||||
g_assert (destroyed);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv);
|
||||
g_test_add_func ("/floatingtest", floating_tests);
|
||||
return g_test_run();
|
||||
}
|
||||
358
gtk/tests/object.c
Normal file
358
gtk/tests/object.c
Normal file
@ -0,0 +1,358 @@
|
||||
/* Gtk+ object tests
|
||||
* Copyright (C) 2007 Imendio AB
|
||||
* Authors: Tim Janik
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
|
||||
/* --- helper macros for property value generation --- */
|
||||
/* dvalue=+0: generate minimum value
|
||||
* dvalue=.x: generate value within value range proportional to x.
|
||||
* dvalue=+1: generate maximum value
|
||||
* dvalue=-1: generate random value within value range
|
||||
* dvalue=+2: initialize value from default_value
|
||||
*/
|
||||
#define ASSIGN_VALUE(__g_value_set_func, __value, PSPECTYPE, __pspec, __default_value, __minimum, __maximum, __dvalue) do { \
|
||||
PSPECTYPE __p = (PSPECTYPE) __pspec; \
|
||||
__g_value_set_func (__value, SELECT_VALUE (__dvalue, __p->__default_value, __p->__minimum, __p->__maximum)); \
|
||||
} while (0)
|
||||
#define SELECT_VALUE(__dvalue, __default_value, __minimum, __maximum) ( \
|
||||
__dvalue >= 0 && __dvalue <= 1 ? __minimum * (1 - __dvalue) + __dvalue * __maximum : \
|
||||
__dvalue <= -1 ? g_test_rand_double_range (__minimum, __maximum) : \
|
||||
__default_value)
|
||||
#define SELECT_NAME(__dvalue) ( \
|
||||
__dvalue == 0 ? "minimum" : \
|
||||
__dvalue == 1 ? "maximum" : \
|
||||
__dvalue >= +2 ? "default" : \
|
||||
__dvalue == 0.5 ? "medium" : \
|
||||
__dvalue > 0 && __dvalue < 1 ? "fractional" : \
|
||||
"random")
|
||||
#define MATCH_ANY_VALUE ((void*) 0xf1874c23)
|
||||
|
||||
/* --- property blacklists --- */
|
||||
typedef struct {
|
||||
const char *type_name;
|
||||
const char *name;
|
||||
gconstpointer value;
|
||||
} IgnoreProperty;
|
||||
static const IgnoreProperty*
|
||||
list_ignore_properties (gboolean buglist)
|
||||
{
|
||||
/* currently untestable properties */
|
||||
static const IgnoreProperty ignore_properties[] = {
|
||||
{ "GtkContainer", "child", NULL, }, /* needs working child widget */
|
||||
{ "GtkRadioMenuItem", "group", NULL, }, /* needs working sibling */
|
||||
{ "GtkWidget", "parent", NULL, }, /* needs working parent widget */
|
||||
{ "GtkCList", "selection-mode", (void*) GTK_SELECTION_NONE, },
|
||||
{ "GtkWidget", "has-default", (void*) TRUE, }, /* conflicts with toplevel-less widgets */
|
||||
{ "GtkWidget", "screen", NULL, },
|
||||
{ "GtkWindow", "type-hint", (void*) GDK_WINDOW_TYPE_HINT_DND, }, /* conflicts with ::visible=TRUE */
|
||||
{ "GtkCellView", "background", (void*) "", }, /* "" is not a valid background color */
|
||||
{ "GtkColorButton", "color", (void*) NULL, }, /* not a valid boxed color */
|
||||
{ "GtkInputDialog", "has-separator", (void*) MATCH_ANY_VALUE, }, /* property disabled */
|
||||
{ "GtkMessageDialog", "has-separator", (void*) MATCH_ANY_VALUE, }, /* property disabled */
|
||||
{ "GtkFontSelectionDialog", "has-separator", (void*) MATCH_ANY_VALUE, }, /* property disabled */
|
||||
{ "GtkColorSelectionDialog","has-separator", (void*) MATCH_ANY_VALUE, }, /* property disabled */
|
||||
{ "GtkColorSelection", "child", NULL, },
|
||||
{ "GtkColorSelection", "current-color", (void*) NULL, }, /* not a valid boxed color */
|
||||
{ "GtkComboBox", "row-span-column", (void*) MATCH_ANY_VALUE }, /* GtkComboBoxEntry needs a tree model for this */
|
||||
{ "GtkComboBox", "column-span-column", (void*) MATCH_ANY_VALUE }, /* GtkComboBoxEntry needs a tree model for this */
|
||||
{ "GtkComboBoxEntry", "text-column", (void*) MATCH_ANY_VALUE }, /* GtkComboBoxEntry needs a tree model for this */
|
||||
{ "GtkFileChooserButton", "select-multiple", (void*) MATCH_ANY_VALUE }, /* property disabled */
|
||||
{ "GtkFileChooserButton", "action", (void*) GTK_FILE_CHOOSER_ACTION_SAVE },
|
||||
{ "GtkFileChooserButton", "action", (void*) GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER },
|
||||
{ "GtkFileChooserWidget", "select-multiple", (void*) 0x1 }, /* property conflicts */
|
||||
{ "GtkFileChooserDialog", "select-multiple", (void*) MATCH_ANY_VALUE }, /* property disabled */
|
||||
{ "GtkRecentChooserMenu", "select-multiple", (void*) MATCH_ANY_VALUE }, /* property disabled */
|
||||
{ "GtkTextView", "overwrite", (void*) MATCH_ANY_VALUE }, /* needs text buffer */
|
||||
{ "GtkToolbar", "icon-size", (void*) GTK_ICON_SIZE_INVALID },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
/* properties suspected to be Gdk/Gtk+ bugs */
|
||||
static const IgnoreProperty bug_properties[] = {
|
||||
{ "GtkMessageDialog", "image", NULL, }, /* FIXME: should accept NULL images */
|
||||
{ "GtkOptionMenu", "menu", NULL, }, /* FIXME: should accept NULL menus */
|
||||
{ "GtkComboBox", "active", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL model bug */
|
||||
{ "GtkComboBoxEntry", "text-column", (void*) 0xffffffff }, /* FIXME: triggers signedness bug */
|
||||
{ "GtkCTree", "indent", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers signedness bug */
|
||||
{ "GtkCTree", "spacing", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers signedness bug */
|
||||
{ "GtkCurve", "curve-type", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers OOM */
|
||||
{ "GtkCurve", "min-x", (void*) 0x80000000 }, /* FIXME: triggers coordinate OOB */
|
||||
{ "GtkCurve", "min-y", (void*) 0x80000000 }, /* FIXME: triggers coordinate OOB */
|
||||
{ "GtkCurve", "max-x", (void*) 0x80000000 }, /* FIXME: triggers coordinate OOB */
|
||||
{ "GtkCurve", "max-y", (void*) 0x80000000 }, /* FIXME: triggers coordinate OOB */
|
||||
{ "GtkFileChooserButton", "local-only", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL path assertion */
|
||||
{ "GtkFileChooserDialog", "local-only", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL path assertion */
|
||||
{ "GtkFileChooserDialog", "action", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers closure->ref_count assertion */
|
||||
{ "GtkFileChooserDialog", "visible", (void*) TRUE }, /* FIXME: triggers gtk_window_resize assertion */
|
||||
{ "GtkFileChooserWidget", "local-only", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL path assertion */
|
||||
{ "GtkFontSelection", "font-name", (void*) MATCH_ANY_VALUE }, /* FIXME: requires non-NULL GdkScreen */
|
||||
{ "GtkInvisible", "has-focus", (void*) TRUE }, /* FIXME: triggers invalid window cast */
|
||||
{ "GtkInvisible", "is-focus", (void*) TRUE }, /* FIXME: triggers invalid window cast */
|
||||
{ "GtkMenu", "tearoff-state", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL widget cast */
|
||||
{ "GtkProgress", "activity-mode", (void*) TRUE }, /* FIXME: segfaults */
|
||||
{ "GtkScaleButton", "adjustment", NULL, }, /* FIXME: should accept NULL adjustments */
|
||||
{ "GtkStatusbar", "sensitive", (void*) FALSE }, /* FIXME: check if widget is realize */
|
||||
{ "GtkTable", "n-rows", (void*) MATCH_ANY_VALUE }, /* FIXME: fix property minimum/maximum */
|
||||
{ "GtkTable", "n-columns", (void*) MATCH_ANY_VALUE }, /* FIXME: fix property minimum/maximum */
|
||||
{ "GtkText", "text-position", (void*) MATCH_ANY_VALUE }, /* FIXME: segfaults, fix property minimum/maximum */
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
if (buglist)
|
||||
return bug_properties;
|
||||
else
|
||||
return ignore_properties;
|
||||
}
|
||||
|
||||
/* --- test functions --- */
|
||||
static void
|
||||
pspec_select_value (GParamSpec *pspec,
|
||||
GValue *value,
|
||||
double dvalue)
|
||||
{
|
||||
/* generate a value suitable for pspec */
|
||||
if (G_IS_PARAM_SPEC_CHAR (pspec))
|
||||
ASSIGN_VALUE (g_value_set_char, value, GParamSpecChar*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_UCHAR (pspec))
|
||||
ASSIGN_VALUE (g_value_set_uchar, value, GParamSpecUChar*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_INT (pspec))
|
||||
ASSIGN_VALUE (g_value_set_int, value, GParamSpecInt*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_UINT (pspec))
|
||||
ASSIGN_VALUE (g_value_set_uint, value, GParamSpecUInt*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_LONG (pspec))
|
||||
ASSIGN_VALUE (g_value_set_long, value, GParamSpecLong*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_ULONG (pspec))
|
||||
ASSIGN_VALUE (g_value_set_ulong, value, GParamSpecULong*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_INT64 (pspec))
|
||||
ASSIGN_VALUE (g_value_set_int64, value, GParamSpecInt64*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_UINT64 (pspec))
|
||||
ASSIGN_VALUE (g_value_set_uint64, value, GParamSpecUInt64*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_FLOAT (pspec))
|
||||
ASSIGN_VALUE (g_value_set_float, value, GParamSpecFloat*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE (pspec))
|
||||
ASSIGN_VALUE (g_value_set_double, value, GParamSpecDouble*, pspec, default_value, minimum, maximum, dvalue);
|
||||
else if (G_IS_PARAM_SPEC_BOOLEAN (pspec))
|
||||
g_value_set_boolean (value, SELECT_VALUE (dvalue, ((GParamSpecBoolean*) pspec)->default_value, FALSE, TRUE));
|
||||
else if (G_IS_PARAM_SPEC_UNICHAR (pspec))
|
||||
g_value_set_uint (value, SELECT_VALUE (dvalue, ((GParamSpecUnichar*) pspec)->default_value, FALSE, TRUE));
|
||||
else if (G_IS_PARAM_SPEC_GTYPE (pspec))
|
||||
g_value_set_gtype (value, SELECT_VALUE ((int) dvalue, ((GParamSpecGType*) pspec)->is_a_type, 0, GTK_TYPE_WIDGET));
|
||||
else if (G_IS_PARAM_SPEC_STRING (pspec))
|
||||
{
|
||||
GParamSpecString *sspec = (GParamSpecString*) pspec;
|
||||
if (dvalue >= +2)
|
||||
g_value_set_string (value, sspec->default_value);
|
||||
if (dvalue > 0 && sspec->cset_first && sspec->cset_nth)
|
||||
g_value_take_string (value, g_strdup_printf ("%c%c", sspec->cset_first[0], sspec->cset_nth[0]));
|
||||
else /* if (sspec->ensure_non_null) */
|
||||
g_value_set_string (value, "");
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_ENUM (pspec))
|
||||
{
|
||||
GParamSpecEnum *espec = (GParamSpecEnum*) pspec;
|
||||
if (dvalue >= +2)
|
||||
g_value_set_enum (value, espec->default_value);
|
||||
if (dvalue >= 0 && dvalue <= 1)
|
||||
g_value_set_enum (value, espec->enum_class->values[(int) ((espec->enum_class->n_values - 1) * dvalue)].value);
|
||||
else if (dvalue <= -1)
|
||||
g_value_set_enum (value, espec->enum_class->values[g_test_rand_int_range (0, espec->enum_class->n_values)].value);
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_FLAGS (pspec))
|
||||
{
|
||||
GParamSpecFlags *fspec = (GParamSpecFlags*) pspec;
|
||||
if (dvalue >= +2)
|
||||
g_value_set_flags (value, fspec->default_value);
|
||||
if (dvalue >= 0 && dvalue <= 1)
|
||||
g_value_set_flags (value, fspec->flags_class->values[(int) ((fspec->flags_class->n_values - 1) * dvalue)].value);
|
||||
else if (dvalue <= -1)
|
||||
g_value_set_flags (value, fspec->flags_class->values[g_test_rand_int_range (0, fspec->flags_class->n_values)].value);
|
||||
}
|
||||
/* unimplemented:
|
||||
* G_IS_PARAM_SPEC_PARAM
|
||||
* G_IS_PARAM_SPEC_BOXED
|
||||
* G_IS_PARAM_SPEC_POINTER
|
||||
* G_IS_PARAM_SPEC_VALUE_ARRAY
|
||||
* G_IS_PARAM_SPEC_OBJECT
|
||||
*/
|
||||
}
|
||||
|
||||
static gpointer
|
||||
value_as_pointer (GValue *value)
|
||||
{
|
||||
if (g_value_fits_pointer (value))
|
||||
return g_value_peek_pointer (value);
|
||||
if (G_VALUE_HOLDS_BOOLEAN (value))
|
||||
return (void*) g_value_get_boolean (value);
|
||||
if (G_VALUE_HOLDS_CHAR (value))
|
||||
return (void*) (gssize) g_value_get_char (value);
|
||||
if (G_VALUE_HOLDS_UCHAR (value))
|
||||
return (void*) (gsize) g_value_get_uchar (value);
|
||||
if (G_VALUE_HOLDS_INT (value))
|
||||
return (void*) g_value_get_int (value);
|
||||
if (G_VALUE_HOLDS_UINT (value))
|
||||
return (void*) g_value_get_uint (value);
|
||||
if (G_VALUE_HOLDS_LONG (value))
|
||||
return (void*) g_value_get_long (value);
|
||||
if (G_VALUE_HOLDS_ULONG (value))
|
||||
return (void*) g_value_get_ulong (value);
|
||||
if (G_VALUE_HOLDS_FLOAT (value))
|
||||
return (void*) (gssize) g_value_get_float (value);
|
||||
if (G_VALUE_HOLDS_DOUBLE (value))
|
||||
return (void*) (gssize) g_value_get_double (value);
|
||||
if (G_VALUE_HOLDS_ENUM (value))
|
||||
return (void*) (gssize) g_value_get_enum (value);
|
||||
if (G_VALUE_HOLDS_FLAGS (value))
|
||||
return (void*) (gsize) g_value_get_flags (value);
|
||||
return (void*) 0x1373babe;
|
||||
}
|
||||
|
||||
static void
|
||||
object_test_property (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
double dvalue)
|
||||
{
|
||||
/* test setting of a normal writable property */
|
||||
if (pspec->flags & G_PARAM_WRITABLE &&
|
||||
!(pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)))
|
||||
{
|
||||
GValue value = { 0, };
|
||||
guint i;
|
||||
const IgnoreProperty *ignore_properties;
|
||||
/* select value to set */
|
||||
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
pspec_select_value (pspec, &value, dvalue);
|
||||
/* ignore untestable properties */
|
||||
ignore_properties = list_ignore_properties (FALSE);
|
||||
for (i = 0; ignore_properties[i].name; i++)
|
||||
if (g_type_is_a (G_OBJECT_TYPE (object), g_type_from_name (ignore_properties[i].type_name)) &&
|
||||
strcmp (pspec->name, ignore_properties[i].name) == 0 &&
|
||||
(MATCH_ANY_VALUE == ignore_properties[i].value ||
|
||||
value_as_pointer (&value) == ignore_properties[i].value ||
|
||||
(G_VALUE_HOLDS_STRING (&value) &&
|
||||
strcmp (g_value_get_string (&value), ignore_properties[i].value) == 0)))
|
||||
break;
|
||||
/* ignore known property bugs if not testing thoroughly */
|
||||
if (ignore_properties[i].name == NULL && !g_test_thorough())
|
||||
{
|
||||
ignore_properties = list_ignore_properties (TRUE);
|
||||
for (i = 0; ignore_properties[i].name; i++)
|
||||
if (g_type_is_a (G_OBJECT_TYPE (object), g_type_from_name (ignore_properties[i].type_name)) &&
|
||||
strcmp (pspec->name, ignore_properties[i].name) == 0 &&
|
||||
(MATCH_ANY_VALUE == ignore_properties[i].value ||
|
||||
value_as_pointer (&value) == ignore_properties[i].value ||
|
||||
(G_VALUE_HOLDS_STRING (&value) &&
|
||||
strcmp (g_value_get_string (&value), ignore_properties[i].value) == 0)))
|
||||
break;
|
||||
}
|
||||
/* assign unignored properties */
|
||||
if (ignore_properties[i].name == NULL)
|
||||
{
|
||||
if (g_test_verbose())
|
||||
g_print ("PropertyTest: %s::%s := (%s value (%s): %p)\n",
|
||||
g_type_name (G_OBJECT_TYPE (object)), pspec->name,
|
||||
SELECT_NAME (dvalue), g_type_name (G_VALUE_TYPE (&value)),
|
||||
value_as_pointer (&value));
|
||||
g_object_set_property (object, pspec->name, &value);
|
||||
}
|
||||
/* cleanups */
|
||||
g_value_unset (&value);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
widget_test_properties (GtkWidget *widget,
|
||||
double dvalue)
|
||||
{
|
||||
/* try setting all possible properties, according to dvalue */
|
||||
guint i, n_pspecs = 0;
|
||||
GParamSpec **pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (widget), &n_pspecs);
|
||||
for (i = 0; i < n_pspecs; i++)
|
||||
{
|
||||
GParamSpec *pspec = pspecs[i];
|
||||
if (pspec->flags & G_PARAM_WRITABLE &&
|
||||
!(pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)))
|
||||
object_test_property (G_OBJECT (widget), pspecs[i], dvalue);
|
||||
}
|
||||
g_free (pspecs);
|
||||
}
|
||||
|
||||
static void
|
||||
widget_fixups (GtkWidget *widget)
|
||||
{
|
||||
/* post-constructor for widgets that need additional settings to work correctly */
|
||||
if (GTK_IS_COMBO_BOX_ENTRY (widget))
|
||||
{
|
||||
GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
g_object_set (widget, "model", store, "text-column", 0, NULL);
|
||||
g_object_unref (store);
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "test text");
|
||||
}
|
||||
else if (GTK_IS_COMBO_BOX (widget))
|
||||
{
|
||||
GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
g_object_set (widget, "model", store, NULL);
|
||||
g_object_unref (store);
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "test text");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
widget_property_tests (gconstpointer test_data)
|
||||
{
|
||||
GType wtype = (GType) test_data;
|
||||
/* create widget */
|
||||
GtkWidget *widget = gtk_widget_new (wtype, NULL);
|
||||
g_object_ref_sink (widget);
|
||||
widget_fixups (widget);
|
||||
/* test property values */
|
||||
widget_test_properties (widget, +2); /* test default_value */
|
||||
widget_test_properties (widget, 0); /* test minimum */
|
||||
widget_test_properties (widget, 0.5); /* test medium */
|
||||
widget_test_properties (widget, 1); /* test maximum */
|
||||
widget_test_properties (widget, -1); /* test random value */
|
||||
/* cleanup */
|
||||
gtk_widget_destroy (widget);
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
extern void pixbuf_init (void);
|
||||
|
||||
/* --- main test program --- */
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
const GType *otypes;
|
||||
guint i;
|
||||
/* initialize test program */
|
||||
pixbuf_init ();
|
||||
gtk_test_init (&argc, &argv);
|
||||
gtk_test_register_all_types();
|
||||
/* install a property test for each widget type */
|
||||
otypes = gtk_test_list_all_types (NULL);
|
||||
for (i = 0; otypes[i]; i++)
|
||||
if (g_type_is_a (otypes[i], GTK_TYPE_WIDGET) &&
|
||||
G_TYPE_IS_OBJECT (otypes[i]) &&
|
||||
!G_TYPE_IS_ABSTRACT (otypes[i]))
|
||||
{
|
||||
gchar *testpath = g_strdup_printf ("/properties/%s", g_type_name (otypes[i]));
|
||||
g_test_add_data_func (testpath, (void*) otypes[i], widget_property_tests);
|
||||
g_free (testpath);
|
||||
}
|
||||
return g_test_run();
|
||||
}
|
||||
20
gtk/tests/pixbuf-init.c
Normal file
20
gtk/tests/pixbuf-init.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static gboolean
|
||||
file_exists (const char *filename)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
return stat (filename, &statbuf) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
pixbuf_init (void)
|
||||
{
|
||||
if (file_exists ("../../gdk-pixbuf/libpixbufloader-pnm.la"))
|
||||
g_setenv ("GDK_PIXBUF_MODULE_FILE", "../../gdk-pixbuf/gdk-pixbuf.loaders", TRUE);
|
||||
}
|
||||
1308
gtk/tests/textbuffer.c
Normal file
1308
gtk/tests/textbuffer.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user