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 TestCases_WidgetDAO.cpp
18 * @author Pawel Sikorski (p.sikorski@samsung.com)
20 * @brief This file contains tests for widget dao class.
28 #include <dpl/test/test_runner.h>
29 #include <dpl/foreach.h>
30 #include <dpl/exception.h>
31 #include <dpl/wrt-dao-rw/widget_dao.h>
32 #include <dpl/wrt-dao-ro/wrt_db_types.h>
33 #include <dpl/string.h>
34 #include <dpl/platform.h>
35 #include <wrt_plugin_export.h>
36 #include <LanguageTagsProvider.h>
38 using namespace WrtDB;
41 class WacSecurityMock : public WrtDB::IWidgetSecurity
46 mDistributorSigned(false)
49 virtual const WidgetCertificateDataList& getCertificateList() const
54 virtual bool isRecognized() const
58 virtual bool isDistributorSigned() const
60 return mDistributorSigned;
62 virtual void getCertificateChainList(CertificateChainList& /*lst*/) const {}
63 virtual void getCertificateChainList(CertificateChainList& /*lst*/,
64 CertificateSource /*source*/) const {}
66 WrtDB::WidgetCertificateDataList& getCertificateListRef()
71 void setRecognized(bool recognized)
73 mRecognized = recognized;
75 void setDistributorSigned(bool distributorSigned)
77 mDistributorSigned = distributorSigned;
81 WrtDB::WidgetCertificateDataList mList;
82 // author signature verified
85 bool mDistributorSigned;
89 TizenAppId _registerWidget(const WidgetRegisterInfo& regInfo,
90 const IWidgetSecurity& sec,
93 TizenAppId tizenAppId;
95 auto previous = WidgetDAO::getTizenAppIdList();
98 tizenAppId = WidgetDAO::registerWidgetGeneratePkgId(regInfo, sec);
100 RUNNER_ASSERT_MSG(!tizenAppId.empty(),
101 "(called from line " << line << ")");
103 auto current = WidgetDAO::getTizenAppIdList();
104 RUNNER_ASSERT_MSG(previous.size() + 1 == current.size(),
105 "(called from line " << line << ")");
107 RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
109 "(called from line " << line << " tizenAppId: " <<
112 Catch(WidgetDAO::Exception::AlreadyRegistered) {
115 "Unexpected exception (called from line " << line << ")");
120 #define REGISTER_WIDGET(regInfo, sec) _registerWidget((regInfo), \
124 template<typename Exception, typename Function>
125 bool checkException(Function fun)
139 // Widgets used <2300,2500), 2000, 2001, 2002, 2003
141 #define RUNNER_ASSERT_WHAT_EQUALS(in, test) \
142 { std::string tmp(in); \
143 RUNNER_ASSERT_MSG(tmp == test, "Equals: [" + tmp + "]"); }
145 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(in, test) \
147 if (!in) { RUNNER_ASSERT_MSG(false, "NULL"); } \
148 else { RUNNER_ASSERT_WHAT_EQUALS(DPL::ToUTF8String(*in), test); } \
151 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONALINT(in, test) \
153 if (!in) { RUNNER_ASSERT_MSG(false, "NULL"); } \
154 else { RUNNER_ASSERT_MSG(*in == test, "Equals: [" + *in + "]"); } \
157 #define RUNNER_ASSERT_EXCEPTION(exceptionType, function) \
159 RUNNER_ASSERT(checkException<exceptionType>([](){function})); \
162 RUNNER_TEST_GROUP_INIT(DAO)
166 * Name: widget_dao_test_register_widget_empty_strings
167 * Description: Tests registeration of new widget with empty values
168 * Expected: widget should be registered in database
170 RUNNER_TEST(widget_dao_test_register_widget_empty_strings)
172 WidgetRegisterInfo regInfo;
175 regInfo.configInfo.widget_id = DPL::FromUTF8String("");
176 regInfo.configInfo.version = DPL::FromUTF8String("");
177 regInfo.configInfo.width = 10;
178 regInfo.configInfo.height = 10;
179 regInfo.configInfo.authorName = DPL::FromUTF8String("");
180 regInfo.configInfo.authorEmail = DPL::FromUTF8String("");
181 regInfo.configInfo.authorHref = DPL::FromUTF8String("");
182 regInfo.baseFolder = "";
183 //TODO authenticated, etc...
184 regInfo.configInfo.flashNeeded = false;
185 regInfo.configInfo.minVersionRequired = DPL::FromUTF8String("1.0");
186 regInfo.configInfo.backSupported = true;
189 ConfigParserData::LocalizedData locData;
190 locData.name = DPL::FromUTF8String("");
191 locData.shortName = DPL::FromUTF8String("");
192 locData.description = DPL::FromUTF8String("");
193 locData.license = DPL::FromUTF8String("");
194 locData.licenseFile = DPL::FromUTF8String("");
195 locData.licenseHref = DPL::FromUTF8String("");
196 regInfo.configInfo.localizedDataSet.insert(
197 std::make_pair(DPL::FromUTF8String("en"), locData));
202 ConfigParserData::Icon icon(DPL::FromUTF8String(""));
206 locs.insert(DPL::FromUTF8String("en"));
207 WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
208 regInfo.localizationData.icons.push_back(locIcon);
211 WidgetRegisterInfo::StartFileProperties prop;
212 prop.encoding = DPL::FromUTF8String("");
213 prop.type = DPL::FromUTF8String("");
214 WidgetRegisterInfo::LocalizedStartFile file;
215 file.path = DPL::FromUTF8String("");
216 file.propertiesForLocales.insert(
217 std::make_pair(DPL::FromUTF8String("en"), prop));
218 regInfo.localizationData.startFiles.push_back(file);
221 ConfigParserData::Preference pref(DPL::FromUTF8String(""), false);
222 pref.value = DPL::FromUTF8String("");
223 regInfo.configInfo.preferencesList.insert(pref);
226 ConfigParserData::Feature feat(DPL::FromUTF8String(""));
227 regInfo.configInfo.featuresList.insert(feat);
230 regInfo.configInfo.windowModes.insert(DPL::FromUTF8String(""));
233 ConfigParserData::AccessInfo access(DPL::FromUTF8String(""), true);
234 regInfo.configInfo.accessInfoSet.insert(access);
237 WidgetCertificateData cert;
238 cert.owner = WidgetCertificateData::AUTHOR;
239 cert.type = WidgetCertificateData::ROOT;
241 cert.strMD5Fingerprint = "";
242 cert.strSHA1Fingerprint = "";
243 cert.strCommonName = DPL::FromUTF8String("");
245 WacSecurityMock security;
246 security.getCertificateListRef().push_back(cert);
248 REGISTER_WIDGET(regInfo, security);
252 * Name: widget_dao_test_register_widget_empty_strings
253 * Description: Tests possiblity of registering twice same content (different
255 * Expected: it should be possible
257 RUNNER_TEST(widget_dao_test_twice_install_same_widget)
261 WidgetRegisterInfo regInfo;
262 REGISTER_WIDGET(regInfo, sec);
265 WidgetRegisterInfo regInfo;
266 REGISTER_WIDGET(regInfo, sec);
271 * Name: widget_dao_test_register_widget_minimum_info
272 * Description: Tests simplest registeration of new widget
273 * Expected: widget should be registered in database
275 RUNNER_TEST(widget_dao_test_register_widget_minimum_info)
278 const std::size_t NUMBER_OF_WIDGETS = 5;
280 TizenAppId lastTizenAppId;
282 for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
283 WidgetRegisterInfo regInfo;
284 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
286 lastTizenAppId = tizenAppId;
288 WidgetDAO dao(tizenAppId);
294 * Name: widget_dao_test_register_widget_info
295 * Description: Tests registeration of many widgets
296 * Expected: all widgets should be registered in database
298 RUNNER_TEST(widget_dao_test_register_widget_info)
301 const std::size_t NUMBER_OF_WIDGETS = 5;
303 for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
304 std::ostringstream str;
305 str << "register_info_test_" << number;
307 WidgetRegisterInfo regInfo;
308 regInfo.configInfo.widget_id = DPL::FromUTF8String(str.str());
309 regInfo.configInfo.version = DPL::FromUTF8String(str.str());
310 regInfo.configInfo.width = 10;
311 regInfo.configInfo.height = 10;
312 regInfo.configInfo.authorName = DPL::FromUTF8String(str.str());
313 regInfo.configInfo.authorEmail = DPL::FromUTF8String(str.str());
314 regInfo.configInfo.authorHref = DPL::FromUTF8String(str.str());
315 regInfo.baseFolder = str.str(); //base folder at the end has /
316 regInfo.configInfo.flashNeeded = false;
317 //TODO authenticated, etc...
318 //in wrt-installer: TaskWidgetConfig::fillWidgetConfig:
319 //regInfo.minVersion = regInfo.configInfo.minVersionRequired
320 regInfo.minVersion = DPL::FromUTF8String("1.0");
321 regInfo.configInfo.backSupported = true;
323 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
325 WidgetDAO dao(tizenAppId);
326 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getGUID(), str.str());
327 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getVersion(), str.str());
328 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorName(), str.str());
329 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorEmail(), str.str());
330 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorHref(), str.str());
331 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getMinimumWacVersion(), "1.0");
336 * Name: widget_dao_test_register_widget_extended_info
337 * Description: Tests registeration of widget_extended_info
338 * Expected: registeration of extended inforamtion is checked
339 * via existence of backgroudn page value
341 RUNNER_TEST(widget_dao_test_register_widget_extended_info)
344 const std::size_t NUMBER_OF_WIDGETS = 5;
346 for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
347 std::ostringstream str;
348 str << "register_ext_info_test_" << number;
350 WidgetRegisterInfo regInfo;
352 regInfo.configInfo.backgroundPage = L"background.html";
354 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
356 WidgetDAO dao(tizenAppId);
358 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getBackgroundPage(),
364 * Name: widget_dao_test_register_widget_localized_info
365 * Description: Tests registeration of localized widgets information
366 * Expected: values received by dao should match those which were registered
368 RUNNER_TEST(widget_dao_test_register_widget_localized_info)
371 const std::size_t NUMBER_OF_WIDGETS = 5;
373 for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
374 WidgetRegisterInfo regInfo;
375 std::ostringstream str_en;
376 std::ostringstream str_pl;
377 str_en << "register_loc_info_test_en_" << number;
378 str_pl << "register_loc_info_test_pl_" << number;
380 ConfigParserData::LocalizedData locDataEn;
381 locDataEn.name = DPL::FromUTF8String(str_en.str());
382 locDataEn.shortName = DPL::FromUTF8String(str_en.str());
383 locDataEn.description = DPL::FromUTF8String(str_en.str());
384 locDataEn.license = DPL::FromUTF8String(str_en.str());
385 locDataEn.licenseFile = DPL::FromUTF8String(str_en.str());
386 locDataEn.licenseHref = DPL::FromUTF8String(str_en.str());
387 regInfo.configInfo.localizedDataSet.insert(
388 std::make_pair(DPL::FromUTF8String("en"), locDataEn));
392 ConfigParserData::LocalizedData locDataPl;
393 locDataPl.name = DPL::FromUTF8String(str_pl.str());
394 locDataPl.shortName = DPL::FromUTF8String(str_pl.str());
395 locDataPl.description = DPL::FromUTF8String(str_pl.str());
396 locDataPl.license = DPL::FromUTF8String(str_pl.str());
397 locDataPl.licenseFile = DPL::FromUTF8String(str_pl.str());
398 locDataPl.licenseHref = DPL::FromUTF8String(str_pl.str());
399 regInfo.configInfo.localizedDataSet.insert(
400 std::make_pair(DPL::FromUTF8String("pl"), locDataPl));
403 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
405 WidgetDAO dao(tizenAppId);
406 RUNNER_ASSERT_MSG(dao.getLanguageTags().size() == 2,
407 "language tags list invalid");
410 WidgetLocalizedInfo locInfo =
411 dao.getLocalizedInfo(DPL::FromUTF8String("en"));
413 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
415 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
417 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
419 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
421 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
426 WidgetLocalizedInfo locInfo =
427 dao.getLocalizedInfo(DPL::FromUTF8String("pl"));
429 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
431 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
433 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
435 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
437 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
444 * Name: widget_dao_test_register_widget_icons
445 * Description: Tests registeration of localized icons information
446 * Expected: values received by dao should match those which were registered
449 RUNNER_TEST(widget_dao_test_register_widget_icons)
452 WidgetRegisterInfo regInfo;
454 ConfigParserData::Icon icon(L"icon1");
458 locs.insert(DPL::FromUTF8String("en"));
459 WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
460 regInfo.localizationData.icons.push_back(locIcon);
462 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
464 WidgetDAO dao(tizenAppId);
465 WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
467 RUNNER_ASSERT(list.size() == regInfo.localizationData.icons.size());
468 WidgetDAOReadOnly::WidgetIconList::const_iterator it1 = list.begin();
469 WidgetRegisterInfo::LocalizedIconList::const_iterator it2 =
470 regInfo.localizationData.icons.begin();
471 for (; it1 != list.end() && it2 != regInfo.localizationData.icons.end();
474 RUNNER_ASSERT(it2->height == it1->iconHeight);
475 RUNNER_ASSERT(it2->width == it1->iconWidth);
476 RUNNER_ASSERT(it2->src == it1->iconSrc);
477 RUNNER_ASSERT(it2->availableLocales == locs);
482 * Name: widget_dao_test_register_widget_start_files
483 * Description: Tests registeration of localized start files
484 * Expected: no expectations as it should be removed
486 RUNNER_TEST(widget_dao_test_register_widget_start_files)
490 WidgetRegisterInfo::LocalizedStartFileList files;
491 WidgetRegisterInfo::StartFilePropertiesForLocalesMap map1;
492 WidgetRegisterInfo::StartFileProperties prop1;
493 prop1.encoding = DPL::FromUTF8String("enc1");
494 prop1.type = DPL::FromUTF8String("type1");
496 map1.insert(std::make_pair(DPL::FromUTF8String("en"), prop1));
497 map1.insert(std::make_pair(DPL::FromUTF8String("pl"), prop1));
499 WidgetRegisterInfo::LocalizedStartFile file1;
500 WidgetRegisterInfo::LocalizedStartFile file2;
501 file1.path = DPL::FromUTF8String("path1");
502 file1.propertiesForLocales = map1;
503 file2.path = DPL::FromUTF8String("path2");
504 file2.propertiesForLocales = map1;
506 files.push_back(file1);
507 files.push_back(file1);
509 WidgetRegisterInfo regInfo;
510 regInfo.localizationData.startFiles = files;
512 REGISTER_WIDGET(regInfo, sec);
514 //TODO no getter in WidgetDAO (getter in LocalizedWidgetDAO,
515 // but it will be removed
519 * Name: widget_dao_test_register_widget_features
520 * Description: Tests registeration of features of widget
521 * Expected: number of features should match (for given widget reginfo)
523 RUNNER_TEST(widget_dao_test_register_widget_features)
526 ConfigParserData::FeaturesList features;
527 features.insert(ConfigParserData::Feature(DPL::FromUTF8String("f1")));
528 features.insert(ConfigParserData::Feature(DPL::FromUTF8String("f2")));
529 features.insert(ConfigParserData::Feature(DPL::FromUTF8String("f3")));
531 WidgetRegisterInfo regInfo;
532 FOREACH(it, features)
533 regInfo.configInfo.featuresList.insert(*it);
535 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
537 WidgetDAO dao(tizenAppId);
538 WidgetFeatureSet out = dao.getFeaturesList();
539 RUNNER_ASSERT_MSG(out.size() == features.size(),
540 "wrong number of features");
542 // RUNNER_ASSERT(features.find(*it) != features.end());
546 * Name: widget_dao_test_register_widget_win_modes
547 * Description: Tests registeration of window modes
548 * Expected: all modes should be returned from dao
550 RUNNER_TEST(widget_dao_test_register_widget_win_modes)
553 std::set<DPL::String> modes;
554 modes.insert(DPL::FromUTF8String("full"));
555 modes.insert(DPL::FromUTF8String("window"));
557 WidgetRegisterInfo regInfo;
560 regInfo.configInfo.windowModes.insert(*it);
562 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
564 WidgetDAO dao(tizenAppId);
565 std::list<DPL::String> wins = dao.getWindowModes();
566 RUNNER_ASSERT_MSG(modes.size() == wins.size(),
567 "wrong number of window modes");
569 RUNNER_ASSERT(modes.find(*it) != modes.end());
573 * Name: widget_dao_test_register_widget_warp_info
574 * Description: Tests registeration of access info iris
575 * Expected: all access info iris should be returned from dao
577 RUNNER_TEST(widget_dao_test_register_widget_warp_info)
580 ConfigParserData::AccessInfoSet orig;
581 orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri1"),
583 orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri2"),
585 orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri3"),
588 WidgetRegisterInfo regInfo;
590 regInfo.configInfo.accessInfoSet.insert(*it);
592 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
594 WidgetDAO dao(tizenAppId);
596 WidgetAccessInfoList out;
597 dao.getWidgetAccessInfo(out);
598 RUNNER_ASSERT_MSG(out.size() == orig.size(),
599 "wrong number of access info elem");
601 ConfigParserData::AccessInfo tmp(it->strIRI, it->bSubDomains);
602 RUNNER_ASSERT(orig.find(tmp) != orig.end());
607 * Name: widget_dao_test_register_widget_certificates
608 * Description: Tests registeration of widget certificates
609 * Expected: all certificates should be returned from dao
610 * and should contain inserted data
612 RUNNER_TEST(widget_dao_test_register_widget_certificates)
615 WidgetRegisterInfo regInfo;
617 WidgetCertificateData cert;
618 cert.owner = WidgetCertificateData::AUTHOR;
619 cert.type = WidgetCertificateData::ROOT;
621 cert.strMD5Fingerprint = "md5";
622 cert.strSHA1Fingerprint = "sha1";
623 cert.strCommonName = DPL::FromUTF8String("common name");
625 WidgetCertificateDataList& certListRef = sec.getCertificateListRef();
626 certListRef.push_back(cert);
629 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
631 WidgetDAO dao(tizenAppId);
634 WidgetCertificateDataList recList = dao.getCertificateDataList();
635 RUNNER_ASSERT(recList.size() == certListRef.size());
637 auto recListIt = recList.begin();
638 auto certListIt = certListRef.begin();
639 for (; recListIt != recList.end() && certListIt != certListRef.end();
640 ++recListIt, ++certListIt)
642 RUNNER_ASSERT(recListIt->chainId == certListIt->chainId);
643 RUNNER_ASSERT(recListIt->owner == certListIt->owner);
644 RUNNER_ASSERT(recListIt->strCommonName == certListIt->strCommonName);
645 RUNNER_ASSERT(recListIt->strMD5Fingerprint ==
646 certListIt->strMD5Fingerprint);
647 RUNNER_ASSERT(recListIt->strSHA1Fingerprint ==
648 certListIt->strSHA1Fingerprint);
649 RUNNER_ASSERT(recListIt->type == certListIt->type);
653 RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
654 WidgetCertificateData::ENDENTITY).
656 RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::AUTHOR,
657 WidgetCertificateData::ENDENTITY).
659 RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
660 WidgetCertificateData::ROOT).empty());
662 FingerPrintList fingerprints = dao.getKeyFingerprints(
663 WidgetCertificateData::AUTHOR,
664 WidgetCertificateData::ROOT);
666 RUNNER_ASSERT(fingerprints.size() == certListRef.size() * 2);
667 FOREACH(it, certListRef)
669 auto md5 = std::find(fingerprints.begin(),
671 it->strMD5Fingerprint);
672 RUNNER_ASSERT(md5 != fingerprints.end());
674 auto sha = std::find(fingerprints.begin(),
676 it->strSHA1Fingerprint);
677 RUNNER_ASSERT(sha != fingerprints.end());
681 RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
682 WidgetCertificateData::ENDENTITY).
684 RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::AUTHOR,
685 WidgetCertificateData::ENDENTITY).
687 RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
688 WidgetCertificateData::ROOT).empty());
690 FingerPrintList commonNames = dao.getKeyCommonNameList(
691 WidgetCertificateData::AUTHOR,
692 WidgetCertificateData::ROOT);
694 RUNNER_ASSERT(commonNames.size() == certListRef.size());
695 FOREACH(it, certListRef)
697 auto cn = std::find(commonNames.begin(),
699 DPL::ToUTF8String(it->strCommonName));
700 RUNNER_ASSERT(cn != commonNames.end());
705 * Name: widget_dao_test_register_widget_privileges
706 * Description: Tests registration of widget privileges
708 RUNNER_TEST(widget_dao_test_register_widget_privileges)
712 WidgetRegisterInfo regInfo;
714 ConfigParserData::PrivilegeList& privilegeList =
715 regInfo.configInfo.privilegeList;
716 privilegeList.insert(DPL::FromUTF8String("name"));
717 privilegeList.insert(DPL::FromUTF8String("name2"));
719 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
720 WidgetDAO dao(tizenAppId);
722 WrtDB::PrivilegeList privListFromDB;
723 privListFromDB = dao.getWidgetPrivilege();
725 RUNNER_ASSERT(privilegeList.size() == privListFromDB.size());
727 auto privListIt = privilegeList.begin();
728 auto privDBIt = privListFromDB.begin();
729 for(; privListIt != privilegeList.end() && privDBIt != privListFromDB.end();
730 ++privListIt, ++privDBIt)
732 RUNNER_ASSERT(*privDBIt == privListIt->name);
737 * Name: widget_dao_test_register_app_control
738 * Description: Tests app control
740 RUNNER_TEST(widget_dao_test_register_app_control)
743 WidgetRegisterInfo regInfo;
745 ConfigParserData::AppControlInfo appControl(DPL::FromUTF8String("operation"));
746 appControl.m_mimeList.insert(DPL::FromUTF8String("mime"));
747 appControl.m_src = DPL::FromUTF8String("src");
748 appControl.m_uriList.insert(DPL::FromUTF8String("uri"));
750 ConfigParserData::AppControlInfoList& appControlListRef
751 = regInfo.configInfo.appControlList;
752 appControlListRef.push_back(appControl);
754 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
756 WidgetDAO dao(tizenAppId);
758 WrtDB::WidgetAppControlList appControlInfoListDB;
759 dao.getAppControlList(appControlInfoListDB);
760 RUNNER_ASSERT(appControlInfoListDB.size() == appControlListRef.size());
761 auto appDBIt = appControlInfoListDB.begin();
762 auto appRefIt = appControlListRef.begin();
764 for (;appDBIt != appControlInfoListDB.end()
765 && appRefIt != appControlListRef.end();
766 ++appDBIt, ++appRefIt)
768 RUNNER_ASSERT(appRefIt->m_operation == appDBIt->operation);
769 RUNNER_ASSERT(appRefIt->m_src == appDBIt->src);
770 for(auto it = appRefIt->m_mimeList.begin();
771 it != appRefIt->m_mimeList.end();
774 RUNNER_ASSERT((*it) == appDBIt->mime);
776 for(auto it = appRefIt->m_uriList.begin();
777 it != appRefIt->m_uriList.end();
780 RUNNER_ASSERT((*it) == appDBIt->uri);
786 * Name: widget_dao_test_is_widget_installed
787 * Description: Tests checking if widgets are installed
788 * Expected: installed widgets should be stated as installed
790 RUNNER_TEST(widget_dao_test_is_widget_installed)
792 RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(L"tizenid201"));
795 WidgetRegisterInfo regInfo;
797 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
799 RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(tizenAppId));
803 * Name: widget_dao_test_unregister_widget
804 * Description: Tests unregistering widgets
805 * Expected: widget register informations should be successfully removed
807 RUNNER_TEST(widget_dao_test_unregister_widget)
810 TizenAppIdList ids = WidgetDAO::getTizenAppIdList();
812 WidgetRegisterInfo regInfo;
814 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
816 WidgetDAO::unregisterWidget(tizenAppId);
818 RUNNER_ASSERT_MSG(ids.size() == WidgetDAO::getTizenAppIdList().size(),
819 "Widget unregister failed");
823 * Name: widget_dao_test_register_or_update_widget
824 * Description: Tests reregistering widgets
825 * Expected: widget should be successfully replaced
827 RUNNER_TEST(widget_dao_test_register_or_update_widget)
831 WidgetRegisterInfo regInfo;
832 regInfo.configInfo.version = L"1.0";
833 regInfo.configInfo.authorName = L"AAA";
835 WidgetRegisterInfo regInfo2;
836 regInfo2.configInfo.version = L"1.1";
837 regInfo2.configInfo.authorName = L"BBB";
839 WrtDB::TizenAppId tizenAppId(L"abcdefghij");
842 WidgetDAO::registerWidget(tizenAppId, regInfo, sec);
843 RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
844 tizenAppId), "Widget is not registered");
846 //success full update
847 WidgetDAO::updateTizenAppId(tizenAppId, L"backup");
848 WidgetDAO::registerWidget(tizenAppId, regInfo2, sec);
849 WidgetDAO::unregisterWidget(L"backup");
850 RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
851 tizenAppId), "Widget is not reregistered");
852 WidgetDAO dao(tizenAppId);
854 *dao.getVersion() == L"1.1", "Data widget was not updated");
856 *dao.getAuthorName() == L"BBB", "Data widget was not updated");
859 WidgetDAO::unregisterWidget(tizenAppId);
863 * Name: widget_dao_test_get_widget_tizenAppId_list
864 * Description: Tests getTizenAppIdList API for backendlib
865 * Expected: For all position in database should be returned one item in list
867 RUNNER_TEST(widget_dao_test_get_widget_tizenAppId_list)
869 TizenAppIdList tizenAppIds = WidgetDAO::getTizenAppIdList();
870 RUNNER_ASSERT(tizenAppIds.size() >= 3);
874 * Name: widget_dao_test_get_widget_list
875 * Description: Tests getTizenAppIdList API for backendlib
876 * Expected: For all position in database should be returned one item in list
877 * Those item should contain valid tizenAppId
879 RUNNER_TEST(widget_dao_test_get_widget_list)
881 WidgetDAOReadOnlyList list = WidgetDAOReadOnly::getWidgetList();
882 RUNNER_ASSERT(list.size() >= 3);
883 RUNNER_ASSERT_MSG(!!list.front(), "widget dao exists");
884 WidgetDAOReadOnlyPtr dao = list.front();
888 * Name: widget_dao_test_get_widget_attributes
889 * Description: Tests returning basic widget attributes by dao
890 * Expected: Attributes should match values inserted into database
892 RUNNER_TEST(widget_dao_test_get_widget_attributes)
895 TizenAppId tizenAppId = L"tizenid201";
896 WidgetDAO dao(tizenAppId);
898 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getGUID(), "w_id_2000");
899 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getVersion(), "1.0.0");
900 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorName(), "a_name_2000");
901 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorEmail(),
903 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorHref(), "a_href_2000");
904 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getMinimumWacVersion(), "1.0");
909 * Name: widget_dao_test_localization
910 * Description: Tests inserting and returning localization info
911 * Expected: Values inserted into database should match values received from
914 RUNNER_TEST(widget_dao_test_localization)
919 WidgetRegisterInfo regInfo;
920 ConfigParserData::Icon icon(L"icon1");
924 locs.insert(DPL::FromUTF8String("en"));
925 locs.insert(DPL::FromUTF8String("pl"));
926 WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
927 regInfo.localizationData.icons.push_back(locIcon);
930 WidgetRegisterInfo::StartFileProperties prop_en;
931 prop_en.encoding = DPL::FromUTF8String("encoding_en");
932 prop_en.type = DPL::FromUTF8String("type_en");
934 WidgetRegisterInfo::StartFileProperties prop_pl;
935 prop_pl.encoding = DPL::FromUTF8String("encoding_pl");
936 prop_pl.type = DPL::FromUTF8String("type_pl");
938 WidgetRegisterInfo::LocalizedStartFile file;
939 file.path = DPL::FromUTF8String("path");
940 file.propertiesForLocales.insert(
941 std::make_pair(DPL::FromUTF8String("en"), prop_en));
942 file.propertiesForLocales.insert(
943 std::make_pair(DPL::FromUTF8String("pl"), prop_pl));
944 regInfo.localizationData.startFiles.push_back(file);
947 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
949 WidgetDAO dao(tizenAppId);
951 // check localized icons
952 WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
953 RUNNER_ASSERT(locList.size() == locs.size());
955 // non-localized icon
956 WidgetDAO::WidgetIconList list = dao.getIconList();
957 int iconId = list.front().iconId;
959 // compare every icon with the origin
960 auto locsIt = locs.begin();
961 auto iconIt = locList.begin();
962 for (; locsIt != locs.end() && iconIt != locList.end(); ++locsIt,
965 RUNNER_ASSERT(iconIt->appId == dao.getHandle());
966 RUNNER_ASSERT(iconIt->iconId == iconId);
967 RUNNER_ASSERT(iconIt->widgetLocale == *locsIt);
970 // localized start file list
971 WidgetDAO::LocalizedStartFileList fList = dao.getLocalizedStartFileList();
972 RUNNER_ASSERT(fList.size() == file.propertiesForLocales.size());
974 int startFileId = dao.getStartFileList().front().startFileId;
978 RUNNER_ASSERT(it->appId == dao.getHandle());
979 auto propIt = file.propertiesForLocales.find(it->widgetLocale);
980 RUNNER_ASSERT(propIt != file.propertiesForLocales.end());
981 RUNNER_ASSERT(it->encoding == propIt->second.encoding);
982 RUNNER_ASSERT(it->type == propIt->second.type);
983 RUNNER_ASSERT(it->startFileId == startFileId);
988 * Name: widget_dao_test_register_scp
989 * Description: Tests inserting and returning scp policy information
990 * Expected: Value inserted into database should match values received from
993 RUNNER_TEST(widget_dao_test_register_scp)
996 WidgetRegisterInfo regInfo;
997 DPL::OptionalString policy = DPL::FromUTF8String("Some awesome csp policy");
998 regInfo.configInfo.cspPolicy = policy;
1001 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1002 WidgetDAO dao(tizenAppId);
1004 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(
1005 dao.getCspPolicy(), DPL::ToUTF8String(*policy));
1010 * Name: widget_dao_test_register_csp_empty
1011 * Description: Tests inserting and returning empty csp policy
1012 * Expected: Value inserted into database should match values received from
1015 RUNNER_TEST(widget_dao_test_register_csp_empty)
1017 WacSecurityMock sec;
1018 WidgetRegisterInfo regInfo;
1021 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1022 WidgetDAO dao(tizenAppId);
1024 RUNNER_ASSERT_MSG(!dao.getCspPolicy(), "Policy is not null");
1029 * Name: widget_dao_test_widget_privileges_basics
1030 * Description: Tests basic operators of privileges
1031 * Expected: operators should behave properly
1033 RUNNER_TEST(widget_dao_test_widget_privileges_basics)
1035 ConfigParserData::Privilege f1(DPL::FromUTF8String("a"));
1036 ConfigParserData::Privilege f2(DPL::FromUTF8String("f2"));
1037 ConfigParserData::Privilege f3(DPL::FromUTF8String("f3"));
1038 ConfigParserData::Privilege f1prim(DPL::FromUTF8String("a"));
1040 RUNNER_ASSERT_MSG(f1 != f2, "features not equal");
1041 RUNNER_ASSERT_MSG(f2 != f3, "features not equal");
1042 RUNNER_ASSERT_MSG(f1 != f3, "features not equal");
1043 RUNNER_ASSERT_MSG(f1 == f1prim, "features equal");
1045 RUNNER_ASSERT(f1 >= f1prim);
1046 RUNNER_ASSERT(f1 <= f1prim);
1047 RUNNER_ASSERT(f1 < f2);
1048 RUNNER_ASSERT(f1 <= f2);
1049 RUNNER_ASSERT(f3 > f2);
1050 RUNNER_ASSERT(f3 >= f2);
1054 * Name: widget_dao_test_widget_preferences_basics
1055 * Description: Tests basic operators of preferences
1056 * Expected: operators should behave properly
1058 RUNNER_TEST(widget_dao_test_widget_preferences_basics)
1060 ConfigParserData::Preference f1(DPL::FromUTF8String("a"));
1061 ConfigParserData::Preference f2(DPL::FromUTF8String("f2"));
1062 ConfigParserData::Preference f3(DPL::FromUTF8String("f3"));
1063 ConfigParserData::Preference f1prim(DPL::FromUTF8String("a"));
1065 RUNNER_ASSERT_MSG(f1 != f2, "preferences not equal");
1066 RUNNER_ASSERT_MSG(f2 != f3, "preferences not equal");
1067 RUNNER_ASSERT_MSG(f1 != f3, "preferences not equal");
1068 RUNNER_ASSERT_MSG(f1 == f1prim, "preferences equal");
1070 RUNNER_ASSERT(f1 >= f1prim);
1071 RUNNER_ASSERT(f1 <= f1prim);
1072 RUNNER_ASSERT(f1 < f2);
1073 RUNNER_ASSERT(f1 <= f2);
1074 RUNNER_ASSERT(f3 > f2);
1075 RUNNER_ASSERT(f3 >= f2);
1079 * Name: widget_dao_test_widget_features_basics
1080 * Description: Tests basic operators of features
1081 * Expected: operators should behave properly
1083 RUNNER_TEST(widget_dao_test_widget_features_basics)
1085 ConfigParserData::Feature f1(DPL::FromUTF8String("a"));
1086 ConfigParserData::Feature f2(DPL::FromUTF8String("f2"));
1087 ConfigParserData::Feature f3(DPL::FromUTF8String("f3"));
1088 ConfigParserData::Feature f1prim(DPL::FromUTF8String("a"));
1090 RUNNER_ASSERT_MSG(f1 != f2, "features not equal");
1091 RUNNER_ASSERT_MSG(f2 != f3, "features not equal");
1092 RUNNER_ASSERT_MSG(f1 != f3, "features not equal");
1093 RUNNER_ASSERT_MSG(f1 == f1prim, "features equal");
1095 RUNNER_ASSERT(f1 >= f1prim);
1096 RUNNER_ASSERT(f1 <= f1prim);
1097 RUNNER_ASSERT(f1 < f2);
1098 RUNNER_ASSERT(f1 <= f2);
1099 RUNNER_ASSERT(f3 > f2);
1100 RUNNER_ASSERT(f3 >= f2);
1104 * Name: widget_dao_test_widget_icons_basics
1105 * Description: Tests basic operators for icons
1106 * Expected: operators should behave properly
1108 RUNNER_TEST(widget_dao_test_widget_icons_basics)
1110 ConfigParserData::Icon f1(DPL::FromUTF8String("a"));
1111 ConfigParserData::Icon f2(DPL::FromUTF8String("f2"));
1112 ConfigParserData::Icon f3(DPL::FromUTF8String("f3"));
1113 ConfigParserData::Icon f1prim(DPL::FromUTF8String("a"));
1115 RUNNER_ASSERT_MSG(f1 != f2, "icons not equal");
1116 RUNNER_ASSERT_MSG(f2 != f3, "icons not equal");
1117 RUNNER_ASSERT_MSG(f1 != f3, "icons not equal");
1118 RUNNER_ASSERT_MSG(f1 == f1prim, "icons equal");
1120 RUNNER_ASSERT(f1 >= f1prim);
1121 RUNNER_ASSERT(f1 <= f1prim);
1122 RUNNER_ASSERT(f1 < f2);
1123 RUNNER_ASSERT(f1 <= f2);
1124 RUNNER_ASSERT(f3 > f2);
1125 RUNNER_ASSERT(f3 >= f2);
1129 * Name: widget_dao_test_widget_settings_basics
1130 * Description: Tests basic operators for settings of widget
1131 * Expected: operators should behave properly
1133 RUNNER_TEST(widget_dao_test_widget_settings_basics)
1135 ConfigParserData::Setting f1(DPL::FromUTF8String("a"), DPL::FromUTF8String("1"));
1136 ConfigParserData::Setting f2(DPL::FromUTF8String("a"), DPL::FromUTF8String("2"));
1137 ConfigParserData::Setting f3(DPL::FromUTF8String("b"), DPL::FromUTF8String("2"));
1138 ConfigParserData::Setting f1prim(DPL::FromUTF8String("a"), DPL::FromUTF8String("1"));
1140 RUNNER_ASSERT_MSG(f1 != f2, "settings not equal");
1141 RUNNER_ASSERT_MSG(f2 != f3, "settings not equal");
1142 RUNNER_ASSERT_MSG(f1 != f3, "settings not equal");
1143 RUNNER_ASSERT_MSG(f1 == f1prim, "settings equal");
1145 RUNNER_ASSERT(f1 >= f1prim);
1146 RUNNER_ASSERT(f1 <= f1prim);
1147 RUNNER_ASSERT(f1 <= f2);
1148 RUNNER_ASSERT(f3 > f2);
1149 RUNNER_ASSERT(f2 < f3);
1150 RUNNER_ASSERT(f3 >= f2);
1154 * Name: widget_dao_test_widget_access_basics
1155 * Description: Tests basic operators for access of widget
1156 * Expected: operators should behave properly
1158 RUNNER_TEST(widget_dao_test_widget_access_basics)
1160 ConfigParserData::AccessInfo a(DPL::FromUTF8String("a"), true);
1161 ConfigParserData::AccessInfo b(DPL::FromUTF8String("b"), true);
1162 ConfigParserData::AccessInfo a1(DPL::FromUTF8String("a"), true);
1163 ConfigParserData::AccessInfo a2(DPL::FromUTF8String("a"), false);
1165 RUNNER_ASSERT_MSG(a != b, "access info not equal");
1166 RUNNER_ASSERT_MSG(a == a1, "access info equal");
1167 RUNNER_ASSERT_MSG(b == b, "access info equal");
1168 RUNNER_ASSERT_MSG(a1 != b, "access info are not equal");
1169 RUNNER_ASSERT_MSG(a1 != a2, "access info are not equal");
1170 RUNNER_ASSERT(a2 < a1);
1171 RUNNER_ASSERT(a1 < b);
1175 * Name: widget_dao_test_widget_metadata_basics
1176 * Description: Tests basic operators for metadata
1177 * Expected: operators should behave properly
1179 RUNNER_TEST(widget_dao_test_widget_metadata_basics)
1181 ConfigParserData::Metadata a(DPL::FromUTF8String("a"), DPL::FromUTF8String("1"));
1182 ConfigParserData::Metadata b(DPL::FromUTF8String("b"), DPL::FromUTF8String("1"));
1183 ConfigParserData::Metadata a1(DPL::FromUTF8String("a"), DPL::FromUTF8String("1"));
1184 ConfigParserData::Metadata a2(DPL::FromUTF8String("a"), DPL::FromUTF8String("2"));
1186 RUNNER_ASSERT_MSG(a != b, "metadata not equal");
1187 RUNNER_ASSERT_MSG(a == a1, "metadata equal");
1188 RUNNER_ASSERT_MSG(b == b, "metadata equal");
1189 RUNNER_ASSERT_MSG(a1 != b, "metadata not equal");
1190 RUNNER_ASSERT_MSG(a1 != a2, "metadata not equal");
1194 * Name: widget_dao_test_widget_appcontrolinfo_basics
1195 * Description: Tests basic operators for app control info
1196 * Expected: operators should behave properly
1198 RUNNER_TEST(widget_dao_test_widget_appcontrolinfo_basics)
1200 ConfigParserData::AppControlInfo a(DPL::FromUTF8String("operation"));
1201 a.m_mimeList.insert(DPL::FromUTF8String("mime"));
1202 a.m_src = DPL::FromUTF8String("src");
1203 a.m_uriList.insert(DPL::FromUTF8String("uri"));
1205 ConfigParserData::AppControlInfo a0(DPL::FromUTF8String("operation1"));
1206 a0.m_mimeList.insert(DPL::FromUTF8String("mime"));
1207 a0.m_src = DPL::FromUTF8String("src");
1208 a0.m_uriList.insert(DPL::FromUTF8String("uri"));
1210 ConfigParserData::AppControlInfo a1(DPL::FromUTF8String("operation"));
1211 a1.m_mimeList.insert(DPL::FromUTF8String("mime"));
1212 a1.m_src = DPL::FromUTF8String("src");
1213 a1.m_uriList.insert(DPL::FromUTF8String("uri"));
1215 ConfigParserData::AppControlInfo a2(DPL::FromUTF8String("operation"));
1216 a2.m_mimeList.insert(DPL::FromUTF8String("mime1"));
1217 a2.m_src = DPL::FromUTF8String("src");
1218 a2.m_uriList.insert(DPL::FromUTF8String("uri"));
1220 ConfigParserData::AppControlInfo a3(DPL::FromUTF8String("operation"));
1221 a3.m_mimeList.insert(DPL::FromUTF8String("mime"));
1222 a3.m_src = DPL::FromUTF8String("src1");
1223 a3.m_uriList.insert(DPL::FromUTF8String("uri"));
1225 ConfigParserData::AppControlInfo a4(DPL::FromUTF8String("operation"));
1226 a4.m_mimeList.insert(DPL::FromUTF8String("mime"));
1227 a4.m_src = DPL::FromUTF8String("src");
1228 a4.m_uriList.insert(DPL::FromUTF8String("uri1"));
1230 ConfigParserData::AppControlInfo a5(DPL::FromUTF8String("operation"));
1231 a5.m_mimeList.insert(DPL::FromUTF8String("mime"));
1232 a5.m_src = DPL::FromUTF8String("src");
1233 a5.m_uriList.insert(DPL::FromUTF8String("uri"));
1235 RUNNER_ASSERT_MSG(a != a0, "app control info not equal");
1236 RUNNER_ASSERT_MSG(a != a1, "app control info not equal");
1237 RUNNER_ASSERT_MSG(a != a2, "app control info not equal");
1238 RUNNER_ASSERT_MSG(a != a3, "app control info not equal");
1239 RUNNER_ASSERT_MSG(a != a4, "app control info not equal");
1240 RUNNER_ASSERT_MSG(a == a5, "app control info equal");
1241 RUNNER_ASSERT_MSG(a == a, "app control info equal");
1244 #if USE(WEB_PROVIDER)
1246 * Name: widget_dao_test_widget_metadata_basics
1247 * Description: Tests basic operators for livebox info
1248 * Expected: operators should behave properly
1250 RUNNER_TEST(widget_dao_test_widget_livebox_basics)
1252 ConfigParserData::LiveboxInfo a;
1253 a.m_icon = DPL::FromUTF8String("icon");
1254 a.m_liveboxId = DPL::FromUTF8String("id");
1255 a.m_autoLaunch = DPL::FromUTF8String("auto");
1256 a.m_updatePeriod = DPL::FromUTF8String("period");
1257 a.m_primary = DPL::FromUTF8String("primary");
1259 ConfigParserData::LiveboxInfo a0;
1260 a0.m_icon = DPL::FromUTF8String("icon0");
1261 a0.m_liveboxId = DPL::FromUTF8String("id");
1262 a0.m_autoLaunch = DPL::FromUTF8String("auto");
1263 a0.m_updatePeriod = DPL::FromUTF8String("period");
1264 a0.m_primary = DPL::FromUTF8String("primary");
1266 ConfigParserData::LiveboxInfo a1;
1267 a1.m_icon = DPL::FromUTF8String("icon");
1268 a1.m_liveboxId = DPL::FromUTF8String("id0");
1269 a1.m_autoLaunch = DPL::FromUTF8String("auto");
1270 a1.m_updatePeriod = DPL::FromUTF8String("period");
1271 a1.m_primary = DPL::FromUTF8String("primary");
1273 ConfigParserData::LiveboxInfo a2;
1274 a2.m_icon = DPL::FromUTF8String("icon");
1275 a2.m_liveboxId = DPL::FromUTF8String("id");
1276 a2.m_autoLaunch = DPL::FromUTF8String("auto0");
1277 a2.m_updatePeriod = DPL::FromUTF8String("period");
1278 a2.m_primary = DPL::FromUTF8String("primary");
1280 ConfigParserData::LiveboxInfo a3;
1281 a3.m_icon = DPL::FromUTF8String("icon");
1282 a3.m_liveboxId = DPL::FromUTF8String("id");
1283 a3.m_autoLaunch = DPL::FromUTF8String("auto");
1284 a3.m_updatePeriod = DPL::FromUTF8String("period0");
1285 a3.m_primary = DPL::FromUTF8String("primary");
1287 ConfigParserData::LiveboxInfo a4;
1288 a4.m_icon = DPL::FromUTF8String("icon");
1289 a4.m_liveboxId = DPL::FromUTF8String("id");
1290 a4.m_autoLaunch = DPL::FromUTF8String("auto");
1291 a4.m_updatePeriod = DPL::FromUTF8String("period");
1292 a4.m_primary = DPL::FromUTF8String("primary0");
1294 ConfigParserData::LiveboxInfo a5;
1295 a5.m_icon = DPL::FromUTF8String("icon");
1296 a5.m_liveboxId = DPL::FromUTF8String("id");
1297 a5.m_autoLaunch = DPL::FromUTF8String("auto");
1298 a5.m_updatePeriod = DPL::FromUTF8String("period");
1299 a5.m_primary = DPL::FromUTF8String("primary");
1301 const DPL::String s1 = DPL::FromUTF8String("1");
1302 const DPL::String s2 = DPL::FromUTF8String("2");
1304 ConfigParserData::LiveboxInfo a10;
1305 a10.m_icon = DPL::FromUTF8String("icon");
1306 a10.m_liveboxId = DPL::FromUTF8String("id");
1307 a10.m_autoLaunch = DPL::FromUTF8String("auto");
1308 a10.m_updatePeriod = DPL::FromUTF8String("period");
1309 a10.m_primary = DPL::FromUTF8String("primary");
1310 a10.m_label.push_back(std::pair<DPL::String,DPL::String>(s1, s1));
1312 ConfigParserData::LiveboxInfo a11;
1313 a11.m_icon = DPL::FromUTF8String("icon");
1314 a11.m_liveboxId = DPL::FromUTF8String("id");
1315 a11.m_autoLaunch = DPL::FromUTF8String("auto");
1316 a11.m_updatePeriod = DPL::FromUTF8String("period");
1317 a11.m_primary = DPL::FromUTF8String("primary");
1318 a11.m_label.push_back(std::pair<DPL::String,DPL::String>(s1, s2));
1319 a11.m_label.push_back(std::pair<DPL::String,DPL::String>(s1, s2));
1321 ConfigParserData::LiveboxInfo a12;
1322 a12.m_icon = DPL::FromUTF8String("icon");
1323 a12.m_liveboxId = DPL::FromUTF8String("id");
1324 a12.m_autoLaunch = DPL::FromUTF8String("auto");
1325 a12.m_updatePeriod = DPL::FromUTF8String("period");
1326 a12.m_primary = DPL::FromUTF8String("primary");
1327 a12.m_label.push_back(std::pair<DPL::String,DPL::String>(s1, s1));
1329 RUNNER_ASSERT_MSG(a != a0, "livebox info not equal");
1330 RUNNER_ASSERT_MSG(a != a1, "livebox info not equal");
1331 RUNNER_ASSERT_MSG(a != a2, "livebox info not equal");
1332 RUNNER_ASSERT_MSG(a != a3, "livebox info not equal");
1333 RUNNER_ASSERT_MSG(a != a4, "livebox info not equal");
1334 RUNNER_ASSERT_MSG(a == a5, "livebox info equal");
1335 RUNNER_ASSERT_MSG(a == a, "livebox info equal");
1336 RUNNER_ASSERT_MSG(a10 != a11, "livebox info not equal");
1337 RUNNER_ASSERT_MSG(a10 == a12, "livebox info equal");
1341 * Name: widget_dao_test_get_widget_by_guid
1342 * Description: Tests creating WidgetDAO using GUID
1343 * Expected: Correct WidgetDAO should be created
1345 RUNNER_TEST(widget_dao_test_get_widget_by_guid)
1347 WidgetDAO dao(DPL::OptionalString(L"w_id_2000"));
1348 RUNNER_ASSERT(dao.getTizenAppId() == L"tizenid201");
1352 * Name: widget_dao_test_set_tizen_app_id
1353 * Description: Tests changing TizenAppId
1354 * Expected: Change should be possible
1356 RUNNER_TEST(widget_dao_test_set_tizen_app_id)
1358 WacSecurityMock sec;
1359 WidgetRegisterInfo regInfo;
1360 TizenAppId originaltizenAppId = REGISTER_WIDGET(regInfo, sec);
1361 TizenAppId changedTizenAppId = L"changedTizenAppId";
1363 TizenAppIdList ids = WidgetDAO::getTizenAppIdList();
1364 RUNNER_ASSERT(std::count(ids.begin(),ids.end(),originaltizenAppId) == 1);
1367 WidgetDAO dao(originaltizenAppId);
1368 dao.setTizenAppId(changedTizenAppId);
1370 ids = WidgetDAO::getTizenAppIdList();
1371 RUNNER_ASSERT(std::count(ids.begin(), ids.end(), originaltizenAppId) == 0);
1372 RUNNER_ASSERT(std::count(ids.begin(), ids.end(), changedTizenAppId) == 1);
1374 bool exceptionCaught = checkException < WidgetDAOReadOnly::Exception::WidgetNotExist > ([&]() {
1375 WidgetDAO dao2(originaltizenAppId);
1376 //Changing should fail because original tizenAppId doesn't exist any more.
1377 dao2.setTizenAppId(changedTizenAppId);
1379 RUNNER_ASSERT(exceptionCaught);
1381 WidgetDAO::unregisterWidget(changedTizenAppId);
1382 ids = WidgetDAO::getTizenAppIdList();
1383 RUNNER_ASSERT(std::count(ids.begin(),ids.end(),originaltizenAppId) == 0);
1384 RUNNER_ASSERT(std::count(ids.begin(),ids.end(),changedTizenAppId) == 0);
1389 * Name: widget_dao_test_update_feature_reject_status
1390 * Description: Tests updating feature reject status
1391 * Expected: Reject status should be properly updated
1393 RUNNER_TEST(widget_dao_test_update_feature_reject_status)
1395 WidgetDAO dao(L"tizenid202");
1396 DbWidgetFeatureSet featureSet = dao.getFeaturesList();
1398 RUNNER_ASSERT(featureSet.size() == 1);
1399 DbWidgetFeature feature = *featureSet.begin();
1400 RUNNER_ASSERT(!feature.rejected);
1402 feature.rejected = true;
1403 dao.updateFeatureRejectStatus(feature);
1405 featureSet = dao.getFeaturesList();
1406 RUNNER_ASSERT(featureSet.size() == 1);
1407 DbWidgetFeature feature2 = *featureSet.begin();
1408 RUNNER_ASSERT(feature.rejected);
1410 feature2.rejected = false;
1411 dao.updateFeatureRejectStatus(feature2);
1415 * Name: widget_dao_test_register_widget_allow_navigation
1416 * Description: Tests AllowNavigationInfo registration
1417 * Expected: AllowNavigationInfo registration should be possible
1419 RUNNER_TEST(widget_dao_test_register_widget_allow_navigation)
1421 WacSecurityMock sec;
1422 WidgetRegisterInfo regInfo;
1423 ConfigParserData::AllowNavigationInfo navigationInfo1(L"scheme1", L"host1");
1424 ConfigParserData::AllowNavigationInfo navigationInfo2(L"scheme2", L"host2");
1425 regInfo.configInfo.allowNavigationInfoList.push_back(navigationInfo1);
1426 regInfo.configInfo.allowNavigationInfoList.push_back(navigationInfo2);
1428 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1430 WidgetDAOReadOnly dao(tizenAppId);
1431 WidgetAllowNavigationInfoList navigationList;
1432 dao.getWidgetAllowNavigationInfo(navigationList);
1434 RUNNER_ASSERT(navigationList.size() == 2);
1436 std::count_if(navigationList.begin(), navigationList.end(), [] (const WidgetAllowNavigationInfo& navInfo)
1437 { return navInfo.host == L"host1" && navInfo.scheme == L"scheme1"; }) == 1);
1439 std::count_if(navigationList.begin(), navigationList.end(), [] (const WidgetAllowNavigationInfo& navInfo)
1440 { return navInfo.host == L"host2" && navInfo.scheme == L"scheme2"; }) == 1);
1445 * Name: widget_dao_test_register_external_locations
1446 * Description: Tests ExternalLocation registration
1447 * Expected: ExternalLocation registration should be possible
1449 RUNNER_TEST(widget_dao_test_register_external_locations)
1451 WacSecurityMock sec;
1452 WidgetRegisterInfo regInfo;
1453 regInfo.externalLocations.push_back("location1");
1454 regInfo.externalLocations.push_back("location2");
1456 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1458 WidgetDAOReadOnly dao(tizenAppId);
1459 ExternalLocationList locationList = dao.getWidgetExternalLocations();
1461 RUNNER_ASSERT(locationList.size() == 2);
1462 RUNNER_ASSERT(std::count(locationList.begin(), locationList.end(), "location1") == 1);
1463 RUNNER_ASSERT(std::count(locationList.begin(), locationList.end(), "location2") == 1);
1466 #if USE(WEB_PROVIDER)
1468 * Name: widget_dao_test_register_widget_liveboxID
1469 * Description: Tests registeration of liveboxID
1470 * Expected: values received by dao should match those which were registered
1473 RUNNER_TEST(widget_dao_test_register_widget_liveboxID)
1475 WacSecurityMock sec;
1476 WidgetRegisterInfo regInfo;
1478 ConfigParserData::LiveboxInfo liveboxInfo1;
1479 liveboxInfo1.m_liveboxId = DPL::FromUTF8String("pkgID.dynamicBoxID");
1480 ConfigParserData::LiveboxInfo liveboxInfo2;
1481 liveboxInfo2.m_liveboxId = DPL::FromUTF8String("pkgID.dynamicBoxID");
1482 ConfigParserData::LiveboxInfo liveboxInfo3;
1483 liveboxInfo3.m_liveboxId = DPL::FromUTF8String("pkgID.dynamicBoxID");
1485 regInfo.configInfo.m_livebox.push_back(liveboxInfo1);
1486 regInfo.configInfo.m_livebox.push_back(liveboxInfo2);
1487 regInfo.configInfo.m_livebox.push_back(liveboxInfo3);
1489 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1491 WidgetDAOReadOnly dao(tizenAppId);
1492 WrtDB::WidgetDAOReadOnly::LiveBoxIdList outLiveBoxIdList;
1493 dao.getLiveBoxInfoList(outLiveBoxIdList);
1495 RUNNER_ASSERT_MSG(outLiveBoxIdList.size() == 3, "list size is OK");
1496 FOREACH(it, outLiveBoxIdList){
1497 RUNNER_ASSERT_MSG(DPL::ToUTF8String(**it) == "pkgID.dynamicBoxID", "liveBox Name is equal");
1502 * Name: widget_dao_test_get_tz_app_id
1503 * Description: Tests getTizenAppId functions
1504 * Expected: TizenAppId is correctly fetched for correct widgets, exception for not existing.
1506 RUNNER_TEST(widget_dao_test_get_tz_app_id)
1509 RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenAppId(1234); );
1511 TizenAppId appId = WidgetDAOReadOnly::getTizenAppId(2001);
1512 RUNNER_ASSERT(L"tizenid202" == appId);
1514 RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenAppId(L"no_such_widget"); );
1516 appId = WidgetDAOReadOnly::getTizenAppId(L"pkgid202");
1517 RUNNER_ASSERT(L"tizenid202" == appId);
1521 * Name: widget_dao_test_get_tz_pkg_id
1522 * Description: Tests getTizenPkgId functions
1523 * Expected: TizenPkgId is correctly fetched for correct widgets, exception for not existing.
1525 RUNNER_TEST(widget_dao_test_get_tz_pkg_id)
1528 RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenPkgId(1234); );
1531 TizenPkgId pkgId = WidgetDAOReadOnly::getTizenPkgId(2001);
1532 RUNNER_ASSERT(L"pkgid202" == pkgId);
1534 RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenPkgId(L"no_such_widget"););
1536 pkgId = WidgetDAOReadOnly::getTizenPkgId(L"tizenid202");
1537 RUNNER_ASSERT(L"pkgid202" == pkgId);
1541 * Name: widget_dao_test_get_property_key
1542 * Description: Tests getPropertyKeyList function
1543 * Expected: Property keys are fetched correctly.
1545 RUNNER_TEST(widget_dao_test_get_property_key)
1547 WidgetDAOReadOnly dao(L"tizenid201");
1548 PropertyDAOReadOnly::WidgetPropertyKeyList propertyKeys = dao.getPropertyKeyList();
1550 RUNNER_ASSERT(propertyKeys.size() == 2);
1551 RUNNER_ASSERT(std::count(propertyKeys.begin(), propertyKeys.end(), L"key1_for_2000") == 1);
1552 RUNNER_ASSERT(std::count(propertyKeys.begin(), propertyKeys.end(), L"key2_for_2000") == 1);
1556 * Name: widget_dao_test_get_property_value
1557 * Description: Tests getPropertyValue function
1558 * Expected: Property key values are fetched correctly.
1560 RUNNER_TEST(widget_dao_test_get_property_value)
1562 WidgetDAOReadOnly dao(L"tizenid201");
1564 RUNNER_ASSERT(dao.getPropertyValue(L"key1_for_2000") ==
1565 PropertyDAOReadOnly::WidgetPropertyValue(L"value_for_key1_2000"));
1566 RUNNER_ASSERT(dao.getPropertyValue(L"key2_for_2000") ==
1567 PropertyDAOReadOnly::WidgetPropertyValue(L"value_for_key2_2000"));
1568 RUNNER_ASSERT(!dao.getPropertyValue(L"not_existing"));
1569 RUNNER_ASSERT(!dao.getPropertyValue(L""));
1573 * Name: widget_dao_test_get_property_read_flag
1574 * Description: Tests checkPropertyReadFlag function
1575 * Expected: Property read flags values are fetched correctly.
1577 RUNNER_TEST(widget_dao_test_get_property_read_flag)
1579 WidgetDAOReadOnly dao(L"tizenid201");
1581 RUNNER_ASSERT(dao.checkPropertyReadFlag(L"key1_for_2000") == 0);
1582 RUNNER_ASSERT(dao.checkPropertyReadFlag(L"key2_for_2000") == 0);
1583 RUNNER_ASSERT(!dao.checkPropertyReadFlag(L"not_existing"));
1584 RUNNER_ASSERT(!dao.checkPropertyReadFlag(L""));
1588 * Name: widget_dao_test_get_pkg_id_list
1589 * Description: Tests getTizenPkgIdList function
1590 * Expected: All pkg ids are returned.
1592 RUNNER_TEST(widget_dao_test_get_pkg_id_list)
1594 TizenPkgIdList pkgIds = WidgetDAOReadOnly::getTizenPkgIdList();
1596 RUNNER_ASSERT(pkgIds.size() == 4);
1597 RUNNER_ASSERT(std::count(pkgIds.begin(), pkgIds.end(), L"pkgid201") == 1);
1598 RUNNER_ASSERT(std::count(pkgIds.begin(), pkgIds.end(), L"pkgid202") == 1);
1599 RUNNER_ASSERT(std::count(pkgIds.begin(), pkgIds.end(), L"") == 2);
1603 * Name: widget_dao_test_get_back_supported
1604 * Description: Tests getBackSupported function
1605 * Expected: Back supported information is fetched properly.
1607 RUNNER_TEST(widget_dao_test_get_back_supported)
1609 WidgetDAOReadOnly dao1(L"tizenid201");
1610 RUNNER_ASSERT(dao1.getBackSupported());
1612 WidgetDAOReadOnly dao2(L"tizenid202");
1613 RUNNER_ASSERT(!dao2.getBackSupported());
1617 * Name: widget_dao_test_get_csp_policy_report
1618 * Description: Tests getCspPolicyReportOnly function
1619 * Expected: CSP policy information is fetched properly.
1621 RUNNER_TEST(widget_dao_test_get_csp_policy_report)
1623 WidgetDAOReadOnly dao1(L"tizenid201");
1624 RUNNER_ASSERT(DPL::OptionalString(L"policy_report201") == dao1.getCspPolicyReportOnly());
1626 WidgetDAOReadOnly dao2(L"tizenid202");
1627 RUNNER_ASSERT(DPL::OptionalString(L"policy_report202") == dao2.getCspPolicyReportOnly());
1631 * Name: widget_dao_test_get_install_time
1632 * Description: Tests getInstallTime function
1633 * Expected: Installation time is fetched properly.
1635 RUNNER_TEST(widget_dao_test_get_install_time)
1637 WidgetDAOReadOnly dao1(L"tizenid201");
1638 RUNNER_ASSERT(1256 == dao1.getInstallTime());
1640 WidgetDAOReadOnly dao2(L"tizenid202");
1641 RUNNER_ASSERT(5687 == dao2.getInstallTime());
1645 * Name: widget_dao_test_get_icon_language_tags
1646 * Description: Tests getIconLanguageTags function
1647 * Expected: Information about icon localization is fetched properly.
1649 RUNNER_TEST(widget_dao_test_get_icon_language_tags)
1651 WidgetDAOReadOnly dao1(L"tizenid201");
1652 LanguageTags languageTags = dao1.getIconLanguageTags();
1654 RUNNER_ASSERT(2 == languageTags.size());
1655 RUNNER_ASSERT(std::count(languageTags.begin(), languageTags.end(), L"en") == 1);
1656 RUNNER_ASSERT(std::count(languageTags.begin(), languageTags.end(), L"pl") == 1);
1659 #undef RUNNER_ASSERT_WHAT_EQUALS