tizen 2.4 release
[framework/web/wrt-commons.git] / tests / dao / TestCases_WidgetDAO.cpp
index 806ee1e..61bcf6b 100644 (file)
@@ -31,6 +31,7 @@
 #include <dpl/wrt-dao-rw/widget_dao.h>
 #include <dpl/wrt-dao-ro/wrt_db_types.h>
 #include <dpl/string.h>
+#include <dpl/platform.h>
 #include <wrt_plugin_export.h>
 #include <LanguageTagsProvider.h>
 
@@ -91,7 +92,7 @@ TizenAppId _registerWidget(const WidgetRegisterInfo& regInfo,
 {
     TizenAppId tizenAppId;
     Try {
-        auto previous = WidgetDAO::getTizenAppidList();
+        auto previous = WidgetDAO::getTizenAppIdList();
 
         // register widget
         tizenAppId = WidgetDAO::registerWidgetGeneratePkgId(regInfo, sec);
@@ -99,7 +100,7 @@ TizenAppId _registerWidget(const WidgetRegisterInfo& regInfo,
         RUNNER_ASSERT_MSG(!tizenAppId.empty(),
                           "(called from line " << line << ")");
 
-        auto current = WidgetDAO::getTizenAppidList();
+        auto current = WidgetDAO::getTizenAppIdList();
         RUNNER_ASSERT_MSG(previous.size() + 1 == current.size(),
                           "(called from line " << line << ")");
 
@@ -143,13 +144,13 @@ bool checkException(Function fun)
 
 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(in, test)          \
     {                                                     \
-        if (in.IsNull()) { RUNNER_ASSERT_MSG(false, "NULL"); } \
+        if (!in) { RUNNER_ASSERT_MSG(false, "NULL"); } \
         else { RUNNER_ASSERT_WHAT_EQUALS(DPL::ToUTF8String(*in), test); } \
     }
 
 #define RUNNER_ASSERT_WHAT_EQUALS_OPTIONALINT(in, test)                   \
     {                                                                 \
-        if (in.IsNull()) { RUNNER_ASSERT_MSG(false, "NULL"); }             \
+        if (!in) { RUNNER_ASSERT_MSG(false, "NULL"); }             \
         else { RUNNER_ASSERT_MSG(*in == test, "Equals: [" + *in + "]"); } \
     }
 
@@ -327,8 +328,6 @@ RUNNER_TEST(widget_dao_test_register_widget_info)
         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorName(), str.str());
         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorEmail(), str.str());
         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorHref(), str.str());
-        RUNNER_ASSERT_WHAT_EQUALS(dao.getBaseFolder(), str.str() + "/");
-        RUNNER_ASSERT(dao.getWebkitPluginsRequired() == false);
         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getMinimumWacVersion(), "1.0");
     }
 }
@@ -744,8 +743,6 @@ RUNNER_TEST(widget_dao_test_register_app_control)
     WidgetRegisterInfo regInfo;
 
     ConfigParserData::AppControlInfo appControl(DPL::FromUTF8String("operation"));
-    appControl.m_disposition
-            = ConfigParserData::AppControlInfo::Disposition::WINDOW;
     appControl.m_mimeList.insert(DPL::FromUTF8String("mime"));
     appControl.m_src = DPL::FromUTF8String("src");
     appControl.m_uriList.insert(DPL::FromUTF8String("uri"));
