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_suite.h"
22
#include "atk_test_util.h"
23

            
24
#define DATA_FILE TESTS_DATA_DIR "/test-value.xml"
25

            
26
static void
27
1
atk_test_value_get_value_iface (TestAppFixture *fixture, gconstpointer user_data)
28
{
29
1
  AtspiAccessible *_obj = fixture->root_obj;
30
1
  g_assert_nonnull (_obj);
31
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
32
1
  g_assert_nonnull (child);
33
1
  AtspiValue *obj = atspi_accessible_get_value_iface (child);
34
1
  g_assert_nonnull (obj);
35
1
  g_object_unref (obj);
36
1
  g_object_unref (child);
37
1
}
38

            
39
static void
40
1
atk_test_value_get_minimum_value (TestAppFixture *fixture, gconstpointer user_data)
41
{
42
1
  AtspiAccessible *_obj = fixture->root_obj;
43
1
  g_assert_nonnull (_obj);
44
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
45
1
  g_assert_nonnull (child);
46
1
  AtspiValue *obj = atspi_accessible_get_value_iface (child);
47
1
  gdouble val = atspi_value_get_minimum_value (obj, NULL);
48
1
  g_assert_cmpfloat (val, ==, 1.25);
49
1
  g_object_unref (obj);
50
1
  g_object_unref (child);
51
1
}
52

            
53
static void
54
1
atk_test_value_get_current_value (TestAppFixture *fixture, gconstpointer user_data)
55
{
56
1
  AtspiAccessible *_obj = fixture->root_obj;
57
1
  g_assert_nonnull (_obj);
58
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
59
1
  g_assert_nonnull (child);
60
1
  AtspiValue *obj = atspi_accessible_get_value_iface (child);
61
1
  gdouble val = atspi_value_get_current_value (obj, NULL);
62
1
  g_assert_cmpfloat (val, ==, 2.25);
63
1
  g_object_unref (obj);
64
1
  g_object_unref (child);
65
1
}
66

            
67
static void
68
1
atk_test_value_get_maximum_value (TestAppFixture *fixture, gconstpointer user_data)
69
{
70
1
  AtspiAccessible *_obj = fixture->root_obj;
71
1
  g_assert_nonnull (_obj);
72
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
73
1
  g_assert_nonnull (child);
74
1
  AtspiValue *obj = atspi_accessible_get_value_iface (child);
75
1
  gdouble val = atspi_value_get_maximum_value (obj, NULL);
76
1
  g_assert_cmpfloat (val, ==, 3.25);
77
1
  g_object_unref (obj);
78
1
  g_object_unref (child);
79
1
}
80

            
81
static void
82
1
atk_test_value_set_current_value (TestAppFixture *fixture, gconstpointer user_data)
83
{
84
1
  AtspiAccessible *_obj = fixture->root_obj;
85
1
  g_assert_nonnull (_obj);
86
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
87
1
  g_assert_nonnull (child);
88
1
  AtspiValue *obj = atspi_accessible_get_value_iface (child);
89
1
  g_assert_true (atspi_value_set_current_value (obj, 2.5, NULL));
90
1
  gdouble val = atspi_value_get_current_value (obj, NULL);
91
1
  g_assert_cmpfloat (val, ==, 2.5);
92
1
  g_object_unref (obj);
93
1
  g_object_unref (child);
94
1
}
95

            
96
static void
97
1
atk_test_value_get_minimum_increment (TestAppFixture *fixture, gconstpointer user_data)
98
{
99
1
  AtspiAccessible *_obj = fixture->root_obj;
100
1
  g_assert_nonnull (_obj);
101
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
102
1
  g_assert_nonnull (child);
103
1
  AtspiValue *obj = atspi_accessible_get_value_iface (child);
104
1
  gdouble val = atspi_value_get_minimum_increment (obj, NULL);
105
1
  g_assert_cmpfloat (val, ==, 0.25);
106
1
  g_object_unref (obj);
107
1
  g_object_unref (child);
108
1
}
109

            
110
static void
111
1
atk_test_value_get_text (TestAppFixture *fixture, gconstpointer user_data)
112
{
113
1
  AtspiAccessible *_obj = fixture->root_obj;
114
1
  g_assert_nonnull (_obj);
115
1
  AtspiAccessible *child = atspi_accessible_get_child_at_index (_obj, 0, NULL);
116
1
  g_assert_nonnull (child);
117
1
  AtspiValue *obj = atspi_accessible_get_value_iface (child);
118
1
  gchar *text = atspi_value_get_text (obj, NULL);
119
1
  g_assert_cmpstr (text, ==, "2.250000");
120
1
  g_free (text);
121
1
  g_object_unref (obj);
122
1
  g_object_unref (child);
123
1
}
124

            
125
void
126
1
atk_test_value (void)
127
{
128
1
  g_test_add ("/value/atk_test_value_get_value_iface",
129
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_value_get_value_iface, fixture_teardown);
130
1
  g_test_add ("/value/atk_test_value_get_minimum_value",
131
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_value_get_minimum_value, fixture_teardown);
132
1
  g_test_add ("/value/atk_test_value_get_current_value",
133
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_value_get_current_value, fixture_teardown);
134
1
  g_test_add ("/value/atk_test_value_get_maximum_value",
135
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_value_get_maximum_value, fixture_teardown);
136
1
  g_test_add ("/value/atk_test_value_set_current_value",
137
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_value_set_current_value, fixture_teardown);
138
1
  g_test_add ("/value/atk_test_value_get_minimum_increment",
139
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_value_get_minimum_increment, fixture_teardown);
140
1
  g_test_add ("/value/atk_test_value_get_text",
141
              TestAppFixture, DATA_FILE, fixture_setup, atk_test_value_get_text, fixture_teardown);
142
1
}