[exif] Fixes based on tests fails
authorGrzegorz Rynkowski <g.rynkowski@samsung.com>
Fri, 13 Feb 2015 14:25:32 +0000 (15:25 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Mon, 23 Feb 2015 15:06:10 +0000 (00:06 +0900)
[Problem]   Fails and timeouts.
    ExifManager_getThumbnail
    ExifManager_getThumbnail_with_errorCallback
    ExifManager_getThumbnail_errorCallback_invoked_InvalidValuesError
    ExifManager_getThumbnail_errorCallback_invoked_NotFoundError
    ExifManager_saveExifInfo_errorCallback_invoked_NotFoundError
    ExifThumbnailSuccessCallback_onsuccess

[Verification]
    1. Build the code.
    2. Run Exif tests.
    3. Mentioned tests should pass.

[SCMRequest]
    Required commit to verification:
    https://mcdsrvbld02.digital.local/review/#/c/20331/

Change-Id: Id7e996f8b9033ddf03327d152daa4204bb1dd8ec
Signed-off-by: Grzegorz Rynkowski <g.rynkowski@samsung.com>
src/exif/exif_api.js
src/exif/exif_information.cc
src/exif/exif_instance.cc

index f9623ccaae8d7cfd482520436516bbc82f7fc833..5b3f7e91ac0cf6fbe7ac859288249604dede8679 100644 (file)
@@ -255,7 +255,9 @@ ExifManager.prototype.getThumbnail = function() {
     }
   ]);
 
-  var callback = function(result) {
+  // TODO: Check if uri contains invalid characters. It should not.
+
+  var _callback = function(result) {
     if (native_.isFailure(result)) {
       native_.callIfPossible(args.errorCallback,
           native_.getErrorObject(result));
@@ -265,7 +267,15 @@ ExifManager.prototype.getThumbnail = function() {
     }
   };
 
-  native_.call('ExifManager_getThumbnail', {'uri': args.uri}, callback);
+  tizen.filesystem.resolve(args.uri,
+      function() {
+        native_.call('ExifManager_getThumbnail', {'uri': args.uri}, _callback);
+      },
+      function() {
+        native_.callIfPossible(args.errorCallback, new tizen.WebAPIException(
+            tizen.WebAPIException.NOT_FOUND_ERR,
+            'File can not be found.'));
+      });
 };
 
 tizen.ExifInformation = function() {
index 63c8f8fa7a0b0cf842c480b60e311fdc3ceb7bb6..4409d622df95986779708b3a37491bc3ff432faa 100644 (file)
@@ -56,7 +56,8 @@ IsoSpeedRatingsVector jsonArray2vector(const picojson::value& a) {
   picojson::array v = a.get<picojson::array>();
 
   for (picojson::array::iterator it = v.begin(); it != v.end(); it++) {
-    result.push_back(static_cast<long long int>((*it).get<double>()));
+    if ((*it).is<double>())
+      result.push_back(static_cast<long long int>((*it).get<double>()));
   }
 
   return result;
index 6d041138505b234357415d7369c0a7d5b7347374..c6d08fccfaf4cd8d5ee3928bc63a978f0ed5b229 100644 (file)
@@ -126,14 +126,15 @@ void ExifInstance::ExifManagerGetThumbnail(const picojson::value& args, picojson
 
         exif_data = exif_data_new_from_file(file_path.c_str());
         if (!exif_data) {
-          throw common::UnknownException("File can not be loaded");
+          LoggerE("Thumbnail can not be loaded from path (%s)",
+                  file_path.c_str());
+          throw common::InvalidValuesException("File can not be loaded");
         }
 
         if (exif_data->data && exif_data->size) {
           gchar* ch_uri = g_base64_encode(exif_data->data, exif_data->size);
-          std::string base64 = "data:image/" + ext + ";base64," + ch_uri;
-
           exif_data_unref(exif_data);
+          std::string base64 = "data:image/" + ext + ";base64," + ch_uri;
 
           std::pair<std::string, picojson::value> pair;
           pair = std::make_pair("src", picojson::value(base64));
@@ -141,11 +142,11 @@ void ExifInstance::ExifManagerGetThumbnail(const picojson::value& args, picojson
         } else {
           exif_data_unref(exif_data);
           LoggerE("File [%s] doesn't contain thumbnail", file_path.c_str());
-          throw common::InvalidValuesException("File doesn't contain thumbnail");
+          throw common::UnknownException("File doesn't contain thumbnail");
         }
       } else {
         LoggerE("extension: %s is not valid (jpeg/jpg/png/gif is supported)", ext.c_str());
-        throw common::NotSupportedException("getThumbnail support only jpeg/jpg/png/gif");
+        throw common::InvalidValuesException("getThumbnail support only jpeg/jpg/png/gif");
       }
 
       ReportSuccess(result, response->get<picojson::object>());