[Content] TCT tests fixes
authorWojciech Kosowicz <w.kosowicz@samsung.com>
Mon, 23 Mar 2015 15:03:12 +0000 (16:03 +0100)
committerRafal Galka <r.galka@samsung.com>
Mon, 23 Mar 2015 15:38:55 +0000 (00:38 +0900)
Fixed throwing errors in playlist methods. Added releaseDate for
video elements

[Verification] All tests passed 230/230
Change-Id: I62007eb557294e775a9283e90f1454a6ebeb6824
Signed-off-by: Wojciech Kosowicz <w.kosowicz@samsung.com>
src/content/content_manager.cc
src/content/js/datatypes.js
src/content/js/manager.js
src/content/js/playlist.js

index c6cd6e88894f11187b2533dbbd981b7b7f723c88..c19183fd6d3603ed20e9008569908b9a17c48178 100755 (executable)
@@ -52,6 +52,23 @@ static int get_utc_offset() {
   return gmtime_hours;
 }
 
+std::string get_date(char* tmpStr) {
+  if (tmpStr) {
+    struct tm* result = (struct tm*) calloc(1, sizeof(struct tm));
+    if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
+      return std::string();
+    } else {
+      time_t t = mktime(result);// + get_utc_offset() * 3600;
+      std::stringstream str_date;
+      str_date << t;
+      free(tmpStr);
+      free(result);
+      tmpStr = NULL;
+      return str_date.str();
+    }
+  }
+  return std::string();
+}
 
 void ContentToJson(media_info_h info, picojson::object& o) {
   int ret;
@@ -75,21 +92,7 @@ void ContentToJson(media_info_h info, picojson::object& o) {
     image_meta_h img;
     if (MEDIA_CONTENT_ERROR_NONE == media_info_get_image(info, &img)) {
       if (MEDIA_CONTENT_ERROR_NONE == image_meta_get_date_taken(img, &tmpStr)) {
-        if (tmpStr) {
-          struct tm* result = (struct tm*) calloc(1, sizeof(struct tm));
-          if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
-            LoggerE("Couldn't convert supplied date.");
-          }
-          else {
-            time_t t = mktime(result);// + get_utc_offset() * 3600;
-            std::stringstream str_date;
-            str_date << t;
-            o["releaseDate"] = picojson::value(str_date.str());
-            free(tmpStr);
-            free(result);
-            tmpStr = NULL;
-          }
-        }
+        o["releaseDate"] = picojson::value(get_date(tmpStr));
       }
       if (MEDIA_CONTENT_ERROR_NONE == image_meta_get_width(img, &tmpInt)) {
         o["width"] = picojson::value(static_cast<double>(tmpInt));
@@ -167,6 +170,9 @@ void ContentToJson(media_info_h info, picojson::object& o) {
       if (MEDIA_CONTENT_ERROR_NONE == video_meta_get_duration(video, &tmpInt)) {
         o["duration"] = picojson::value(static_cast<double>(tmpInt));
       }
+      if (MEDIA_CONTENT_ERROR_NONE == video_meta_get_recorded_date(video, &tmpStr)) {
+        o["releaseDate"] = picojson::value(get_date(tmpStr));
+      }
     }
     picojson::object geo;
     if (MEDIA_CONTENT_ERROR_NONE == media_info_get_latitude(info, &tmpDouble)) {
@@ -182,20 +188,7 @@ void ContentToJson(media_info_h info, picojson::object& o) {
     audio_meta_h audio;
     if (MEDIA_CONTENT_ERROR_NONE == media_info_get_audio(info, &audio)) {
       if (MEDIA_CONTENT_ERROR_NONE == audio_meta_get_recorded_date(audio, &tmpStr)) {
-        if (tmpStr) {
-          struct tm* result = (struct tm*) calloc(1, sizeof(struct tm));
-
-          if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
-            LoggerD("Couldn't convert supplied date.");
-          }
-          time_t t = mktime(result) + get_utc_offset() * 3600;
-          std::stringstream str_date;
-          str_date << t;
-          o["releaseDate"] = picojson::value(str_date.str());
-          free(tmpStr);
-          free(result);
-          tmpStr = NULL;
-        }
+        o["releaseDate"] = picojson::value(get_date(tmpStr));
       }
       if (MEDIA_CONTENT_ERROR_NONE == audio_meta_get_album(audio, &tmpStr)) {
         if (tmpStr) {
index 3dc178bdc6e444b95164d9c191b5d9156b8bd5ae..3078ad7f3d7cff0f2eaf70e8d296059fe349c275 100644 (file)
@@ -685,7 +685,7 @@ function PlaylistItem(data) {
         return content;
       },
       set: function(v) {
-        if (edit_.isAllowed && v instanceof Content ) {
+        if (edit_.isAllowed && v instanceof Content) {
           content = v;
         }
       },
index d623a63082091f30b466740c6dd0752378df78e3..18f9871fb540f1ca7f22f5a162a378a27c0ce2e2 100644 (file)
@@ -223,6 +223,14 @@ ContentManager.prototype.createPlaylist = function(name, successCallback, errorC
     {name: 'sourcePlaylist', type: types_.PLATFORM_OBJECT, values: Playlist, optional: true, nullable: true}
   ]);
 
+  if (!arguments.length || !type_.isString(arguments[0]) ||
+    (type_.isString(arguments[0]) && !arguments[0].length)) {
+    setTimeout(function() {
+      args.errorCallback(new WebAPIException(WebAPIException.INVALID_VALUES_ERR));
+    }, 0);
+    return;
+  }
+
   var data = {
     name: args.name,
     sourcePlaylist: args.sourcePlaylist
index 6e5aeeb793677d162b68783aa5875bbbc3693f46..e75cbf270f523a5a806fc6231b6181e9055e687f 100644 (file)
@@ -162,6 +162,13 @@ Playlist.prototype.get = function (successCallback, errorCallback, count, offset
     {name: 'offset', type: types_.LONG, optional: true}
   ]);
 
+  if (args.offset < 0 || args.count < 0) {
+    setTimeout(function() {
+      args.errorCallback(new WebAPIException(WebAPIException.INVALID_VALUES_ERR));
+    }, 0);
+    return;
+  }
+
   var data = {
     playlistId: this.id,
     count: type_.isNullOrUndefined(args.count) ? -1 : args.count,
@@ -193,6 +200,13 @@ Playlist.prototype.setOrder = function (items, successCallback, errorCallback) {
     {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
   ]);
 
+  if (!args.items.length) {
+    setTimeout(function() {
+      args.errorCallback(new WebAPIException(WebAPIException.INVALID_VALUES_ERR));
+    }, 0);
+    return;
+  }
+
   var members = [];
   for (var i = 0; i < args.items.length; i++) {
     members.push(args.items[i].content.memberId);