2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <system_settings.h>
28 #include <glib-object.h>
30 static void startup(void);
31 static void cleanup(void);
33 void (*tet_startup)(void) = startup;
34 void (*tet_cleanup)(void) = cleanup;
37 #define API_NAME_SETTINGS_SET_VALUE_STRING "system_settings_set_value_string"
38 #define API_NAME_SETTINGS_GET_VALUE_STRING "system_settings_get_value_string"
39 #define API_NAME_SETTINGS_SET_VALUE_INT "system_settings_set_value_int"
40 #define API_NAME_SETTINGS_GET_VALUE_INT "system_settings_get_value_int"
41 #define API_NAME_SETTINGS_SET_VALUE_BOOL "system_settings_set_value_bool"
42 #define API_NAME_SETTINGS_GET_VALUE_BOOL "system_settings_get_value_bool"
43 #define API_NAME_SETTINGS_SET_CHANGED_CB "system_settings_set_changed_cb"
44 #define API_NAME_SETTINGS_UNSET_CHANGED_CB "system_settings_unset_changed_cb"
46 static void utc_system_settings_set_string_p(void);
47 static void utc_system_settings_set_bool_p(void);
48 static void utc_system_settings_get_string_p(void);
49 static void utc_system_settings_get_int_p(void);
50 static void utc_system_settings_get_bool_p(void);
51 static void utc_system_settings_set_changed_cb(void);
52 static void utc_system_settings_unset_changed_cb(void);
55 struct tet_testlist tet_testlist[] = {
56 {utc_system_settings_set_string_p, 1},
57 {utc_system_settings_set_bool_p, 1},
58 {utc_system_settings_get_string_p, 1},
59 {utc_system_settings_get_int_p, 1},
60 {utc_system_settings_get_bool_p, 1},
61 {utc_system_settings_set_changed_cb, 1},
62 {utc_system_settings_unset_changed_cb, 1},
66 static GMainLoop* main_loop;
67 static int timeout = 5;
69 static void startup(void)
71 main_loop = g_main_loop_new(NULL, FALSE);
74 static void cleanup(void)
79 static gboolean callback(gpointer data)
81 /*int ret =*/ system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 1);
87 g_main_loop_quit((GMainLoop*)data);
94 static void utc_system_settings_changed_motion_activation(system_settings_key_e key, void *user_data)
99 static void utc_system_settings_set_string_p(void)
101 int retcode = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, "/opt/share/settings/Ringtones/General_Over the horizon.mp3");
103 if (retcode == SYSTEM_SETTINGS_ERROR_NONE) {
104 dts_pass(API_NAME_SETTINGS_SET_VALUE_STRING, "passed");
107 dts_fail(API_NAME_SETTINGS_SET_VALUE_STRING, "failed");
111 static void utc_system_settings_set_bool_p(void)
113 int retcode = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, true);
115 if (retcode == SYSTEM_SETTINGS_ERROR_NONE) {
116 dts_pass(API_NAME_SETTINGS_SET_VALUE_BOOL, "passed");
119 dts_fail(API_NAME_SETTINGS_SET_VALUE_BOOL, "failed");
123 static void utc_system_settings_get_string_p(void)
126 int retcode = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &value);
128 if (retcode == SYSTEM_SETTINGS_ERROR_NONE) {
129 dts_pass(API_NAME_SETTINGS_GET_VALUE_STRING, "passed");
132 dts_fail(API_NAME_SETTINGS_GET_VALUE_STRING, "failed");
136 static void utc_system_settings_get_int_p(void)
139 int retcode = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &value);
141 if (retcode == SYSTEM_SETTINGS_ERROR_NONE) {
142 dts_pass(API_NAME_SETTINGS_GET_VALUE_INT, "passed");
145 dts_fail(API_NAME_SETTINGS_GET_VALUE_INT, "failed");
149 static void utc_system_settings_get_bool_p(void)
152 int retcode = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, &value);
154 if (retcode == SYSTEM_SETTINGS_ERROR_NONE) {
155 dts_pass(API_NAME_SETTINGS_GET_VALUE_BOOL, "passed");
158 dts_fail(API_NAME_SETTINGS_GET_VALUE_BOOL, "failed");
162 static void utc_system_settings_set_changed_cb(void)
164 int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, utc_system_settings_changed_motion_activation, NULL);
166 if (retcode == SYSTEM_SETTINGS_ERROR_NONE) {
167 dts_pass(API_NAME_SETTINGS_SET_CHANGED_CB, "passed");
170 dts_fail(API_NAME_SETTINGS_SET_CHANGED_CB, "failed");
173 g_timeout_add_seconds(5, callback, main_loop);
174 g_main_loop_run(main_loop);
175 g_main_loop_unref(main_loop);
178 static void utc_system_settings_unset_changed_cb(void)
180 int retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION);
182 if (retcode == SYSTEM_SETTINGS_ERROR_NONE) {
183 dts_pass(API_NAME_SETTINGS_UNSET_CHANGED_CB, "passed");
186 dts_fail(API_NAME_SETTINGS_UNSET_CHANGED_CB, "failed");