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 <wrt_plugin_export.h>
35 #include <LanguageTagsProvider.h>
37 using namespace WrtDB;
40 class WacSecurityMock : public WrtDB::IWidgetSecurity
45 mDistributorSigned(false)
48 virtual const WidgetCertificateDataList& getCertificateList() const
53 virtual bool isRecognized() const
57 virtual bool isDistributorSigned() const
59 return mDistributorSigned;
61 virtual void getCertificateChainList(CertificateChainList& /*lst*/) const {}
62 virtual void getCertificateChainList(CertificateChainList& /*lst*/,
63 CertificateSource /*source*/) const {}
65 WrtDB::WidgetCertificateDataList& getCertificateListRef()
70 void setRecognized(bool recognized)
72 mRecognized = recognized;
74 void setDistributorSigned(bool distributorSigned)
76 mDistributorSigned = distributorSigned;
80 WrtDB::WidgetCertificateDataList mList;
81 // author signature verified
84 bool mDistributorSigned;
88 TizenAppId _registerWidget(const WidgetRegisterInfo& regInfo,
89 const IWidgetSecurity& sec,
92 TizenAppId tizenAppId;
94 auto previous = WidgetDAO::getTizenAppidList();
97 tizenAppId = WidgetDAO::registerWidgetGeneratePkgId(regInfo, sec);
99 RUNNER_ASSERT_MSG(!tizenAppId.empty(),
100 "(called from line " << line << ")");
102 auto current = WidgetDAO::getTizenAppidList();
103 RUNNER_ASSERT_MSG(previous.size() + 1 == current.size(),
104 "(called from line " << line << ")");
106 RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
108 "(called from line " << line << " tizenAppId: " <<
111 Catch(WidgetDAO::Exception::AlreadyRegistered) {
114 "Unexpected exception (called from line " << line << ")");
119 #define REGISTER_WIDGET(regInfo, sec) _registerWidget((regInfo), \
123 template<typename Exception, typename Function>
124 bool checkException(Function fun)
138 // Widgets used <2300,2500), 2000, 2001, 2002, 2003
140 #define RUNNER_ASSERT_WHAT_EQUALS(in, test) \
141 { std::string tmp(in); \
142 RUNNER_ASSERT_MSG(tmp == test, "Equals: [" + tmp + "]"); }
144 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(in, test) \
146 if (in.IsNull()) { RUNNER_ASSERT_MSG(false, "NULL"); } \
147 else { RUNNER_ASSERT_WHAT_EQUALS(DPL::ToUTF8String(*in), test); } \
150 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONALINT(in, test) \
152 if (in.IsNull()) { RUNNER_ASSERT_MSG(false, "NULL"); } \
153 else { RUNNER_ASSERT_MSG(*in == test, "Equals: [" + *in + "]"); } \
156 #define RUNNER_ASSERT_EXCEPTION(exceptionType, function) \
158 RUNNER_ASSERT(checkException<exceptionType>([](){function})); \
161 RUNNER_TEST_GROUP_INIT(DAO)
165 * Name: widget_dao_test_register_widget_empty_strings
166 * Description: Tests registeration of new widget with empty values
167 * Expected: widget should be registered in database
169 RUNNER_TEST(widget_dao_test_register_widget_empty_strings)
171 WidgetRegisterInfo regInfo;
174 regInfo.configInfo.widget_id = DPL::FromUTF8String("");
175 regInfo.configInfo.version = DPL::FromUTF8String("");
176 regInfo.configInfo.width = 10;
177 regInfo.configInfo.height = 10;
178 regInfo.configInfo.authorName = DPL::FromUTF8String("");
179 regInfo.configInfo.authorEmail = DPL::FromUTF8String("");
180 regInfo.configInfo.authorHref = DPL::FromUTF8String("");
181 regInfo.baseFolder = "";
182 //TODO authenticated, etc...
183 regInfo.configInfo.flashNeeded = false;
184 regInfo.configInfo.minVersionRequired = DPL::FromUTF8String("1.0");
185 regInfo.configInfo.backSupported = true;
188 ConfigParserData::LocalizedData locData;
189 locData.name = DPL::FromUTF8String("");
190 locData.shortName = DPL::FromUTF8String("");
191 locData.description = DPL::FromUTF8String("");
192 locData.license = DPL::FromUTF8String("");
193 locData.licenseFile = DPL::FromUTF8String("");
194 locData.licenseHref = DPL::FromUTF8String("");
195 regInfo.configInfo.localizedDataSet.insert(
196 std::make_pair(DPL::FromUTF8String("en"), locData));
201 ConfigParserData::Icon icon(DPL::FromUTF8String(""));
205 locs.insert(DPL::FromUTF8String("en"));
206 WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
207 regInfo.localizationData.icons.push_back(locIcon);
210 WidgetRegisterInfo::StartFileProperties prop;
211 prop.encoding = DPL::FromUTF8String("");
212 prop.type = DPL::FromUTF8String("");
213 WidgetRegisterInfo::LocalizedStartFile file;
214 file.path = DPL::FromUTF8String("");
215 file.propertiesForLocales.insert(
216 std::make_pair(DPL::FromUTF8String("en"), prop));
217 regInfo.localizationData.startFiles.push_back(file);
220 ConfigParserData::Preference pref(DPL::FromUTF8String(""), false);
221 pref.value = DPL::FromUTF8String("");
222 regInfo.configInfo.preferencesList.insert(pref);
225 ConfigParserData::Feature feat(DPL::FromUTF8String(""));
226 regInfo.configInfo.featuresList.insert(feat);
229 regInfo.configInfo.windowModes.insert(DPL::FromUTF8String(""));
232 ConfigParserData::AccessInfo access(DPL::FromUTF8String(""), true);
233 regInfo.configInfo.accessInfoSet.insert(access);
236 WidgetCertificateData cert;
237 cert.owner = WidgetCertificateData::AUTHOR;
238 cert.type = WidgetCertificateData::ROOT;
240 cert.strMD5Fingerprint = "";
241 cert.strSHA1Fingerprint = "";
242 cert.strCommonName = DPL::FromUTF8String("");
244 WacSecurityMock security;
245 security.getCertificateListRef().push_back(cert);
247 REGISTER_WIDGET(regInfo, security);
251 * Name: widget_dao_test_register_widget_empty_strings
252 * Description: Tests possiblity of registering twice same content (different
254 * Expected: it should be possible
256 RUNNER_TEST(widget_dao_test_twice_install_same_widget)
260 WidgetRegisterInfo regInfo;
261 REGISTER_WIDGET(regInfo, sec);
264 WidgetRegisterInfo regInfo;
265 REGISTER_WIDGET(regInfo, sec);
270 * Name: widget_dao_test_register_widget_minimum_info
271 * Description: Tests simplest registeration of new widget
272 * Expected: widget should be registered in database
274 RUNNER_TEST(widget_dao_test_register_widget_minimum_info)
277 const std::size_t NUMBER_OF_WIDGETS = 5;
279 TizenAppId lastTizenAppId;
281 for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
282 WidgetRegisterInfo regInfo;
283 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
285 lastTizenAppId = tizenAppId;
287 WidgetDAO dao(tizenAppId);
293 * Name: widget_dao_test_register_widget_info
294 * Description: Tests registeration of many widgets
295 * Expected: all widgets should be registered in database
297 RUNNER_TEST(widget_dao_test_register_widget_info)
300 const std::size_t NUMBER_OF_WIDGETS = 5;
302 for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
303 std::ostringstream str;
304 str << "register_info_test_" << number;
306 WidgetRegisterInfo regInfo;
307 regInfo.configInfo.widget_id = DPL::FromUTF8String(str.str());
308 regInfo.configInfo.version = DPL::FromUTF8String(str.str());
309 regInfo.configInfo.width = 10;
310 regInfo.configInfo.height = 10;
311 regInfo.configInfo.authorName = DPL::FromUTF8String(str.str());
312 regInfo.configInfo.authorEmail = DPL::FromUTF8String(str.str());
313 regInfo.configInfo.authorHref = DPL::FromUTF8String(str.str());
314 regInfo.baseFolder = str.str(); //base folder at the end has /
315 regInfo.configInfo.flashNeeded = false;
316 //TODO authenticated, etc...
317 //in wrt-installer: TaskWidgetConfig::fillWidgetConfig:
318 //regInfo.minVersion = regInfo.configInfo.minVersionRequired
319 regInfo.minVersion = DPL::FromUTF8String("1.0");
320 regInfo.configInfo.backSupported = true;
322 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
324 WidgetDAO dao(tizenAppId);
325 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getGUID(), str.str());
326 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getVersion(), str.str());
327 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorName(), str.str());
328 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorEmail(), str.str());
329 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorHref(), str.str());
330 RUNNER_ASSERT_WHAT_EQUALS(dao.getBaseFolder(), str.str() + "/");
331 RUNNER_ASSERT(dao.getWebkitPluginsRequired() == false);
332 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getMinimumWacVersion(), "1.0");
337 * Name: widget_dao_test_register_widget_extended_info
338 * Description: Tests registeration of widget_extended_info
339 * Expected: registeration of extended inforamtion is checked
340 * via existence of backgroudn page value
342 RUNNER_TEST(widget_dao_test_register_widget_extended_info)
345 const std::size_t NUMBER_OF_WIDGETS = 5;
347 for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
348 std::ostringstream str;
349 str << "register_ext_info_test_" << number;
351 WidgetRegisterInfo regInfo;
353 regInfo.configInfo.backgroundPage = L"background.html";
355 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
357 WidgetDAO dao(tizenAppId);
359 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getBackgroundPage(),
365 * Name: widget_dao_test_register_widget_localized_info
366 * Description: Tests registeration of localized widgets information
367 * Expected: values received by dao should match those which were registered
369 RUNNER_TEST(widget_dao_test_register_widget_localized_info)
372 const std::size_t NUMBER_OF_WIDGETS = 5;
374 for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
375 WidgetRegisterInfo regInfo;
376 std::ostringstream str_en;
377 std::ostringstream str_pl;
378 str_en << "register_loc_info_test_en_" << number;
379 str_pl << "register_loc_info_test_pl_" << number;
381 ConfigParserData::LocalizedData locDataEn;
382 locDataEn.name = DPL::FromUTF8String(str_en.str());
383 locDataEn.shortName = DPL::FromUTF8String(str_en.str());
384 locDataEn.description = DPL::FromUTF8String(str_en.str());
385 locDataEn.license = DPL::FromUTF8String(str_en.str());
386 locDataEn.licenseFile = DPL::FromUTF8String(str_en.str());
387 locDataEn.licenseHref = DPL::FromUTF8String(str_en.str());
388 regInfo.configInfo.localizedDataSet.insert(
389 std::make_pair(DPL::FromUTF8String("en"), locDataEn));
393 ConfigParserData::LocalizedData locDataPl;
394 locDataPl.name = DPL::FromUTF8String(str_pl.str());
395 locDataPl.shortName = DPL::FromUTF8String(str_pl.str());
396 locDataPl.description = DPL::FromUTF8String(str_pl.str());
397 locDataPl.license = DPL::FromUTF8String(str_pl.str());
398 locDataPl.licenseFile = DPL::FromUTF8String(str_pl.str());
399 locDataPl.licenseHref = DPL::FromUTF8String(str_pl.str());
400 regInfo.configInfo.localizedDataSet.insert(
401 std::make_pair(DPL::FromUTF8String("pl"), locDataPl));
404 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
406 WidgetDAO dao(tizenAppId);
407 RUNNER_ASSERT_MSG(dao.getLanguageTags().size() == 2,
408 "language tags list invalid");
411 WidgetLocalizedInfo locInfo =
412 dao.getLocalizedInfo(DPL::FromUTF8String("en"));
414 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
416 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
418 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
420 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
422 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
427 WidgetLocalizedInfo locInfo =
428 dao.getLocalizedInfo(DPL::FromUTF8String("pl"));
430 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
432 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
434 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
436 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
438 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
445 * Name: widget_dao_test_register_widget_icons
446 * Description: Tests registeration of localized icons information
447 * Expected: values received by dao should match those which were registered
450 RUNNER_TEST(widget_dao_test_register_widget_icons)
453 WidgetRegisterInfo regInfo;
455 ConfigParserData::Icon icon(L"icon1");
459 locs.insert(DPL::FromUTF8String("en"));
460 WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
461 regInfo.localizationData.icons.push_back(locIcon);
463 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
465 WidgetDAO dao(tizenAppId);
466 WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
468 RUNNER_ASSERT(list.size() == regInfo.localizationData.icons.size());
469 WidgetDAOReadOnly::WidgetIconList::const_iterator it1 = list.begin();
470 WidgetRegisterInfo::LocalizedIconList::const_iterator it2 =
471 regInfo.localizationData.icons.begin();
472 for (; it1 != list.end() && it2 != regInfo.localizationData.icons.end();
475 RUNNER_ASSERT(it2->height == it1->iconHeight);
476 RUNNER_ASSERT(it2->width == it1->iconWidth);
477 RUNNER_ASSERT(it2->src == it1->iconSrc);
478 RUNNER_ASSERT(it2->availableLocales == locs);
483 * Name: widget_dao_test_register_widget_start_files
484 * Description: Tests registeration of localized start files
485 * Expected: no expectations as it should be removed
487 RUNNER_TEST(widget_dao_test_register_widget_start_files)
491 WidgetRegisterInfo::LocalizedStartFileList files;
492 WidgetRegisterInfo::StartFilePropertiesForLocalesMap map1;
493 WidgetRegisterInfo::StartFileProperties prop1;
494 prop1.encoding = DPL::FromUTF8String("enc1");
495 prop1.type = DPL::FromUTF8String("type1");
497 map1.insert(std::make_pair(DPL::FromUTF8String("en"), prop1));
498 map1.insert(std::make_pair(DPL::FromUTF8String("pl"), prop1));
500 WidgetRegisterInfo::LocalizedStartFile file1;
501 WidgetRegisterInfo::LocalizedStartFile file2;
502 file1.path = DPL::FromUTF8String("path1");
503 file1.propertiesForLocales = map1;
504 file2.path = DPL::FromUTF8String("path2");
505 file2.propertiesForLocales = map1;
507 files.push_back(file1);
508 files.push_back(file1);
510 WidgetRegisterInfo regInfo;
511 regInfo.localizationData.startFiles = files;
513 REGISTER_WIDGET(regInfo, sec);
515 //TODO no getter in WidgetDAO (getter in LocalizedWidgetDAO,
516 // but it will be removed
520 * Name: widget_dao_test_register_widget_features
521 * Description: Tests registeration of features of widget
522 * Expected: number of features should match (for given widget reginfo)
524 RUNNER_TEST(widget_dao_test_register_widget_features)
527 ConfigParserData::FeaturesList features;
528 features.insert(ConfigParserData::Feature(DPL::FromUTF8String("f1")));
529 features.insert(ConfigParserData::Feature(DPL::FromUTF8String("f2")));
530 features.insert(ConfigParserData::Feature(DPL::FromUTF8String("f3")));
532 WidgetRegisterInfo regInfo;
533 FOREACH(it, features)
534 regInfo.configInfo.featuresList.insert(*it);
536 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
538 WidgetDAO dao(tizenAppId);
539 WidgetFeatureSet out = dao.getFeaturesList();
540 RUNNER_ASSERT_MSG(out.size() == features.size(),
541 "wrong number of features");
543 // RUNNER_ASSERT(features.find(*it) != features.end());
547 * Name: widget_dao_test_register_widget_win_modes
548 * Description: Tests registeration of window modes
549 * Expected: all modes should be returned from dao
551 RUNNER_TEST(widget_dao_test_register_widget_win_modes)
554 std::set<DPL::String> modes;
555 modes.insert(DPL::FromUTF8String("full"));
556 modes.insert(DPL::FromUTF8String("window"));
558 WidgetRegisterInfo regInfo;
561 regInfo.configInfo.windowModes.insert(*it);
563 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
565 WidgetDAO dao(tizenAppId);
566 std::list<DPL::String> wins = dao.getWindowModes();
567 RUNNER_ASSERT_MSG(modes.size() == wins.size(),
568 "wrong number of window modes");
570 RUNNER_ASSERT(modes.find(*it) != modes.end());
574 * Name: widget_dao_test_register_widget_warp_info
575 * Description: Tests registeration of access info iris
576 * Expected: all access info iris should be returned from dao
578 RUNNER_TEST(widget_dao_test_register_widget_warp_info)
581 ConfigParserData::AccessInfoSet orig;
582 orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri1"),
584 orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri2"),
586 orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri3"),
589 WidgetRegisterInfo regInfo;
591 regInfo.configInfo.accessInfoSet.insert(*it);
593 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
595 WidgetDAO dao(tizenAppId);
597 WidgetAccessInfoList out;
598 dao.getWidgetAccessInfo(out);
599 RUNNER_ASSERT_MSG(out.size() == orig.size(),
600 "wrong number of access info elem");
602 ConfigParserData::AccessInfo tmp(it->strIRI, it->bSubDomains);
603 RUNNER_ASSERT(orig.find(tmp) != orig.end());
608 * Name: widget_dao_test_register_widget_certificates
609 * Description: Tests registeration of widget certificates
610 * Expected: all certificates should be returned from dao
611 * and should contain inserted data
613 RUNNER_TEST(widget_dao_test_register_widget_certificates)
616 WidgetRegisterInfo regInfo;
618 WidgetCertificateData cert;
619 cert.owner = WidgetCertificateData::AUTHOR;
620 cert.type = WidgetCertificateData::ROOT;
622 cert.strMD5Fingerprint = "md5";
623 cert.strSHA1Fingerprint = "sha1";
624 cert.strCommonName = DPL::FromUTF8String("common name");
626 WidgetCertificateDataList& certListRef = sec.getCertificateListRef();
627 certListRef.push_back(cert);
630 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
632 WidgetDAO dao(tizenAppId);
635 WidgetCertificateDataList recList = dao.getCertificateDataList();
636 RUNNER_ASSERT(recList.size() == certListRef.size());
638 auto recListIt = recList.begin();
639 auto certListIt = certListRef.begin();
640 for (; recListIt != recList.end() && certListIt != certListRef.end();
641 ++recListIt, ++certListIt)
643 RUNNER_ASSERT(recListIt->chainId == certListIt->chainId);
644 RUNNER_ASSERT(recListIt->owner == certListIt->owner);
645 RUNNER_ASSERT(recListIt->strCommonName == certListIt->strCommonName);
646 RUNNER_ASSERT(recListIt->strMD5Fingerprint ==
647 certListIt->strMD5Fingerprint);
648 RUNNER_ASSERT(recListIt->strSHA1Fingerprint ==
649 certListIt->strSHA1Fingerprint);
650 RUNNER_ASSERT(recListIt->type == certListIt->type);
654 RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
655 WidgetCertificateData::ENDENTITY).
657 RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::AUTHOR,
658 WidgetCertificateData::ENDENTITY).
660 RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
661 WidgetCertificateData::ROOT).empty());
663 FingerPrintList fingerprints = dao.getKeyFingerprints(
664 WidgetCertificateData::AUTHOR,
665 WidgetCertificateData::ROOT);
667 RUNNER_ASSERT(fingerprints.size() == certListRef.size() * 2);
668 FOREACH(it, certListRef)
670 auto md5 = std::find(fingerprints.begin(),
672 it->strMD5Fingerprint);
673 RUNNER_ASSERT(md5 != fingerprints.end());
675 auto sha = std::find(fingerprints.begin(),
677 it->strSHA1Fingerprint);
678 RUNNER_ASSERT(sha != fingerprints.end());
682 RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
683 WidgetCertificateData::ENDENTITY).
685 RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::AUTHOR,
686 WidgetCertificateData::ENDENTITY).
688 RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
689 WidgetCertificateData::ROOT).empty());
691 FingerPrintList commonNames = dao.getKeyCommonNameList(
692 WidgetCertificateData::AUTHOR,
693 WidgetCertificateData::ROOT);
695 RUNNER_ASSERT(commonNames.size() == certListRef.size());
696 FOREACH(it, certListRef)
698 auto cn = std::find(commonNames.begin(),
700 DPL::ToUTF8String(it->strCommonName));
701 RUNNER_ASSERT(cn != commonNames.end());
706 * Name: widget_dao_test_register_widget_privileges
707 * Description: Tests registration of widget privileges
709 RUNNER_TEST(widget_dao_test_register_widget_privileges)
713 WidgetRegisterInfo regInfo;
715 ConfigParserData::PrivilegeList& privilegeList =
716 regInfo.configInfo.privilegeList;
717 privilegeList.insert(DPL::FromUTF8String("name"));
718 privilegeList.insert(DPL::FromUTF8String("name2"));
720 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
721 WidgetDAO dao(tizenAppId);
723 WrtDB::PrivilegeList privListFromDB;
724 privListFromDB = dao.getWidgetPrivilege();
726 RUNNER_ASSERT(privilegeList.size() == privListFromDB.size());
728 auto privListIt = privilegeList.begin();
729 auto privDBIt = privListFromDB.begin();
730 for(; privListIt != privilegeList.end() && privDBIt != privListFromDB.end();
731 ++privListIt, ++privDBIt)
733 RUNNER_ASSERT(*privDBIt == privListIt->name);
738 * Name: widget_dao_test_register_app_control
739 * Description: Tests app control
741 RUNNER_TEST(widget_dao_test_register_app_control)
744 WidgetRegisterInfo regInfo;
746 ConfigParserData::AppControlInfo appControl(DPL::FromUTF8String("operation"));
747 appControl.m_disposition
748 = ConfigParserData::AppControlInfo::Disposition::WINDOW;
749 appControl.m_mimeList.insert(DPL::FromUTF8String("mime"));
750 appControl.m_src = DPL::FromUTF8String("src");
751 appControl.m_uriList.insert(DPL::FromUTF8String("uri"));
753 ConfigParserData::AppControlInfoList& appControlListRef
754 = regInfo.configInfo.appControlList;
755 appControlListRef.push_back(appControl);
757 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
759 WidgetDAO dao(tizenAppId);
761 WrtDB::WidgetAppControlList appControlInfoListDB;
762 dao.getAppControlList(appControlInfoListDB);
763 RUNNER_ASSERT(appControlInfoListDB.size() == appControlListRef.size());
764 auto appDBIt = appControlInfoListDB.begin();
765 auto appRefIt = appControlListRef.begin();
767 for (;appDBIt != appControlInfoListDB.end()
768 && appRefIt != appControlListRef.end();
769 ++appDBIt, ++appRefIt)
771 RUNNER_ASSERT((WidgetAppControl::Disposition)
772 appRefIt->m_disposition == appDBIt->disposition);
773 RUNNER_ASSERT(appRefIt->m_index == appDBIt->index);
774 RUNNER_ASSERT(appRefIt->m_operation == appDBIt->operation);
775 RUNNER_ASSERT(appRefIt->m_src == appDBIt->src);
776 for(auto it = appRefIt->m_mimeList.begin();
777 it != appRefIt->m_mimeList.end();
780 RUNNER_ASSERT((*it) == appDBIt->mime);
782 for(auto it = appRefIt->m_uriList.begin();
783 it != appRefIt->m_uriList.end();
786 RUNNER_ASSERT((*it) == appDBIt->uri);
792 * Name: widget_dao_test_is_widget_installed
793 * Description: Tests checking if widgets are installed
794 * Expected: installed widgets should be stated as installed
796 RUNNER_TEST(widget_dao_test_is_widget_installed)
798 RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(L"tizenid201"));
801 WidgetRegisterInfo regInfo;
803 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
805 RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(tizenAppId));
809 * Name: widget_dao_test_unregister_widget
810 * Description: Tests unregistering widgets
811 * Expected: widget register informations should be successfully removed
813 RUNNER_TEST(widget_dao_test_unregister_widget)
816 TizenAppIdList ids = WidgetDAO::getTizenAppidList();
818 WidgetRegisterInfo regInfo;
820 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
822 WidgetDAO::unregisterWidget(tizenAppId);
824 RUNNER_ASSERT_MSG(ids.size() == WidgetDAO::getTizenAppidList().size(),
825 "Widget unregister failed");
829 * Name: widget_dao_test_register_or_update_widget
830 * Description: Tests reregistering widgets
831 * Expected: widget should be successfully replaced
833 RUNNER_TEST(widget_dao_test_register_or_update_widget)
837 WidgetRegisterInfo regInfo;
838 regInfo.configInfo.version = L"1.0";
839 regInfo.configInfo.authorName = L"AAA";
841 WidgetRegisterInfo regInfo2;
842 regInfo2.configInfo.version = L"1.1";
843 regInfo2.configInfo.authorName = L"BBB";
845 WrtDB::TizenAppId tizenAppId(L"abcdefghij");
848 WidgetDAO::registerWidget(tizenAppId, regInfo, sec);
849 RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
850 tizenAppId), "Widget is not registered");
852 //success full update
853 WidgetDAO::updateTizenAppId(tizenAppId, L"backup");
854 WidgetDAO::registerWidget(tizenAppId, regInfo2, sec);
855 WidgetDAO::unregisterWidget(L"backup");
856 RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
857 tizenAppId), "Widget is not reregistered");
858 WidgetDAO dao(tizenAppId);
860 *dao.getVersion() == L"1.1", "Data widget was not updated");
862 *dao.getAuthorName() == L"BBB", "Data widget was not updated");
865 WidgetDAO::unregisterWidget(tizenAppId);
869 * Name: widget_dao_test_get_widget_tizenAppId_list
870 * Description: Tests getTizenAppidList API for backendlib
871 * Expected: For all position in database should be returned one item in list
873 RUNNER_TEST(widget_dao_test_get_widget_tizenAppId_list)
875 TizenAppIdList tizenAppIds = WidgetDAO::getTizenAppidList();
876 RUNNER_ASSERT(tizenAppIds.size() >= 3);
880 * Name: widget_dao_test_get_widget_list
881 * Description: Tests getTizenAppidList API for backendlib
882 * Expected: For all position in database should be returned one item in list
883 * Those item should contain valid tizenAppId
885 RUNNER_TEST(widget_dao_test_get_widget_list)
887 WidgetDAOReadOnlyList list = WidgetDAOReadOnly::getWidgetList();
888 RUNNER_ASSERT(list.size() >= 3);
889 RUNNER_ASSERT_MSG(!!list.front(), "widget dao exists");
890 WidgetDAOReadOnlyPtr dao = list.front();
894 * Name: widget_dao_test_get_widget_attributes
895 * Description: Tests returning basic widget attributes by dao
896 * Expected: Attributes should match values inserted into database
898 RUNNER_TEST(widget_dao_test_get_widget_attributes)
901 TizenAppId tizenAppId = L"tizenid201";
902 WidgetDAO dao(tizenAppId);
904 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getGUID(), "w_id_2000");
905 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getVersion(), "1.0.0");
906 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorName(), "a_name_2000");
907 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorEmail(),
909 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorHref(), "a_href_2000");
910 RUNNER_ASSERT_WHAT_EQUALS(dao.getBaseFolder(), "basef_2000/");
911 RUNNER_ASSERT(dao.getWebkitPluginsRequired() == true);
912 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getMinimumWacVersion(), "1.0");
917 * Name: widget_dao_test_localization
918 * Description: Tests inserting and returning localization info
919 * Expected: Values inserted into database should match values received from
922 RUNNER_TEST(widget_dao_test_localization)
927 WidgetRegisterInfo regInfo;
928 ConfigParserData::Icon icon(L"icon1");
932 locs.insert(DPL::FromUTF8String("en"));
933 locs.insert(DPL::FromUTF8String("pl"));
934 WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
935 regInfo.localizationData.icons.push_back(locIcon);
938 WidgetRegisterInfo::StartFileProperties prop_en;
939 prop_en.encoding = DPL::FromUTF8String("encoding_en");
940 prop_en.type = DPL::FromUTF8String("type_en");
942 WidgetRegisterInfo::StartFileProperties prop_pl;
943 prop_pl.encoding = DPL::FromUTF8String("encoding_pl");
944 prop_pl.type = DPL::FromUTF8String("type_pl");
946 WidgetRegisterInfo::LocalizedStartFile file;
947 file.path = DPL::FromUTF8String("path");
948 file.propertiesForLocales.insert(
949 std::make_pair(DPL::FromUTF8String("en"), prop_en));
950 file.propertiesForLocales.insert(
951 std::make_pair(DPL::FromUTF8String("pl"), prop_pl));
952 regInfo.localizationData.startFiles.push_back(file);
955 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
957 WidgetDAO dao(tizenAppId);
959 // check localized icons
960 WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
961 RUNNER_ASSERT(locList.size() == locs.size());
963 // non-localized icon
964 WidgetDAO::WidgetIconList list = dao.getIconList();
965 int iconId = list.front().iconId;
967 // compare every icon with the origin
968 auto locsIt = locs.begin();
969 auto iconIt = locList.begin();
970 for (; locsIt != locs.end() && iconIt != locList.end(); ++locsIt,
973 RUNNER_ASSERT(iconIt->appId == dao.getHandle());
974 RUNNER_ASSERT(iconIt->iconId == iconId);
975 RUNNER_ASSERT(iconIt->widgetLocale == *locsIt);
978 // localized start file list
979 WidgetDAO::LocalizedStartFileList fList = dao.getLocalizedStartFileList();
980 RUNNER_ASSERT(fList.size() == file.propertiesForLocales.size());
982 int startFileId = dao.getStartFileList().front().startFileId;
986 RUNNER_ASSERT(it->appId == dao.getHandle());
987 auto propIt = file.propertiesForLocales.find(it->widgetLocale);
988 RUNNER_ASSERT(propIt != file.propertiesForLocales.end());
989 RUNNER_ASSERT(it->encoding == propIt->second.encoding);
990 RUNNER_ASSERT(it->type == propIt->second.type);
991 RUNNER_ASSERT(it->startFileId == startFileId);
996 * Name: widget_dao_test_register_scp
997 * Description: Tests inserting and returning scp policy information
998 * Expected: Value inserted into database should match values received from
1001 RUNNER_TEST(widget_dao_test_register_scp)
1003 WacSecurityMock sec;
1004 WidgetRegisterInfo regInfo;
1005 DPL::OptionalString policy = DPL::FromUTF8String("Some awesome csp policy");
1006 regInfo.configInfo.cspPolicy = policy;
1009 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1010 WidgetDAO dao(tizenAppId);
1012 RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(
1013 dao.getCspPolicy(), DPL::ToUTF8String(*policy));
1018 * Name: widget_dao_test_register_csp_empty
1019 * Description: Tests inserting and returning empty csp policy
1020 * Expected: Value inserted into database should match values received from
1023 RUNNER_TEST(widget_dao_test_register_csp_empty)
1025 WacSecurityMock sec;
1026 WidgetRegisterInfo regInfo;
1029 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1030 WidgetDAO dao(tizenAppId);
1032 RUNNER_ASSERT_MSG(dao.getCspPolicy().IsNull(), "Policy is not null");
1037 * Name: widget_dao_test_widget_privileges_basics
1038 * Description: Tests basic operators of privileges
1039 * Expected: operators should behave properly
1041 RUNNER_TEST(widget_dao_test_widget_privileges_basics)
1043 ConfigParserData::Privilege f1(DPL::FromUTF8String("a"));
1044 ConfigParserData::Privilege f2(DPL::FromUTF8String("f2"));
1045 ConfigParserData::Privilege f3(DPL::FromUTF8String("f3"));
1046 ConfigParserData::Privilege f1prim(DPL::FromUTF8String("a"));
1048 RUNNER_ASSERT_MSG(f1 != f2, "features not equal");
1049 RUNNER_ASSERT_MSG(f2 != f3, "features not equal");
1050 RUNNER_ASSERT_MSG(f1 != f3, "features not equal");
1051 RUNNER_ASSERT_MSG(f1 == f1prim, "features equal");
1053 RUNNER_ASSERT(f1 >= f1prim);
1054 RUNNER_ASSERT(f1 <= f1prim);
1055 RUNNER_ASSERT(f1 < f2);
1056 RUNNER_ASSERT(f1 <= f2);
1057 RUNNER_ASSERT(f3 > f2);
1058 RUNNER_ASSERT(f3 >= f2);
1062 * Name: widget_dao_test_widget_preferences_basics
1063 * Description: Tests basic operators of preferences
1064 * Expected: operators should behave properly
1066 RUNNER_TEST(widget_dao_test_widget_preferences_basics)
1068 ConfigParserData::Preference f1(DPL::FromUTF8String("a"));
1069 ConfigParserData::Preference f2(DPL::FromUTF8String("f2"));
1070 ConfigParserData::Preference f3(DPL::FromUTF8String("f3"));
1071 ConfigParserData::Preference f1prim(DPL::FromUTF8String("a"));
1073 RUNNER_ASSERT_MSG(f1 != f2, "preferences not equal");
1074 RUNNER_ASSERT_MSG(f2 != f3, "preferences not equal");
1075 RUNNER_ASSERT_MSG(f1 != f3, "preferences not equal");
1076 RUNNER_ASSERT_MSG(f1 == f1prim, "preferences equal");
1078 RUNNER_ASSERT(f1 >= f1prim);
1079 RUNNER_ASSERT(f1 <= f1prim);
1080 RUNNER_ASSERT(f1 < f2);
1081 RUNNER_ASSERT(f1 <= f2);
1082 RUNNER_ASSERT(f3 > f2);
1083 RUNNER_ASSERT(f3 >= f2);
1087 * Name: widget_dao_test_widget_features_basics
1088 * Description: Tests basic operators of features
1089 * Expected: operators should behave properly
1091 RUNNER_TEST(widget_dao_test_widget_features_basics)
1093 ConfigParserData::Feature f1(DPL::FromUTF8String("a"));
1094 ConfigParserData::Feature f2(DPL::FromUTF8String("f2"));
1095 ConfigParserData::Feature f3(DPL::FromUTF8String("f3"));
1096 ConfigParserData::Feature f1prim(DPL::FromUTF8String("a"));
1098 RUNNER_ASSERT_MSG(f1 != f2, "features not equal");
1099 RUNNER_ASSERT_MSG(f2 != f3, "features not equal");
1100 RUNNER_ASSERT_MSG(f1 != f3, "features not equal");
1101 RUNNER_ASSERT_MSG(f1 == f1prim, "features equal");
1103 RUNNER_ASSERT(f1 >= f1prim);
1104 RUNNER_ASSERT(f1 <= f1prim);
1105 RUNNER_ASSERT(f1 < f2);
1106 RUNNER_ASSERT(f1 <= f2);
1107 RUNNER_ASSERT(f3 > f2);
1108 RUNNER_ASSERT(f3 >= f2);
1112 * Name: widget_dao_test_widget_icons_basics
1113 * Description: Tests basic operators for icons
1114 * Expected: operators should behave properly
1116 RUNNER_TEST(widget_dao_test_widget_icons_basics)
1118 ConfigParserData::Icon f1(DPL::FromUTF8String("a"));
1119 ConfigParserData::Icon f2(DPL::FromUTF8String("f2"));
1120 ConfigParserData::Icon f3(DPL::FromUTF8String("f3"));
1121 ConfigParserData::Icon f1prim(DPL::FromUTF8String("a"));
1123 RUNNER_ASSERT_MSG(f1 != f2, "icons not equal");
1124 RUNNER_ASSERT_MSG(f2 != f3, "icons not equal");
1125 RUNNER_ASSERT_MSG(f1 != f3, "icons not equal");
1126 RUNNER_ASSERT_MSG(f1 == f1prim, "icons equal");
1128 RUNNER_ASSERT(f1 >= f1prim);
1129 RUNNER_ASSERT(f1 <= f1prim);
1130 RUNNER_ASSERT(f1 < f2);
1131 RUNNER_ASSERT(f1 <= f2);
1132 RUNNER_ASSERT(f3 > f2);
1133 RUNNER_ASSERT(f3 >= f2);
1137 * Name: widget_dao_test_widget_settings_basics
1138 * Description: Tests basic operators for settings of widget
1139 * Expected: operators should behave properly
1141 RUNNER_TEST(widget_dao_test_widget_settings_basics)
1143 ConfigParserData::Setting f1(DPL::FromUTF8String("a"), DPL::FromUTF8String("1"));
1144 ConfigParserData::Setting f2(DPL::FromUTF8String("a"), DPL::FromUTF8String("2"));
1145 ConfigParserData::Setting f3(DPL::FromUTF8String("b"), DPL::FromUTF8String("2"));
1146 ConfigParserData::Setting f1prim(DPL::FromUTF8String("a"), DPL::FromUTF8String("1"));
1148 RUNNER_ASSERT_MSG(f1 != f2, "settings not equal");
1149 RUNNER_ASSERT_MSG(f2 != f3, "settings not equal");
1150 RUNNER_ASSERT_MSG(f1 != f3, "settings not equal");
1151 RUNNER_ASSERT_MSG(f1 == f1prim, "settings equal");
1153 RUNNER_ASSERT(f1 >= f1prim);
1154 RUNNER_ASSERT(f1 <= f1prim);
1155 RUNNER_ASSERT(f1 <= f2);
1156 RUNNER_ASSERT(f3 > f2);
1157 RUNNER_ASSERT(f2 < f3);
1158 RUNNER_ASSERT(f3 >= f2);
1162 * Name: widget_dao_test_widget_access_basics
1163 * Description: Tests basic operators for access of widget
1164 * Expected: operators should behave properly
1166 RUNNER_TEST(widget_dao_test_widget_access_basics)
1168 ConfigParserData::AccessInfo a(DPL::FromUTF8String("a"), true);
1169 ConfigParserData::AccessInfo b(DPL::FromUTF8String("b"), true);
1170 ConfigParserData::AccessInfo a1(DPL::FromUTF8String("a"), true);
1171 ConfigParserData::AccessInfo a2(DPL::FromUTF8String("a"), false);
1173 RUNNER_ASSERT_MSG(a != b, "access info not equal");
1174 RUNNER_ASSERT_MSG(a == a1, "access info equal");
1175 RUNNER_ASSERT_MSG(b == b, "access info equal");
1176 RUNNER_ASSERT_MSG(a1 != b, "access info are not equal");
1177 RUNNER_ASSERT_MSG(a1 != a2, "access info are not equal");
1178 RUNNER_ASSERT(a2 < a1);
1179 RUNNER_ASSERT(a1 < b);
1183 * Name: widget_dao_test_widget_metadata_basics
1184 * Description: Tests basic operators for metadata
1185 * Expected: operators should behave properly
1187 RUNNER_TEST(widget_dao_test_widget_metadata_basics)
1189 ConfigParserData::Metadata a(DPL::FromUTF8String("a"), DPL::FromUTF8String("1"));
1190 ConfigParserData::Metadata b(DPL::FromUTF8String("b"), DPL::FromUTF8String("1"));
1191 ConfigParserData::Metadata a1(DPL::FromUTF8String("a"), DPL::FromUTF8String("1"));
1192 ConfigParserData::Metadata a2(DPL::FromUTF8String("a"), DPL::FromUTF8String("2"));
1194 RUNNER_ASSERT_MSG(a != b, "metadata not equal");
1195 RUNNER_ASSERT_MSG(a == a1, "metadata equal");
1196 RUNNER_ASSERT_MSG(b == b, "metadata equal");
1197 RUNNER_ASSERT_MSG(a1 != b, "metadata not equal");
1198 RUNNER_ASSERT_MSG(a1 != a2, "metadata not equal");
1202 * Name: widget_dao_test_widget_appcontrolinfo_basics
1203 * Description: Tests basic operators for app control info
1204 * Expected: operators should behave properly
1206 RUNNER_TEST(widget_dao_test_widget_appcontrolinfo_basics)
1208 ConfigParserData::AppControlInfo a(DPL::FromUTF8String("operation"));
1209 a.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
1210 a.m_mimeList.insert(DPL::FromUTF8String("mime"));
1211 a.m_src = DPL::FromUTF8String("src");
1212 a.m_uriList.insert(DPL::FromUTF8String("uri"));
1214 ConfigParserData::AppControlInfo a0(DPL::FromUTF8String("operation1"));
1215 a0.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
1216 a0.m_mimeList.insert(DPL::FromUTF8String("mime"));
1217 a0.m_src = DPL::FromUTF8String("src");
1218 a0.m_uriList.insert(DPL::FromUTF8String("uri"));
1220 ConfigParserData::AppControlInfo a1(DPL::FromUTF8String("operation"));
1221 a1.m_disposition = ConfigParserData::AppControlInfo::Disposition::UNDEFINE;
1222 a1.m_mimeList.insert(DPL::FromUTF8String("mime"));
1223 a1.m_src = DPL::FromUTF8String("src");
1224 a1.m_uriList.insert(DPL::FromUTF8String("uri"));
1226 ConfigParserData::AppControlInfo a2(DPL::FromUTF8String("operation"));
1227 a2.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
1228 a2.m_mimeList.insert(DPL::FromUTF8String("mime1"));
1229 a2.m_src = DPL::FromUTF8String("src");
1230 a2.m_uriList.insert(DPL::FromUTF8String("uri"));
1232 ConfigParserData::AppControlInfo a3(DPL::FromUTF8String("operation"));
1233 a3.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
1234 a3.m_mimeList.insert(DPL::FromUTF8String("mime"));
1235 a3.m_src = DPL::FromUTF8String("src1");
1236 a3.m_uriList.insert(DPL::FromUTF8String("uri"));
1238 ConfigParserData::AppControlInfo a4(DPL::FromUTF8String("operation"));
1239 a4.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
1240 a4.m_mimeList.insert(DPL::FromUTF8String("mime"));
1241 a4.m_src = DPL::FromUTF8String("src");
1242 a4.m_uriList.insert(DPL::FromUTF8String("uri1"));
1244 ConfigParserData::AppControlInfo a5(DPL::FromUTF8String("operation"));
1245 a5.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
1246 a5.m_mimeList.insert(DPL::FromUTF8String("mime"));
1247 a5.m_src = DPL::FromUTF8String("src");
1248 a5.m_uriList.insert(DPL::FromUTF8String("uri"));
1250 RUNNER_ASSERT_MSG(a != a0, "app control info not equal");
1251 RUNNER_ASSERT_MSG(a != a1, "app control info not equal");
1252 RUNNER_ASSERT_MSG(a != a2, "app control info not equal");
1253 RUNNER_ASSERT_MSG(a != a3, "app control info not equal");
1254 RUNNER_ASSERT_MSG(a != a4, "app control info not equal");
1255 RUNNER_ASSERT_MSG(a == a5, "app control info equal");
1256 RUNNER_ASSERT_MSG(a == a, "app control info equal");
1260 * Name: widget_dao_test_widget_metadata_basics
1261 * Description: Tests basic operators for livebox info
1262 * Expected: operators should behave properly
1264 RUNNER_TEST(widget_dao_test_widget_livebox_basics)
1266 ConfigParserData::LiveboxInfo a;
1267 a.m_icon = DPL::FromUTF8String("icon");
1268 a.m_liveboxId = DPL::FromUTF8String("id");
1269 a.m_autoLaunch = DPL::FromUTF8String("auto");
1270 a.m_updatePeriod = DPL::FromUTF8String("period");
1271 a.m_primary = DPL::FromUTF8String("primary");
1273 ConfigParserData::LiveboxInfo a0;
1274 a0.m_icon = DPL::FromUTF8String("icon0");
1275 a0.m_liveboxId = DPL::FromUTF8String("id");
1276 a0.m_autoLaunch = DPL::FromUTF8String("auto");
1277 a0.m_updatePeriod = DPL::FromUTF8String("period");
1278 a0.m_primary = DPL::FromUTF8String("primary");
1280 ConfigParserData::LiveboxInfo a1;
1281 a1.m_icon = DPL::FromUTF8String("icon");
1282 a1.m_liveboxId = DPL::FromUTF8String("id0");
1283 a1.m_autoLaunch = DPL::FromUTF8String("auto");
1284 a1.m_updatePeriod = DPL::FromUTF8String("period");
1285 a1.m_primary = DPL::FromUTF8String("primary");
1287 ConfigParserData::LiveboxInfo a2;
1288 a2.m_icon = DPL::FromUTF8String("icon");
1289 a2.m_liveboxId = DPL::FromUTF8String("id");
1290 a2.m_autoLaunch = DPL::FromUTF8String("auto0");
1291 a2.m_updatePeriod = DPL::FromUTF8String("period");
1292 a2.m_primary = DPL::FromUTF8String("primary");
1294 ConfigParserData::LiveboxInfo a3;
1295 a3.m_icon = DPL::FromUTF8String("icon");
1296 a3.m_liveboxId = DPL::FromUTF8String("id");
1297 a3.m_autoLaunch = DPL::FromUTF8String("auto");
1298 a3.m_updatePeriod = DPL::FromUTF8String("period0");
1299 a3.m_primary = DPL::FromUTF8String("primary");
1301 ConfigParserData::LiveboxInfo a4;
1302 a4.m_icon = DPL::FromUTF8String("icon");
1303 a4.m_liveboxId = DPL::FromUTF8String("id");
1304 a4.m_autoLaunch = DPL::FromUTF8String("auto");
1305 a4.m_updatePeriod = DPL::FromUTF8String("period");
1306 a4.m_primary = DPL::FromUTF8String("primary0");
1308 ConfigParserData::LiveboxInfo a5;
1309 a5.m_icon = DPL::FromUTF8String("icon");
1310 a5.m_liveboxId = DPL::FromUTF8String("id");
1311 a5.m_autoLaunch = DPL::FromUTF8String("auto");
1312 a5.m_updatePeriod = DPL::FromUTF8String("period");
1313 a5.m_primary = DPL::FromUTF8String("primary");
1315 const DPL::String s1 = DPL::FromUTF8String("1");
1316 const DPL::String s2 = DPL::FromUTF8String("2");
1318 ConfigParserData::LiveboxInfo a10;
1319 a10.m_icon = DPL::FromUTF8String("icon");
1320 a10.m_liveboxId = DPL::FromUTF8String("id");
1321 a10.m_autoLaunch = DPL::FromUTF8String("auto");
1322 a10.m_updatePeriod = DPL::FromUTF8String("period");
1323 a10.m_primary = DPL::FromUTF8String("primary");
1324 a10.m_label.push_back(std::pair<DPL::String,DPL::String>(s1, s1));
1326 ConfigParserData::LiveboxInfo a11;
1327 a11.m_icon = DPL::FromUTF8String("icon");
1328 a11.m_liveboxId = DPL::FromUTF8String("id");
1329 a11.m_autoLaunch = DPL::FromUTF8String("auto");
1330 a11.m_updatePeriod = DPL::FromUTF8String("period");
1331 a11.m_primary = DPL::FromUTF8String("primary");
1332 a11.m_label.push_back(std::pair<DPL::String,DPL::String>(s1, s2));
1333 a11.m_label.push_back(std::pair<DPL::String,DPL::String>(s1, s2));
1335 ConfigParserData::LiveboxInfo a12;
1336 a12.m_icon = DPL::FromUTF8String("icon");
1337 a12.m_liveboxId = DPL::FromUTF8String("id");
1338 a12.m_autoLaunch = DPL::FromUTF8String("auto");
1339 a12.m_updatePeriod = DPL::FromUTF8String("period");
1340 a12.m_primary = DPL::FromUTF8String("primary");
1341 a12.m_label.push_back(std::pair<DPL::String,DPL::String>(s1, s1));
1343 RUNNER_ASSERT_MSG(a != a0, "livebox info not equal");
1344 RUNNER_ASSERT_MSG(a != a1, "livebox info not equal");
1345 RUNNER_ASSERT_MSG(a != a2, "livebox info not equal");
1346 RUNNER_ASSERT_MSG(a != a3, "livebox info not equal");
1347 RUNNER_ASSERT_MSG(a != a4, "livebox info not equal");
1348 RUNNER_ASSERT_MSG(a == a5, "livebox info equal");
1349 RUNNER_ASSERT_MSG(a == a, "livebox info equal");
1350 RUNNER_ASSERT_MSG(a10 != a11, "livebox info not equal");
1351 RUNNER_ASSERT_MSG(a10 == a12, "livebox info equal");
1355 * Name: widget_dao_test_get_widget_by_guid
1356 * Description: Tests creating WidgetDAO using GUID
1357 * Expected: Correct WidgetDAO should be created
1359 RUNNER_TEST(widget_dao_test_get_widget_by_guid)
1361 WidgetDAO dao(DPL::OptionalString(L"w_id_2000"));
1362 RUNNER_ASSERT(dao.getTizenAppId() == L"tizenid201");
1366 * Name: widget_dao_test_set_tizen_app_id
1367 * Description: Tests changing TizenAppId
1368 * Expected: Change should be possible
1370 RUNNER_TEST(widget_dao_test_set_tizen_app_id)
1372 WacSecurityMock sec;
1373 WidgetRegisterInfo regInfo;
1374 TizenAppId originaltizenAppId = REGISTER_WIDGET(regInfo, sec);
1375 TizenAppId changedTizenAppId = L"changedTizenAppId";
1377 TizenAppIdList ids = WidgetDAO::getTizenAppidList();
1378 RUNNER_ASSERT(std::count(ids.begin(),ids.end(),originaltizenAppId) == 1);
1381 WidgetDAO dao(originaltizenAppId);
1382 dao.setTizenAppId(changedTizenAppId);
1384 ids = WidgetDAO::getTizenAppidList();
1385 RUNNER_ASSERT(std::count(ids.begin(), ids.end(), originaltizenAppId) == 0);
1386 RUNNER_ASSERT(std::count(ids.begin(), ids.end(), changedTizenAppId) == 1);
1388 bool exceptionCaught = checkException < WidgetDAOReadOnly::Exception::WidgetNotExist > ([&]() {
1389 WidgetDAO dao2(originaltizenAppId);
1390 //Changing should fail because original tizenAppId doesn't exist any more.
1391 dao2.setTizenAppId(changedTizenAppId);
1393 RUNNER_ASSERT(exceptionCaught);
1395 WidgetDAO::unregisterWidget(changedTizenAppId);
1396 ids = WidgetDAO::getTizenAppidList();
1397 RUNNER_ASSERT(std::count(ids.begin(),ids.end(),originaltizenAppId) == 0);
1398 RUNNER_ASSERT(std::count(ids.begin(),ids.end(),changedTizenAppId) == 0);
1403 * Name: widget_dao_test_update_feature_reject_status
1404 * Description: Tests updating feature reject status
1405 * Expected: Reject status should be properly updated
1407 RUNNER_TEST(widget_dao_test_update_feature_reject_status)
1409 WidgetDAO dao(L"tizenid202");
1410 DbWidgetFeatureSet featureSet = dao.getFeaturesList();
1412 RUNNER_ASSERT(featureSet.size() == 1);
1413 DbWidgetFeature feature = *featureSet.begin();
1414 RUNNER_ASSERT(!feature.rejected);
1416 feature.rejected = true;
1417 dao.updateFeatureRejectStatus(feature);
1419 featureSet = dao.getFeaturesList();
1420 RUNNER_ASSERT(featureSet.size() == 1);
1421 DbWidgetFeature feature2 = *featureSet.begin();
1422 RUNNER_ASSERT(feature.rejected);
1424 feature2.rejected = false;
1425 dao.updateFeatureRejectStatus(feature2);
1429 * Name: widget_dao_test_register_widget_allow_navigation
1430 * Description: Tests AllowNavigationInfo registration
1431 * Expected: AllowNavigationInfo registration should be possible
1433 RUNNER_TEST(widget_dao_test_register_widget_allow_navigation)
1435 WacSecurityMock sec;
1436 WidgetRegisterInfo regInfo;
1437 ConfigParserData::AllowNavigationInfo navigationInfo1(L"scheme1", L"host1");
1438 ConfigParserData::AllowNavigationInfo navigationInfo2(L"scheme2", L"host2");
1439 regInfo.configInfo.allowNavigationInfoList.push_back(navigationInfo1);
1440 regInfo.configInfo.allowNavigationInfoList.push_back(navigationInfo2);
1442 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1444 WidgetDAOReadOnly dao(tizenAppId);
1445 WidgetAllowNavigationInfoList navigationList;
1446 dao.getWidgetAllowNavigationInfo(navigationList);
1448 RUNNER_ASSERT(navigationList.size() == 2);
1450 std::count_if(navigationList.begin(), navigationList.end(), [] (const WidgetAllowNavigationInfo& navInfo)
1451 { return navInfo.host == L"host1" && navInfo.scheme == L"scheme1"; }) == 1);
1453 std::count_if(navigationList.begin(), navigationList.end(), [] (const WidgetAllowNavigationInfo& navInfo)
1454 { return navInfo.host == L"host2" && navInfo.scheme == L"scheme2"; }) == 1);
1459 * Name: widget_dao_test_register_external_locations
1460 * Description: Tests ExternalLocation registration
1461 * Expected: ExternalLocation registration should be possible
1463 RUNNER_TEST(widget_dao_test_register_external_locations)
1465 WacSecurityMock sec;
1466 WidgetRegisterInfo regInfo;
1467 regInfo.externalLocations.push_back("location1");
1468 regInfo.externalLocations.push_back("location2");
1470 TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1472 WidgetDAOReadOnly dao(tizenAppId);
1473 ExternalLocationList locationList = dao.getWidgetExternalLocations();
1475 RUNNER_ASSERT(locationList.size() == 2);
1476 RUNNER_ASSERT(std::count(locationList.begin(), locationList.end(), "location1") == 1);
1477 RUNNER_ASSERT(std::count(locationList.begin(), locationList.end(), "location2") == 1);
1481 * Name: widget_dao_test_get_tz_app_id
1482 * Description: Tests getTizenAppId functions
1483 * Expected: TizenAppId is correctly fetched for correct widgets, exception for not existing.
1485 RUNNER_TEST(widget_dao_test_get_tz_app_id)
1488 RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenAppId(1234); );
1490 TizenAppId appId = WidgetDAOReadOnly::getTizenAppId(2001);
1491 RUNNER_ASSERT(L"tizenid202" == appId);
1493 RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenAppId(L"no_such_widget"); );
1495 appId = WidgetDAOReadOnly::getTizenAppId(L"pkgid202");
1496 RUNNER_ASSERT(L"tizenid202" == appId);
1500 * Name: widget_dao_test_get_tz_pkg_id
1501 * Description: Tests getTizenPkgId functions
1502 * Expected: TizenPkgId is correctly fetched for correct widgets, exception for not existing.
1504 RUNNER_TEST(widget_dao_test_get_tz_pkg_id)
1507 RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenPkgId(1234); );
1510 TizenPkgId pkgId = WidgetDAOReadOnly::getTizenPkgId(2001);
1511 RUNNER_ASSERT(L"pkgid202" == pkgId);
1513 RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenPkgId(L"no_such_widget"););
1515 pkgId = WidgetDAOReadOnly::getTizenPkgId(L"tizenid202");
1516 RUNNER_ASSERT(L"pkgid202" == pkgId);
1520 * Name: widget_dao_test_get_property_key
1521 * Description: Tests getPropertyKeyList function
1522 * Expected: Property keys are fetched correctly.
1524 RUNNER_TEST(widget_dao_test_get_property_key)
1526 WidgetDAOReadOnly dao(L"tizenid201");
1527 PropertyDAOReadOnly::WidgetPropertyKeyList propertyKeys = dao.getPropertyKeyList();
1529 RUNNER_ASSERT(propertyKeys.size() == 2);
1530 RUNNER_ASSERT(std::count(propertyKeys.begin(), propertyKeys.end(), L"key1_for_2000") == 1);
1531 RUNNER_ASSERT(std::count(propertyKeys.begin(), propertyKeys.end(), L"key2_for_2000") == 1);
1535 * Name: widget_dao_test_get_property_value
1536 * Description: Tests getPropertyValue function
1537 * Expected: Property key values are fetched correctly.
1539 RUNNER_TEST(widget_dao_test_get_property_value)
1541 WidgetDAOReadOnly dao(L"tizenid201");
1543 RUNNER_ASSERT(dao.getPropertyValue(L"key1_for_2000") == L"value_for_key1_2000");
1544 RUNNER_ASSERT(dao.getPropertyValue(L"key2_for_2000") == L"value_for_key2_2000");
1545 RUNNER_ASSERT(dao.getPropertyValue(L"not_existing").IsNull());
1546 RUNNER_ASSERT(dao.getPropertyValue(L"").IsNull());
1550 * Name: widget_dao_test_get_property_read_flag
1551 * Description: Tests checkPropertyReadFlag function
1552 * Expected: Property read flags values are fetched correctly.
1554 RUNNER_TEST(widget_dao_test_get_property_read_flag)
1556 WidgetDAOReadOnly dao(L"tizenid201");
1558 RUNNER_ASSERT(dao.checkPropertyReadFlag(L"key1_for_2000") == 0);
1559 RUNNER_ASSERT(dao.checkPropertyReadFlag(L"key2_for_2000") == 0);
1560 RUNNER_ASSERT(dao.checkPropertyReadFlag(L"not_existing").IsNull());
1561 RUNNER_ASSERT(dao.checkPropertyReadFlag(L"").IsNull());
1565 * Name: widget_dao_test_get_pkg_id_list
1566 * Description: Tests getTizenPkgIdList function
1567 * Expected: All pkg ids are returned.
1569 RUNNER_TEST(widget_dao_test_get_pkg_id_list)
1571 TizenPkgIdList pkgIds = WidgetDAOReadOnly::getTizenPkgIdList();
1573 RUNNER_ASSERT(pkgIds.size() == 4);
1574 RUNNER_ASSERT(std::count(pkgIds.begin(), pkgIds.end(), L"pkgid201") == 1);
1575 RUNNER_ASSERT(std::count(pkgIds.begin(), pkgIds.end(), L"pkgid202") == 1);
1576 RUNNER_ASSERT(std::count(pkgIds.begin(), pkgIds.end(), L"") == 2);
1580 * Name: widget_dao_test_get_back_supported
1581 * Description: Tests getBackSupported function
1582 * Expected: Back supported information is fetched properly.
1584 RUNNER_TEST(widget_dao_test_get_back_supported)
1586 WidgetDAOReadOnly dao1(L"tizenid201");
1587 RUNNER_ASSERT(dao1.getBackSupported());
1589 WidgetDAOReadOnly dao2(L"tizenid202");
1590 RUNNER_ASSERT(!dao2.getBackSupported());
1594 * Name: widget_dao_test_get_csp_policy_report
1595 * Description: Tests getCspPolicyReportOnly function
1596 * Expected: CSP policy information is fetched properly.
1598 RUNNER_TEST(widget_dao_test_get_csp_policy_report)
1600 WidgetDAOReadOnly dao1(L"tizenid201");
1601 RUNNER_ASSERT(DPL::OptionalString(L"policy_report201") == dao1.getCspPolicyReportOnly());
1603 WidgetDAOReadOnly dao2(L"tizenid202");
1604 RUNNER_ASSERT(DPL::OptionalString(L"policy_report202") == dao2.getCspPolicyReportOnly());
1608 * Name: widget_dao_test_get_install_time
1609 * Description: Tests getInstallTime function
1610 * Expected: Installation time is fetched properly.
1612 RUNNER_TEST(widget_dao_test_get_install_time)
1614 WidgetDAOReadOnly dao1(L"tizenid201");
1615 RUNNER_ASSERT(1256 == dao1.getInstallTime());
1617 WidgetDAOReadOnly dao2(L"tizenid202");
1618 RUNNER_ASSERT(5687 == dao2.getInstallTime());
1622 * Name: widget_dao_test_get_icon_language_tags
1623 * Description: Tests getIconLanguageTags function
1624 * Expected: Information about icon localization is fetched properly.
1626 RUNNER_TEST(widget_dao_test_get_icon_language_tags)
1628 WidgetDAOReadOnly dao1(L"tizenid201");
1629 LanguageTags languageTags = dao1.getIconLanguageTags();
1631 RUNNER_ASSERT(2 == languageTags.size());
1632 RUNNER_ASSERT(std::count(languageTags.begin(), languageTags.end(), L"en") == 1);
1633 RUNNER_ASSERT(std::count(languageTags.begin(), languageTags.end(), L"pl") == 1);
1636 #undef RUNNER_ASSERT_WHAT_EQUALS