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-editable-text.xml"
27

            
28
static void
29
1
atk_test_editable_text_get_editable_text_iface (TestAppFixture *fixture, gconstpointer user_data)
30
{
31
1
  AtspiAccessible *obj = fixture->root_obj;
32
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
33
1
  AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
34
1
  g_assert_nonnull (iface);
35
1
  g_object_unref (iface);
36
1
  g_object_unref (child);
37
1
}
38

            
39
#if 0
40
/* Function is in docs but not implemented */
41
static void
42
atk_test_editable_text_set_attributes  (TestAppFixture *fixture, gconstpointer user_data)
43
{
44
  AtspiAccessible *obj = fixture->root_obj;
45
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
46
  AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
47
  g_assert_nonnull (iface);
48

            
49
  g_assert_true (atspi_editable_text_set_attributes (iface, "attribute", 1, 2, NULL));
50
}
51
#endif
52

            
53
static void
54
1
atk_test_editable_text_insert_text (TestAppFixture *fixture, gconstpointer user_data)
55
{
56
1
  AtspiAccessible *obj = fixture->root_obj;
57
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
58
1
  AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
59
1
  g_assert_nonnull (iface);
60
1
  g_assert_true (atspi_editable_text_insert_text (iface, 0, "test_text", 9, NULL));
61
1
  g_object_unref (iface);
62
1
  g_object_unref (child);
63
1
}
64

            
65
static void
66
1
atk_test_editable_text_copy_text (TestAppFixture *fixture, gconstpointer user_data)
67
{
68
1
  AtspiAccessible *obj = fixture->root_obj;
69
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
70
1
  AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
71
1
  g_assert_nonnull (iface);
72
1
  g_assert_true (atspi_editable_text_copy_text (iface, 1, 2, NULL));
73
1
  g_object_unref (iface);
74
1
  g_object_unref (child);
75
1
}
76

            
77
static void
78
1
atk_test_editable_text_cut_text (TestAppFixture *fixture, gconstpointer user_data)
79
{
80
1
  AtspiAccessible *obj = fixture->root_obj;
81
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
82
1
  AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
83
1
  g_assert_nonnull (iface);
84
1
  g_assert_true (atspi_editable_text_cut_text (iface, 1, 2, NULL));
85
1
  g_object_unref (iface);
86
1
  g_object_unref (child);
87
1
}
88

            
89
static void
90
1
atk_test_editable_text_delete_text (TestAppFixture *fixture, gconstpointer user_data)
91
{
92
1
  AtspiAccessible *obj = fixture->root_obj;
93
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
94
1
  AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
95
1
  g_assert_nonnull (iface);
96

            
97
1
  g_assert_true (atspi_editable_text_delete_text (iface, 1, 2, NULL));
98
1
  g_object_unref (iface);
99
1
  g_object_unref (child);
100
1
}
101

            
102
static void
103
1
atk_test_editable_text_paste_text (TestAppFixture *fixture, gconstpointer user_data)
104
{
105
1
  AtspiAccessible *obj = fixture->root_obj;
106
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
107
1
  AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
108
1
  g_assert_nonnull (iface);
109

            
110
1
  g_assert_true (atspi_editable_text_paste_text (iface, 2, NULL));
111
1
  g_object_unref (iface);
112
1
  g_object_unref (child);
113
1
}
114

            
115
void
116
1
atk_test_editable_text (void)
117
{
118
1
  g_test_add ("/editable_text/atk_test_editable_text_get_editable_text_iface",
119
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_editable_text_get_editable_text_iface, fixture_teardown);
120
#if 0
121
  g_test_add ("/editable_text/atk_test_editable_text_set_attributes",
122
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_editable_text_set_attributes, fixture_teardown);
123
#endif
124
1
  g_test_add ("/editable_text/atk_test_editable_text_insert_text",
125
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_editable_text_insert_text, fixture_teardown);
126
1
  g_test_add ("/editable_text/atk_test_editable_text_copy_text",
127
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_editable_text_copy_text, fixture_teardown);
128
1
  g_test_add ("/editable_text/atk_test_editable_text_cut_text",
129
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_editable_text_cut_text, fixture_teardown);
130
1
  g_test_add ("/editable_text/atk_test_editable_text_delete_text",
131
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_editable_text_delete_text, fixture_teardown);
132
1
  g_test_add ("/editable_text/atk_test_editable_text_paste_text",
133
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_editable_text_paste_text, fixture_teardown);
134
1
}