@@ -768,9 +765,6 @@ RUNNER_TEST(widget_dao_test_register_app_control)
             && appRefIt != appControlListRef.end();
             ++appDBIt, ++appRefIt)
     {
-        RUNNER_ASSERT((WidgetAppControl::Disposition)
-                appRefIt->m_disposition == appDBIt->disposition);
-        RUNNER_ASSERT(appRefIt->m_index == appDBIt->index);
         RUNNER_ASSERT(appRefIt->m_operation == appDBIt->operation);
         RUNNER_ASSERT(appRefIt->m_src == appDBIt->src);
         for(auto it = appRefIt->m_mimeList.begin();
@@ -813,7 +807,7 @@ RUNNER_TEST(widget_dao_test_is_widget_installed)
 RUNNER_TEST(widget_dao_test_unregister_widget)
 {
     WacSecurityMock sec;
-    TizenAppIdList ids = WidgetDAO::getTizenAppidList();
+    TizenAppIdList ids = WidgetDAO::getTizenAppIdList();
 
     WidgetRegisterInfo regInfo;
 
@@ -821,7 +815,7 @@ RUNNER_TEST(widget_dao_test_unregister_widget)
 
     WidgetDAO::unregisterWidget(tizenAppId);
 
-    RUNNER_ASSERT_MSG(ids.size() == WidgetDAO::getTizenAppidList().size(),
+    RUNNER_ASSERT_MSG(ids.size() == WidgetDAO::getTizenAppIdList().size(),
                       "Widget unregister failed");
 }
 
@@ -867,18 +861,18 @@ RUNNER_TEST(widget_dao_test_register_or_update_widget)
 
 /*
  * Name: widget_dao_test_get_widget_tizenAppId_list
- * Description: Tests getTizenAppidList API for backendlib
+ * Description: Tests getTizenAppIdList API for backendlib
  * Expected: For all position in database should be returned one item in list
  */
 RUNNER_TEST(widget_dao_test_get_widget_tizenAppId_list)
 {
-    TizenAppIdList tizenAppIds = WidgetDAO::getTizenAppidList();
+    TizenAppIdList tizenAppIds = WidgetDAO::getTizenAppIdList();
     RUNNER_ASSERT(tizenAppIds.size() >= 3);
 }
 
 /*
  * Name: widget_dao_test_get_widget_list
- * Description: Tests getTizenAppidList API for backendlib
+ * Description: Tests getTizenAppIdList API for backendlib
  * Expected: For all position in database should be returned one item in list
  * Those item should contain valid tizenAppId
  */
@@ -907,8 +901,6 @@ RUNNER_TEST(widget_dao_test_get_widget_attributes)
         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorEmail(),
                                            "a_email_2000");
         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorHref(), "a_href_2000");
-        RUNNER_ASSERT_WHAT_EQUALS(dao.getBaseFolder(), "basef_2000/");
-        RUNNER_ASSERT(dao.getWebkitPluginsRequired() == true);
         RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getMinimumWacVersion(), "1.0");
     }
 }
@@ -1029,7 +1021,7 @@ RUNNER_TEST(widget_dao_test_register_csp_empty)
         TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
         WidgetDAO dao(tizenAppId);
 
-        RUNNER_ASSERT_MSG(dao.getCspPolicy().IsNull(), "Policy is not null");
+        RUNNER_ASSERT_MSG(!dao.getCspPolicy(), "Policy is not null");
     }
 }
 
