[CTS Week24] W3C P&C wiget installation
authorKamil Nowac <k.nowac@partner.samsung.com>
Wed, 12 Jun 2013 14:46:15 +0000 (16:46 +0200)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Thu, 13 Jun 2013 10:25:14 +0000 (10:25 +0000)
[Issue#] LINUXWRT-437
[Problem] Unhandled exception during instalation
of bg.wgt and bh.wgt
[Cause] N/A
[Solution] Checking existence of config.xml
[Verification]
1.Build wrt-extra and wrt-installer with --define "WITH_TESTS ON"
2.Install widgets bg.wgt and bh.wgt (/opt/share/widget/tests/w3c_widgets/)
Installation should fail but without unhandled exceptions.

Change-Id: I8ccf79e30f89664e2b66ad96efb715721c62aecc

src/jobs/widget_install/job_widget_install.cpp

index c10e6e8..f837c27 100644 (file)
@@ -38,6 +38,7 @@
 #include <dpl/sstream.h>
 #include <dpl/file_input.h>
 #include <dpl/utils/wrt_utility.h>
+#include <dpl/utils/path.h>
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/wrt-dao-ro/global_config.h>
@@ -627,7 +628,6 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
     // Parse config
     ParserRunner parser;
     ConfigParserData configInfo;
-
     Try
     {
         if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
@@ -659,14 +659,18 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
                                  configInfo,
                                  DPL::FromUTF32String(L"widget"))));
         } else {
-            std::string configFile;
+            DPL::Utils::Path configFile;
             if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
-                configFile = tempPath + "/" + WITH_OSP_XML;
+                configFile = DPL::Utils::Path(tempPath);
+                configFile /= WITH_OSP_XML;
             } else {
-                configFile = tempPath + "/" + CONFIG_XML;
+                configFile = DPL::Utils::Path(tempPath);
+                configFile /= CONFIG_XML;
+                if(!configFile.Exists()){
+                    Throw(Exceptions::WidgetConfigFileNotFound);
+                }
             }
-
-            parser.Parse(configFile,
+            parser.Parse(configFile.Fullpath(),
                     ElementParserPtr(
                         new RootParser<WidgetParser>(configInfo,
                             DPL::
@@ -684,6 +688,10 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
         LogError("Failed to find installed widget - give proper tizenId");
         return ConfigParserData();
     }
+    Catch(Exceptions::WidgetConfigFileNotFound){
+        LogError("Failed to find config.xml");
+        return ConfigParserData();
+    }
 
     return configInfo;
 }
@@ -902,7 +910,6 @@ WrtDB::PackagingType JobWidgetInstall::checkPackageType(
     if (WrtUtilFileExists(configFile)) {
         return PKG_TYPE_HYBRID_WEB_APP;
     }
-
     return PKG_TYPE_UNKNOWN;
 }