2.38.0
[platform/upstream/at-spi2-atk.git] / tests / atk_test_editable_text.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-editable-text.xml"
27
28 static void
29 teardown_editable_text_test (gpointer fixture, gconstpointer user_data)
30 {
31   terminate_app ();
32 }
33
34 static void
35 atk_test_editable_text_get_editable_text_iface (gpointer fixture, gconstpointer user_data)
36 {
37   AtspiAccessible *obj = get_root_obj (DATA_FILE);
38   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
39   AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
40   g_assert (iface != NULL);
41 }
42
43 #if 0
44 /* Function is in docs but not implemented */
45 static void
46 atk_test_editable_text_set_attributes  (gpointer fixture, gconstpointer user_data)
47 {
48   AtspiAccessible *obj = get_root_obj (DATA_FILE);
49   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
50   AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
51   g_assert (iface != NULL);
52
53   g_assert (atspi_editable_text_set_attributes (iface, "attribute", 1, 2, NULL));
54 }
55 #endif
56
57 static void
58 atk_test_editable_text_insert_text (gpointer fixture, gconstpointer user_data)
59 {
60   AtspiAccessible *obj = get_root_obj (DATA_FILE);
61   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
62   AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
63   g_assert (iface != NULL);
64   g_assert (atspi_editable_text_insert_text (iface, 0, "test_text", 9, NULL));
65 }
66
67 static void
68 atk_test_editable_text_copy_text (gpointer fixture, gconstpointer user_data)
69 {
70   AtspiAccessible *obj = get_root_obj (DATA_FILE);
71   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
72   AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
73   g_assert (iface != NULL);
74   g_assert (atspi_editable_text_copy_text (iface, 1, 2, NULL));
75 }
76
77 static void
78 atk_test_editable_text_cut_text (gpointer fixture, gconstpointer user_data)
79 {
80   AtspiAccessible *obj = get_root_obj (DATA_FILE);
81   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
82   AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
83   g_assert (iface != NULL);
84   g_assert (atspi_editable_text_cut_text (iface, 1, 2, NULL));
85 }
86
87 static void
88 atk_test_editable_text_delete_text (gpointer fixture, gconstpointer user_data)
89 {
90   AtspiAccessible *obj = get_root_obj (DATA_FILE);
91   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
92   AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
93   g_assert (iface != NULL);
94
95   g_assert (atspi_editable_text_delete_text (iface, 1, 2, NULL));
96 }
97
98 static void
99 atk_test_editable_text_paste_text (gpointer fixture, gconstpointer user_data)
100 {
101   AtspiAccessible *obj = get_root_obj (DATA_FILE);
102   AtspiAccessible *child = atspi_accessible_get_child_at_index (obj, 1, NULL);
103   AtspiEditableText *iface = atspi_accessible_get_editable_text_iface (child);
104   g_assert (iface != NULL);
105
106   g_assert (atspi_editable_text_paste_text (iface, 2, NULL));
107 }
108
109 void
110 atk_test_editable_text(void )
111 {
112   g_test_add_vtable (ATK_TEST_PATH_EDIT_TEXT "/atk_test_editable_text_get_editable_text_iface",
113                      0, NULL, NULL, atk_test_editable_text_get_editable_text_iface, teardown_editable_text_test);
114 #if 0
115   g_test_add_vtable (ATK_TEST_PATH_EDIT_TEXT "/atk_test_editable_text_set_attributes",
116                      0, NULL, NULL, atk_test_editable_text_set_attributes, teardown_editable_text_test);
117 #endif
118   g_test_add_vtable (ATK_TEST_PATH_EDIT_TEXT "/atk_test_editable_text_insert_text",
119                      0, NULL, NULL, atk_test_editable_text_insert_text, teardown_editable_text_test);
120   g_test_add_vtable (ATK_TEST_PATH_EDIT_TEXT "/atk_test_editable_text_copy_text",
121                      0, NULL, NULL, atk_test_editable_text_copy_text, teardown_editable_text_test);
122   g_test_add_vtable (ATK_TEST_PATH_EDIT_TEXT "/atk_test_editable_text_cut_text",
123                      0, NULL, NULL, atk_test_editable_text_cut_text, teardown_editable_text_test);
124   g_test_add_vtable (ATK_TEST_PATH_EDIT_TEXT "/atk_test_editable_text_delete_text",
125                      0, NULL, NULL, atk_test_editable_text_delete_text, teardown_editable_text_test);
126   g_test_add_vtable (ATK_TEST_PATH_EDIT_TEXT "/atk_test_editable_text_paste_text",
127                      0, NULL, NULL, atk_test_editable_text_paste_text, teardown_editable_text_test);
128 }