@@ -1206,43 +1198,36 @@ RUNNER_TEST(widget_dao_test_widget_metadata_basics)
 RUNNER_TEST(widget_dao_test_widget_appcontrolinfo_basics)
 {
     ConfigParserData::AppControlInfo a(DPL::FromUTF8String("operation"));
-    a.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
     a.m_mimeList.insert(DPL::FromUTF8String("mime"));
     a.m_src = DPL::FromUTF8String("src");
     a.m_uriList.insert(DPL::FromUTF8String("uri"));
 
     ConfigParserData::AppControlInfo a0(DPL::FromUTF8String("operation1"));
-    a0.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
     a0.m_mimeList.insert(DPL::FromUTF8String("mime"));
     a0.m_src = DPL::FromUTF8String("src");
     a0.m_uriList.insert(DPL::FromUTF8String("uri"));
 
     ConfigParserData::AppControlInfo a1(DPL::FromUTF8String("operation"));
-    a1.m_disposition = ConfigParserData::AppControlInfo::Disposition::UNDEFINE;
     a1.m_mimeList.insert(DPL::FromUTF8String("mime"));
     a1.m_src = DPL::FromUTF8String("src");
     a1.m_uriList.insert(DPL::FromUTF8String("uri"));
 
     ConfigParserData::AppControlInfo a2(DPL::FromUTF8String("operation"));
-    a2.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
     a2.m_mimeList.insert(DPL::FromUTF8String("mime1"));
     a2.m_src = DPL::FromUTF8String("src");
     a2.m_uriList.insert(DPL::FromUTF8String("uri"));
 
     ConfigParserData::AppControlInfo a3(DPL::FromUTF8String("operation"));
-    a3.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
     a3.m_mimeList.insert(DPL::FromUTF8String("mime"));
     a3.m_src = DPL::FromUTF8String("src1");
     a3.m_uriList.insert(DPL::FromUTF8String("uri"));
 
     ConfigParserData::AppControlInfo a4(DPL::FromUTF8String("operation"));
-    a4.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
     a4.m_mimeList.insert(DPL::FromUTF8String("mime"));
     a4.m_src = DPL::FromUTF8String("src");
     a4.m_uriList.insert(DPL::FromUTF8String("uri1"));
 
     ConfigParserData::AppControlInfo a5(DPL::FromUTF8String("operation"));
-    a5.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
     a5.m_mimeList.insert(DPL::FromUTF8String("mime"));
     a5.m_src = DPL::FromUTF8String("src");
     a5.m_uriList.insert(DPL::FromUTF8String("uri"));
@@ -1256,6 +1241,7 @@ RUNNER_TEST(widget_dao_test_widget_appcontrolinfo_basics)
     RUNNER_ASSERT_MSG(a == a, "app control info equal");
 }
 
