tizen 2.3 release
[framework/web/wearable/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 <wrt_plugin_export.h>
35 #include <LanguageTagsProvider.h>
36
37 using namespace WrtDB;
38
39 namespace {
40 class WacSecurityMock : public WrtDB::IWidgetSecurity
41 {
42   public:
43     WacSecurityMock() :
44         mRecognized(false),
45         mDistributorSigned(false)
46     {}
47
48     virtual const WidgetCertificateDataList& getCertificateList() const
49     {
50         return mList;
51     }
52
53     virtual bool isRecognized() const
54     {
55         return mRecognized;
56     }
57     virtual bool isDistributorSigned() const
58     {
59         return mDistributorSigned;
60     }
61     virtual void getCertificateChainList(CertificateChainList& /*lst*/) const {}
62     virtual void getCertificateChainList(CertificateChainList& /*lst*/,
63                                          CertificateSource /*source*/) const {}
64
65     WrtDB::WidgetCertificateDataList& getCertificateListRef()
66     {
67         return mList;
68     }
69
70     void setRecognized(bool recognized)
71     {
72         mRecognized = recognized;
73     }
74     void setDistributorSigned(bool distributorSigned)
75     {
76         mDistributorSigned = distributorSigned;
77     }
78
79   private:
80     WrtDB::WidgetCertificateDataList mList;
81     // author signature verified
82     bool mRecognized;
83     // known distribuor
84     bool mDistributorSigned;
85     // distributor is wac
86 };
87
88 TizenAppId _registerWidget(const WidgetRegisterInfo& regInfo,
89                            const IWidgetSecurity& sec,
90                            int line)
91 {
92     TizenAppId tizenAppId;
93     Try {
94         auto previous = WidgetDAO::getTizenAppidList();
95
96         // register widget
97         tizenAppId = WidgetDAO::registerWidgetGeneratePkgId(regInfo, sec);
98
99         RUNNER_ASSERT_MSG(!tizenAppId.empty(),
100                           "(called from line " << line << ")");
101
102         auto current = WidgetDAO::getTizenAppidList();
103         RUNNER_ASSERT_MSG(previous.size() + 1 == current.size(),
104                           "(called from line " << line << ")");
105
106         RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
107                               tizenAppId),
108                           "(called from line " << line << " tizenAppId: " <<
109                           tizenAppId << ")");
110     }
111     Catch(WidgetDAO::Exception::AlreadyRegistered) {
112         RUNNER_ASSERT_MSG(
113             false,
114             "Unexpected exception (called from line " << line << ")");
115     }
116     return tizenAppId;
117 }
118
119 #define REGISTER_WIDGET(regInfo, sec) _registerWidget((regInfo), \
120                                                       (sec), \
121                                                       __LINE__)
122
123 template<typename Exception, typename Function>
124 bool checkException(Function fun)
125 {
126     Try
127     {
128         fun();
129     }
130     Catch(Exception){
131         return true;
132     }
133     return false;
134 }
135
136 } // namespace
137
138 // Widgets used <2300,2500), 2000, 2001, 2002, 2003
139
140 #define RUNNER_ASSERT_WHAT_EQUALS(in, test)                   \
141     { std::string tmp(in);                                     \
142       RUNNER_ASSERT_MSG(tmp == test, "Equals: [" + tmp + "]"); }
143
144 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(in, test)          \
145     {                                                     \
146         if (in.IsNull()) { RUNNER_ASSERT_MSG(false, "NULL"); } \
147         else { RUNNER_ASSERT_WHAT_EQUALS(DPL::ToUTF8String(*in), test); } \
148     }
149
150 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONALINT(in, test)                   \
151     {                                                                 \
152         if (in.IsNull()) { RUNNER_ASSERT_MSG(false, "NULL"); }             \
153         else { RUNNER_ASSERT_MSG(*in == test, "Equals: [" + *in + "]"); } \
154     }
155
156 #define RUNNER_ASSERT_EXCEPTION(exceptionType, function)             \
157     {                                                                \
158         RUNNER_ASSERT(checkException<exceptionType>([](){function})); \
159     }
160
161 RUNNER_TEST_GROUP_INIT(DAO)
162
163 //2300
164 /*
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
168  */
169 RUNNER_TEST(widget_dao_test_register_widget_empty_strings)
170 {
171     WidgetRegisterInfo regInfo;
172
173     //info
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;
186
187     //loc info
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));
197
198     //userAgentLoc
199
200     //icons
201     ConfigParserData::Icon icon(DPL::FromUTF8String(""));
202     icon.width = 10;
203     icon.height = 10;
204     LocaleSet locs;
205     locs.insert(DPL::FromUTF8String("en"));
206     WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
207     regInfo.localizationData.icons.push_back(locIcon);
208
209     //start file
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);
218
219     //widget pref
220     ConfigParserData::Preference pref(DPL::FromUTF8String(""), false);
221     pref.value = DPL::FromUTF8String("");
222     regInfo.configInfo.preferencesList.insert(pref);
223
224     //widget feature
225     ConfigParserData::Feature feat(DPL::FromUTF8String(""));
226     regInfo.configInfo.featuresList.insert(feat);
227
228     //win modes
229     regInfo.configInfo.windowModes.insert(DPL::FromUTF8String(""));
230
231     //WARP info
232     ConfigParserData::AccessInfo access(DPL::FromUTF8String(""), true);
233     regInfo.configInfo.accessInfoSet.insert(access);
234
235     //certificates
236     WidgetCertificateData cert;
237     cert.owner = WidgetCertificateData::AUTHOR;
238     cert.type = WidgetCertificateData::ROOT;
239     cert.chainId = 1;
240     cert.strMD5Fingerprint = "";
241     cert.strSHA1Fingerprint = "";
242     cert.strCommonName = DPL::FromUTF8String("");
243
244     WacSecurityMock security;
245     security.getCertificateListRef().push_back(cert);
246
247     REGISTER_WIDGET(regInfo, security);
248 }
249
250 /*
251  * Name: widget_dao_test_register_widget_empty_strings
252  * Description: Tests possiblity of registering twice same content (different
253  * tizenId)
254  * Expected: it should be possible
255  */
256 RUNNER_TEST(widget_dao_test_twice_install_same_widget)
257 {
258     WacSecurityMock sec;
259     {
260         WidgetRegisterInfo regInfo;
261         REGISTER_WIDGET(regInfo, sec);
262     }
263     {
264         WidgetRegisterInfo regInfo;
265         REGISTER_WIDGET(regInfo, sec);
266     }
267 }
268
269 /*
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
273  */
274 RUNNER_TEST(widget_dao_test_register_widget_minimum_info)
275 {
276     WacSecurityMock sec;
277     const std::size_t NUMBER_OF_WIDGETS = 5;
278
279     TizenAppId lastTizenAppId;
280
281     for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
282         WidgetRegisterInfo regInfo;
283         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
284
285         lastTizenAppId = tizenAppId;
286
287         WidgetDAO dao(tizenAppId);
288         //TODO check nulls
289     }
290 }
291
292 /*
293  * Name: widget_dao_test_register_widget_info
294  * Description: Tests registeration of many widgets
295  * Expected: all widgets should be registered in database
296  */
297 RUNNER_TEST(widget_dao_test_register_widget_info)
298 {
299     WacSecurityMock sec;
300     const std::size_t NUMBER_OF_WIDGETS = 5;
301
302     for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
303         std::ostringstream str;
304         str << "register_info_test_" << number;
305
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;
321
322         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
323
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");
333     }
334 }
335
336 /*
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
341  */
342 RUNNER_TEST(widget_dao_test_register_widget_extended_info)
343 {
344     WacSecurityMock sec;
345     const std::size_t NUMBER_OF_WIDGETS = 5;
346
347     for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
348         std::ostringstream str;
349         str << "register_ext_info_test_" << number;
350
351         WidgetRegisterInfo regInfo;
352
353         regInfo.configInfo.backgroundPage = L"background.html";
354
355         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
356
357         WidgetDAO dao(tizenAppId);
358
359         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getBackgroundPage(),
360                                            "background.html");
361     }
362 }
363
364 /*
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
368  */
369 RUNNER_TEST(widget_dao_test_register_widget_localized_info)
370 {
371     WacSecurityMock sec;
372     const std::size_t NUMBER_OF_WIDGETS = 5;
373
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;
380         { //EN
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));
390         }
391
392         { //PL
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));
402         }
403
404         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
405
406         WidgetDAO dao(tizenAppId);
407         RUNNER_ASSERT_MSG(dao.getLanguageTags().size() == 2,
408                           "language tags list invalid");
409
410         { //EN
411             WidgetLocalizedInfo locInfo =
412                 dao.getLocalizedInfo(DPL::FromUTF8String("en"));
413
414             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
415                                                str_en.str());
416             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
417                                                str_en.str());
418             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
419                                                str_en.str());
420             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
421                                                str_en.str());
422             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
423                                                str_en.str());
424         }
425
426         { //PL
427             WidgetLocalizedInfo locInfo =
428                 dao.getLocalizedInfo(DPL::FromUTF8String("pl"));
429
430             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
431                                                str_pl.str());
432             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
433                                                str_pl.str());
434             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
435                                                str_pl.str());
436             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
437                                                str_pl.str());
438             RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
439                                                str_pl.str());
440         }
441     }
442 }
443
444 /*
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
448  * for icon
449  */
450 RUNNER_TEST(widget_dao_test_register_widget_icons)
451 {
452     WacSecurityMock sec;
453     WidgetRegisterInfo regInfo;
454
455     ConfigParserData::Icon icon(L"icon1");
456     icon.width = 10;
457     icon.height = 10;
458     LocaleSet locs;
459     locs.insert(DPL::FromUTF8String("en"));
460     WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
461     regInfo.localizationData.icons.push_back(locIcon);
462
463     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
464
465     WidgetDAO dao(tizenAppId);
466     WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
467
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();
473          ++it1, ++it2)
474     {
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);
479     }
480 }
481
482 /*
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
486  */
487 RUNNER_TEST(widget_dao_test_register_widget_start_files)
488 {
489     WacSecurityMock sec;
490
491     WidgetRegisterInfo::LocalizedStartFileList files;
492     WidgetRegisterInfo::StartFilePropertiesForLocalesMap map1;
493     WidgetRegisterInfo::StartFileProperties prop1;
494     prop1.encoding = DPL::FromUTF8String("enc1");
495     prop1.type = DPL::FromUTF8String("type1");
496
497     map1.insert(std::make_pair(DPL::FromUTF8String("en"), prop1));
498     map1.insert(std::make_pair(DPL::FromUTF8String("pl"), prop1));
499
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;
506
507     files.push_back(file1);
508     files.push_back(file1);
509
510     WidgetRegisterInfo regInfo;
511     regInfo.localizationData.startFiles = files;
512
513     REGISTER_WIDGET(regInfo, sec);
514
515     //TODO no getter in WidgetDAO (getter in LocalizedWidgetDAO,
516     // but it will be removed
517 }
518
519 /*
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)
523  */
524 RUNNER_TEST(widget_dao_test_register_widget_features)
525 {
526     WacSecurityMock sec;
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")));
531
532     WidgetRegisterInfo regInfo;
533     FOREACH(it, features)
534     regInfo.configInfo.featuresList.insert(*it);
535
536     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
537
538     WidgetDAO dao(tizenAppId);
539     WidgetFeatureSet out = dao.getFeaturesList();
540     RUNNER_ASSERT_MSG(out.size() == features.size(),
541                       "wrong number of features");
542     //    FOREACH(it, out)
543     //        RUNNER_ASSERT(features.find(*it) != features.end());
544 }
545
546 /*
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
550  */
551 RUNNER_TEST(widget_dao_test_register_widget_win_modes)
552 {
553     WacSecurityMock sec;
554     std::set<DPL::String> modes;
555     modes.insert(DPL::FromUTF8String("full"));
556     modes.insert(DPL::FromUTF8String("window"));
557
558     WidgetRegisterInfo regInfo;
559
560     FOREACH(it, modes)
561     regInfo.configInfo.windowModes.insert(*it);
562
563     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
564
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");
569     FOREACH(it, wins)
570     RUNNER_ASSERT(modes.find(*it) != modes.end());
571 }
572
573 /*
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
577  */
578 RUNNER_TEST(widget_dao_test_register_widget_warp_info)
579 {
580     WacSecurityMock sec;
581     ConfigParserData::AccessInfoSet orig;
582     orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri1"),
583                                              true));
584     orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri2"),
585                                              false));
586     orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri3"),
587                                              true));
588
589     WidgetRegisterInfo regInfo;
590     FOREACH(it, orig)
591     regInfo.configInfo.accessInfoSet.insert(*it);
592
593     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
594
595     WidgetDAO dao(tizenAppId);
596
597     WidgetAccessInfoList out;
598     dao.getWidgetAccessInfo(out);
599     RUNNER_ASSERT_MSG(out.size() == orig.size(),
600                       "wrong number of access info elem");
601     FOREACH(it, out){
602         ConfigParserData::AccessInfo tmp(it->strIRI, it->bSubDomains);
603         RUNNER_ASSERT(orig.find(tmp) != orig.end());
604     }
605 }
606
607 /*
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
612  */
613 RUNNER_TEST(widget_dao_test_register_widget_certificates)
614 {
615     WacSecurityMock sec;
616     WidgetRegisterInfo regInfo;
617
618     WidgetCertificateData cert;
619     cert.owner = WidgetCertificateData::AUTHOR;
620     cert.type = WidgetCertificateData::ROOT;
621     cert.chainId = 1;
622     cert.strMD5Fingerprint = "md5";
623     cert.strSHA1Fingerprint = "sha1";
624     cert.strCommonName = DPL::FromUTF8String("common name");
625
626     WidgetCertificateDataList& certListRef = sec.getCertificateListRef();
627     certListRef.push_back(cert);
628
629     // register widget
630     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
631
632     WidgetDAO dao(tizenAppId);
633
634     // certificates
635     WidgetCertificateDataList recList = dao.getCertificateDataList();
636     RUNNER_ASSERT(recList.size() == certListRef.size());
637
638     auto recListIt = recList.begin();
639     auto certListIt = certListRef.begin();
640     for (; recListIt != recList.end() && certListIt != certListRef.end();
641          ++recListIt, ++certListIt)
642     {
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);
651     }
652
653     // fingerprints
654     RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
655                                          WidgetCertificateData::ENDENTITY).
656                       empty());
657     RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::AUTHOR,
658                                          WidgetCertificateData::ENDENTITY).
659                       empty());
660     RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
661                                          WidgetCertificateData::ROOT).empty());
662
663     FingerPrintList fingerprints = dao.getKeyFingerprints(
664             WidgetCertificateData::AUTHOR,
665             WidgetCertificateData::ROOT);
666
667     RUNNER_ASSERT(fingerprints.size() == certListRef.size() * 2);
668     FOREACH(it, certListRef)
669     {
670         auto md5 = std::find(fingerprints.begin(),
671                              fingerprints.end(),
672                              it->strMD5Fingerprint);
673         RUNNER_ASSERT(md5 != fingerprints.end());
674
675         auto sha = std::find(fingerprints.begin(),
676                              fingerprints.end(),
677                              it->strSHA1Fingerprint);
678         RUNNER_ASSERT(sha != fingerprints.end());
679     }
680
681     // common names
682     RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
683                                            WidgetCertificateData::ENDENTITY).
684                       empty());
685     RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::AUTHOR,
686                                            WidgetCertificateData::ENDENTITY).
687                       empty());
688     RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
689                                            WidgetCertificateData::ROOT).empty());
690
691     FingerPrintList commonNames = dao.getKeyCommonNameList(
692             WidgetCertificateData::AUTHOR,
693             WidgetCertificateData::ROOT);
694
695     RUNNER_ASSERT(commonNames.size() == certListRef.size());
696     FOREACH(it, certListRef)
697     {
698         auto cn = std::find(commonNames.begin(),
699                             commonNames.end(),
700                             DPL::ToUTF8String(it->strCommonName));
701         RUNNER_ASSERT(cn != commonNames.end());
702     }
703 }
704
705 /*
706  * Name: widget_dao_test_register_widget_privileges
707  * Description: Tests registration of widget privileges
708  */
709 RUNNER_TEST(widget_dao_test_register_widget_privileges)
710 {
711
712     WacSecurityMock sec;
713     WidgetRegisterInfo regInfo;
714
715     ConfigParserData::PrivilegeList& privilegeList =
716             regInfo.configInfo.privilegeList;
717     privilegeList.insert(DPL::FromUTF8String("name"));
718     privilegeList.insert(DPL::FromUTF8String("name2"));
719
720     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
721     WidgetDAO dao(tizenAppId);
722
723     WrtDB::PrivilegeList privListFromDB;
724     privListFromDB = dao.getWidgetPrivilege();
725
726     RUNNER_ASSERT(privilegeList.size() == privListFromDB.size());
727
728     auto privListIt = privilegeList.begin();
729     auto privDBIt = privListFromDB.begin();
730     for(; privListIt != privilegeList.end() && privDBIt != privListFromDB.end();
731             ++privListIt, ++privDBIt)
732     {
733         RUNNER_ASSERT(*privDBIt == privListIt->name);
734     }
735 }
736
737 /*
738  * Name: widget_dao_test_register_app_control
739  * Description: Tests app control
740  */
741 RUNNER_TEST(widget_dao_test_register_app_control)
742 {
743     WacSecurityMock sec;
744     WidgetRegisterInfo regInfo;
745
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"));
752
753     ConfigParserData::AppControlInfoList& appControlListRef
754             = regInfo.configInfo.appControlList;
755     appControlListRef.push_back(appControl);
756
757     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
758
759     WidgetDAO dao(tizenAppId);
760
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();
766
767     for (;appDBIt != appControlInfoListDB.end()
768             && appRefIt != appControlListRef.end();
769             ++appDBIt, ++appRefIt)
770     {
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();
778                 ++it)
779         {
780             RUNNER_ASSERT((*it) == appDBIt->mime);
781         }
782         for(auto it = appRefIt->m_uriList.begin();
783                 it != appRefIt->m_uriList.end();
784                 ++it)
785         {
786             RUNNER_ASSERT((*it) == appDBIt->uri);
787         }
788     }
789 }
790
791 /*
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
795  */
796 RUNNER_TEST(widget_dao_test_is_widget_installed)
797 {
798     RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(L"tizenid201"));
799
800     WacSecurityMock sec;
801     WidgetRegisterInfo regInfo;
802
803     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
804
805     RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(tizenAppId));
806 }
807
808 /*
809  * Name: widget_dao_test_unregister_widget
810  * Description: Tests unregistering widgets
811  * Expected: widget register informations should be successfully removed
812  */
813 RUNNER_TEST(widget_dao_test_unregister_widget)
814 {
815     WacSecurityMock sec;
816     TizenAppIdList ids = WidgetDAO::getTizenAppidList();
817
818     WidgetRegisterInfo regInfo;
819
820     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
821
822     WidgetDAO::unregisterWidget(tizenAppId);
823
824     RUNNER_ASSERT_MSG(ids.size() == WidgetDAO::getTizenAppidList().size(),
825                       "Widget unregister failed");
826 }
827
828 /*
829  * Name: widget_dao_test_register_or_update_widget
830  * Description: Tests reregistering widgets
831  * Expected: widget should be successfully replaced
832  */
833 RUNNER_TEST(widget_dao_test_register_or_update_widget)
834 {
835     WacSecurityMock sec;
836
837     WidgetRegisterInfo regInfo;
838     regInfo.configInfo.version = L"1.0";
839     regInfo.configInfo.authorName = L"AAA";
840
841     WidgetRegisterInfo regInfo2;
842     regInfo2.configInfo.version = L"1.1";
843     regInfo2.configInfo.authorName = L"BBB";
844
845     WrtDB::TizenAppId tizenAppId(L"abcdefghij");
846
847     //first installation
848     WidgetDAO::registerWidget(tizenAppId, regInfo, sec);
849     RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
850                           tizenAppId), "Widget is not registered");
851
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);
859     RUNNER_ASSERT_MSG(
860         *dao.getVersion() == L"1.1", "Data widget was not updated");
861     RUNNER_ASSERT_MSG(
862         *dao.getAuthorName() == L"BBB", "Data widget was not updated");
863
864
865     WidgetDAO::unregisterWidget(tizenAppId);
866 }
867
868 /*
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
872  */
873 RUNNER_TEST(widget_dao_test_get_widget_tizenAppId_list)
874 {
875     TizenAppIdList tizenAppIds = WidgetDAO::getTizenAppidList();
876     RUNNER_ASSERT(tizenAppIds.size() >= 3);
877 }
878
879 /*
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
884  */
885 RUNNER_TEST(widget_dao_test_get_widget_list)
886 {
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();
891 }
892
893 /*
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
897  */
898 RUNNER_TEST(widget_dao_test_get_widget_attributes)
899 {
900     {
901         TizenAppId tizenAppId = L"tizenid201";
902         WidgetDAO dao(tizenAppId);
903
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(),
908                                            "a_email_2000");
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");
913     }
914 }
915
916 /*
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
920  * database
921  */
922 RUNNER_TEST(widget_dao_test_localization)
923 {
924     WacSecurityMock sec;
925
926     // icon
927     WidgetRegisterInfo regInfo;
928     ConfigParserData::Icon icon(L"icon1");
929     icon.width = 10;
930     icon.height = 10;
931     LocaleSet locs;
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);
936
937     //start file
938     WidgetRegisterInfo::StartFileProperties prop_en;
939     prop_en.encoding = DPL::FromUTF8String("encoding_en");
940     prop_en.type = DPL::FromUTF8String("type_en");
941
942     WidgetRegisterInfo::StartFileProperties prop_pl;
943     prop_pl.encoding = DPL::FromUTF8String("encoding_pl");
944     prop_pl.type = DPL::FromUTF8String("type_pl");
945
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);
953
954     // register widget
955     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
956
957     WidgetDAO dao(tizenAppId);
958
959     // check localized icons
960     WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
961     RUNNER_ASSERT(locList.size() == locs.size());
962
963     // non-localized icon
964     WidgetDAO::WidgetIconList list = dao.getIconList();
965     int iconId = list.front().iconId;
966
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,
971          ++iconIt)
972     {
973         RUNNER_ASSERT(iconIt->appId == dao.getHandle());
974         RUNNER_ASSERT(iconIt->iconId == iconId);
975         RUNNER_ASSERT(iconIt->widgetLocale == *locsIt);
976     }
977
978     // localized start file list
979     WidgetDAO::LocalizedStartFileList fList = dao.getLocalizedStartFileList();
980     RUNNER_ASSERT(fList.size() == file.propertiesForLocales.size());
981
982     int startFileId = dao.getStartFileList().front().startFileId;
983
984     FOREACH(it, fList)
985     {
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);
992     }
993 }
994
995 /*
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
999  * database
1000  */
1001 RUNNER_TEST(widget_dao_test_register_scp)
1002 {
1003     WacSecurityMock sec;
1004     WidgetRegisterInfo regInfo;
1005     DPL::OptionalString policy = DPL::FromUTF8String("Some awesome csp policy");
1006     regInfo.configInfo.cspPolicy = policy;
1007     {
1008         // register widget
1009         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1010         WidgetDAO dao(tizenAppId);
1011
1012         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(
1013             dao.getCspPolicy(), DPL::ToUTF8String(*policy));
1014     }
1015 }
1016
1017 /*
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
1021  * database
1022  */
1023 RUNNER_TEST(widget_dao_test_register_csp_empty)
1024 {
1025     WacSecurityMock sec;
1026     WidgetRegisterInfo regInfo;
1027     {
1028         // register widget
1029         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1030         WidgetDAO dao(tizenAppId);
1031
1032         RUNNER_ASSERT_MSG(dao.getCspPolicy().IsNull(), "Policy is not null");
1033     }
1034 }
1035
1036 /*
1037  * Name: widget_dao_test_widget_privileges_basics
1038  * Description: Tests basic operators of privileges
1039  * Expected: operators should behave properly
1040  */
1041 RUNNER_TEST(widget_dao_test_widget_privileges_basics)
1042 {
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"));
1047
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");
1052
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);
1059 }
1060
1061 /*
1062  * Name: widget_dao_test_widget_preferences_basics
1063  * Description: Tests basic operators of preferences
1064  * Expected: operators should behave properly
1065  */
1066 RUNNER_TEST(widget_dao_test_widget_preferences_basics)
1067 {
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"));
1072
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");
1077
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);
1084 }
1085
1086 /*
1087  * Name: widget_dao_test_widget_features_basics
1088  * Description: Tests basic operators of features
1089  * Expected: operators should behave properly
1090  */
1091 RUNNER_TEST(widget_dao_test_widget_features_basics)
1092 {
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"));
1097
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");
1102
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);
1109 }
1110
1111 /*
1112  * Name: widget_dao_test_widget_icons_basics
1113  * Description: Tests basic operators for icons
1114  * Expected: operators should behave properly
1115  */
1116 RUNNER_TEST(widget_dao_test_widget_icons_basics)
1117 {
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"));
1122
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");
1127
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);
1134 }
1135
1136 /*
1137  * Name: widget_dao_test_widget_settings_basics
1138  * Description: Tests basic operators for settings of widget
1139  * Expected: operators should behave properly
1140  */
1141 RUNNER_TEST(widget_dao_test_widget_settings_basics)
1142 {
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"));
1147
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");
1152
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);
1159 }
1160
1161 /*
1162  * Name: widget_dao_test_widget_access_basics
1163  * Description: Tests basic operators for access of widget
1164  * Expected: operators should behave properly
1165  */
1166 RUNNER_TEST(widget_dao_test_widget_access_basics)
1167 {
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);
1172
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);
1180 }
1181
1182 /*
1183  * Name: widget_dao_test_widget_metadata_basics
1184  * Description: Tests basic operators for metadata
1185  * Expected: operators should behave properly
1186  */
1187 RUNNER_TEST(widget_dao_test_widget_metadata_basics)
1188 {
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"));
1193
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");
1199 }
1200
1201 /*
1202  * Name: widget_dao_test_widget_appcontrolinfo_basics
1203  * Description: Tests basic operators for app control info
1204  * Expected: operators should behave properly
1205  */
1206 RUNNER_TEST(widget_dao_test_widget_appcontrolinfo_basics)
1207 {
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"));
1213
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"));
1219
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"));
1225
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"));
1231
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"));
1237
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"));
1243
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"));
1249
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");
1257 }
1258
1259 /*
1260  * Name: widget_dao_test_widget_metadata_basics
1261  * Description: Tests basic operators for livebox info
1262  * Expected: operators should behave properly
1263  */
1264 RUNNER_TEST(widget_dao_test_widget_livebox_basics)
1265 {
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");
1272
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");
1279
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");
1286
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");
1293
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");
1300
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");
1307
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");
1314
1315     const DPL::String s1 = DPL::FromUTF8String("1");
1316     const DPL::String s2 =  DPL::FromUTF8String("2");
1317
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));
1325
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));
1334
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));
1342
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");
1352 }
1353
1354 /*
1355  * Name: widget_dao_test_get_widget_by_guid
1356  * Description: Tests creating WidgetDAO using GUID
1357  * Expected: Correct WidgetDAO should be created
1358  */
1359 RUNNER_TEST(widget_dao_test_get_widget_by_guid)
1360 {
1361     WidgetDAO dao(DPL::OptionalString(L"w_id_2000"));
1362     RUNNER_ASSERT(dao.getTizenAppId() == L"tizenid201");
1363 }
1364
1365 /*
1366  * Name: widget_dao_test_set_tizen_app_id
1367  * Description: Tests changing TizenAppId
1368  * Expected: Change should be possible
1369  */
1370 RUNNER_TEST(widget_dao_test_set_tizen_app_id)
1371 {
1372     WacSecurityMock sec;
1373     WidgetRegisterInfo regInfo;
1374     TizenAppId originaltizenAppId = REGISTER_WIDGET(regInfo, sec);
1375     TizenAppId changedTizenAppId = L"changedTizenAppId";
1376
1377     TizenAppIdList ids = WidgetDAO::getTizenAppidList();
1378     RUNNER_ASSERT(std::count(ids.begin(),ids.end(),originaltizenAppId) == 1);
1379
1380     //Change tizenAppId
1381     WidgetDAO dao(originaltizenAppId);
1382     dao.setTizenAppId(changedTizenAppId);
1383
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);
1387
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);
1392         });
1393     RUNNER_ASSERT(exceptionCaught);
1394
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);
1399
1400 }
1401
1402 /*
1403  * Name: widget_dao_test_update_feature_reject_status
1404  * Description: Tests updating feature reject status
1405  * Expected: Reject status should be properly updated
1406  */
1407 RUNNER_TEST(widget_dao_test_update_feature_reject_status)
1408 {
1409     WidgetDAO dao(L"tizenid202");
1410     DbWidgetFeatureSet featureSet = dao.getFeaturesList();
1411
1412     RUNNER_ASSERT(featureSet.size() == 1);
1413     DbWidgetFeature feature = *featureSet.begin();
1414     RUNNER_ASSERT(!feature.rejected);
1415
1416     feature.rejected = true;
1417     dao.updateFeatureRejectStatus(feature);
1418
1419     featureSet = dao.getFeaturesList();
1420     RUNNER_ASSERT(featureSet.size() == 1);
1421     DbWidgetFeature feature2 = *featureSet.begin();
1422     RUNNER_ASSERT(feature.rejected);
1423
1424     feature2.rejected = false;
1425     dao.updateFeatureRejectStatus(feature2);
1426 }
1427
1428 /*
1429  * Name: widget_dao_test_register_widget_allow_navigation
1430  * Description: Tests AllowNavigationInfo registration
1431  * Expected: AllowNavigationInfo registration should be possible
1432  */
1433 RUNNER_TEST(widget_dao_test_register_widget_allow_navigation)
1434 {
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);
1441
1442     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1443
1444     WidgetDAOReadOnly dao(tizenAppId);
1445     WidgetAllowNavigationInfoList navigationList;
1446     dao.getWidgetAllowNavigationInfo(navigationList);
1447
1448     RUNNER_ASSERT(navigationList.size() == 2);
1449     RUNNER_ASSERT(
1450             std::count_if(navigationList.begin(), navigationList.end(), [] (const WidgetAllowNavigationInfo& navInfo)
1451                     { return navInfo.host == L"host1" && navInfo.scheme == L"scheme1"; }) == 1);
1452     RUNNER_ASSERT(
1453             std::count_if(navigationList.begin(), navigationList.end(), [] (const WidgetAllowNavigationInfo& navInfo)
1454                     { return navInfo.host == L"host2" && navInfo.scheme == L"scheme2"; }) == 1);
1455
1456 }
1457
1458 /*
1459  * Name: widget_dao_test_register_external_locations
1460  * Description: Tests ExternalLocation registration
1461  * Expected: ExternalLocation registration should be possible
1462  */
1463 RUNNER_TEST(widget_dao_test_register_external_locations)
1464 {
1465     WacSecurityMock sec;
1466     WidgetRegisterInfo regInfo;
1467     regInfo.externalLocations.push_back("location1");
1468     regInfo.externalLocations.push_back("location2");
1469
1470     TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
1471
1472     WidgetDAOReadOnly dao(tizenAppId);
1473     ExternalLocationList locationList = dao.getWidgetExternalLocations();
1474
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);
1478 }
1479
1480  /*
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.
1484   */
1485 RUNNER_TEST(widget_dao_test_get_tz_app_id)
1486 {
1487     //No such widget
1488     RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenAppId(1234); );
1489
1490     TizenAppId appId = WidgetDAOReadOnly::getTizenAppId(2001);
1491     RUNNER_ASSERT(L"tizenid202" == appId);
1492
1493     RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenAppId(L"no_such_widget"); );
1494
1495     appId = WidgetDAOReadOnly::getTizenAppId(L"pkgid202");
1496     RUNNER_ASSERT(L"tizenid202" == appId);
1497 }
1498
1499 /*
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.
1503  */
1504 RUNNER_TEST(widget_dao_test_get_tz_pkg_id)
1505 {
1506     //No such widget
1507     RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenPkgId(1234); );
1508
1509
1510     TizenPkgId pkgId = WidgetDAOReadOnly::getTizenPkgId(2001);
1511     RUNNER_ASSERT(L"pkgid202" == pkgId);
1512
1513     RUNNER_ASSERT_EXCEPTION(WidgetDAOReadOnly::Exception::WidgetNotExist, WidgetDAOReadOnly::getTizenPkgId(L"no_such_widget"););
1514
1515     pkgId = WidgetDAOReadOnly::getTizenPkgId(L"tizenid202");
1516     RUNNER_ASSERT(L"pkgid202" == pkgId);
1517 }
1518
1519 /*
1520  * Name: widget_dao_test_get_property_key
1521  * Description: Tests getPropertyKeyList function
1522  * Expected: Property keys are fetched correctly.
1523  */
1524 RUNNER_TEST(widget_dao_test_get_property_key)
1525 {
1526     WidgetDAOReadOnly dao(L"tizenid201");
1527     PropertyDAOReadOnly::WidgetPropertyKeyList propertyKeys = dao.getPropertyKeyList();
1528
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);
1532 }
1533
1534 /*
1535  * Name: widget_dao_test_get_property_value
1536  * Description: Tests getPropertyValue function
1537  * Expected: Property key values are fetched correctly.
1538  */
1539 RUNNER_TEST(widget_dao_test_get_property_value)
1540 {
1541     WidgetDAOReadOnly dao(L"tizenid201");
1542
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());
1547 }
1548
1549 /*
1550  * Name: widget_dao_test_get_property_read_flag
1551  * Description: Tests checkPropertyReadFlag function
1552  * Expected: Property read flags values are fetched correctly.
1553  */
1554 RUNNER_TEST(widget_dao_test_get_property_read_flag)
1555 {
1556     WidgetDAOReadOnly dao(L"tizenid201");
1557
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());
1562 }
1563
1564 /*
1565  * Name: widget_dao_test_get_pkg_id_list
1566  * Description: Tests getTizenPkgIdList function
1567  * Expected: All pkg ids are returned.
1568  */
1569 RUNNER_TEST(widget_dao_test_get_pkg_id_list)
1570 {
1571     TizenPkgIdList pkgIds = WidgetDAOReadOnly::getTizenPkgIdList();
1572
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);
1577 }
1578
1579 /*
1580  * Name: widget_dao_test_get_back_supported
1581  * Description: Tests getBackSupported function
1582  * Expected: Back supported information is fetched properly.
1583  */
1584 RUNNER_TEST(widget_dao_test_get_back_supported)
1585 {
1586     WidgetDAOReadOnly dao1(L"tizenid201");
1587     RUNNER_ASSERT(dao1.getBackSupported());
1588
1589     WidgetDAOReadOnly dao2(L"tizenid202");
1590     RUNNER_ASSERT(!dao2.getBackSupported());
1591 }
1592
1593 /*
1594  * Name: widget_dao_test_get_csp_policy_report
1595  * Description: Tests getCspPolicyReportOnly function
1596  * Expected: CSP policy information is fetched properly.
1597  */
1598 RUNNER_TEST(widget_dao_test_get_csp_policy_report)
1599 {
1600     WidgetDAOReadOnly dao1(L"tizenid201");
1601     RUNNER_ASSERT(DPL::OptionalString(L"policy_report201") == dao1.getCspPolicyReportOnly());
1602
1603     WidgetDAOReadOnly dao2(L"tizenid202");
1604     RUNNER_ASSERT(DPL::OptionalString(L"policy_report202") == dao2.getCspPolicyReportOnly());
1605 }
1606
1607 /*
1608  * Name: widget_dao_test_get_install_time
1609  * Description: Tests getInstallTime function
1610  * Expected: Installation time is fetched properly.
1611  */
1612 RUNNER_TEST(widget_dao_test_get_install_time)
1613 {
1614     WidgetDAOReadOnly dao1(L"tizenid201");
1615     RUNNER_ASSERT(1256 == dao1.getInstallTime());
1616
1617     WidgetDAOReadOnly dao2(L"tizenid202");
1618     RUNNER_ASSERT(5687 == dao2.getInstallTime());
1619 }
1620
1621 /*
1622  * Name: widget_dao_test_get_icon_language_tags
1623  * Description: Tests getIconLanguageTags function
1624  * Expected: Information about icon localization is fetched properly.
1625  */
1626 RUNNER_TEST(widget_dao_test_get_icon_language_tags)
1627 {
1628     WidgetDAOReadOnly dao1(L"tizenid201");
1629     LanguageTags languageTags = dao1.getIconLanguageTags();
1630
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);
1634 }
1635
1636 #undef RUNNER_ASSERT_WHAT_EQUALS