From 533e09fbd64c268e3e82f0555100fd0b63d041bd Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Wed, 22 May 2019 14:43:32 -0400 Subject: [PATCH 1/3] Add mediaImage to MediaServiceData --- .../proxy/rpc/MediaServiceData.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java index cdd5d21a44..d9e79612f5 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java @@ -45,6 +45,7 @@ public class MediaServiceData extends RPCStruct { public static final String KEY_MEDIA_TITLE = "mediaTitle"; public static final String KEY_MEDIA_ARTIST = "mediaArtist"; public static final String KEY_MEDIA_ALBUM = "mediaAlbum"; + public static final String KEY_MEDIA_IMAGE = "mediaImage"; public static final String KEY_PLAYLIST_NAME = "playlistName"; public static final String KEY_IS_EXPLICIT = "isExplicit"; public static final String KEY_TRACK_PLAYBACK_PROGRESS = "trackPlaybackProgress"; @@ -138,6 +139,28 @@ public String getMediaAlbum() { return getString(KEY_MEDIA_ALBUM); } + /** + * Sets the media image associated with the currently playing media + * Music: The album art of the current track + * Podcast: The podcast or chapter artwork of the current podcast episode + * Audiobook: The book or chapter artwork of the current audiobook + * @param mediaImage + */ + public void setMediaImage(Image mediaImage){ + setValue(KEY_MEDIA_IMAGE, mediaImage); + } + + /** + * Returns the media image associated with the currently playing media + * Music: The album art of the current track + * Podcast: The podcast or chapter artwork of the current podcast episode + * Audiobook: The book or chapter artwork of the current audiobook + * @param mediaImage + */ + public Image getMediaImage(Image mediaImage){ + return (Image) getObject(Image.class, KEY_MEDIA_IMAGE); + } + /** * Music: The name of the playlist or radio station, if the user is playing from a playlist, otherwise, Null * Podcast: The name of the playlist, if the user is playing from a playlist, otherwise, Null From 966f51809692e67786c62ad1f20ed1e55e461c20 Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Wed, 22 May 2019 15:06:07 -0400 Subject: [PATCH 2/3] Remove param from getMediaImage signature --- .../java/com/smartdevicelink/proxy/rpc/MediaServiceData.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java index d9e79612f5..16065f669c 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/MediaServiceData.java @@ -155,9 +155,8 @@ public void setMediaImage(Image mediaImage){ * Music: The album art of the current track * Podcast: The podcast or chapter artwork of the current podcast episode * Audiobook: The book or chapter artwork of the current audiobook - * @param mediaImage */ - public Image getMediaImage(Image mediaImage){ + public Image getMediaImage(){ return (Image) getObject(Image.class, KEY_MEDIA_IMAGE); } From f20420dc90622b735617b02b646de9728cf0dd2e Mon Sep 17 00:00:00 2001 From: Joey Grover Date: Wed, 22 May 2019 15:15:27 -0400 Subject: [PATCH 3/3] Add tests for mediaImage --- .../rpc/datatypes/MediaServiceDataTests.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/MediaServiceDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/MediaServiceDataTests.java index 2b4c352c52..2883fca6bf 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/MediaServiceDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/MediaServiceDataTests.java @@ -1,15 +1,19 @@ package com.smartdevicelink.test.rpc.datatypes; +import com.smartdevicelink.marshal.JsonRPCMarshaller; +import com.smartdevicelink.proxy.rpc.Image; import com.smartdevicelink.proxy.rpc.MediaServiceData; import com.smartdevicelink.proxy.rpc.enums.MediaType; import com.smartdevicelink.test.JsonUtils; import com.smartdevicelink.test.Test; +import com.smartdevicelink.test.Validator; import junit.framework.TestCase; import org.json.JSONException; import org.json.JSONObject; +import java.util.Hashtable; import java.util.Iterator; /** @@ -28,6 +32,7 @@ public void setUp(){ msg.setMediaTitle(Test.GENERAL_STRING); msg.setMediaArtist(Test.GENERAL_STRING); msg.setMediaAlbum(Test.GENERAL_STRING); + msg.setMediaImage(Test.GENERAL_IMAGE); msg.setPlaylistName(Test.GENERAL_STRING); msg.setIsExplicit(Test.GENERAL_BOOLEAN); msg.setTrackPlaybackProgress(Test.GENERAL_INTEGER); @@ -47,6 +52,7 @@ public void testRpcValues () { String mediaTitle = msg.getMediaTitle(); String mediaArtist = msg.getMediaArtist(); String mediaAlbum = msg.getMediaAlbum(); + Image mediaImage = msg.getMediaImage(); String playlistName = msg.getPlaylistName(); boolean isExplicit = msg.getIsExplicit(); Integer trackPlaybackProgress = msg.getTrackPlaybackProgress(); @@ -61,6 +67,7 @@ public void testRpcValues () { assertEquals(Test.GENERAL_STRING, mediaTitle); assertEquals(Test.GENERAL_STRING, mediaArtist); assertEquals(Test.GENERAL_STRING, mediaAlbum); + assertEquals(Test.GENERAL_IMAGE, mediaImage); assertEquals(Test.GENERAL_STRING, playlistName); assertEquals(Test.GENERAL_BOOLEAN, isExplicit); assertEquals(Test.GENERAL_INTEGER, trackPlaybackProgress); @@ -78,6 +85,7 @@ public void testRpcValues () { assertNull(Test.NULL, msg.getMediaTitle()); assertNull(Test.NULL, msg.getMediaArtist()); assertNull(Test.NULL, msg.getMediaAlbum()); + assertNull(Test.NULL, msg.getMediaImage()); assertNull(Test.NULL, msg.getPlaylistName()); assertNull(Test.NULL, msg.getIsExplicit()); assertNull(Test.NULL, msg.getTrackPlaybackProgress()); @@ -96,6 +104,7 @@ public void testJson(){ reference.put(MediaServiceData.KEY_MEDIA_TITLE, Test.GENERAL_STRING); reference.put(MediaServiceData.KEY_MEDIA_ARTIST, Test.GENERAL_STRING); reference.put(MediaServiceData.KEY_MEDIA_ALBUM, Test.GENERAL_STRING); + reference.put(MediaServiceData.KEY_MEDIA_IMAGE, Test.GENERAL_IMAGE); reference.put(MediaServiceData.KEY_PLAYLIST_NAME, Test.GENERAL_STRING); reference.put(MediaServiceData.KEY_IS_EXPLICIT, Test.GENERAL_BOOLEAN); reference.put(MediaServiceData.KEY_TRACK_PLAYBACK_PROGRESS, Test.GENERAL_INTEGER); @@ -111,7 +120,14 @@ public void testJson(){ Iterator iterator = reference.keys(); while(iterator.hasNext()){ String key = (String) iterator.next(); - assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); + + if (key.equals(MediaServiceData.KEY_MEDIA_IMAGE)){ + JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key); + Hashtable hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals); + assertTrue(Test.TRUE, Validator.validateImage(Test.GENERAL_IMAGE, new Image(hashTest))); + } else { + assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); + } } } catch(JSONException e){ fail(Test.JSON_FAIL);