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
1
atk_test_image_sample_get_interface (TestAppFixture *fixture, gconstpointer user_data)
30
{
31
1
  AtspiAccessible *obj = fixture->root_obj;
32
1
  check_name (obj, "root_object");
33
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
34
1
  AtspiImage *iface = atspi_accessible_get_image_iface (child);
35
1
  g_assert_nonnull (iface);
36
1
  g_object_unref (iface);
37
1
  g_object_unref (child);
38
1
}
39

            
40
static void
41
1
atk_test_image_get_image_description (TestAppFixture *fixture, gconstpointer user_data)
42
{
43
1
  AtspiAccessible *obj = fixture->root_obj;
44
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
45
1
  AtspiImage *image = atspi_accessible_get_image_iface (child);
46
1
  gchar *desc = atspi_image_get_image_description (image, NULL);
47
1
  g_assert_nonnull (desc);
48
1
  g_assert_cmpstr (desc, ==, "image description");
49
1
  g_free (desc);
50
1
  g_object_unref (image);
51
1
  g_object_unref (child);
52
1
}
53

            
54
static void
55
1
atk_test_image_get_image_size (TestAppFixture *fixture, gconstpointer user_data)
56
{
57
1
  AtspiAccessible *obj = fixture->root_obj;
58
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
59
1
  AtspiImage *image = atspi_accessible_get_image_iface (child);
60
1
  AtspiPoint *p = atspi_image_get_image_size (image, NULL);
61
1
  g_assert_nonnull (p);
62

            
63
1
  g_assert_cmpint (p->x, ==, 100);
64
1
  g_assert_cmpint (p->y, ==, 50);
65
1
  g_free (p);
66
1
  g_object_unref (image);
67
1
  g_object_unref (child);
68
1
}
69

            
70
static void
71
1
atk_test_image_get_image_position (TestAppFixture *fixture, gconstpointer user_data)
72
{
73
1
  AtspiAccessible *obj = fixture->root_obj;
74
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
75
1
  AtspiImage *image = atspi_accessible_get_image_iface (child);
76
1
  AtspiPoint *p = atspi_image_get_image_position (image, ATSPI_COORD_TYPE_SCREEN, NULL);
77
1
  g_assert_nonnull (p);
78
1
  g_assert_cmpint (p->x, ==, 500);
79
1
  g_assert_cmpint (p->y, ==, 50);
80
1
  g_free (p);
81
1
  g_object_unref (image);
82
1
  g_object_unref (child);
83
1
}
84

            
85
static void
86
1
atk_test_image_get_image_extents (TestAppFixture *fixture, gconstpointer user_data)
87
{
88
1
  AtspiAccessible *obj = fixture->root_obj;
89
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
90
1
  AtspiImage *image = atspi_accessible_get_image_iface (child);
91
1
  AtspiRect *r = atspi_image_get_image_extents (image, ATSPI_COORD_TYPE_SCREEN, NULL);
92
1
  g_assert_nonnull (r);
93

            
94
1
  g_assert_cmpint (r->x, ==, 500);
95
1
  g_assert_cmpint (r->y, ==, 50);
96
1
  g_assert_cmpint (r->width, ==, 100);
97
1
  g_assert_cmpint (r->height, ==, 50);
98

            
99
1
  g_free (r);
100
1
  g_object_unref (image);
101
1
  g_object_unref (child);
102
1
}
103

            
104
static void
105
1
atk_test_image_get_image_locale (TestAppFixture *fixture, gconstpointer user_data)
106
{
107
1
  AtspiAccessible *obj = fixture->root_obj;
108
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
109
1
  AtspiImage *image = atspi_accessible_get_image_iface (child);
110
1
  gchar *locale = atspi_image_get_image_locale (image, NULL);
111

            
112
1
  g_assert_nonnull (locale);
113
1
  g_assert_cmpstr (locale, ==, "image_locale");
114
1
  g_free (locale);
115
1
  g_object_unref (image);
116
1
  g_object_unref (child);
117
1
}
118

            
119
void
120
1
atk_test_image (void)
121
{
122
1
  g_test_add ("/image/atk_test_image_sample_get_interface",
123
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_image_sample_get_interface, fixture_teardown);
124
1
  g_test_add ("/image/atk_test_image_get_image_description",
125
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_image_get_image_description, fixture_teardown);
126
1
  g_test_add ("/image/atk_test_image_get_image_size",
127
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_image_get_image_size, fixture_teardown);
128
1
  g_test_add ("/image/atk_test_image_get_image_position",
129
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_image_get_image_position, fixture_teardown);
130
1
  g_test_add ("/image/atk_test_image_get_image_extents",
131
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_image_get_image_extents, fixture_teardown);
132
1
  g_test_add ("/image/atk_test_image_get_image_locale",
133
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_image_get_image_locale, fixture_teardown);
134
1
}