+#if USE(WEB_PROVIDER)
 /*
  * Name: widget_dao_test_widget_metadata_basics
  * Description: Tests basic operators for livebox info
@@ -1350,7 +1336,7 @@ RUNNER_TEST(widget_dao_test_widget_livebox_basics)
     RUNNER_ASSERT_MSG(a10 != a11, "livebox info not equal");
     RUNNER_ASSERT_MSG(a10 == a12, "livebox info equal");
 }
-
+#endif
 /*
  * Name: widget_dao_test_get_widget_by_guid
  * Description: Tests creating WidgetDAO using GUID
@@ -1374,14 +1360,14 @@ RUNNER_TEST(widget_dao_test_set_tizen_app_id)
     TizenAppId originaltizenAppId = REGISTER_WIDGET(regInfo, sec);
     TizenAppId changedTizenAppId = L"changedTizenAppId";
 
-    TizenAppIdList ids = WidgetDAO::getTizenAppidList();
+    TizenAppIdList ids = WidgetDAO::getTizenAppIdList();
     RUNNER_ASSERT(std::count(ids.begin(),ids.end(),originaltizenAppId) == 1);
 
     //Change tizenAppId
     WidgetDAO dao(originaltizenAppId);
     dao.setTizenAppId(changedTizenAppId);
 
-    ids = WidgetDAO::getTizenAppidList();
+    ids = WidgetDAO::getTizenAppIdList();
     RUNNER_ASSERT(std::count(ids.begin(), ids.end(), originaltizenAppId) == 0);
     RUNNER_ASSERT(std::count(ids.begin(), ids.end(), changedTizenAppId) == 1);
 
@@ -1393,7 +1379,7 @@ RUNNER_TEST(widget_dao_test_set_tizen_app_id)
     RUNNER_ASSERT(exceptionCaught);
 
     WidgetDAO::unregisterWidget(changedTizenAppId);
-    ids = WidgetDAO::getTizenAppidList();
+    ids = WidgetDAO::getTizenAppIdList();
     RUNNER_ASSERT(std::count(ids.begin(),ids.end(),originaltizenAppId) == 0);
     RUNNER_ASSERT(std::count(ids.begin(),ids.end(),changedTizenAppId) == 0);
 
@@ -1477,6 +1463,41 @@ RUNNER_TEST(widget_dao_test_register_external_locations)
     RUNNER_ASSERT(std::count(locationList.begin(), locationList.end(), "location2") == 1);
 }
 
+#if USE(WEB_PROVIDER)
+/*
+ * Name: widget_dao_test_register_widget_liveboxID
+ * Description: Tests registeration of liveboxID
+ * Expected: values received by dao should match those which were registered
+ * for icon
+ */
+RUNNER_TEST(widget_dao_test_register_widget_liveboxID)
+{
+    WacSecurityMock sec;
+    WidgetRegisterInfo regInfo;
+
+    ConfigParserData::LiveboxInfo liveboxInfo1;
+    liveboxInfo1.m_liveboxId = DPL::FromUTF8String("pkgID.dynamicBoxID");
+    ConfigParserData::LiveboxInfo liveboxInfo2;
+    liveboxInfo2.m_liveboxId = DPL::FromUTF8String("pkgID.dynamicBoxID");
+    ConfigParserData::LiveboxInfo liveboxInfo3;
+    liveboxInfo3.m_liveboxId = DPL::FromUTF8String("pkgID.dynamicBoxID");
+
+    regInfo.configInfo.m_livebox.push_back(liveboxInfo1);
+    regInfo.configInfo.m_livebox.push_back(liveboxInfo2);
+    regInfo.configInfo.m_livebox.push_back(liveboxInfo3);
+
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    WidgetDAOReadOnly dao(tizenAppId);
+    WrtDB::WidgetDAOReadOnly::LiveBoxIdList outLiveBoxIdList;
+    dao.getLiveBoxInfoList(outLiveBoxIdList);
+
+    RUNNER_ASSERT_MSG(outLiveBoxIdList.size() == 3, "list size is OK");
+    FOREACH(it, outLiveBoxIdList){
+        RUNNER_ASSERT_MSG(DPL::ToUTF8String(**it) == "pkgID.dynamicBoxID", "liveBox Name is equal");
+    }
+}
+#endif
  /*
   * Name: widget_dao_test_get_tz_app_id
   * Description: Tests getTizenAppId functions
@@ -1540,10 +1561,12 @@ RUNNER_TEST(widget_dao_test_get_property_value)
 {
     WidgetDAOReadOnly dao(L"tizenid201");
 
-    RUNNER_ASSERT(dao.getPropertyValue(L"key1_for_2000") == L"value_for_key1_2000");
-    RUNNER_ASSERT(dao.getPropertyValue(L"key2_for_2000") == L"value_for_key2_2000");
-    RUNNER_ASSERT(dao.getPropertyValue(L"not_existing").IsNull());
-    RUNNER_ASSERT(dao.getPropertyValue(L"").IsNull());
+    RUNNER_ASSERT(dao.getPropertyValue(L"key1_for_2000") ==
+        PropertyDAOReadOnly::WidgetPropertyValue(L"value_for_key1_2000"));
+    RUNNER_ASSERT(dao.getPropertyValue(L"key2_for_2000") ==
+        PropertyDAOReadOnly::WidgetPropertyValue(L"value_for_key2_2000"));
+    RUNNER_ASSERT(!dao.getPropertyValue(L"not_existing"));
+    RUNNER_ASSERT(!dao.getPropertyValue(L""));
 }
 
 /*
@@ -1557,8 +1580,8 @@ RUNNER_TEST(widget_dao_test_get_property_read_flag)
 
     RUNNER_ASSERT(dao.checkPropertyReadFlag(L"key1_for_2000") == 0);
     RUNNER_ASSERT(dao.checkPropertyReadFlag(L"key2_for_2000") == 0);
-    RUNNER_ASSERT(dao.checkPropertyReadFlag(L"not_existing").IsNull());
-    RUNNER_ASSERT(dao.checkPropertyReadFlag(L"").IsNull());
+    RUNNER_ASSERT(!dao.checkPropertyReadFlag(L"not_existing"));
+    RUNNER_ASSERT(!dao.checkPropertyReadFlag(L""));
 }
 
 /*