Added atk tests
[platform/core/uifw/at-spi2-atk.git] / atk-tests / test-simple-child.c
1 /* This file contains both declaration and definition of the TestSimpleChild class 
2  * derived from AtkObject. The TestSimpleChild instances can be used as children by 
3  * the TestSimpleSelection and TestSimpleTable instances.
4  */
5
6 #include "test-simple-child.h"
7
8 GType 
9 test_simple_child_get_type (void);
10
11 static GObjectClass *parent_class_simple_child = NULL;
12
13 /******************************************************************/
14 /*                    Implementation                              */
15 /******************************************************************/
16 static void
17 simple_child_instance_init (GTypeInstance *instance, gpointer g_class)
18 {
19         TestSimpleChild *self = (TestSimpleChild *)instance;
20         
21         self->disposed = FALSE;
22         self->id = -1;  /* invalid ID value by default */
23 }
24
25 static void
26 test_simple_child_dispose (GObject *obj)
27 {
28         TestSimpleChild *self = (TestSimpleChild *)obj;
29
30         if (self->disposed) 
31         {
32                         return;
33         }
34         
35         /* Make sure dispose does not run twice. */
36         self->disposed = TRUE;
37
38         /* Chain up to the parent class */
39         G_OBJECT_CLASS (parent_class_simple_child)->dispose (obj);
40 }
41
42 static void
43 test_simple_child_finalize (GObject *obj)
44 {
45         TestSimpleChild *self = (TestSimpleChild *)obj;
46         if (self)
47         {
48                 /*free (self->pdata->descr);
49                 g_free (self->pdata);*/
50         }
51         
52         /* Chain up to the parent class */
53         G_OBJECT_CLASS (parent_class_simple_child)->finalize (obj);
54 }
55
56 static void
57 test_simple_child_class_init (gpointer g_class, gpointer g_class_data)
58 {
59         GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
60         TestSimpleChildClass *klass = TEST_SIMPLE_CHILD_CLASS (g_class);
61
62         gobject_class->dispose = test_simple_child_dispose;
63         gobject_class->finalize = test_simple_child_finalize;
64
65         parent_class_simple_child = g_type_class_peek_parent (klass);
66 }
67
68 GType 
69 test_simple_child_get_type (void)
70 {
71         static GType type = 0;
72         if (type == 0) 
73         {
74                         static const GTypeInfo info = 
75                         {
76                                         sizeof (TestSimpleChildClass),
77                                         NULL,   /* base_init */
78                                         NULL,   /* base_finalize */
79                                         test_simple_child_class_init, /* class_init */
80                                         NULL,   /* class_finalize */
81                                         NULL,   /* class_data */
82                                         sizeof (TestSimpleChild),
83                                         0,      /* n_preallocs */
84                                         simple_child_instance_init    /* instance_init */
85                         };
86
87                         type = g_type_register_static (ATK_TYPE_OBJECT,
88                                                                                    "TestSimpleChildType",
89                                                                                    &info, 0);
90         }
91         return type;
92 }