tizen 2.4 release
[framework/web/wrt-commons.git] / tests / dao / TestCases_WidgetDAO.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  * @file   TestCases_WidgetDAO.cpp
18  * @author  Pawel Sikorski (p.sikorski@samsung.com)
19  * @version 1.0
20  * @brief   This file contains tests for widget dao class.
21  */
22
23 #include <list>
24 #include <cstdlib>
25 #include <cstdio>
26 #include <string>
27 #include <algorithm>
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>
37
38 using namespace WrtDB;
39
40 namespace {
41 class WacSecurityMock : public WrtDB::IWidgetSecurity
42 {
43   public:
44     WacSecurityMock() :
45         mRecognized(false),
46         mDistributorSigned(false)
47     {}
48
49     virtual const WidgetCertificateDataList& getCertificateList() const
50     {
51         return mList;
52     }
53
54     virtual bool isRecognized() const
55     {
56         return mRecognized;
57     }
58     virtual bool isDistributorSigned() const
59     {
60         return mDistributorSigned;
61     }
62     virtual void getCertificateChainList(CertificateChainList& /*lst*/) const {}
63     virtual void getCertificateChainList(CertificateChainList& /*lst*/,
64                                          CertificateSource /*source*/) const {}
65
66     WrtDB::WidgetCertificateDataList& getCertificateListRef()
67     {
68         return mList;
69     }
70
71     void setRecognized(bool recognized)
72     {
73         mRecognized = recognized;
74     }
75     void setDistributorSigned(bool distributorSigned)
76     {
77         mDistributorSigned = distributorSigned;
78     }
79
80   private:
81     WrtDB::WidgetCertificateDataList mList;
82     // author signature verified
83     bool mRecognized;
84     // known distribuor
85     bool mDistributorSigned;
86     // distributor is wac
87 };
88
89 TizenAppId _registerWidget(const WidgetRegisterInfo& regInfo,
90                            const IWidgetSecurity& sec,
91                            int line)
92 {
93     TizenAppId tizenAppId;
94     Try {
95         auto previous = WidgetDAO::getTizenAppIdList();
96
97         // register widget
98         tizenAppId = WidgetDAO::registerWidgetGeneratePkgId(regInfo, sec);
99
100         RUNNER_ASSERT_MSG(!tizenAppId.empty(),
101                           "(called from line " << line << ")");
102
103         auto current = WidgetDAO::getTizenAppIdList();
104         RUNNER_ASSERT_MSG(previous.size() + 1 == current.size(),
105                           "(called from line " << line << ")");
106
107         RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
108                               tizenAppId),
109                           "(called from line " << line << " tizenAppId: " <<
110                           tizenAppId << ")");
111     }
112     Catch(WidgetDAO::Exception::AlreadyRegistered) {
113         RUNNER_ASSERT_MSG(
114             false,
115             "Unexpected exception (called from line " << line << ")");
116     }
117     return tizenAppId;
118 }
119
120 #define REGISTER_WIDGET(regInfo, sec) _registerWidget((regInfo), \
121                                                       (sec), \
122                                                       __LINE__)
123
124 template<typename Exception, typename Function>
125 bool checkException(Function fun)
126 {
127     Try
128     {
129         fun();
130     }
131     Catch(Exception){
132         return true;
133     }
134     return false;
135 }
136
137 } // namespace
138
139 // Widgets used <2300,2500), 2000, 2001, 2002, 2003
140
141 #define RUNNER_ASSERT_WHAT_EQUALS(in, test)                   \
142     { std::string tmp(in);                                     \
143       RUNNER_ASSERT_MSG(tmp == test, "Equals: [" + tmp + "]"); }
144
145 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(in, test)          \
146     {                                                     \
147         if (!in) { RUNNER_ASSERT_MSG(false, "NULL"); } \
148         else { RUNNER_ASSERT_WHAT_EQUALS(DPL::ToUTF8String(*in), test); } \
149     }
150
151 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONALINT(in, test)                   \
152     {                                                                 \
153         if (!in) { RUNNER_ASSERT_MSG(false, "NULL"); }             \
154         else { RUNNER_ASSERT_MSG(*in == test, "Equals: [" + *in + "]"); } \
155     }
156
157 #define RUNNER_ASSERT_EXCEPTION(exceptionType, function)             \
158     {                                                                \
159         RUNNER_ASSERT(checkException<exceptionType>([](){function})); \
160     }
161
162 RUNNER_TEST_GROUP_INIT(DAO)
163
164 //2300
165 /*
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
169  */
170 RUNNER_TEST(widget_dao_test_register_widget_empty_strings)
171 {
172     WidgetRegisterInfo regInfo;
173
174     //info
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;
187
188     //loc info
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));
198
199     //userAgentLoc
200
201     //icons
202     ConfigParserData::Icon icon(DPL::FromUTF8String(""));
203     icon.width = 10;
204     icon.height = 10;
205     LocaleSet locs;
206     locs.insert(DPL::FromUTF8String("en"));
207     WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
208     regInfo.localizationData.icons.push_back(locIcon);
209
210     //start file
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);
219
220     //widget pref
221     ConfigParserData::Preference pref(DPL::FromUTF8String(""), false);
222     pref.value = DPL::FromUTF8String("");
223     regInfo.configInfo.preferencesList.insert(pref);
224
225     //widget feature
226     ConfigParserData::Feature feat(DPL::FromUTF8String(""));
227     regInfo.configInfo.featuresList.insert(feat);
228
229     //win modes
230     regInfo.configInfo.windowModes.insert(DPL::FromUTF8String(""));
231
232     //WARP info
233     ConfigParserData::AccessInfo access(DPL::FromUTF8String(""), true);
234     regInfo.configInfo.accessInfoSet.insert(access);
235
236     //certificates
237     WidgetCertificateData cert;
238     cert.owner = WidgetCertificateData::AUTHOR;
239     cert.type = WidgetCertificateData::ROOT;
240     cert.chainId = 1;
241     cert.strMD5Fingerprint = "";
242     cert.strSHA1Fingerprint = "";
243     cert.strCommonName = DPL::FromUTF8String("");
244
245     WacSecurityMock security;
246     security.getCertificateListRef().push_back(cert);
247
248     REGISTER_WIDGET(regInfo, security);
249 }
250
251 /*
252  * Name: widget_dao_test_register_widget_empty_strings
253  * Description: Tests possiblity of registering twice same content (different
254  * tizenId)
255  * Expected: it should be possible
256  */
257 RUNNER_TEST(widget_dao_test_twice_install_same_widget)
258 {
259     WacSecurityMock sec;
260     {
261         WidgetRegisterInfo regInfo;
262         REGISTER_WIDGET(regInfo, sec);
263     }
264     {
265         WidgetRegisterInfo regInfo;
266         REGISTER_WIDGET(regInfo, sec);
267     }
268 }
269
270 /*
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
274  */
275 RUNNER_TEST(widget_dao_test_register_widget_minimum_info)
276 {
277     WacSecurityMock sec;
278     const std::size_t NUMBER_OF_WIDGETS = 5;
279
280     TizenAppId lastTizenAppId;
281
282     for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
283         WidgetRegisterInfo regInfo;
284         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
285
286         lastTizenAppId = tizenAppId;
287
288         WidgetDAO dao(tizenAppId);
289         //TODO check nulls
290     }
291 }
292
293 /*
294  * Name: widget_dao_test_register_widget_info
295  * Description: Tests registeration of many widgets
296  * Expected: all widgets should be registered in database
297  */
298 RUNNER_TEST(widget_dao_test_register_widget_info)
299 {
300     WacSecurityMock sec;
301     const std::size_t NUMBER_OF_WIDGETS = 5;
302
303     for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
304         std::ostringstream str;
305         str << "register_info_test_" << number;
306
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;
322
323         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
324
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");
332     }
333 }
334
335 /*
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
340  */
341 RUNNER_TEST(widget_dao_test_register_widget_extended_info)
342 {
343     WacSecurityMock sec;
344     const std::size_t NUMBER_OF_WIDGETS = 5;
345
346     for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
347         std::ostringstream str;
348         str << "register_ext_info_test_" << number;
349
350         WidgetRegisterInfo regInfo;
351
352         regInfo.configInfo.backgroundPage = L"background.html";
353
354         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
355
356         WidgetDAO dao(tizenAppId);
357
358         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getBackgroundPage(),
359                                            "background.html");
360     }
361 }
362
363 /*
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
367  */
368 RUNNER_TEST(widget_dao_test_register_widget_localized_info)
369 {
370     WacSecurityMock sec;
371     const std::size_t NUMBER_OF_WIDGETS = 5;
372
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;
379         { //EN
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));
389         }
390
391         { //PL
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));
401         }
402
403         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
404
405         WidgetDAO dao(tizenAppId);
406         RUNNER_ASSERT_MSG(dao.getLanguageTags().size() == 2,
407                           "language tags list invalid");
408
409         { //EN
410             WidgetLocalizedInfo locInfo =
411                 dao.getLocalizedInfo(DPL::FromUTF8String("en"));
412
413             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
414                                                str_en.str());
415             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
416                                                str_en.str());
417             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
418                                                str_en.str());
419             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
420                                                str_en.str());
421             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
422                                                str_en.str());
423         }
424
425         { //PL
426             WidgetLocalizedInfo locInfo =
427                 dao.getLocalizedInfo(DPL::FromUTF8String("pl"));
428
429             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
430                                                str_pl.str());
431             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
432                                                str_pl.str());
433             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
434                                                str_pl.str());
435             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
436                                                str_pl.str());
437             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
438                                                str_pl.str());
439         }
440     }
441 }
442
443 /*
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
447  * for icon
448  */
449 RUNNER_TEST(widget_dao_test_register_widget_icons)
450 {
451     WacSecurityMock sec;
452     WidgetRegisterInfo regInfo;
453
454     ConfigParserData::Icon icon(L"icon1");
455     icon.width = 10;
456     icon.height = 10;
457     LocaleSet locs;
458     locs.insert(DPL::FromUTF8String("en"));
459     WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
460     regInfo.localizationData.icons.push_back(locIcon);
461
462     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
463
464     WidgetDAO dao(tizenAppId);
465     WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
466
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();
472          ++it1, ++it2)
473     {
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);
478     }
479 }
480
481 /*
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
485  */
486 RUNNER_TEST(widget_dao_test_register_widget_start_files)
487 {
488     WacSecurityMock sec;
489
490     WidgetRegisterInfo::LocalizedStartFileList files;
491     WidgetRegisterInfo::StartFilePropertiesForLocalesMap map1;
492     WidgetRegisterInfo::StartFileProperties prop1;
493     prop1.encoding = DPL::FromUTF8String("enc1");
494     prop1.type = DPL::FromUTF8String("type1");
495
496     map1.insert(std::make_pair(DPL::FromUTF8String("en"), prop1));
497     map1.insert(std::make_pair(DPL::FromUTF8String("pl"), prop1));
498
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;
505
506     files.push_back(file1);
507     files.push_back(file1);
508
509     WidgetRegisterInfo regInfo;
510     regInfo.localizationData.startFiles = files;
511
512     REGISTER_WIDGET(regInfo, sec);
513
514     //TODO no getter in WidgetDAO (getter in LocalizedWidgetDAO,
515     // but it will be removed
516 }
517
518 /*
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)
522  */
523 RUNNER_TEST(widget_dao_test_register_widget_features)
524 {
525     WacSecurityMock sec;
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")));
530
531     WidgetRegisterInfo regInfo;
532     FOREACH(it, features)
533     regInfo.configInfo.featuresList.insert(*it);
534
535     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
536
537     WidgetDAO dao(tizenAppId);
538     WidgetFeatureSet out = dao.getFeaturesList();
539     RUNNER_ASSERT_MSG(out.size() == features.size(),
540                       "wrong number of features");
541     //    FOREACH(it, out)
542     //        RUNNER_ASSERT(features.find(*it) != features.end());
543 }
544
545 /*
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
549  */
550 RUNNER_TEST(widget_dao_test_register_widget_win_modes)
551 {
552     WacSecurityMock sec;
553     std::set<DPL::String> modes;
554     modes.insert(DPL::FromUTF8String("full"));
555     modes.insert(DPL::FromUTF8String("window"));
556
557     WidgetRegisterInfo regInfo;
558
559     FOREACH(it, modes)
560     regInfo.configInfo.windowModes.insert(*it);
561
562     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
563
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");
568     FOREACH(it, wins)
569     RUNNER_ASSERT(modes.find(*it) != modes.end());
570 }
571
572 /*
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
576  */
577 RUNNER_TEST(widget_dao_test_register_widget_warp_info)
578 {
579     WacSecurityMock sec;
580     ConfigParserData::AccessInfoSet orig;
581     orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri1"),
582                                              true));
583     orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri2"),
584                                              false));
585     orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri3"),
586                                              true));
587
588     WidgetRegisterInfo regInfo;
589     FOREACH(it, orig)
590     regInfo.configInfo.accessInfoSet.insert(*it);
591
592     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
593
594     WidgetDAO dao(tizenAppId);
595
596     WidgetAccessInfoList out;
597     dao.getWidgetAccessInfo(out);
598     RUNNER_ASSERT_MSG(out.size() == orig.size(),
599                       "wrong number of access info elem");
600     FOREACH(it, out){
601         ConfigParserData::AccessInfo tmp(it->strIRI, it->bSubDomains);
602         RUNNER_ASSERT(orig.find(tmp) != orig.end());
603     }
604 }
605
606 /*
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
611  */
612 RUNNER_TEST(widget_dao_test_register_widget_certificates)
613 {
614     WacSecurityMock sec;
615     WidgetRegisterInfo regInfo;
616
617     WidgetCertificateData cert;
618     cert.owner = WidgetCertificateData::AUTHOR;
619     cert.type = WidgetCertificateData::ROOT;
620     cert.chainId = 1;
621     cert.strMD5Fingerprint = "md5";
622     cert.strSHA1Fingerprint = "sha1";
623     cert.strCommonName = DPL::FromUTF8String("common name");
624
625     WidgetCertificateDataList& certListRef = sec.getCertificateListRef();
626     certListRef.push_back(cert);
627
628     // register widget
629     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
630
631     WidgetDAO dao(tizenAppId);
632
633     // certificates
634     WidgetCertificateDataList recList = dao.getCertificateDataList();
635     RUNNER_ASSERT(recList.size() == certListRef.size());
636
637     auto recListIt = recList.begin();
638     auto certListIt = certListRef.begin();
639     for (; recListIt != recList.end() && certListIt != certListRef.end();
640          ++recListIt, ++certListIt)
641     {
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);
650     }
651
652     // fingerprints
653     RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
654                                          WidgetCertificateData::ENDENTITY).
655                       empty());
656     RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::AUTHOR,
657                                          WidgetCertificateData::ENDENTITY).
658                       empty());
659     RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
660                                          WidgetCertificateData::ROOT).empty());
661
662     FingerPrintList fingerprints = dao.getKeyFingerprints(
663             WidgetCertificateData::AUTHOR,
664             WidgetCertificateData::ROOT);
665
666     RUNNER_ASSERT(fingerprints.size() == certListRef.size() * 2);
667     FOREACH(it, certListRef)
668     {
669         auto md5 = std::find(fingerprints.begin(),
670                              fingerprints.end(),
671                              it->strMD5Fingerprint);
672         RUNNER_ASSERT(md5 != fingerprints.end());
673
674         auto sha = std::find(fingerprints.begin(),
675                              fingerprints.end(),
676                              it->strSHA1Fingerprint);
677         RUNNER_ASSERT(sha != fingerprints.end());
678     }
679
680     // common names
681     RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
682                                            WidgetCertificateData::ENDENTITY).
683                       empty());
684     RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::AUTHOR,
685                                            WidgetCertificateData::ENDENTITY).
686                       empty());
687     RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
688                                            WidgetCertificateData::ROOT).empty());
689
690     FingerPrintList commonNames = dao.getKeyCommonNameList(
691             WidgetCertificateData::AUTHOR,
692             WidgetCertificateData::ROOT);
693
694     RUNNER_ASSERT(commonNames.size() == certListRef.size());
695     FOREACH(it, certListRef)
696     {
697         auto cn = std::find(commonNames.begin(),
698                             commonNames.end(),
699                             DPL::ToUTF8String(it->strCommonName));
700         RUNNER_ASSERT(cn != commonNames.end());
701     }
702 }
703
704 /*
705  * Name: widget_dao_test_register_widget_privileges
706  * Description: Tests registration of widget privileges
707  */
708 RUNNER_TEST(widget_dao_test_register_widget_privileges)
709 {
710
711     WacSecurityMock sec;
712     WidgetRegisterInfo regInfo;
713
714     ConfigParserData::PrivilegeList& privilegeList =
715             regInfo.configInfo.privilegeList;
716     privilegeList.insert(DPL::FromUTF8String("name"));
717     privilegeList.insert(DPL::FromUTF8String("name2"));
718
719     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
720     WidgetDAO dao(tizenAppId);
721
722     WrtDB::PrivilegeList privListFromDB;
723     privListFromDB = dao.getWidgetPrivilege();
724
725     RUNNER_ASSERT(privilegeList.size() == privListFromDB.size());
726
727     auto privListIt = privilegeList.begin();
728     auto privDBIt = privListFromDB.begin();
729     for(; privListIt != privilegeList.end() && privDBIt != privListFromDB.end();
730             ++privListIt, ++privDBIt)
731     {
732         RUNNER_ASSERT(*privDBIt == privListIt->name);
733     }
734 }
735
736 /*
737  * Name: widget_dao_test_register_app_control
738  * Description: Tests app control
739  */
740 RUNNER_TEST(widget_dao_test_register_app_control)
741 {
742     WacSecurityMock sec;
743     WidgetRegisterInfo regInfo;
744
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"));
749
750     ConfigParserData::AppControlInfoList& appControlListRef
751             = regInfo.configInfo.appControlList;
752     appControlListRef.push_back(appControl);
753
754     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
755
756     WidgetDAO dao(tizenAppId);
757
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();
763
764     for (;appDBIt != appControlInfoListDB.end()
765             && appRefIt != appControlListRef.end();
766             ++appDBIt, ++appRefIt)
767     {
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();
772                 ++it)
773         {
774             RUNNER_ASSERT((*it) == appDBIt->mime);
775         }
776         for(auto it = appRefIt->m_uriList.begin();
777                 it != appRefIt->m_uriList.end();
778                 ++it)
779         {
780             RUNNER_ASSERT((*it) == appDBIt->uri);
781         }
782     }
783 }
784
785 /*
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
789  */
790 RUNNER_TEST(widget_dao_test_is_widget_installed)
791 {
792     RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(L"tizenid201"));
793
794     WacSecurityMock sec;
795     WidgetRegisterInfo regInfo;
796
797     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
798
799     RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(tizenAppId));
800 }
801
802 /*
803  * Name: widget_dao_test_unregister_widget
804  * Description: Tests unregistering widgets
805  * Expected: widget register informations should be successfully removed
806  */
807 RUNNER_TEST(widget_dao_test_unregister_widget)
808 {
809     WacSecurityMock sec;
810     TizenAppIdList ids = WidgetDAO::getTizenAppIdList();
811
812     WidgetRegisterInfo regInfo;
813
814     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
815
816     WidgetDAO::unregisterWidget(tizenAppId);
817
818     RUNNER_ASSERT_MSG(ids.size() == WidgetDAO::getTizenAppIdList().size(),
819                       "Widget unregister failed");
820 }
821
822 /*
823  * Name: widget_dao_test_register_or_update_widget
824  * Description: Tests reregistering widgets
825  * Expected: widget should be successfully replaced
826  */
827 RUNNER_TEST(widget_dao_test_register_or_update_widget)
828 {
829     WacSecurityMock sec;
830
831     WidgetRegisterInfo regInfo;
832     regInfo.configInfo.version = L"1.0";
833     regInfo.configInfo.authorName = L"AAA";
834
835     WidgetRegisterInfo regInfo2;
836     regInfo2.configInfo.version = L"1.1";
837     regInfo2.configInfo.authorName = L"BBB";
838
839     WrtDB::TizenAppId tizenAppId(L"abcdefghij");
840
841     //first installation
842     WidgetDAO::registerWidget(tizenAppId, regInfo, sec);
843     RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
844                           tizenAppId), "Widget is not registered");
845
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);
853     RUNNER_ASSERT_MSG(
854         *dao.getVersion() == L"1.1", "Data widget was not updated");
855     RUNNER_ASSERT_MSG(
856         *dao.getAuthorName() == L"BBB", "Data widget was not updated");
857
858
859     WidgetDAO::unregisterWidget(tizenAppId);
860 }
861
862 /*
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
866  */
867 RUNNER_TEST(widget_dao_test_get_widget_tizenAppId_list)
868 {
869     TizenAppIdList tizenAppIds = WidgetDAO::getTizenAppIdList();
870     RUNNER_ASSERT(tizenAppIds.size() >= 3);
871 }
872
873 /*
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
878  */
879 RUNNER_TEST(widget_dao_test_get_widget_list)
880 {
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();
885 }
886
887 /*
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
891  */
892 RUNNER_TEST(widget_dao_test_get_widget_attributes)
893 {
894     {
895         TizenAppId tizenAppId = L"tizenid201";
896         WidgetDAO dao(tizenAppId);
897
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(),
902                                            "a_email_2000");
903         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorHref(), "a_href_2000");
904         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getMinimumWacVersion(), "1.0");
905     }
906 }
907
908 /*
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
912  * database
913  */
914 RUNNER_TEST(widget_dao_test_localization)
915 {
916     WacSecurityMock sec;
917
918     // icon
919     WidgetRegisterInfo regInfo;
920     ConfigParserData::Icon icon(L"icon1");
921     icon.width = 10;
922     icon.height = 10;
923     LocaleSet locs;
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);
928
929     //start file
930     WidgetRegisterInfo::StartFileProperties prop_en;
931     prop_en.encoding = DPL::FromUTF8String("encoding_en");
932     prop_en.type = DPL::FromUTF8String("type_en");
933
934     WidgetRegisterInfo::StartFileProperties prop_pl;
935     prop_pl.encoding = DPL::FromUTF8String("encoding_pl");
936     prop_pl.type = DPL::FromUTF8String("type_pl");
937
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);
945
946     // register widget
947     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
948
949     WidgetDAO dao(tizenAppId);
950
951     // check localized icons
952     WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
953     RUNNER_ASSERT(locList.size() == locs.size());
954
955     // non-localized icon
956     WidgetDAO::WidgetIconList list = dao.getIconList();
957     int iconId = list.front().iconId;
958
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,
963          ++iconIt)
964     {
965         RUNNER_ASSERT(iconIt->appId == dao.getHandle());
966         RUNNER_ASSERT(iconIt->iconId == iconId);
967         RUNNER_ASSERT(iconIt->widgetLocale == *locsIt);
968     }
969
970     // localized start file list
971     WidgetDAO::LocalizedStartFileList fList = dao.getLocalizedStartFileList();
972     RUNNER_ASSERT(fList.size() == file.propertiesForLocales.size());
973
974     int startFileId = dao.getStartFileList().front().startFileId;
975
976     FOREACH(it, fList)
977     {
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);
984     }
985 }
986
987 /*
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
991  * database
992  */
993 RUNNER_TEST(widget_dao_test_register_scp)
994 {
995     WacSecurityMock sec;
996     WidgetRegisterInfo regInfo;
997     DPL::OptionalString policy = DPL::FromUTF8String("Some awesome csp policy");
998     regInfo.configInfo.cspPolicy = policy;
999     {
1000         // register widget
1001         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1002         WidgetDAO dao(tizenAppId);
1003
1004         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(
1005             dao.getCspPolicy(), DPL::ToUTF8String(*policy));
1006     }
1007 }
1008
1009 /*
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
1013  * database
1014  */
1015 RUNNER_TEST(widget_dao_test_register_csp_empty)
1016 {
1017     WacSecurityMock sec;
1018     WidgetRegisterInfo regInfo;
1019     {
1020         // register widget
1021         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1022         WidgetDAO dao(tizenAppId);
1023
1024         RUNNER_ASSERT_MSG(!dao.getCspPolicy(), "Policy is not null");
1025     }
1026 }
1027
1028 /*
1029  * Name: widget_dao_test_widget_privileges_basics
1030  * Description: Tests basic operators of privileges
1031  * Expected: operators should behave properly
1032  */
1033 RUNNER_TEST(widget_dao_test_widget_privileges_basics)
1034 {
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"));
1039
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");
1044
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);
1051 }
1052
1053 /*
1054  * Name: widget_dao_test_widget_preferences_basics
1055  * Description: Tests basic operators of preferences
1056  * Expected: operators should behave properly
1057  */
1058 RUNNER_TEST(widget_dao_test_widget_preferences_basics)
1059 {
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"));
1064
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");
1069
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);
1076 }
1077
1078 /*
1079  * Name: widget_dao_test_widget_features_basics
1080  * Description: Tests basic operators of features
1081  * Expected: operators should behave properly
1082  */
1083 RUNNER_TEST(widget_dao_test_widget_features_basics)
1084 {
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"));
1089
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");
1094
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);
1101 }
1102
1103 /*
1104  * Name: widget_dao_test_widget_icons_basics
1105  * Description: Tests basic operators for icons
1106  * Expected: operators should behave properly
1107  */
1108 RUNNER_TEST(widget_dao_test_widget_icons_basics)
1109 {
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"));
1114
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");
1119
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);
1126 }
1127
1128 /*
1129  * Name: widget_dao_test_widget_settings_basics
1130  * Description: Tests basic operators for settings of widget
1131  * Expected: operators should behave properly
1132  */
1133 RUNNER_TEST(widget_dao_test_widget_settings_basics)
1134 {
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"));
1139
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");
1144
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);
1151 }
1152
1153 /*
1154  * Name: widget_dao_test_widget_access_basics
1155  * Description: Tests basic operators for access of widget
1156  * Expected: operators should behave properly
1157  */
1158 RUNNER_TEST(widget_dao_test_widget_access_basics)
1159 {
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);
1164
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);
1172 }
1173
1174 /*
1175  * Name: widget_dao_test_widget_metadata_basics
1176  * Description: Tests basic operators for metadata
1177  * Expected: operators should behave properly
1178  */
1179 RUNNER_TEST(widget_dao_test_widget_metadata_basics)
1180 {
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"));
1185
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");
1191 }
1192
1193 /*
1194  * Name: widget_dao_test_widget_appcontrolinfo_basics
1195  * Description: Tests basic operators for app control info
1196  * Expected: operators should behave properly
1197  */
1198 RUNNER_TEST(widget_dao_test_widget_appcontrolinfo_basics)
1199 {
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"));
1204
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"));
1209
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"));
1214
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"));
1219
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"));
1224
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"));
1229
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"));
1234
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");
1242 }
1243
1244 #if USE(WEB_PROVIDER)
1245 /*
1246  * Name: widget_dao_test_widget_metadata_basics
1247  * Description: Tests basic operators for livebox info
1248  * Expected: operators should behave properly
1249  */
1250 RUNNER_TEST(widget_dao_test_widget_livebox_basics)
1251 {
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");
1258
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");
1265
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");
1272
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");
1279
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");
1286
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");
1293
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");
1300
1301     const DPL::String s1 = DPL::FromUTF8String("1");
1302     const DPL::String s2 =  DPL::FromUTF8String("2");
1303
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));
1311
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));
1320
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));
1328
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");
1338 }
1339 #endif
1340 /*
1341  * Name: widget_dao_test_get_widget_by_guid
1342  * Description: Tests creating WidgetDAO using GUID
1343  * Expected: Correct WidgetDAO should be created
1344  */
1345 RUNNER_TEST(widget_dao_test_get_widget_by_guid)
1346 {
1347     WidgetDAO dao(DPL::OptionalString(L"w_id_2000"));
1348     RUNNER_ASSERT(dao.getTizenAppId() == L"tizenid201");
1349 }
1350
1351 /*
1352  * Name: widget_dao_test_set_tizen_app_id
1353  * Description: Tests changing TizenAppId
1354  * Expected: Change should be possible
1355  */
1356 RUNNER_TEST(widget_dao_test_set_tizen_app_id)
1357 {
1358     WacSecurityMock sec;
1359     WidgetRegisterInfo regInfo;
1360     TizenAppId originaltizenAppId = REGISTER_WIDGET(regInfo, sec);
1361     TizenAppId changedTizenAppId = L"changedTizenAppId";
1362
1363     TizenAppIdList ids = WidgetDAO::getTizenAppIdList();
1364     RUNNER_ASSERT(std::count(ids.begin(),ids.end(),originaltizenAppId) == 1);
1365
1366     //Change tizenAppId
1367     WidgetDAO dao(originaltizenAppId);
1368     dao.setTizenAppId(changedTizenAppId);
1369
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);
1373
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);
1378         });
1379     RUNNER_ASSERT(exceptionCaught);
1380
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);
1385
1386 }
1387
1388 /*
1389  * Name: widget_dao_test_update_feature_reject_status
1390  * Description: Tests updating feature reject status
1391  * Expected: Reject status should be properly updated
1392  */
1393 RUNNER_TEST(widget_dao_test_update_feature_reject_status)
1394 {
1395     WidgetDAO dao(L"tizenid202");
1396     DbWidgetFeatureSet featureSet = dao.getFeaturesList();
1397
1398     RUNNER_ASSERT(featureSet.size() == 1);
1399     DbWidgetFeature feature = *featureSet.begin();
1400     RUNNER_ASSERT(!feature.rejected);
1401
1402     feature.rejected = true;
1403     dao.updateFeatureRejectStatus(feature);
1404
1405     featureSet = dao.getFeaturesList();
1406     RUNNER_ASSERT(featureSet.size() == 1);
1407     DbWidgetFeature feature2 = *featureSet.begin();
1408     RUNNER_ASSERT(feature.rejected);
1409
1410     feature2.rejected = false;
1411     dao.updateFeatureRejectStatus(feature2);
1412 }
1413
1414 /*
1415  * Name: widget_dao_test_register_widget_allow_navigation
1416  * Description: Tests AllowNavigationInfo registration
1417  * Expected: AllowNavigationInfo registration should be possible
1418  */
1419 RUNNER_TEST(widget_dao_test_register_widget_allow_navigation)
1420 {
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);
1427
1428     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1429
1430     WidgetDAOReadOnly dao(tizenAppId);
1431     WidgetAllowNavigationInfoList navigationList;
1432     dao.getWidgetAllowNavigationInfo(navigationList);
1433
1434     RUNNER_ASSERT(navigationList.size() == 2);
1435     RUNNER_ASSERT(
1436             std::count_if(navigationList.begin(), navigationList.end(), [] (const WidgetAllowNavigationInfo& navInfo)
1437                     { return navInfo.host == L"host1" && navInfo.scheme == L"scheme1"; }) == 1);
1438     RUNNER_ASSERT(
1439             std::count_if(navigationList.begin(), navigationList.end(), [] (const WidgetAllowNavigationInfo& navInfo)
1440                     { return navInfo.host == L"host2" && navInfo.scheme == L"scheme2"; }) == 1);
1441
1442 }
1443
1444 /*
1445  * Name: widget_dao_test_register_external_locations
1446  * Description: Tests ExternalLocation registration
1447  * Expected: ExternalLocation registration should be possible
1448  */
1449 RUNNER_TEST(widget_dao_test_register_external_locations)
1450 {
1451     WacSecurityMock sec;
1452     WidgetRegisterInfo regInfo;
1453     regInfo.externalLocations.push_back("location1");
1454     regInfo.externalLocations.push_back("location2");
1455
1456     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1457
1458     WidgetDAOReadOnly dao(tizenAppId);
1459     ExternalLocationList locationList = dao.getWidgetExternalLocations();
1460
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);
1464 }
1465
1466 #if USE(WEB_PROVIDER)
1467 /*
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
1471  * for icon
1472  */
1473 RUNNER_TEST(widget_dao_test_register_widget_liveboxID)
1474 {
1475     WacSecurityMock sec;
1476     WidgetRegisterInfo regInfo;
1477
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");
1484
1485     regInfo.configInfo.m_livebox.push_back(liveboxInfo1);
1486     regInfo.configInfo.m_livebox.push_back(liveboxInfo2);
1487     regInfo.configInfo.m_livebox.push_back(liveboxInfo3);
1488
1489     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1490
1491     WidgetDAOReadOnly dao(tizenAppId);
1492     WrtDB::WidgetDAOReadOnly::LiveBoxIdList outLiveBoxIdList;
1493     dao.getLiveBoxInfoList(outLiveBoxIdList);
1494
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");
1498     }
1499 }
1500 #endif
1501  /*
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.
1505   */
1506 RUNNER_TEST(widget_dao_test_get_tz_app_id)
1507 {
1508     //No such widget
1509     RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenAppId(1234); );
1510
1511     TizenAppId appId = WidgetDAOReadOnly::getTizenAppId(2001);
1512     RUNNER_ASSERT(L"tizenid202" == appId);
1513
1514     RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenAppId(L"no_such_widget"); );
1515
1516     appId = WidgetDAOReadOnly::getTizenAppId(L"pkgid202");
1517     RUNNER_ASSERT(L"tizenid202" == appId);
1518 }
1519
1520 /*
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.
1524  */
1525 RUNNER_TEST(widget_dao_test_get_tz_pkg_id)
1526 {
1527     //No such widget
1528     RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenPkgId(1234); );
1529
1530
1531     TizenPkgId pkgId = WidgetDAOReadOnly::getTizenPkgId(2001);
1532     RUNNER_ASSERT(L"pkgid202" == pkgId);
1533
1534     RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenPkgId(L"no_such_widget"););
1535
1536     pkgId = WidgetDAOReadOnly::getTizenPkgId(L"tizenid202");
1537     RUNNER_ASSERT(L"pkgid202" == pkgId);
1538 }
1539
1540 /*
1541  * Name: widget_dao_test_get_property_key
1542  * Description: Tests getPropertyKeyList function
1543  * Expected: Property keys are fetched correctly.
1544  */
1545 RUNNER_TEST(widget_dao_test_get_property_key)
1546 {
1547     WidgetDAOReadOnly dao(L"tizenid201");
1548     PropertyDAOReadOnly::WidgetPropertyKeyList propertyKeys = dao.getPropertyKeyList();
1549
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);
1553 }
1554
1555 /*
1556  * Name: widget_dao_test_get_property_value
1557  * Description: Tests getPropertyValue function
1558  * Expected: Property key values are fetched correctly.
1559  */
1560 RUNNER_TEST(widget_dao_test_get_property_value)
1561 {
1562     WidgetDAOReadOnly dao(L"tizenid201");
1563
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""));
1570 }
1571
1572 /*
1573  * Name: widget_dao_test_get_property_read_flag
1574  * Description: Tests checkPropertyReadFlag function
1575  * Expected: Property read flags values are fetched correctly.
1576  */
1577 RUNNER_TEST(widget_dao_test_get_property_read_flag)
1578 {
1579     WidgetDAOReadOnly dao(L"tizenid201");
1580
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""));
1585 }
1586
1587 /*
1588  * Name: widget_dao_test_get_pkg_id_list
1589  * Description: Tests getTizenPkgIdList function
1590  * Expected: All pkg ids are returned.
1591  */
1592 RUNNER_TEST(widget_dao_test_get_pkg_id_list)
1593 {
1594     TizenPkgIdList pkgIds = WidgetDAOReadOnly::getTizenPkgIdList();
1595
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);
1600 }
1601
1602 /*
1603  * Name: widget_dao_test_get_back_supported
1604  * Description: Tests getBackSupported function
1605  * Expected: Back supported information is fetched properly.
1606  */
1607 RUNNER_TEST(widget_dao_test_get_back_supported)
1608 {
1609     WidgetDAOReadOnly dao1(L"tizenid201");
1610     RUNNER_ASSERT(dao1.getBackSupported());
1611
1612     WidgetDAOReadOnly dao2(L"tizenid202");
1613     RUNNER_ASSERT(!dao2.getBackSupported());
1614 }
1615
1616 /*
1617  * Name: widget_dao_test_get_csp_policy_report
1618  * Description: Tests getCspPolicyReportOnly function
1619  * Expected: CSP policy information is fetched properly.
1620  */
1621 RUNNER_TEST(widget_dao_test_get_csp_policy_report)
1622 {
1623     WidgetDAOReadOnly dao1(L"tizenid201");
1624     RUNNER_ASSERT(DPL::OptionalString(L"policy_report201") == dao1.getCspPolicyReportOnly());
1625
1626     WidgetDAOReadOnly dao2(L"tizenid202");
1627     RUNNER_ASSERT(DPL::OptionalString(L"policy_report202") == dao2.getCspPolicyReportOnly());
1628 }
1629
1630 /*
1631  * Name: widget_dao_test_get_install_time
1632  * Description: Tests getInstallTime function
1633  * Expected: Installation time is fetched properly.
1634  */
1635 RUNNER_TEST(widget_dao_test_get_install_time)
1636 {
1637     WidgetDAOReadOnly dao1(L"tizenid201");
1638     RUNNER_ASSERT(1256 == dao1.getInstallTime());
1639
1640     WidgetDAOReadOnly dao2(L"tizenid202");
1641     RUNNER_ASSERT(5687 == dao2.getInstallTime());
1642 }
1643
1644 /*
1645  * Name: widget_dao_test_get_icon_language_tags
1646  * Description: Tests getIconLanguageTags function
1647  * Expected: Information about icon localization is fetched properly.
1648  */
1649 RUNNER_TEST(widget_dao_test_get_icon_language_tags)
1650 {
1651     WidgetDAOReadOnly dao1(L"tizenid201");
1652     LanguageTags languageTags = dao1.getIconLanguageTags();
1653
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);
1657 }
1658
1659 #undef RUNNER_ASSERT_WHAT_EQUALS