90f861dd2a940bb7bc23a84698c7dc1941fdb03c
[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 Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 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  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, 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_row_span (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, 9, NULL);
87   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
88   g_assert (obj);
89
90   g_assert_cmpint (2, ==, atspi_table_cell_get_row_span (obj, NULL));
91
92   cell = atspi_accessible_get_child_at_index (child, 11, NULL);
93   obj = atspi_accessible_get_table_cell (cell);
94   g_assert (obj);
95
96   g_assert_cmpint (1, ==, atspi_table_cell_get_column_span (obj, NULL));
97 }
98
99 /*
100 static void
101 atk_test_table_cell_get_row_header_cells (gpointer fixture, gconstpointer user_data)
102 {
103   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
104   g_assert (_obj);
105   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
106   g_assert (child);
107
108   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 10, NULL);
109   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
110   g_assert (obj);
111
112   GPtrArray *ret = atspi_table_cell_get_row_header_cells (obj, NULL);
113   g_assert_cmpint (4, ==, ret->len);
114 }
115 */
116
117 static void
118 atk_test_table_cell_get_row_column_span (gpointer fixture, gconstpointer user_data)
119 {
120   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
121   g_assert (_obj);
122   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
123   g_assert (child);
124
125   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 9, NULL);
126   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
127   g_assert (obj);
128
129   gint row = 10;
130   gint column = 10;
131   gint row_span = 10;
132   gint column_span = 10;
133
134   atspi_table_cell_get_row_column_span (obj, &row, &column, &row_span, &column_span, NULL);
135
136   g_assert_cmpint (row, ==, 0);
137   g_assert_cmpint (column, ==, 0);
138   g_assert_cmpint (row_span, ==, 2);
139   g_assert_cmpint (column_span, ==, 1);
140 }
141
142 static void
143 atk_test_table_cell_get_position (gpointer fixture, gconstpointer user_data)
144 {
145   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
146   g_assert (_obj);
147   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
148   g_assert (child);
149
150   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 9, NULL);
151   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
152   g_assert (cell);
153
154   gint row = 10;
155   gint column = 10;
156
157   atspi_table_cell_get_position (obj, &row, &column, NULL);
158
159   /* TODO: not a very good test for the app to return (-1, -1) */
160   g_assert_cmpint (row, ==, -1);
161   g_assert_cmpint (column, ==, -1);
162 }
163
164 static void
165 atk_test_table_cell_get_table (gpointer fixture, gconstpointer user_data)
166 {
167   AtspiAccessible *_obj = get_root_obj (DATA_FILE);
168   g_assert (_obj);
169   AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
170   g_assert (child);
171
172   AtspiAccessible *cell = atspi_accessible_get_child_at_index (child, 9, NULL);
173   AtspiTableCell *obj = atspi_accessible_get_table_cell (cell);
174   g_assert (obj);
175
176   AtspiAccessible *tab = atspi_table_cell_get_table (obj, NULL);
177   g_assert (tab);
178   g_assert (child == tab);
179 }
180
181 static void
182 teardown_table_cell_test (gpointer fixture, gconstpointer user_data)
183 {
184   terminate_app ();
185 }
186
187 void
188 atk_test_table_cell (void)
189 {
190   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_accessible_get_table_cell",
191                      0, NULL, NULL, atk_test_accessible_get_table_cell, teardown_table_cell_test);
192   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_column_span",
193                      0, NULL, NULL, atk_test_table_cell_get_column_span, teardown_table_cell_test);
194   /*
195     g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_column_header_cells",
196                        0, NULL, NULL, atk_test_table_cell_get_column_header_cells, teardown_table_cell_test);
197   */
198   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_row_span",
199                      0, NULL, NULL, atk_test_table_cell_get_row_span, teardown_table_cell_test);
200   /*
201     g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_row_header_cells",
202                        0, NULL, NULL, atk_test_table_cell_get_row_header_cells, teardown_table_cell_test);
203   */
204   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_row_column_span",
205                      0, NULL, NULL, atk_test_table_cell_get_row_column_span, teardown_table_cell_test);
206   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_position",
207                      0, NULL, NULL, atk_test_table_cell_get_position, teardown_table_cell_test);
208   g_test_add_vtable (ATK_TEST_PATH_TABLE_CELL "/atk_test_table_cell_get_table",
209                      0, NULL, NULL, atk_test_table_cell_get_table, teardown_table_cell_test);
210
211
212 }