2.34.1
[platform/upstream/at-spi2-atk.git] / tests / atk_test_image.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility)
4  *
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #include "atk_suite.h"
24 #include "atk_test_util.h"
25
26 #define DATA_FILE TESTS_DATA_DIR"/test-image.xml"
27
28 static void
29 teardown_image_test (gpointer fixture, gconstpointer user_data)
30 {
31   terminate_app ();
32 }
33
34 static void
35 atk_test_image_sample_get_interface (gpointer fixture, gconstpointer user_data)
36 {
37   AtspiAccessible *obj = get_root_obj (DATA_FILE);
38   g_assert_cmpstr (atspi_accessible_get_name (obj, NULL), ==, "root_object");
39   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL);
40   AtspiImage *iface = atspi_accessible_get_image_iface (child);
41   g_assert (iface != NULL);
42 }
43
44 static void
45 atk_test_image_get_image_description (gpointer fixture, gconstpointer user_data)
46 {
47   AtspiAccessible *obj = get_root_obj (DATA_FILE);
48   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL);
49   AtspiImage *image = atspi_accessible_get_image_iface (child);
50   gchar *desc = atspi_image_get_image_description (image, NULL);
51   g_assert (desc);
52   g_assert_cmpstr (desc, == ,"image description");
53   g_free (desc);
54 }
55
56 static void
57 atk_test_image_get_image_size (gpointer fixture, gconstpointer user_data)
58 {
59   AtspiAccessible *obj = get_root_obj (DATA_FILE);
60   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL);
61   AtspiImage *image = atspi_accessible_get_image_iface (child);
62   AtspiPoint *p = atspi_image_get_image_size (image, NULL);
63   g_assert (p);
64
65   g_assert_cmpint (p->x,==,100);
66   g_assert_cmpint (p->y,==,50);
67   g_free (p);
68 }
69
70 static void
71 atk_test_image_get_image_position (gpointer fixture, gconstpointer user_data)
72 {
73   AtspiAccessible *obj = get_root_obj (DATA_FILE);
74   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL);
75   AtspiImage *image = atspi_accessible_get_image_iface (child);
76   AtspiPoint *p = atspi_image_get_image_position (image, ATSPI_COORD_TYPE_SCREEN, NULL);
77   g_assert (p);
78   g_assert_cmpint (p->x,==,500);
79   g_assert_cmpint (p->y,==,50);
80   g_free (p);
81 }
82
83 static void
84 atk_test_image_get_image_extents (gpointer fixture, gconstpointer user_data)
85 {
86   AtspiAccessible *obj = get_root_obj (DATA_FILE);
87   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL);
88   AtspiImage *image = atspi_accessible_get_image_iface (child);
89   AtspiRect *r = atspi_image_get_image_extents (image, ATSPI_COORD_TYPE_SCREEN, NULL);
90   g_assert (r);
91
92   g_assert_cmpint (r->x, ==, 500);
93   g_assert_cmpint (r->y, ==, 50);
94   g_assert_cmpint (r->width, ==, 100);
95   g_assert_cmpint (r->height, ==, 50);
96
97   g_free (r);
98 }
99
100 static void
101 atk_test_image_get_image_locale (gpointer fixture, gconstpointer user_data)
102 {
103   AtspiAccessible *obj = get_root_obj (DATA_FILE);
104   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj,1, NULL);
105   AtspiImage *image = atspi_accessible_get_image_iface (child);
106   gchar *locale = atspi_image_get_image_locale (image, NULL);
107
108   g_assert (locale);
109   g_assert_cmpstr (locale, ==,"image_locale");
110   g_free (locale);
111 }
112
113 void
114 atk_test_image (void)
115 {
116   g_test_add_vtable (ATK_TEST_PATH_IMAGE "/atk_test_image_sample_get_interface",
117                      0, NULL, NULL, atk_test_image_sample_get_interface, teardown_image_test);
118   g_test_add_vtable (ATK_TEST_PATH_IMAGE "/atk_test_image_get_image_description",
119                      0, NULL, NULL, atk_test_image_get_image_description, teardown_image_test);
120   g_test_add_vtable (ATK_TEST_PATH_IMAGE "/atk_test_image_get_image_size",
121                      0, NULL, NULL, atk_test_image_get_image_size, teardown_image_test);
122   g_test_add_vtable (ATK_TEST_PATH_IMAGE "/atk_test_image_get_image_position",
123                      0, NULL, NULL, atk_test_image_get_image_position, teardown_image_test);
124   g_test_add_vtable (ATK_TEST_PATH_IMAGE "/atk_test_image_get_image_extents",
125                      0, NULL, NULL, atk_test_image_get_image_extents, teardown_image_test);
126   g_test_add_vtable (ATK_TEST_PATH_IMAGE "/atk_test_image_get_image_locale",
127                      0, NULL, NULL, atk_test_image_get_image_locale, teardown_image_test);
128 }