summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2022-05-26 18:37:19 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2022-05-26 18:37:19 +0000
commit81fd75b4bb39349aaf709377abfeaf6ff420c3b4 (patch)
tree38cbfc7fe0b2202f89b4e60f7670a7b6b2fc7577 /tests
parentd1cb96b5e3bc0e557bd5f9134eca9e104befceaa (diff)
parent4e02be948b7761a56fb572aa8704643d24b3735c (diff)
downloadglib-81fd75b4bb39349aaf709377abfeaf6ff420c3b4.tar.gz
Merge branch 'move_gobject_tests' into 'main'
Moving gobject tests from tests/gobjects to gobjects/tests See merge request GNOME/glib!2550
Diffstat (limited to 'tests')
-rw-r--r--tests/gobject/accumulator.c307
-rw-r--r--tests/gobject/defaultiface.c199
-rw-r--r--tests/gobject/deftype.c59
-rw-r--r--tests/gobject/dynamictype.c175
-rw-r--r--tests/gobject/meson.build42
-rw-r--r--tests/gobject/override.c418
-rw-r--r--tests/gobject/references.c280
-rw-r--r--tests/gobject/signals.c134
-rw-r--r--tests/gobject/singleton.c84
-rw-r--r--tests/gobject/testmarshal.list4
-rw-r--r--tests/gobject/testmodule.c66
-rw-r--r--tests/gobject/testmodule.h55
12 files changed, 0 insertions, 1823 deletions
diff --git a/tests/gobject/accumulator.c b/tests/gobject/accumulator.c
deleted file mode 100644
index a41815113..000000000
--- a/tests/gobject/accumulator.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2001, 2003 Red Hat, Inc.
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "TestAccumulator"
-
-#undef G_DISABLE_ASSERT
-#undef G_DISABLE_CHECKS
-#undef G_DISABLE_CAST_CHECKS
-
-#include <string.h>
-
-#include <glib-object.h>
-
-#include "testmarshal.h"
-#include "testcommon.h"
-
-/* What this test tests is the behavior of signal accumulators
- * Two accumulators are tested:
- *
- * 1: A custom accumulator that appends the returned strings
- * 2: The standard g_signal_accumulator_true_handled that stops
- * emission on TRUE returns.
- */
-
-/*
- * TestObject, a parent class for TestObject
- */
-#define TEST_TYPE_OBJECT (test_object_get_type ())
-typedef struct _TestObject TestObject;
-typedef struct _TestObjectClass TestObjectClass;
-
-struct _TestObject
-{
- GObject parent_instance;
-};
-struct _TestObjectClass
-{
- GObjectClass parent_class;
-
- gchar* (*test_signal1) (TestObject *tobject,
- gint param);
- gboolean (*test_signal2) (TestObject *tobject,
- gint param);
- GVariant* (*test_signal3) (TestObject *tobject,
- gboolean *weak_ptr);
-};
-
-static GType test_object_get_type (void);
-
-static gboolean
-test_signal1_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer data)
-{
- const gchar *accu_string = g_value_get_string (return_accu);
- const gchar *new_string = g_value_get_string (handler_return);
- gchar *result_string;
-
- if (accu_string)
- result_string = g_strconcat (accu_string, new_string, NULL);
- else if (new_string)
- result_string = g_strdup (new_string);
- else
- result_string = NULL;
-
- g_value_set_string_take_ownership (return_accu, result_string);
-
- return TRUE;
-}
-
-static gchar *
-test_object_signal1_callback_before (TestObject *tobject,
- gint param,
- gpointer data)
-{
- return g_strdup ("<before>");
-}
-
-static gchar *
-test_object_real_signal1 (TestObject *tobject,
- gint param)
-{
- return g_strdup ("<default>");
-}
-
-static gchar *
-test_object_signal1_callback_after (TestObject *tobject,
- gint param,
- gpointer data)
-{
- return g_strdup ("<after>");
-}
-
-static gboolean
-test_object_signal2_callback_before (TestObject *tobject,
- gint param)
-{
- switch (param)
- {
- case 1: return TRUE;
- case 2: return FALSE;
- case 3: return FALSE;
- case 4: return FALSE;
- }
-
- g_assert_not_reached ();
- return FALSE;
-}
-
-static gboolean
-test_object_real_signal2 (TestObject *tobject,
- gint param)
-{
- switch (param)
- {
- case 1: g_assert_not_reached (); return FALSE;
- case 2: return TRUE;
- case 3: return FALSE;
- case 4: return FALSE;
- }
-
- g_assert_not_reached ();
- return FALSE;
-}
-
-static gboolean
-test_object_signal2_callback_after (TestObject *tobject,
- gint param)
-{
- switch (param)
- {
- case 1: g_assert_not_reached (); return FALSE;
- case 2: g_assert_not_reached (); return FALSE;
- case 3: return TRUE;
- case 4: return FALSE;
- }
-
- g_assert_not_reached ();
- return FALSE;
-}
-
-static gboolean
-test_signal3_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer data)
-{
- GVariant *variant;
-
- variant = g_value_get_variant (handler_return);
- g_assert (!g_variant_is_floating (variant));
-
- g_value_set_variant (return_accu, variant);
-
- return variant == NULL;
-}
-
-/* To be notified when the variant is finalised, we construct
- * it from data with a custom GDestroyNotify.
- */
-
-typedef struct {
- char *mem;
- gsize n;
- gboolean *weak_ptr;
-} VariantData;
-
-static void
-free_data (VariantData *data)
-{
- *(data->weak_ptr) = TRUE;
- g_free (data->mem);
- g_slice_free (VariantData, data);
-}
-
-static GVariant *
-test_object_real_signal3 (TestObject *tobject,
- gboolean *weak_ptr)
-{
- GVariant *variant;
- VariantData *data;
-
- variant = g_variant_ref_sink (g_variant_new_uint32 (42));
- data = g_slice_new (VariantData);
- data->weak_ptr = weak_ptr;
- data->n = g_variant_get_size (variant);
- data->mem = g_malloc (data->n);
- g_variant_store (variant, data->mem);
- g_variant_unref (variant);
-
- variant = g_variant_new_from_data (G_VARIANT_TYPE ("u"),
- data->mem,
- data->n,
- TRUE,
- (GDestroyNotify) free_data,
- data);
- return g_variant_ref_sink (variant);
-}
-
-static void
-test_object_class_init (TestObjectClass *class)
-{
- class->test_signal1 = test_object_real_signal1;
- class->test_signal2 = test_object_real_signal2;
- class->test_signal3 = test_object_real_signal3;
-
- g_signal_new ("test-signal1",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (TestObjectClass, test_signal1),
- test_signal1_accumulator, NULL,
- test_marshal_STRING__INT,
- G_TYPE_STRING, 1, G_TYPE_INT);
- g_signal_new ("test-signal2",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (TestObjectClass, test_signal2),
- g_signal_accumulator_true_handled, NULL,
- test_marshal_BOOLEAN__INT,
- G_TYPE_BOOLEAN, 1, G_TYPE_INT);
- g_signal_new ("test-signal3",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (TestObjectClass, test_signal3),
- test_signal3_accumulator, NULL,
- test_marshal_VARIANT__POINTER,
- G_TYPE_VARIANT, 1, G_TYPE_POINTER);
-}
-
-static DEFINE_TYPE(TestObject, test_object,
- test_object_class_init, NULL, NULL,
- G_TYPE_OBJECT)
-
-int
-main (int argc,
- char *argv[])
-{
- TestObject *object;
- gchar *string_result;
- gboolean bool_result;
- gboolean variant_finalised;
- GVariant *variant_result;
-
- g_log_set_always_fatal (g_log_set_always_fatal (G_LOG_FATAL_MASK) |
- G_LOG_LEVEL_WARNING |
- G_LOG_LEVEL_CRITICAL);
-
- object = g_object_new (TEST_TYPE_OBJECT, NULL);
-
- g_signal_connect (object, "test-signal1",
- G_CALLBACK (test_object_signal1_callback_before), NULL);
- g_signal_connect_after (object, "test-signal1",
- G_CALLBACK (test_object_signal1_callback_after), NULL);
-
- g_signal_emit_by_name (object, "test-signal1", 0, &string_result);
- g_assert (strcmp (string_result, "<before><default><after>") == 0);
- g_free (string_result);
-
- g_signal_connect (object, "test-signal2",
- G_CALLBACK (test_object_signal2_callback_before), NULL);
- g_signal_connect_after (object, "test-signal2",
- G_CALLBACK (test_object_signal2_callback_after), NULL);
-
- bool_result = FALSE;
- g_signal_emit_by_name (object, "test-signal2", 1, &bool_result);
- g_assert (bool_result == TRUE);
- bool_result = FALSE;
- g_signal_emit_by_name (object, "test-signal2", 2, &bool_result);
- g_assert (bool_result == TRUE);
- bool_result = FALSE;
- g_signal_emit_by_name (object, "test-signal2", 3, &bool_result);
- g_assert (bool_result == TRUE);
- bool_result = TRUE;
- g_signal_emit_by_name (object, "test-signal2", 4, &bool_result);
- g_assert (bool_result == FALSE);
-
- variant_finalised = FALSE;
- variant_result = NULL;
- g_signal_emit_by_name (object, "test-signal3", &variant_finalised, &variant_result);
- g_assert (variant_result != NULL);
- g_assert (!g_variant_is_floating (variant_result));
-
- /* Test that variant_result had refcount 1 */
- g_assert (!variant_finalised);
- g_variant_unref (variant_result);
- g_assert (variant_finalised);
-
- g_object_unref (object);
-
- return 0;
-}
diff --git a/tests/gobject/defaultiface.c b/tests/gobject/defaultiface.c
deleted file mode 100644
index 92e45cefb..000000000
--- a/tests/gobject/defaultiface.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2001, 2003 Red Hat, Inc.
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "TestDefaultIface"
-
-#undef G_DISABLE_ASSERT
-#undef G_DISABLE_CHECKS
-#undef G_DISABLE_CAST_CHECKS
-
-#include <glib-object.h>
-
-#include "testcommon.h"
-#include "testmodule.h"
-
-/* This test tests getting the default vtable for an interface
- * and the initialization and finalization of such default
- * interfaces.
- *
- * We test this both for static and for dynamic interfaces.
- */
-
-/**********************************************************************
- * Static interface tests
- **********************************************************************/
-
-typedef struct _TestStaticIfaceClass TestStaticIfaceClass;
-
-struct _TestStaticIfaceClass
-{
- GTypeInterface base_iface;
- guint val;
-};
-
-GType test_static_iface_get_type (void);
-#define TEST_TYPE_STATIC_IFACE (test_static_iface_get_type ())
-
-static void
-test_static_iface_default_init (TestStaticIfaceClass *iface)
-{
- iface->val = 42;
-}
-
-DEFINE_IFACE (TestStaticIface, test_static_iface,
- NULL, test_static_iface_default_init)
-
-static void
-test_static_iface (void)
-{
- TestStaticIfaceClass *static_iface;
-
- /* Not loaded until we call ref for the first time */
- static_iface = g_type_default_interface_peek (TEST_TYPE_STATIC_IFACE);
- g_assert (static_iface == NULL);
-
- /* Ref loads */
- static_iface = g_type_default_interface_ref (TEST_TYPE_STATIC_IFACE);
- g_assert (static_iface && static_iface->val == 42);
-
- /* Peek then works */
- static_iface = g_type_default_interface_peek (TEST_TYPE_STATIC_IFACE);
- g_assert (static_iface && static_iface->val == 42);
-
- /* Unref does nothing */
- g_type_default_interface_unref (static_iface);
-
- /* And peek still works */
- static_iface = g_type_default_interface_peek (TEST_TYPE_STATIC_IFACE);
- g_assert (static_iface && static_iface->val == 42);
-}
-
-/**********************************************************************
- * Dynamic interface tests
- **********************************************************************/
-
-typedef struct _TestDynamicIfaceClass TestDynamicIfaceClass;
-
-struct _TestDynamicIfaceClass
-{
- GTypeInterface base_iface;
- guint val;
-};
-
-static GType test_dynamic_iface_type;
-static gboolean dynamic_iface_init = FALSE;
-
-#define TEST_TYPE_DYNAMIC_IFACE (test_dynamic_iface_type)
-
-static void
-test_dynamic_iface_default_init (TestStaticIfaceClass *iface)
-{
- dynamic_iface_init = TRUE;
- iface->val = 42;
-}
-
-static void
-test_dynamic_iface_default_finalize (TestStaticIfaceClass *iface)
-{
- dynamic_iface_init = FALSE;
-}
-
-static void
-test_dynamic_iface_register (GTypeModule *module)
-{
- const GTypeInfo iface_info =
- {
- sizeof (TestDynamicIfaceClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) test_dynamic_iface_default_init,
- (GClassFinalizeFunc) test_dynamic_iface_default_finalize,
- NULL,
- 0,
- 0,
- NULL,
- NULL
- };
-
- test_dynamic_iface_type = g_type_module_register_type (module, G_TYPE_INTERFACE,
- "TestDynamicIface", &iface_info, 0);
-}
-
-static void
-module_register (GTypeModule *module)
-{
- test_dynamic_iface_register (module);
-}
-
-static void
-test_dynamic_iface (void)
-{
- TestDynamicIfaceClass *dynamic_iface;
-
- test_module_new (module_register);
-
- /* Not loaded until we call ref for the first time */
- dynamic_iface = g_type_default_interface_peek (TEST_TYPE_DYNAMIC_IFACE);
- g_assert (dynamic_iface == NULL);
-
- /* Ref loads */
- dynamic_iface = g_type_default_interface_ref (TEST_TYPE_DYNAMIC_IFACE);
- g_assert (dynamic_iface_init);
- g_assert (dynamic_iface && dynamic_iface->val == 42);
-
- /* Peek then works */
- dynamic_iface = g_type_default_interface_peek (TEST_TYPE_DYNAMIC_IFACE);
- g_assert (dynamic_iface && dynamic_iface->val == 42);
-
- /* Unref causes finalize */
- g_type_default_interface_unref (dynamic_iface);
-#if 0
- g_assert (!dynamic_iface_init);
-#endif
-
- /* Peek returns NULL */
- dynamic_iface = g_type_default_interface_peek (TEST_TYPE_DYNAMIC_IFACE);
-#if 0
- g_assert (dynamic_iface == NULL);
-#endif
-
- /* Ref reloads */
- dynamic_iface = g_type_default_interface_ref (TEST_TYPE_DYNAMIC_IFACE);
- g_assert (dynamic_iface_init);
- g_assert (dynamic_iface && dynamic_iface->val == 42);
-
- /* And Unref causes finalize once more*/
- g_type_default_interface_unref (dynamic_iface);
-#if 0
- g_assert (!dynamic_iface_init);
-#endif
-}
-
-int
-main (int argc,
- char *argv[])
-{
- g_log_set_always_fatal (g_log_set_always_fatal (G_LOG_FATAL_MASK) |
- G_LOG_LEVEL_WARNING |
- G_LOG_LEVEL_CRITICAL);
-
- test_static_iface ();
- test_dynamic_iface ();
-
- return 0;
-}
diff --git a/tests/gobject/deftype.c b/tests/gobject/deftype.c
deleted file mode 100644
index 773aaa1bd..000000000
--- a/tests/gobject/deftype.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* deftype.c
- * Copyright (C) 2006 Behdad Esfahbod
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-#include <glib-object.h>
-
-/* see http://bugzilla.gnome.org/show_bug.cgi?id=337128 for the purpose of this test */
-
-#define MY_G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) { \
- const GInterfaceInfo g_implement_interface_info = { \
- (GInterfaceInitFunc) iface_init, \
- NULL, \
- NULL \
- }; \
- g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
-}
-
-#define MY_DEFINE_TYPE(TN, t_n, T_P) \
- G_DEFINE_TYPE_WITH_CODE (TN, t_n, T_P, \
- MY_G_IMPLEMENT_INTERFACE (G_TYPE_INTERFACE, NULL))
-
-typedef struct _TypeName {
- GObject parent_instance;
- const char *name;
-} TypeName;
-
-typedef struct _TypeNameClass {
- GObjectClass parent_parent;
-} TypeNameClass;
-
-GType type_name_get_type (void);
-
-MY_DEFINE_TYPE (TypeName, type_name, G_TYPE_OBJECT)
-
-static void type_name_init (TypeName *self)
-{
-}
-
-static void type_name_class_init (TypeNameClass *klass)
-{
-}
-
-int
-main (void)
-{
- return 0;
-}
diff --git a/tests/gobject/dynamictype.c b/tests/gobject/dynamictype.c
deleted file mode 100644
index c3db276cf..000000000
--- a/tests/gobject/dynamictype.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2001, 2003 Red Hat, Inc.
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "TestDynamicType"
-
-#undef G_DISABLE_ASSERT
-#undef G_DISABLE_CHECKS
-#undef G_DISABLE_CAST_CHECKS
-
-#include <glib-object.h>
-
-#include "testcommon.h"
-#include "testmodule.h"
-
-/* This test tests the macros for defining dynamic types.
- */
-
-static gboolean loaded = FALSE;
-
-struct _TestIfaceClass
-{
- GTypeInterface base_iface;
- guint val;
-};
-
-static GType test_iface_get_type (void);
-#define TEST_TYPE_IFACE (test_iface_get_type ())
-#define TEST_IFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_IFACE, TestIfaceClass))
-typedef struct _TestIface TestIface;
-typedef struct _TestIfaceClass TestIfaceClass;
-
-static void test_iface_base_init (TestIfaceClass *iface);
-static void test_iface_default_init (TestIfaceClass *iface, gpointer class_data);
-
-static DEFINE_IFACE(TestIface, test_iface, test_iface_base_init, test_iface_default_init)
-
-static void
-test_iface_default_init (TestIfaceClass *iface,
- gpointer class_data)
-{
-}
-
-static void
-test_iface_base_init (TestIfaceClass *iface)
-{
-}
-
-GType dynamic_object_get_type (void);
-#define DYNAMIC_OBJECT_TYPE (dynamic_object_get_type ())
-
-typedef GObject DynamicObject;
-typedef struct _DynamicObjectClass DynamicObjectClass;
-
-struct _DynamicObjectClass
-{
- GObjectClass parent_class;
- guint val;
-};
-
-static void dynamic_object_iface_init (TestIface *iface);
-
-G_DEFINE_DYNAMIC_TYPE_EXTENDED(DynamicObject, dynamic_object, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE_DYNAMIC (TEST_TYPE_IFACE,
- dynamic_object_iface_init));
-
-static void
-dynamic_object_class_init (DynamicObjectClass *class)
-{
- class->val = 42;
- loaded = TRUE;
-}
-
-static void
-dynamic_object_class_finalize (DynamicObjectClass *class)
-{
- loaded = FALSE;
-}
-
-static void
-dynamic_object_iface_init (TestIface *iface)
-{
-}
-
-static void
-dynamic_object_init (DynamicObject *dynamic_object)
-{
-}
-
-static void
-module_register (GTypeModule *module)
-{
- dynamic_object_register_type (module);
-}
-
-static void
-test_dynamic_type (void)
-{
- DynamicObjectClass *class;
-
- test_module_new (module_register);
-
- /* Not loaded until we call ref for the first time */
- class = g_type_class_peek (DYNAMIC_OBJECT_TYPE);
- g_assert (class == NULL);
- g_assert (!loaded);
-
- /* Make sure interfaces work */
- g_assert (g_type_is_a (DYNAMIC_OBJECT_TYPE,
- TEST_TYPE_IFACE));
-
- /* Ref loads */
- class = g_type_class_ref (DYNAMIC_OBJECT_TYPE);
- g_assert (class && class->val == 42);
- g_assert (loaded);
-
- /* Peek then works */
- class = g_type_class_peek (DYNAMIC_OBJECT_TYPE);
- g_assert (class && class->val == 42);
- g_assert (loaded);
-
- /* Make sure interfaces still work */
- g_assert (g_type_is_a (DYNAMIC_OBJECT_TYPE,
- TEST_TYPE_IFACE));
-
- /* Unref causes finalize */
- g_type_class_unref (class);
-
- /* Peek returns NULL */
- class = g_type_class_peek (DYNAMIC_OBJECT_TYPE);
-#if 0
- g_assert (!class);
- g_assert (!loaded);
-#endif
-
- /* Ref reloads */
- class = g_type_class_ref (DYNAMIC_OBJECT_TYPE);
- g_assert (class && class->val == 42);
- g_assert (loaded);
-
- /* And Unref causes finalize once more*/
- g_type_class_unref (class);
- class = g_type_class_peek (DYNAMIC_OBJECT_TYPE);
-#if 0
- g_assert (!class);
- g_assert (!loaded);
-#endif
-}
-
-int
-main (int argc,
- char *argv[])
-{
- g_log_set_always_fatal (g_log_set_always_fatal (G_LOG_FATAL_MASK) |
- G_LOG_LEVEL_WARNING |
- G_LOG_LEVEL_CRITICAL);
-
- test_dynamic_type ();
-
- return 0;
-}
diff --git a/tests/gobject/meson.build b/tests/gobject/meson.build
index a02480e02..8766932f5 100644
--- a/tests/gobject/meson.build
+++ b/tests/gobject/meson.build
@@ -1,47 +1,5 @@
-# We cannot use gnome.genmarshal() here
-testmarshal_h = custom_target('testmarshal_h',
- output : 'testmarshal.h',
- input : 'testmarshal.list',
- command : [
- python, glib_genmarshal,
- '--prefix=test_marshal',
- '--output=@OUTPUT@',
- '--quiet',
- '--header',
- '@INPUT@',
- ],
-)
-
-testmarshal_c = custom_target('testmarshal_c',
- output : 'testmarshal.c',
- input : 'testmarshal.list',
- command : [
- python, glib_genmarshal,
- '--prefix=test_marshal',
- '--include-header=testmarshal.h',
- '--output=@OUTPUT@',
- '--quiet',
- '--body',
- '@INPUT@',
- ],
-)
-
gobject_tests = {
- 'deftype' : {},
- 'defaultiface' : {
- 'extra_sources' : ['testmodule.c'],
- },
- 'dynamictype' : {
- 'extra_sources' : ['testmodule.c'],
- },
- 'override' : {},
- 'signals' : {},
- 'singleton' : {},
- 'references' : {},
'testgobject' : {},
- 'accumulator' : {
- 'extra_sources' : [testmarshal_c, testmarshal_h],
- },
}
if host_system != 'windows'
diff --git a/tests/gobject/override.c b/tests/gobject/override.c
deleted file mode 100644
index d048a4669..000000000
--- a/tests/gobject/override.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/* GObject - GLib Type, Object, Parameter and Signal Library
- * override.c: Closure override test program
- * Copyright (C) 2001, James Henstridge
- * Copyright (C) 2003, Red Hat, Inc.
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "TestOverride"
-
-#undef G_DISABLE_ASSERT
-#undef G_DISABLE_CHECKS
-#undef G_DISABLE_CAST_CHECKS
-
-#undef VERBOSE
-
-#include <string.h>
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "testcommon.h"
-
-static guint foo_signal_id = 0;
-static guint bar_signal_id = 0;
-static guint baz_signal_id = 0;
-
-static GType test_i_get_type (void);
-static GType test_a_get_type (void);
-static GType test_b_get_type (void);
-static GType test_c_get_type (void);
-
-static void record (const gchar *str);
-
-#define TEST_TYPE_I (test_i_get_type ())
-
-typedef struct _TestI TestI;
-typedef struct _TestIClass TestIClass;
-
-struct _TestIClass
-{
- GTypeInterface base_iface;
-};
-
-static void
-test_i_foo (TestI *self)
-{
- record ("TestI::foo");
-}
-
-static void
-test_i_default_init (gpointer g_class)
-{
- foo_signal_id = g_signal_newv ("foo",
- TEST_TYPE_I,
- G_SIGNAL_RUN_LAST,
- g_cclosure_new(G_CALLBACK(test_i_foo),
- NULL, NULL),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0, NULL);
-}
-
-static DEFINE_IFACE (TestI, test_i, NULL, test_i_default_init)
-
-#define TEST_TYPE_A (test_a_get_type())
-
- typedef struct _TestA TestA;
- typedef struct _TestAClass TestAClass;
-
-struct _TestA {
- GObject parent;
-};
-struct _TestAClass {
- GObjectClass parent_class;
-
- void (* bar) (TestA *self);
-};
-
-static void
-test_a_foo (TestI *self)
-{
- GValue args[1] = { G_VALUE_INIT };
-
- record ("TestA::foo");
-
- g_value_init (&args[0], TEST_TYPE_A);
- g_value_set_object (&args[0], self);
-
- g_assert (g_signal_get_invocation_hint (self)->signal_id == foo_signal_id);
- g_signal_chain_from_overridden (args, NULL);
-
- g_value_unset (&args[0]);
-}
-
-static void
-test_a_bar (TestA *self)
-{
- record ("TestA::bar");
-}
-
-static gchar *
-test_a_baz (TestA *self,
- GObject *object,
- gpointer pointer)
-{
- record ("TestA::baz");
-
- g_assert (object == G_OBJECT (self));
- g_assert (GPOINTER_TO_INT (pointer) == 23);
-
- return g_strdup ("TestA::baz");
-}
-
-static void
-test_a_class_init (TestAClass *class)
-{
- class->bar = test_a_bar;
-
- bar_signal_id = g_signal_new ("bar",
- TEST_TYPE_A,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (TestAClass, bar),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0, NULL);
-
- baz_signal_id = g_signal_new_class_handler ("baz",
- TEST_TYPE_A,
- G_SIGNAL_RUN_LAST,
- G_CALLBACK (test_a_baz),
- NULL, NULL,
- g_cclosure_marshal_STRING__OBJECT_POINTER,
- G_TYPE_STRING, 2,
- G_TYPE_OBJECT,
- G_TYPE_POINTER);
-}
-
-static void
-test_a_interface_init (TestIClass *iface)
-{
- g_signal_override_class_closure (foo_signal_id,
- TEST_TYPE_A,
- g_cclosure_new (G_CALLBACK (test_a_foo),
- NULL, NULL));
-}
-
-static DEFINE_TYPE_FULL (TestA, test_a,
- test_a_class_init, NULL, NULL,
- G_TYPE_OBJECT,
- INTERFACE (test_a_interface_init, TEST_TYPE_I))
-
-#define TEST_TYPE_B (test_b_get_type())
-
-typedef struct _TestB TestB;
-typedef struct _TestBClass TestBClass;
-
-struct _TestB {
- TestA parent;
-};
-struct _TestBClass {
- TestAClass parent_class;
-};
-
-static void
-test_b_foo (TestI *self)
-{
- GValue args[1] = { G_VALUE_INIT };
-
- record ("TestB::foo");
-
- g_value_init (&args[0], TEST_TYPE_A);
- g_value_set_object (&args[0], self);
-
- g_assert (g_signal_get_invocation_hint (self)->signal_id == foo_signal_id);
- g_signal_chain_from_overridden (args, NULL);
-
- g_value_unset (&args[0]);
-}
-
-static void
-test_b_bar (TestA *self)
-{
- GValue args[1] = { G_VALUE_INIT };
-
- record ("TestB::bar");
-
- g_value_init (&args[0], TEST_TYPE_A);
- g_value_set_object (&args[0], self);
-
- g_assert (g_signal_get_invocation_hint (self)->signal_id == bar_signal_id);
- g_signal_chain_from_overridden (args, NULL);
-
- g_value_unset (&args[0]);
-}
-
-static gchar *
-test_b_baz (TestA *self,
- GObject *object,
- gpointer pointer)
-{
- gchar *retval = NULL;
-
- record ("TestB::baz");
-
- g_assert (object == G_OBJECT (self));
- g_assert (GPOINTER_TO_INT (pointer) == 23);
-
- g_signal_chain_from_overridden_handler (self, object, pointer, &retval);
-
- if (retval)
- {
- gchar *tmp = g_strconcat (retval , ",TestB::baz", NULL);
- g_free (retval);
- retval = tmp;
- }
-
- return retval;
-}
-
-static void
-test_b_class_init (TestBClass *class)
-{
- g_signal_override_class_closure (foo_signal_id,
- TEST_TYPE_B,
- g_cclosure_new (G_CALLBACK (test_b_foo),
- NULL, NULL));
- g_signal_override_class_closure (bar_signal_id,
- TEST_TYPE_B,
- g_cclosure_new (G_CALLBACK (test_b_bar),
- NULL, NULL));
- g_signal_override_class_handler ("baz",
- TEST_TYPE_B,
- G_CALLBACK (test_b_baz));
-}
-
-static DEFINE_TYPE (TestB, test_b,
- test_b_class_init, NULL, NULL,
- TEST_TYPE_A)
-
-#define TEST_TYPE_C (test_c_get_type())
-
-typedef struct _TestC TestC;
-typedef struct _TestCClass TestCClass;
-
-struct _TestC {
- TestB parent;
-};
-struct _TestCClass {
- TestBClass parent_class;
-};
-
-static void
-test_c_foo (TestI *self)
-{
- GValue args[1] = { G_VALUE_INIT };
-
- record ("TestC::foo");
-
- g_value_init (&args[0], TEST_TYPE_A);
- g_value_set_object (&args[0], self);
-
- g_assert (g_signal_get_invocation_hint (self)->signal_id == foo_signal_id);
- g_signal_chain_from_overridden (args, NULL);
-
- g_value_unset (&args[0]);
-}
-
-static void
-test_c_bar (TestA *self)
-{
- GValue args[1] = { G_VALUE_INIT };
-
- record ("TestC::bar");
-
- g_value_init (&args[0], TEST_TYPE_A);
- g_value_set_object (&args[0], self);
-
- g_assert (g_signal_get_invocation_hint (self)->signal_id == bar_signal_id);
- g_signal_chain_from_overridden (args, NULL);
-
- g_value_unset (&args[0]);
-}
-
-static gchar *
-test_c_baz (TestA *self,
- GObject *object,
- gpointer pointer)
-{
- gchar *retval = NULL;
-
- record ("TestC::baz");
-
- g_assert (object == G_OBJECT (self));
- g_assert (GPOINTER_TO_INT (pointer) == 23);
-
- g_signal_chain_from_overridden_handler (self, object, pointer, &retval);
-
- if (retval)
- {
- gchar *tmp = g_strconcat (retval , ",TestC::baz", NULL);
- g_free (retval);
- retval = tmp;
- }
-
- return retval;
-}
-
-static void
-test_c_class_init (TestBClass *class)
-{
- g_signal_override_class_closure (foo_signal_id,
- TEST_TYPE_C,
- g_cclosure_new (G_CALLBACK (test_c_foo),
- NULL, NULL));
- g_signal_override_class_closure (bar_signal_id,
- TEST_TYPE_C,
- g_cclosure_new (G_CALLBACK (test_c_bar),
- NULL, NULL));
- g_signal_override_class_handler ("baz",
- TEST_TYPE_C,
- G_CALLBACK (test_c_baz));
-}
-
-
-static DEFINE_TYPE (TestC, test_c,
- test_c_class_init, NULL, NULL,
- TEST_TYPE_B)
-
-static GString *test_string = NULL;
-gboolean failed = FALSE;
-
-static void
-record (const gchar *str)
-{
- if (test_string->len)
- g_string_append_c (test_string, ',');
- g_string_append (test_string, str);
-}
-
-static void
-test (GType type,
- const gchar *signal,
- const gchar *expected,
- const gchar *expected_retval)
-{
- GObject *self = g_object_new (type, NULL);
-
- test_string = g_string_new (NULL);
-
- if (strcmp (signal, "baz"))
- {
- g_signal_emit_by_name (self, signal);
- }
- else
- {
- gchar *ret;
-
- g_signal_emit_by_name (self, signal, self, GINT_TO_POINTER (23), &ret);
-
- if (strcmp (ret, expected_retval) != 0)
- failed = TRUE;
-
- g_free (ret);
- }
-
-#ifndef VERBOSE
- if (strcmp (test_string->str, expected) != 0)
-#endif
- {
- g_printerr ("*** emitting %s on a %s instance\n"
- " Expecting: %s\n"
- " Got: %s\n",
- signal, g_type_name (type),
- expected,
- test_string->str);
-
- if (strcmp (test_string->str, expected) != 0)
- failed = TRUE;
- }
-
- g_string_free (test_string, TRUE);
- g_object_unref (self);
-}
-
-int
-main (int argc, char **argv)
-{
- g_log_set_always_fatal (g_log_set_always_fatal (G_LOG_FATAL_MASK) |
- G_LOG_LEVEL_WARNING |
- G_LOG_LEVEL_CRITICAL);
-
- test (TEST_TYPE_A, "foo", "TestA::foo,TestI::foo", NULL);
- test (TEST_TYPE_A, "bar", "TestA::bar", NULL);
- test (TEST_TYPE_A, "baz", "TestA::baz", "TestA::baz");
-
- test (TEST_TYPE_B, "foo", "TestB::foo,TestA::foo,TestI::foo", NULL);
- test (TEST_TYPE_B, "bar", "TestB::bar,TestA::bar", NULL);
- test (TEST_TYPE_B, "baz", "TestB::baz,TestA::baz", "TestA::baz,TestB::baz");
-
- test (TEST_TYPE_C, "foo", "TestC::foo,TestB::foo,TestA::foo,TestI::foo", NULL);
- test (TEST_TYPE_C, "bar", "TestC::bar,TestB::bar,TestA::bar", NULL);
- test (TEST_TYPE_C, "baz", "TestC::baz,TestB::baz,TestA::baz", "TestA::baz,TestB::baz,TestC::baz");
-
- return failed ? 1 : 0;
-}
diff --git a/tests/gobject/references.c b/tests/gobject/references.c
deleted file mode 100644
index 36ff35c63..000000000
--- a/tests/gobject/references.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2005 Red Hat, Inc.
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "TestReferences"
-
-#undef G_DISABLE_ASSERT
-#undef G_DISABLE_CHECKS
-#undef G_DISABLE_CAST_CHECKS
-
-#include <glib-object.h>
-
-/* This test tests weak and toggle references
- */
-
-static GObject *global_object;
-
-static gboolean object_destroyed;
-static gboolean weak_ref1_notified;
-static gboolean weak_ref2_notified;
-static gboolean toggle_ref1_weakened;
-static gboolean toggle_ref1_strengthened;
-static gboolean toggle_ref2_weakened;
-static gboolean toggle_ref2_strengthened;
-static gboolean toggle_ref3_weakened;
-static gboolean toggle_ref3_strengthened;
-
-/*
- * TestObject, a parent class for TestObject
- */
-static GType test_object_get_type (void);
-#define TEST_TYPE_OBJECT (test_object_get_type ())
-typedef struct _TestObject TestObject;
-typedef struct _TestObjectClass TestObjectClass;
-
-struct _TestObject
-{
- GObject parent_instance;
-};
-struct _TestObjectClass
-{
- GObjectClass parent_class;
-};
-
-G_DEFINE_TYPE (TestObject, test_object, G_TYPE_OBJECT)
-
-static void
-test_object_finalize (GObject *object)
-{
- object_destroyed = TRUE;
-
- G_OBJECT_CLASS (test_object_parent_class)->finalize (object);
-}
-
-static void
-test_object_class_init (TestObjectClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- object_class->finalize = test_object_finalize;
-}
-
-static void
-test_object_init (TestObject *test_object)
-{
-}
-
-static void
-clear_flags (void)
-{
- object_destroyed = FALSE;
- weak_ref1_notified = FALSE;
- weak_ref2_notified = FALSE;
- toggle_ref1_weakened = FALSE;
- toggle_ref1_strengthened = FALSE;
- toggle_ref2_weakened = FALSE;
- toggle_ref2_strengthened = FALSE;
- toggle_ref3_weakened = FALSE;
- toggle_ref3_strengthened = FALSE;
-}
-
-static void
-weak_ref1 (gpointer data,
- GObject *object)
-{
- g_assert (object == global_object);
- g_assert (data == GUINT_TO_POINTER (42));
-
- weak_ref1_notified = TRUE;
-}
-
-static void
-weak_ref2 (gpointer data,
- GObject *object)
-{
- g_assert (object == global_object);
- g_assert (data == GUINT_TO_POINTER (24));
-
- weak_ref2_notified = TRUE;
-}
-
-static void
-toggle_ref1 (gpointer data,
- GObject *object,
- gboolean is_last_ref)
-{
- g_assert (object == global_object);
- g_assert (data == GUINT_TO_POINTER (42));
-
- if (is_last_ref)
- toggle_ref1_weakened = TRUE;
- else
- toggle_ref1_strengthened = TRUE;
-}
-
-static void
-toggle_ref2 (gpointer data,
- GObject *object,
- gboolean is_last_ref)
-{
- g_assert (object == global_object);
- g_assert (data == GUINT_TO_POINTER (24));
-
- if (is_last_ref)
- toggle_ref2_weakened = TRUE;
- else
- toggle_ref2_strengthened = TRUE;
-}
-
-static void
-toggle_ref3 (gpointer data,
- GObject *object,
- gboolean is_last_ref)
-{
- g_assert (object == global_object);
- g_assert (data == GUINT_TO_POINTER (34));
-
- if (is_last_ref)
- {
- toggle_ref3_weakened = TRUE;
- g_object_remove_toggle_ref (object, toggle_ref3, GUINT_TO_POINTER (34));
- }
- else
- toggle_ref3_strengthened = TRUE;
-}
-
-int
-main (int argc,
- char *argv[])
-{
- GObject *object;
-
- g_log_set_always_fatal (g_log_set_always_fatal (G_LOG_FATAL_MASK) |
- G_LOG_LEVEL_WARNING |
- G_LOG_LEVEL_CRITICAL);
-
- /* Test basic weak reference operation
- */
- global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
-
- g_object_weak_ref (object, weak_ref1, GUINT_TO_POINTER (42));
-
- clear_flags ();
- g_object_unref (object);
- g_assert (weak_ref1_notified == TRUE);
- g_assert (object_destroyed == TRUE);
-
- /* Test two weak references at once
- */
- global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
-
- g_object_weak_ref (object, weak_ref1, GUINT_TO_POINTER (42));
- g_object_weak_ref (object, weak_ref2, GUINT_TO_POINTER (24));
-
- clear_flags ();
- g_object_unref (object);
- g_assert (weak_ref1_notified == TRUE);
- g_assert (weak_ref2_notified == TRUE);
- g_assert (object_destroyed == TRUE);
-
- /* Test remove weak references
- */
- global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
-
- g_object_weak_ref (object, weak_ref1, GUINT_TO_POINTER (42));
- g_object_weak_ref (object, weak_ref2, GUINT_TO_POINTER (24));
- g_object_weak_unref (object, weak_ref1, GUINT_TO_POINTER (42));
-
- clear_flags ();
- g_object_unref (object);
- g_assert (weak_ref1_notified == FALSE);
- g_assert (weak_ref2_notified == TRUE);
- g_assert (object_destroyed == TRUE);
-
- /* Test basic toggle reference operation
- */
- global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
-
- g_object_add_toggle_ref (object, toggle_ref1, GUINT_TO_POINTER (42));
-
- clear_flags ();
- g_object_unref (object);
- g_assert (toggle_ref1_weakened == TRUE);
- g_assert (toggle_ref1_strengthened == FALSE);
- g_assert (object_destroyed == FALSE);
-
- clear_flags ();
- g_object_ref (object);
- g_assert (toggle_ref1_weakened == FALSE);
- g_assert (toggle_ref1_strengthened == TRUE);
- g_assert (object_destroyed == FALSE);
-
- g_object_unref (object);
-
- clear_flags ();
- g_object_remove_toggle_ref (object, toggle_ref1, GUINT_TO_POINTER (42));
- g_assert (toggle_ref1_weakened == FALSE);
- g_assert (toggle_ref1_strengthened == FALSE);
- g_assert (object_destroyed == TRUE);
-
- global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
-
- /* Test two toggle references at once
- */
- g_object_add_toggle_ref (object, toggle_ref1, GUINT_TO_POINTER (42));
- g_object_add_toggle_ref (object, toggle_ref2, GUINT_TO_POINTER (24));
-
- clear_flags ();
- g_object_unref (object);
- g_assert (toggle_ref1_weakened == FALSE);
- g_assert (toggle_ref1_strengthened == FALSE);
- g_assert (toggle_ref2_weakened == FALSE);
- g_assert (toggle_ref2_strengthened == FALSE);
- g_assert (object_destroyed == FALSE);
-
- clear_flags ();
- g_object_remove_toggle_ref (object, toggle_ref1, GUINT_TO_POINTER (42));
- g_assert (toggle_ref1_weakened == FALSE);
- g_assert (toggle_ref1_strengthened == FALSE);
- g_assert (toggle_ref2_weakened == TRUE);
- g_assert (toggle_ref2_strengthened == FALSE);
- g_assert (object_destroyed == FALSE);
-
- clear_flags ();
- /* Check that removing a toggle ref with %NULL data works fine. */
- g_object_remove_toggle_ref (object, toggle_ref2, NULL);
- g_assert (toggle_ref1_weakened == FALSE);
- g_assert (toggle_ref1_strengthened == FALSE);
- g_assert (toggle_ref2_weakened == FALSE);
- g_assert (toggle_ref2_strengthened == FALSE);
- g_assert (object_destroyed == TRUE);
-
- /* Test a toggle reference that removes itself
- */
- global_object = object = g_object_new (TEST_TYPE_OBJECT, NULL);
-
- g_object_add_toggle_ref (object, toggle_ref3, GUINT_TO_POINTER (34));
-
- clear_flags ();
- g_object_unref (object);
- g_assert (toggle_ref3_weakened == TRUE);
- g_assert (toggle_ref3_strengthened == FALSE);
- g_assert (object_destroyed == TRUE);
-
- return 0;
-}
diff --git a/tests/gobject/signals.c b/tests/gobject/signals.c
deleted file mode 100644
index 3b1f3b6eb..000000000
--- a/tests/gobject/signals.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2013 Red Hat, Inc.
- * Copy and pasted from accumulator.c and modified.
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "TestSignals"
-
-#undef G_DISABLE_ASSERT
-#undef G_DISABLE_CHECKS
-#undef G_DISABLE_CAST_CHECKS
-
-#include <glib-object.h>
-
-#include "testcommon.h"
-
-/* What this test tests is the behavior of signal disconnection
- * from within a signal handler for the signal being disconnected.
- *
- * The test demonstrates that signal handlers disconnected from a signal
- * from an earlier handler in the same emission will not be run.
- *
- * It also demonstrates that signal handlers connected from a signal
- * from an earlier handler in the same emission will not be run.
- */
-
-/*
- * TestObject, a parent class for TestObject
- */
-#define TEST_TYPE_OBJECT (test_object_get_type ())
-typedef struct _TestObject TestObject;
-typedef struct _TestObjectClass TestObjectClass;
-static gboolean callback1_ran = FALSE, callback2_ran = FALSE, callback3_ran = FALSE, default_handler_ran = FALSE;
-
-struct _TestObject
-{
- GObject parent_instance;
-};
-struct _TestObjectClass
-{
- GObjectClass parent_class;
-
- void (*test_signal) (TestObject *object);
-};
-
-static GType test_object_get_type (void);
-
-static void
-test_object_real_signal (TestObject *object)
-{
- default_handler_ran = TRUE;
-}
-
-static void
-test_object_signal_callback3 (TestObject *object,
- gpointer data)
-{
- callback3_ran = TRUE;
-}
-
-static void
-test_object_signal_callback2 (TestObject *object,
- gpointer data)
-{
- callback2_ran = TRUE;
-}
-
-static void
-test_object_signal_callback1 (TestObject *object,
- gpointer data)
-{
- callback1_ran = TRUE;
- g_signal_handlers_disconnect_by_func (G_OBJECT (object),
- test_object_signal_callback2,
- data);
- g_signal_connect (object, "test-signal",
- G_CALLBACK (test_object_signal_callback3), NULL);
-}
-
-static void
-test_object_class_init (TestObjectClass *class)
-{
- class->test_signal = test_object_real_signal;
-
- g_signal_new ("test-signal",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (TestObjectClass, test_signal),
- NULL, NULL, NULL, G_TYPE_NONE, 0);
-}
-
-static DEFINE_TYPE(TestObject, test_object,
- test_object_class_init, NULL, NULL,
- G_TYPE_OBJECT)
-
-int
-main (int argc,
- char *argv[])
-{
- TestObject *object;
-
- g_log_set_always_fatal (g_log_set_always_fatal (G_LOG_FATAL_MASK) |
- G_LOG_LEVEL_WARNING |
- G_LOG_LEVEL_CRITICAL);
-
- object = g_object_new (TEST_TYPE_OBJECT, NULL);
-
- g_signal_connect (object, "test-signal",
- G_CALLBACK (test_object_signal_callback1), NULL);
- g_signal_connect (object, "test-signal",
- G_CALLBACK (test_object_signal_callback2), NULL);
- g_signal_emit_by_name (object, "test-signal");
-
- g_assert (callback1_ran);
- g_assert (!callback2_ran);
- g_assert (!callback3_ran);
- g_assert (default_handler_ran);
-
- g_object_unref (object);
- return 0;
-}
diff --git a/tests/gobject/singleton.c b/tests/gobject/singleton.c
deleted file mode 100644
index 79a41b263..000000000
--- a/tests/gobject/singleton.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* GObject - GLib Type, Object, Parameter and Signal Library
- * Copyright (C) 2006 Imendio AB
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "TestSingleton"
-#include <glib-object.h>
-#include <string.h>
-
-/* --- MySingleton class --- */
-typedef struct {
- GObject parent_instance;
-} MySingleton;
-typedef struct {
- GObjectClass parent_class;
-} MySingletonClass;
-
-static GType my_singleton_get_type (void);
-#define MY_TYPE_SINGLETON (my_singleton_get_type ())
-#define MY_SINGLETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MY_TYPE_SINGLETON, MySingleton))
-#define MY_IS_SINGLETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MY_TYPE_SINGLETON))
-#define MY_SINGLETON_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), MY_TYPE_SINGLETON, MySingletonClass))
-#define MY_IS_SINGLETON_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), MY_TYPE_SINGLETON))
-#define MY_SINGLETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MY_TYPE_SINGLETON, MySingletonClass))
-
-G_DEFINE_TYPE (MySingleton, my_singleton, G_TYPE_OBJECT)
-
-static MySingleton *the_one_and_only = NULL;
-
-/* --- methods --- */
-static GObject*
-my_singleton_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- if (the_one_and_only)
- return g_object_ref (G_OBJECT (the_one_and_only));
- else
- return G_OBJECT_CLASS (my_singleton_parent_class)->constructor (type, n_construct_properties, construct_properties);
-}
-
-static void
-my_singleton_init (MySingleton *self)
-{
- g_assert (the_one_and_only == NULL);
- the_one_and_only = self;
-}
-
-static void
-my_singleton_class_init (MySingletonClass *klass)
-{
- G_OBJECT_CLASS (klass)->constructor = my_singleton_constructor;
-}
-
-/* --- test program --- */
-int
-main (int argc,
- char *argv[])
-{
- MySingleton *singleton, *obj;
-
- /* create the singleton */
- singleton = g_object_new (MY_TYPE_SINGLETON, NULL);
- g_assert (singleton != NULL);
- /* assert _singleton_ creation */
- obj = g_object_new (MY_TYPE_SINGLETON, NULL);
- g_assert (singleton == obj);
- g_object_unref (obj);
- /* shutdown */
- g_object_unref (singleton);
- return 0;
-}
diff --git a/tests/gobject/testmarshal.list b/tests/gobject/testmarshal.list
deleted file mode 100644
index 198c4f9af..000000000
--- a/tests/gobject/testmarshal.list
+++ /dev/null
@@ -1,4 +0,0 @@
-# Marshallers used in tests
-BOOLEAN:INT
-STRING:INT
-VARIANT:POINTER
diff --git a/tests/gobject/testmodule.c b/tests/gobject/testmodule.c
deleted file mode 100644
index 3133be100..000000000
--- a/tests/gobject/testmodule.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* GObject - GLib Type, Object, Parameter and Signal Library
- * testmodule.c: Dummy dynamic type module
- * Copyright (C) 2003 Red Hat, Inc.
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include "testmodule.h"
-#include "testcommon.h"
-
-static gboolean test_module_load (GTypeModule *module);
-static void test_module_unload (GTypeModule *module);
-
-static void
-test_module_class_init (TestModuleClass *class)
-{
- GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
-
- module_class->load = test_module_load;
- module_class->unload = test_module_unload;
-}
-
-DEFINE_TYPE (TestModule, test_module,
- test_module_class_init, NULL, NULL,
- G_TYPE_TYPE_MODULE)
-
-static gboolean
-test_module_load (GTypeModule *module)
-{
- TestModule *test_module = TEST_MODULE (module);
-
- test_module->register_func (module);
-
- return TRUE;
-}
-
-static void
-test_module_unload (GTypeModule *module)
-{
-}
-
-GTypeModule *
-test_module_new (TestModuleRegisterFunc register_func)
-{
- TestModule *test_module = g_object_new (TEST_TYPE_MODULE, NULL);
- GTypeModule *module = G_TYPE_MODULE (test_module);
-
- test_module->register_func = register_func;
-
- /* Register the types initially */
- g_type_module_use (module);
- g_type_module_unuse (module);
-
- return G_TYPE_MODULE (module);
-}
diff --git a/tests/gobject/testmodule.h b/tests/gobject/testmodule.h
deleted file mode 100644
index e849b4d9c..000000000
--- a/tests/gobject/testmodule.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* GObject - GLib Type, Object, Parameter and Signal Library
- * testmodule.h: Dummy dynamic type module
- * Copyright (C) 2003 Red Hat, Inc.
- *
- * 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.1 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __TEST_MODULE_H__
-#define __TEST_MODULE_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-typedef struct _TestModule TestModule;
-typedef struct _TestModuleClass TestModuleClass;
-
-#define TEST_TYPE_MODULE (test_module_get_type ())
-#define TEST_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), TEST_TYPE_MODULE, TestModule))
-#define TEST_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), TEST_TYPE_MODULE, TestModuleClass))
-#define TEST_IS_MODULE(module) (G_TYPE_CHECK_INSTANCE_TYPE ((module), TEST_TYPE_MODULE))
-#define TEST_IS_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), TEST_TYPE_MODULE))
-#define TEST_MODULE_GET_CLASS(module) (G_TYPE_INSTANCE_GET_CLASS ((module), TEST_TYPE_MODULE, TestModuleClass))
-
-typedef void (*TestModuleRegisterFunc) (GTypeModule *module);
-
-struct _TestModule
-{
- GTypeModule parent_instance;
-
- TestModuleRegisterFunc register_func;
-};
-
-struct _TestModuleClass
-{
- GTypeModuleClass parent_class;
-};
-
-GType test_module_get_type (void);
-GTypeModule *test_module_new (TestModuleRegisterFunc register_func);
-
-G_END_DECLS
-
-#endif /* __TEST_MODULE_H__ */