c431f087893310735b71adc3258f294784279224
[platform/upstream/at-spi2-atk.git] / tests / atk_test_table_cell.c
1 /*
2  * Copyright 2008 Codethink Ltd.
3  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include "atk_test_util.h"
22 #include "atk_suite.h"
23
24 #define DATA_FILE TESTS_DATA_DIR"/test-table.xml"
25
26 static void
27 atk_test_accessible_get_table_cell (gpointer fixture, gconstpointer user_data)
28 {
29   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
30   g_assert (_obj);
31   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
32   g_assert (child);
33
34   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 9, NULL);
35   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
36   g_assert (obj);
37 }
38
39 static void
40 atk_test_table_cell_get_column_span (gpointer fixture, gconstpointer user_data)
41 {
42   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
43   g_assert (_obj);
44   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
45   g_assert (child);
46
47   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 10, NULL);
48   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
49   g_assert (obj);
50
51   g_assert_cmpint (3, ==, atspi_table_cell_get_column_span (obj, NULL));
52
53   cell = atspi_accessible_get_child_at_index (child, 11, NULL);
54   obj = atspi_accessible_get_table_cell (cell);
55   g_assert (obj);
56
57   g_assert_cmpint (1, ==, atspi_table_cell_get_column_span (obj, NULL));
58 }
59
60 /*
61 static void
62 atk_test_table_cell_get_column_header_cells (gpointer fixture, gconstpointer user_data)
63 {
64   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
65   g_assert (_obj);
66   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
67   g_assert (child);
68
69   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 10, NULL);
70   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
71   g_assert (obj);
72
73   GPtrArray *ret = atspi_table_cell_get_column_header_cells (obj, NULL);
74   g_assert_cmpint (3, ==, ret->len);
75 }
76 */
77
78 static void
79 atk_test_table_cell_get_column_index (gpointer fixture, gconstpointer user_data)
80 {
81   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
82   g_assert (_obj);
83   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
84   g_assert (child);
85
86   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 10, NULL);
87   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
88   g_assert (obj);
89
90   /* ATK Table Cell interface do not implement that func */
91   g_assert_cmpint (-1, ==, atspi_table_cell_get_column_index (obj, NULL));
92 }
93
94 static void
95 atk_test_table_cell_get_row_span (gpointer fixture, gconstpointer user_data)
96 {
97   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
98   g_assert (_obj);
99   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
100   g_assert (child);
101
102   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 9, NULL);
103   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
104   g_assert (obj);
105
106   g_assert_cmpint (2, ==, atspi_table_cell_get_row_span (obj, NULL));
107
108   cell = atspi_accessible_get_child_at_index (child, 11, NULL);
109   obj = atspi_accessible_get_table_cell (cell);
110   g_assert (obj);
111
112   g_assert_cmpint (1, ==, atspi_table_cell_get_column_span (obj, NULL));
113 }
114
115 /*
116 static void
117 atk_test_table_cell_get_row_header_cells (gpointer fixture, gconstpointer user_data)
118 {
119   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
120   g_assert (_obj);
121   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
122   g_assert (child);
123
124   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 10, NULL);
125   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
126   g_assert (obj);
127
128   GPtrArray *ret = atspi_table_cell_get_row_header_cells (obj, NULL);
129   g_assert_cmpint (4, ==, ret->len);
130 }
131 */
132
133 static void
134 atk_test_table_cell_get_row_column_span (gpointer fixture, gconstpointer user_data)
135 {
136   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
137   g_assert (_obj);
138   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
139   g_assert (child);
140
141   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 9, NULL);
142   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
143   g_assert (obj);
144
145   gint row = 10;
146   gint column = 10;
147   gint row_span = 10;
148   gint column_span = 10;
149
150   atspi_table_cell_get_row_column_span (obj, &row, &column, &row_span, &column_span, NULL);
151
152   g_assert_cmpint (row, ==, 0);
153   g_assert_cmpint (column, ==, 0);
154   g_assert_cmpint (row_span, ==, 2);
155   g_assert_cmpint (column_span, ==, 1);
156 }
157
158 static void
159 atk_test_table_cell_get_table (gpointer fixture, gconstpointer user_data)
160 {
161   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
162   g_assert (_obj);
163   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
164   g_assert (child);
165
166   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 9, NULL);
167   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
168   g_assert (obj);
169
170   AtspiAccessible *tab = atspi_table_cell_get_table (obj, NULL);
171   g_assert (tab);
172   g_assert (child == tab);
173 }
174
175 static void
176 teardown_table_cell_test (gpointer fixture, gconstpointer user_data)
177 {
178   kill (child_pid, SIGTERM);
179 }
180
181 void
182 atk_test_table_cell (void)
183 {
184   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_accessible_get_table_cell",
185                      0, NULL, NULL, atk_test_accessible_get_table_cell, teardown_table_cell_test);
186   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_column_span",
187                      0, NULL, NULL, atk_test_table_cell_get_column_span, teardown_table_cell_test);
188   /*
189     g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_column_header_cells",
190                        0, NULL, NULL, atk_test_table_cell_get_column_header_cells, teardown_table_cell_test);
191   */
192   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_column_index",
193                      0, NULL, NULL, atk_test_table_cell_get_column_index, teardown_table_cell_test);
194   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_row_span",
195                      0, NULL, NULL, atk_test_table_cell_get_row_span, teardown_table_cell_test);
196   /*
197     g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_row_header_cells",
198                        0, NULL, NULL, atk_test_table_cell_get_row_header_cells, teardown_table_cell_test);
199   */
200   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_row_column_span",
201                      0, NULL, NULL, atk_test_table_cell_get_row_column_span, teardown_table_cell_test);
202   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_table",
203                      0, NULL, NULL, atk_test_table_cell_get_table, teardown_table_cell_test);
204
205
206 }