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 WidgetDBTest.cpp
18 * @author Andrzej Surdej (a.surdej@samsung.com)
20 * @brief This file contains tests for widgetDB commons module
23 #include <dpl/test/test_runner.h>
24 #include <dpl/foreach.h>
25 #include <dpl/log/log.h>
26 #include <WidgetDB/IWidgetDB.h>
27 #include <WidgetDB/WidgetDBMgr.h>
28 #include <Commons/Exception.h>
30 using namespace WrtDeviceApis::WidgetDB::Api;
32 #define RUNNER_ASSERT_WHAT_EQUALS(in, test) \
35 std::string temp(in); \
36 RUNNER_ASSERT_MSG(temp == (test), "Equals: [" << temp << "]"); \
40 RUNNER_TEST_GROUP_INIT(WidgetDB)
43 * Name: widgetDB_test_get_language1
44 * Description: check default widget language
45 * Expected: default should be "en"
47 RUNNER_TEST(widgetDB_test_get_language1)
50 IWidgetDBPtr widget = getWidgetDB(2000);
51 std::string lang = widget->getLanguage();
53 LogDebug("language is: " << lang);
54 RUNNER_ASSERT_WHAT_EQUALS(lang, "en");
55 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
56 LogError("Exception thrown." << e.DumpToString());
62 * Name: widgetDB_test_get_language2
63 * Description: check language returned by WidgetDB if widget does nto exists
64 * Expected: result should be ""
66 RUNNER_TEST(widgetDB_test_get_language2)
69 IWidgetDBPtr widget = getWidgetDB(1000); //widget not exist
70 std::string lang = widget->getLanguage();
72 LogDebug("language is: " << lang);
73 RUNNER_ASSERT_WHAT_EQUALS(lang, "");
74 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
75 LogError("Exception thrown." << e.DumpToString());
81 * Name: widgetDB_test_get_config_value_id
82 * Description: check GUID returned by WidgetDB
83 * Expected: GUID should match this, which was inserted into widget database
85 RUNNER_TEST(widgetDB_test_get_config_value_id)
88 IWidgetDBPtr widget = getWidgetDB(2000);
89 std::string tmp = widget->getConfigValue(ConfigAttribute::ID);
91 LogDebug("id is: " << tmp);
92 RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_id_2000");
93 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
94 LogError("Exception thrown." << e.DumpToString());
100 * Name: widgetDB_test_get_config_value_version
101 * Description: check version returned by WidgetDB
102 * Expected: version should match this, which was inserted into widget database
104 RUNNER_TEST(widgetDB_test_get_config_value_version)
107 IWidgetDBPtr widget = getWidgetDB(2000);
108 std::string tmp = widget->getConfigValue(ConfigAttribute::VERSION);
110 LogDebug("version is: " << tmp);
111 RUNNER_ASSERT_WHAT_EQUALS(tmp, "1.0.0");
112 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
113 LogError("Exception thrown." << e.DumpToString());
114 RUNNER_ASSERT(false);
119 * Name: widgetDB_test_get_config_value_description
120 * Description: check description returned by WidgetDB
121 * Expected: description should match this, which was inserted into widget
124 RUNNER_TEST(widgetDB_test_get_config_value_description)
127 IWidgetDBPtr widget = getWidgetDB(2000);
128 std::string tmp = widget->getConfigValue(ConfigAttribute::DESCRIPTION);
130 LogDebug("description is: " << tmp);
131 RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_desc_2000_en");
132 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
133 LogError("Exception thrown." << e.DumpToString());
134 RUNNER_ASSERT(false);
139 * Name: widgetDB_test_get_config_value_license
140 * Description: check license returned by WidgetDB
141 * Expected: license should match this, which was inserted into widget database
143 RUNNER_TEST(widgetDB_test_get_config_value_license)
146 IWidgetDBPtr widget = getWidgetDB(2000);
147 std::string tmp = widget->getConfigValue(ConfigAttribute::LICENSE);
149 LogDebug("licence is: " << tmp);
150 RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_lic_2000_en");
151 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
152 LogError("Exception thrown." << e.DumpToString());
153 RUNNER_ASSERT(false);
158 * Name: widgetDB_test_get_config_value_license_href
159 * Description: check license href returned by WidgetDB
160 * Expected: license href should match this, which was inserted into widget
163 RUNNER_TEST(widgetDB_test_get_config_value_license_href)
166 IWidgetDBPtr widget = getWidgetDB(2000);
167 std::string tmp = widget->getConfigValue(ConfigAttribute::LICENSE_HREF);
169 LogDebug("license href is: " << tmp);
170 RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_lic_href_2000_en");
171 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
172 LogError("Exception thrown." << e.DumpToString());
173 RUNNER_ASSERT(false);
178 * Name: widgetDB_test_get_config_value_author_name
179 * Description: check author name href returned by WidgetDB
180 * Expected: author name should match this, which was inserted into widget
183 RUNNER_TEST(widgetDB_test_get_config_value_author_name)
186 IWidgetDBPtr widget = getWidgetDB(2000);
187 std::string tmp = widget->getConfigValue(ConfigAttribute::AUTHOR_NAME);
189 LogDebug("author name is: " << tmp);
190 RUNNER_ASSERT_WHAT_EQUALS(tmp, "a_name_2000");
191 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
192 LogError("Exception thrown." << e.DumpToString());
193 RUNNER_ASSERT(false);
198 * Name: widgetDB_test_get_config_value_author_href
199 * Description: check author href returned by WidgetDB
200 * Expected: author href should match this, which was inserted into widget
203 RUNNER_TEST(widgetDB_test_get_config_value_author_href)
206 IWidgetDBPtr widget = getWidgetDB(2000);
207 std::string tmp = widget->getConfigValue(ConfigAttribute::AUTHOR_HREF);
209 LogDebug("author href is: " << tmp);
210 RUNNER_ASSERT_WHAT_EQUALS(tmp, "a_href_2000");
211 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
212 LogError("Exception thrown." << e.DumpToString());
213 RUNNER_ASSERT(false);
218 * Name: widgetDB_test_get_config_value_author_email
219 * Description: check author email returned by WidgetDB
220 * Expected: author email should match this, which was inserted into widget
223 RUNNER_TEST(widgetDB_test_get_config_value_author_email)
226 IWidgetDBPtr widget = getWidgetDB(2000);
227 std::string tmp = widget->getConfigValue(ConfigAttribute::AUTHOR_EMAIL);
229 LogDebug("author email is: " << tmp);
230 RUNNER_ASSERT_WHAT_EQUALS(tmp, "a_email_2000");
231 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
232 LogError("Exception thrown." << e.DumpToString());
233 RUNNER_ASSERT(false);
238 * Name: widgetDB_test_get_config_value_name
239 * Description: check localized widget name returned by WidgetDB
240 * Expected: localized widget name should match this, which was inserted into
243 RUNNER_TEST(widgetDB_test_get_config_value_name)
246 IWidgetDBPtr widget = getWidgetDB(2000);
247 std::string tmp = widget->getConfigValue(ConfigAttribute::NAME);
249 LogDebug("name is: " << tmp);
250 RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_name_2000_en");
251 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
252 LogError("Exception thrown." << e.DumpToString());
253 RUNNER_ASSERT(false);
258 * Name: widgetDB_test_get_config_value_short_name
259 * Description: check localized widget short name returned by WidgetDB
260 * Expected: localized widget short name should match this, which was inserted
261 * into widget database
263 RUNNER_TEST(widgetDB_test_get_config_value_short_name)
266 IWidgetDBPtr widget = getWidgetDB(2000);
267 std::string tmp = widget->getConfigValue(ConfigAttribute::SHORT_NAME);
269 LogDebug("short name is: " << tmp);
270 RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_shortname_2000_en");
271 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
272 LogError("Exception thrown." << e.DumpToString());
273 RUNNER_ASSERT(false);
278 * Name: widgetDB_test_get_config_value_access_network
279 * Description: check network access returned by WidgetDB
280 * Expected: network access should be set to "yes"
282 RUNNER_TEST(widgetDB_test_get_config_value_access_network)
285 IWidgetDBPtr widget = getWidgetDB(2000);
286 std::string tmp = widget->getConfigValue(
287 ConfigAttribute::ACCESS_NETWORK);
289 LogDebug("acces network is always true: " << tmp);
290 RUNNER_ASSERT_WHAT_EQUALS(tmp, "yes");
291 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
292 LogError("Exception thrown." << e.DumpToString());
293 RUNNER_ASSERT(false);
298 * Name: widgetDB_test_get_config_value_width
299 * Description: check widget prefered width returned by WidgetDB
300 * Expected: widget prefered width should match this, which was inserted into
303 RUNNER_TEST(widgetDB_test_get_config_value_width)
306 IWidgetDBPtr widget = getWidgetDB(2000);
307 std::string tmp = widget->getConfigValue(ConfigAttribute::WIDTH);
309 LogDebug("width is: " << tmp);
310 RUNNER_ASSERT_WHAT_EQUALS(tmp, "100");
311 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
312 LogError("Exception thrown." << e.DumpToString());
313 RUNNER_ASSERT(false);
318 * Name: widgetDB_test_get_config_value_height
319 * Description: check widget prefered height returned by WidgetDB
320 * Expected: widget prefered height should match this, which was inserted into
323 RUNNER_TEST(widgetDB_test_get_config_value_height)
326 IWidgetDBPtr widget = getWidgetDB(2000);
327 std::string tmp = widget->getConfigValue(ConfigAttribute::HEIGHT);
329 LogDebug("height is: " << tmp);
330 RUNNER_ASSERT_WHAT_EQUALS(tmp, "200");
331 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
332 LogError("Exception thrown." << e.DumpToString());
333 RUNNER_ASSERT(false);
338 * Name: widgetDB_test_get_config_value_paths
339 * Description: check widget installation path returned by WidgetDB
340 * Expected: widget installation path should match this, which was inserted into
343 RUNNER_TEST(widgetDB_test_get_config_value_paths)
346 IWidgetDBPtr widget = getWidgetDB(2000);
347 std::string tmp = widget->getConfigValue(ConfigAttribute::INSTALL_PATH);
349 LogDebug("install path is: " << tmp);
351 tmp = widget->getConfigValue(
352 ConfigAttribute::PUBLIC_STORAGE_PATH);
354 LogDebug("public storage path is: " << tmp);
355 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
356 LogDebug("Exception thrown." << e.DumpToString());
357 RUNNER_ASSERT(false);
362 * Name: widgetDB_test_get_config_value_empty
363 * Description: check if requesting GUID from WidgetDB throw excpetion if widget
365 * Expected: accessing GUID should throw
366 * WrtDeviceApis::Commons::SecurityException
368 RUNNER_TEST(widgetDB_test_get_config_value_empty)
371 IWidgetDBPtr widget = getWidgetDB(2005);
372 widget->getConfigValue(ConfigAttribute::ID);
374 //exception should be thrown
375 RUNNER_ASSERT(false);
376 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
377 LogDebug("OK. Exception thrown." << e.DumpToString());
382 * Name: widgetDB_test_check_installation_status_installed
383 * Description: check if widget is installed by WidgetDB
384 * Expected: plugin should be notified that widget is installed
386 RUNNER_TEST(widgetDB_test_check_installation_status_installed)
389 IWidgetDBPtr widget = getWidgetDB(2000);
390 InstallationStatus tmp = widget->checkInstallationStatus(
391 "w_id_2000", "w_name_2000_en", "2.0.0");
393 RUNNER_ASSERT(tmp == InstallationStatus::STATUS_INSTALLED);
394 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
395 LogError("Exception thrown." << e.DumpToString());
396 RUNNER_ASSERT(false);
401 * Name: widgetDB_test_check_installation_status_uninstalled
402 * Description: check if widget is not installed by WidgetDB
403 * Expected: plugin should be notified that widget is not installed
405 RUNNER_TEST(widgetDB_test_check_installation_status_uninstalled)
408 IWidgetDBPtr widget = getWidgetDB(2000);
409 InstallationStatus tmp = widget->checkInstallationStatus(
410 "w_id_2011", "w_name_2000_en", "2.0.0");
412 RUNNER_ASSERT(tmp == InstallationStatus::STATUS_UNINSTALLED);
413 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
414 LogError("Exception thrown." << e.DumpToString());
415 RUNNER_ASSERT(false);
420 * Name: widgetDB_test_check_installation_status_latest
421 * Description: check if widget installation information is taken from latest
423 * Expected: plugin installation status should be same is both calls of WidgetDB
425 RUNNER_TEST(widgetDB_test_check_installation_status_latest)
428 IWidgetDBPtr widget = getWidgetDB(2000);
429 InstallationStatus tmp1 = widget->checkInstallationStatus(
430 "w_id_2000", "w_name_2000_en", "0.1.0");
431 InstallationStatus tmp2 = widget->checkInstallationStatus(
432 "w_id_2000", "w_name_2000_en", "1.0.0");
434 RUNNER_ASSERT(tmp1 == InstallationStatus::STATUS_LATEST);
435 RUNNER_ASSERT(tmp2 == InstallationStatus::STATUS_LATEST);
436 } catch (const WrtDeviceApis::Commons::SecurityException &e) {
437 LogError("Exception thrown." << e.DumpToString());
438 RUNNER_ASSERT(false);
442 #undef RUNNER_ASSERT_WHAT_EQUALS