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.
17 * @file test_cases.cpp
18 * @author Tonasz Swierczek (t.swierczek@samsung.com)
20 * @brief Implementation file for ACE settings test cases.
22 #include <dpl/test/test_runner.h>
24 #include "ace_api_settings.h"
28 static const char* resource1 = "resource1-name";
29 static const char* resource2 = "resource2-name";
30 static int handle1 = 0;
31 static int handle2 = 1;
32 static ace_preference_t preference1 = ACE_PREFERENCE_PERMIT;
33 static ace_preference_t preference2 = ACE_PREFERENCE_BLANKET_PROMPT;
37 RUNNER_TEST_GROUP_INIT(ACE_SETTINGS_TEST_SUITE)
40 * test author: Tomasz Swierczek (t.swierczek@samsung.com)
41 * tested functions: ace_settings_initialize(), ace_settings_shutdown()
42 * purpose: New C-API tests. Tests proper initialization and deinitialization
43 * of ace-settings library.
45 RUNNER_TEST(ace_settings_test_01_initialization)
47 RUNNER_ASSERT(ACE_OK == ace_settings_initialize());
48 RUNNER_ASSERT(ACE_OK == ace_settings_shutdown());
49 RUNNER_ASSERT(ACE_OK == ace_settings_initialize());
53 * test author: Tomasz Swierczek (t.swierczek@samsung.com)
54 * tested functions: ace_set_global_resource_preference(),
55 * ace_get_global_resource_preference()
56 * purpose: New C-API tests. Tests setting and getting global per resource
59 RUNNER_TEST(ace_settings_test_02_global_preferences)
61 RUNNER_ASSERT(ACE_OK == ace_set_global_resource_preference(
62 const_cast<char*>(resource1), preference1));
63 ace_preference_t pref;
64 RUNNER_ASSERT(ACE_OK == ace_get_global_resource_preference(
65 const_cast<char*>(resource1), &pref));
66 RUNNER_ASSERT(preference1 == pref);
68 RUNNER_ASSERT(ACE_OK == ace_set_global_resource_preference(
69 const_cast<char*>(resource2), preference2));
70 RUNNER_ASSERT(ACE_OK == ace_get_global_resource_preference(
71 const_cast<char*>(resource2), &pref));
72 RUNNER_ASSERT(preference2 == pref);
76 * test author: Tomasz Swierczek (t.swierczek@samsung.com)
77 * tested functions: ace_set_widget_resource_preference(),
78 * ace_get_widget_resource_preference()
79 * purpose: New C-API tests. Tests setting and getting per widget/resource
82 RUNNER_TEST(ace_settings_test_03_widget_preferences)
84 RUNNER_ASSERT(ACE_OK == ace_set_widget_resource_preference(handle1,
85 const_cast<char*>(resource1),
87 ace_preference_t pref;
88 RUNNER_ASSERT(ACE_OK == ace_get_widget_resource_preference(handle1,
89 const_cast<char*>(resource1),
91 RUNNER_ASSERT(preference1 == pref);
93 RUNNER_ASSERT(ACE_OK == ace_set_widget_resource_preference(handle2,
94 const_cast<char*>(resource2),
96 RUNNER_ASSERT(ACE_OK == ace_get_widget_resource_preference(handle2,
97 const_cast<char*>(resource2),
99 RUNNER_ASSERT(preference2 == pref);
103 * test author: Tomasz Swierczek (t.swierczek@samsung.com)
104 * tested functions: ace_get_widget_resource_preference(),
105 * ace_get_global_resource_preference(),
106 * ace_reset_widget_resource_settings(),
107 * ace_reset_global_resource_settings()
108 * purpose: New C-API tests. Tests proper resetting of settings database.
110 RUNNER_TEST(ace_settings_test_04_database_reset)
112 RUNNER_ASSERT(ACE_OK == ace_reset_widget_resource_settings());
113 RUNNER_ASSERT(ACE_OK == ace_reset_global_resource_settings());
114 ace_preference_t pref;
115 RUNNER_ASSERT(ACE_OK == ace_get_widget_resource_preference(handle1,
116 const_cast<char*>(resource1),
118 RUNNER_ASSERT(ACE_PREFERENCE_DEFAULT == pref);
119 RUNNER_ASSERT(ACE_OK == ace_get_widget_resource_preference(handle2,
120 const_cast<char*>(resource2),
122 RUNNER_ASSERT(ACE_PREFERENCE_DEFAULT == pref);
123 RUNNER_ASSERT(ACE_OK == ace_get_global_resource_preference(
124 const_cast<char*>(resource1),
126 RUNNER_ASSERT(ACE_PREFERENCE_DEFAULT == pref);
127 RUNNER_ASSERT(ACE_OK == ace_get_global_resource_preference(
128 const_cast<char*>(resource2),
130 RUNNER_ASSERT(ACE_PREFERENCE_DEFAULT == pref);
134 * test author: Bartlomiej Grzelewski (b.grzelewski@samsung.com)
135 * tested functions: ace_is_private_api
136 * purpose: This function should return true if device cap
137 * belongs to private api.
139 RUNNER_TEST(ace_settings_test_05_private_api_positive)
141 static const char *api_private[] = {
147 for (int i=0; api_private[i]; ++i) {
148 ace_bool_t response = ACE_FALSE;
149 RUNNER_ASSERT(ACE_OK == ace_is_private_api(
150 const_cast<char*>(api_private[i]), &response));
151 RUNNER_ASSERT(ACE_TRUE == response);
156 * test author: Bartlomiej Grzelewski (b.grzelewski@samsung.com)
157 * tested functions: ace_is_private_api
158 * purpose: All calls should fail as non of the strings are connected with
161 RUNNER_TEST(ace_settings_test_06_private_api_negative)
163 static const char *api_private[] = {
171 for (int i=0; api_private[i]; ++i) {
172 ace_bool_t response = ACE_TRUE;
173 RUNNER_ASSERT(ACE_OK == ace_is_private_api(
174 const_cast<char*>(api_private[i]), &response));
175 RUNNER_ASSERT(ACE_FALSE == response);