diff options
author | Brett W <geekman3454@protonmail.com> | 2017-08-24 10:22:07 -0400 |
---|---|---|
committer | Brett W <geekman3454@protonmail.com> | 2017-08-24 10:22:07 -0400 |
commit | 0e4184bff63fb45a5899bd7b5382980bf1994560 (patch) | |
tree | 75db5fdc12c5dc2a62fc315c573e9e5e111a359f | |
parent | 2455d4949e42657eeea1e4f1539c2681147daaa5 (diff) | |
download | sdl_android-0e4184bff63fb45a5899bd7b5382980bf1994560.tar.gz |
updated per new spec
5 files changed, 94 insertions, 17 deletions
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java index 01d4666cd..100d9f8c4 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java @@ -21,6 +21,7 @@ import com.smartdevicelink.proxy.rpc.OasisAddress; import com.smartdevicelink.proxy.rpc.ParameterPermissions; import com.smartdevicelink.proxy.rpc.PermissionItem; import com.smartdevicelink.proxy.rpc.PresetBankCapabilities; +import com.smartdevicelink.proxy.rpc.Rectangle; import com.smartdevicelink.proxy.rpc.ScreenParams; import com.smartdevicelink.proxy.rpc.SdlMsgVersion; import com.smartdevicelink.proxy.rpc.SoftButton; @@ -215,6 +216,7 @@ public class Test { public static final VideoStreamingCodec GENERAL_VIDEOSTREAMINGCODEC = VideoStreamingCodec.H264; public static final VideoStreamingCapability GENERAL_VIDEOSTREAMINGCAPABILITY = new VideoStreamingCapability(); public static final VideoStreamingFormat GENERAL_VIDEOSTREAMINGFORMAT = new VideoStreamingFormat(); + public static final Rectangle GENERAL_RECTANGLE = new Rectangle(); public static final List<Long> GENERAL_LONG_LIST = Arrays.asList(new Long[]{ 1L, 2L }); public static final List<Turn> GENERAL_TURN_LIST = new ArrayList<Turn>(); @@ -483,6 +485,11 @@ public class Test { GENERAL_VIDEOSTREAMINGCAPABILITY.setMaxBitrate(GENERAL_INT); GENERAL_VIDEOSTREAMINGCAPABILITY.setPreferredResolution(GENERAL_IMAGERESOLUTION); GENERAL_VIDEOSTREAMINGCAPABILITY.setSupportedFormats(GENERAL_VIDEOSTREAMINGFORMAT_LIST); + + GENERAL_RECTANGLE.setX(GENERAL_FLOAT); + GENERAL_RECTANGLE.setY(GENERAL_FLOAT); + GENERAL_RECTANGLE.setWidth(GENERAL_FLOAT); + GENERAL_RECTANGLE.setHeight(GENERAL_FLOAT); try { JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_ALLOWED, GENERAL_HMILEVEL_LIST); diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java new file mode 100644 index 000000000..655d30415 --- /dev/null +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java @@ -0,0 +1,44 @@ +package com.smartdevicelink.test.rpc.datatypes; + +import com.smartdevicelink.proxy.rpc.HapticRect; +import com.smartdevicelink.proxy.rpc.Rectangle; +import com.smartdevicelink.test.Test; + +import junit.framework.TestCase; + +/** + * Created by brettywhite on 8/24/17. + */ + +public class HapticRectTests extends TestCase { + + private HapticRect msg; + + @Override + public void setUp() { + msg = new HapticRect(); + + msg.setId(Test.GENERAL_STRING); + msg.setRect(Test.GENERAL_RECTANGLE); + } + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + String id = msg.getId(); + Rectangle rect = msg.getRect(); + + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_STRING, id); + assertEquals(Test.MATCH, Test.GENERAL_RECTANGLE, rect); + + // Invalid/Null Tests + HapticRect msg = new HapticRect(); + assertNotNull(Test.NOT_NULL, msg); + + assertNull(Test.NULL, msg.getId()); + assertNull(Test.NULL, msg.getRect()); + } +} diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java index 2daa716db..162ddbadd 100644 --- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java +++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java @@ -2,6 +2,7 @@ package com.smartdevicelink.test.rpc.requests; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.rpc.HapticRect; import com.smartdevicelink.proxy.rpc.SendHapticData; import com.smartdevicelink.proxy.rpc.Rectangle; import com.smartdevicelink.test.BaseRpcTests; @@ -16,18 +17,16 @@ import org.json.JSONObject; public class SendHapticDataTests extends BaseRpcTests { - private Rectangle spatialStruct; + private HapticRect hapticRect; @Override protected RPCMessage createMessage(){ - spatialStruct = new Rectangle(); - spatialStruct.setX(Test.GENERAL_FLOAT); - spatialStruct.setY(Test.GENERAL_FLOAT); - spatialStruct.setWidth(Test.GENERAL_FLOAT); - spatialStruct.setHeight(Test.GENERAL_FLOAT); + hapticRect = new HapticRect(); + hapticRect.setId(Test.GENERAL_STRING); + hapticRect.setRect(Test.GENERAL_RECTANGLE); SendHapticData msg = new SendHapticData(); - msg.setHapticSpatialData(spatialStruct); + msg.setHapticRectData(hapticRect); return msg; } @@ -47,7 +46,7 @@ public class SendHapticDataTests extends BaseRpcTests { JSONObject result = new JSONObject(); try{ - result.put(SendHapticData.KEY_HAPTIC_SPATIAL_DATA, spatialStruct.serializeJSON()); + result.put(SendHapticData.KEY_HAPTIC_RECT_DATA, hapticRect.serializeJSON()); }catch(JSONException e){ fail(Test.JSON_FAIL); } @@ -60,16 +59,16 @@ public class SendHapticDataTests extends BaseRpcTests { */ public void testRpcValues () { // Test Values - Rectangle testSpatialStruct = ((SendHapticData) msg).getHapticSpatialData(); + HapticRect testSpatialStruct = ((SendHapticData) msg).getHapticRectData(); // Valid Tests - assertEquals(Test.MATCH, spatialStruct, testSpatialStruct); + assertEquals(Test.MATCH, hapticRect, testSpatialStruct); // Invalid/Null Tests SendHapticData msg = new SendHapticData(); assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull(Test.NULL, msg.getHapticSpatialData()); + assertNull(Test.NULL, msg.getHapticRectData()); } } diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java index 19118f1ef..21ed41297 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java @@ -17,5 +17,25 @@ public class HapticRect extends RPCStruct { super(hash); } + /** + * A user control spatial identifier + */ + public void setId(String id) { + setValue(KEY_ID, id); + } + + public String getId() { + return getString(KEY_ID); + } + /** + * The position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs. + */ + public void setRect(Rectangle rect) { + setValue(KEY_RECT, rect); + } + + public Rectangle getRect() { + return (Rectangle) getObject(Rectangle.class, KEY_RECT); + } } diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java index 3e6bbb350..2cb32eff9 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java @@ -6,7 +6,7 @@ import com.smartdevicelink.proxy.RPCRequest; import java.util.Hashtable; public class SendHapticData extends RPCRequest { - public static final String KEY_HAPTIC_SPATIAL_DATA = "hapticSpatialData"; + public static final String KEY_HAPTIC_RECT_DATA = "hapticRectData"; /** * Constructs a new SendHapticData object */ @@ -16,7 +16,8 @@ public class SendHapticData extends RPCRequest { /** * <p> - * Constructs a new SendHapticData object indicated by the Hashtable parameter + * Send the spatial data gathered from SDLCarWindow or VirtualDisplayEncoder to the HMI. + * This data will be utilized by the HMI to determine how and when haptic events should occur * </p> * * @param hash The Hashtable to use @@ -25,12 +26,18 @@ public class SendHapticData extends RPCRequest { super(hash); } - public void setHapticSpatialData(Rectangle hapticSpatialData) { - setParameters(KEY_HAPTIC_SPATIAL_DATA, hapticSpatialData); + /** + * Array of spatial data structures that represent the locations of all user controls present on the HMI. + * This data should be updated if/when the application presents a new screen. + * When a request is sent, if successful, it will replace all spatial data previously sent through RPC. + * If an empty array is sent, the existing spatial data will be cleared + */ + public void setHapticRectData(HapticRect hapticRectData) { + setParameters(KEY_HAPTIC_RECT_DATA, hapticRectData); } - public Rectangle getHapticSpatialData() { - return (Rectangle) getObject(Rectangle.class, KEY_HAPTIC_SPATIAL_DATA); + public HapticRect getHapticRectData() { + return (HapticRect) getObject(HapticRect.class, KEY_HAPTIC_RECT_DATA); } } |