Update contrib.
2 * Portions copyright (c) 2006-2009 Nokia Corporation. All rights reserved.
6 #include <glib-object.h>
9 #include "mrt2_glib2_test.h"
10 #endif /*__SYMBIAN32__*/
11 #define G_TYPE_TEST (my_test_get_type ())
12 #define MY_TEST(test) (G_TYPE_CHECK_INSTANCE_CAST ((test), G_TYPE_TEST, GTest))
13 #define MY_IS_TEST(test) (G_TYPE_CHECK_INSTANCE_TYPE ((test), G_TYPE_TEST))
14 #define MY_TEST_CLASS(tclass) (G_TYPE_CHECK_CLASS_CAST ((tclass), G_TYPE_TEST, GTestClass))
15 #define MY_IS_TEST_CLASS(tclass) (G_TYPE_CHECK_CLASS_TYPE ((tclass), G_TYPE_TEST))
16 #define MY_TEST_GET_CLASS(test) (G_TYPE_INSTANCE_GET_CLASS ((test), G_TYPE_TEST, GTestClass))
23 typedef struct _GTest GTest;
24 typedef struct _GTestClass GTestClass;
35 GObjectClass parent_class;
38 static GType my_test_get_type (void);
40 static void my_test_class_init (GTestClass * klass);
41 static void my_test_init (GTest * test);
42 static void my_test_dispose (GObject * object);
43 static void my_test_get_property (GObject *object,
47 static void my_test_set_property (GObject *object,
52 static GObjectClass *parent_class = NULL;
55 my_test_get_type (void)
57 static GType test_type = 0;
60 static const GTypeInfo test_info = {
64 (GClassInitFunc) my_test_class_init,
69 (GInstanceInitFunc) my_test_init,
73 test_type = g_type_register_static (G_TYPE_OBJECT, "GTest",
80 my_test_class_init (GTestClass * klass)
82 GObjectClass *gobject_class;
84 gobject_class = (GObjectClass *) klass;
86 parent_class = g_type_class_ref (G_TYPE_OBJECT);
88 gobject_class->dispose = my_test_dispose;
89 gobject_class->get_property = my_test_get_property;
90 gobject_class->set_property = my_test_set_property;
92 g_object_class_install_property (gobject_class,
94 g_param_spec_int ("dummy",
102 my_test_init (GTest * test)
104 g_print ("init %p\n", test);
108 my_test_dispose (GObject * object)
112 test = MY_TEST (object);
114 g_print ("dispose %p!\n", object);
116 G_OBJECT_CLASS (parent_class)->dispose (object);
120 my_test_get_property (GObject *object,
127 test = MY_TEST (object);
132 g_value_set_int (value, test->dummy);
135 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
141 my_test_set_property (GObject *object,
148 test = MY_TEST (object);
153 test->dummy = g_value_get_int (value);
156 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
161 static gint count = 0;
164 dummy_notify (GObject *object,
168 if (count % 10000 == 0)
173 my_test_do_property (GTest * test)
177 g_object_get (test, "dummy", &dummy, NULL);
178 g_object_set (test, "dummy", dummy + 1, NULL);
182 main (int argc, char **argv)
189 g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
190 g_set_print_handler(mrtPrintHandler);
191 #endif /*__SYMBIAN32__*/
192 g_thread_init (NULL);
193 g_print ("START: %s\n", argv[0]);
194 g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK));
197 test = g_object_new (G_TYPE_TEST, NULL);
199 g_signal_connect (test, "notify::dummy", G_CALLBACK (dummy_notify), NULL);
201 g_assert (count == test->dummy);
204 for (i=0; i<10000; i++) {
206 for (i=0; i<1000000; i++) {
207 #endif//__SYMBIAN32__
208 my_test_do_property (test);
211 g_assert (count == test->dummy);
213 testResultXml("properties2");
214 #endif /* EMULATOR */