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-value.xml"
25
26 static void
atk_test_value_get_value_iface(gpointer fixture,gconstpointer user_data)27 atk_test_value_get_value_iface (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 AtspiValue *obj = atspi_accessible_get_value_iface (child);
34 g_assert (obj);
35 }
36
37 static void
atk_test_value_get_minimum_value(gpointer fixture,gconstpointer user_data)38 atk_test_value_get_minimum_value (gpointer fixture, gconstpointer user_data)
39 {
40 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
41 g_assert (_obj);
42 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
43 g_assert (child);
44 AtspiValue *obj = atspi_accessible_get_value_iface (child);
45 gdouble val = atspi_value_get_minimum_value (obj, NULL);
46 g_assert_cmpfloat (val, ==, 1.25);
47 }
48
49 static void
atk_test_value_get_current_value(gpointer fixture,gconstpointer user_data)50 atk_test_value_get_current_value (gpointer fixture, gconstpointer user_data)
51 {
52 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
53 g_assert (_obj);
54 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
55 g_assert (child);
56 AtspiValue *obj = atspi_accessible_get_value_iface (child);
57 gdouble val = atspi_value_get_current_value (obj, NULL);
58 g_assert_cmpfloat (val, ==, 2.25);
59 }
60
61 static void
atk_test_value_get_maximum_value(gpointer fixture,gconstpointer user_data)62 atk_test_value_get_maximum_value (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 AtspiValue *obj = atspi_accessible_get_value_iface (child);
69 gdouble val = atspi_value_get_maximum_value (obj, NULL);
70 g_assert_cmpfloat (val, ==, 3.25);
71 }
72
73 static void
atk_test_value_set_current_value(gpointer fixture,gconstpointer user_data)74 atk_test_value_set_current_value (gpointer fixture, gconstpointer user_data)
75 {
76 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
77 g_assert (_obj);
78 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
79 g_assert (child);
80 AtspiValue *obj = atspi_accessible_get_value_iface (child);
81 g_assert (atspi_value_set_current_value (obj, 2.5, NULL));
82 gdouble val = atspi_value_get_current_value (obj, NULL);
83 g_assert_cmpfloat (val, ==, 2.5);
84 }
85
86 static void
atk_test_value_get_minimum_increment(gpointer fixture,gconstpointer user_data)87 atk_test_value_get_minimum_increment (gpointer fixture, gconstpointer user_data)
88 {
89 AtspiAccessible *_obj = get_root_obj (DATA_FILE);
90 g_assert (_obj);
91 AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
92 g_assert (child);
93 AtspiValue *obj = atspi_accessible_get_value_iface (child);
94 gdouble val = atspi_value_get_minimum_increment (obj, NULL);
95 g_assert_cmpfloat (val, ==, 0.25);
96 }
97
98 static void
teardown_value_test(gpointer fixture,gconstpointer user_data)99 teardown_value_test (gpointer fixture, gconstpointer user_data)
100 {
101 terminate_app ();
102 }
103
104 void
atk_test_value(void)105 atk_test_value (void)
106 {
107 g_test_add_vtable (ATK_TEST_PATH_VALUE "/atk_test_value_get_value_iface",
108 0, NULL, NULL, atk_test_value_get_value_iface, teardown_value_test );
109 g_test_add_vtable (ATK_TEST_PATH_VALUE "/atk_test_value_get_minimum_value",
110 0, NULL, NULL, atk_test_value_get_minimum_value, teardown_value_test );
111 g_test_add_vtable (ATK_TEST_PATH_VALUE "/atk_test_value_get_current_value",
112 0, NULL, NULL, atk_test_value_get_current_value, teardown_value_test );
113 g_test_add_vtable (ATK_TEST_PATH_VALUE "/atk_test_value_get_maximum_value",
114 0, NULL, NULL, atk_test_value_get_maximum_value, teardown_value_test );
115 g_test_add_vtable (ATK_TEST_PATH_VALUE "/atk_test_value_set_current_value",
116 0, NULL, NULL, atk_test_value_set_current_value, teardown_value_test );
117 g_test_add_vtable (ATK_TEST_PATH_VALUE "/atk_test_value_get_minimum_increment",
118 0, NULL, NULL, atk_test_value_get_minimum_increment, teardown_value_test );
119 }
120