From: Grzegorz Rynkowski Date: Fri, 13 Feb 2015 14:25:32 +0000 (+0100) Subject: [exif] Fixes based on tests fails X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~383 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63829ec85f82719dd319527bb0e41cfca7b299d8;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [exif] Fixes based on tests fails [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 --- diff --git a/src/exif/exif_api.js b/src/exif/exif_api.js index f9623cca..5b3f7e91 100644 --- a/src/exif/exif_api.js +++ b/src/exif/exif_api.js @@ -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() { diff --git a/src/exif/exif_information.cc b/src/exif/exif_information.cc index 63c8f8fa..4409d622 100644 --- a/src/exif/exif_information.cc +++ b/src/exif/exif_information.cc @@ -56,7 +56,8 @@ IsoSpeedRatingsVector jsonArray2vector(const picojson::value& a) { picojson::array v = a.get(); for (picojson::array::iterator it = v.begin(); it != v.end(); it++) { - result.push_back(static_cast((*it).get())); + if ((*it).is()) + result.push_back(static_cast((*it).get())); } return result; diff --git a/src/exif/exif_instance.cc b/src/exif/exif_instance.cc index 6d041138..c6d08fcc 100644 --- a/src/exif/exif_instance.cc +++ b/src/exif/exif_instance.cc @@ -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 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());