summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilal Alsharifi <599206+bilal-alsharifi@users.noreply.github.com>2020-08-05 12:02:11 -0400
committerGitHub <noreply@github.com>2020-08-05 12:02:11 -0400
commit10e0b5398b848508e6a55c75c7a4c7f95907a9f4 (patch)
tree9bfc191fbbb73b3cfbfffb06d65ef125cdd553bb
parentf66bc5bfc4a5048269070bcce15523e75e7b2e30 (diff)
parentd3bf3c00c36d2f78ec3de3fb16e31da21d189c3f (diff)
downloadsdl_android-10e0b5398b848508e6a55c75c7a4c7f95907a9f4.tar.gz
Merge pull request #1423 from smartdevicelink/feature/issue-423-additional-submenus
Implement SDL-0148 Additional SubMenus
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java16
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java39
2 files changed, 46 insertions, 9 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java
index da2bbfab8..1885f8c9b 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java
@@ -40,6 +40,7 @@ public class AddSubmenuTests extends BaseRpcTests{
msg.setPosition(TestValues.GENERAL_INT);
msg.setMenuIcon(TestValues.GENERAL_IMAGE);
msg.setMenuLayout(TestValues.GENERAL_MENU_LAYOUT);
+ msg.setParentID(TestValues.GENERAL_MENU_MAX_ID);
return msg;
}
@@ -64,6 +65,7 @@ public class AddSubmenuTests extends BaseRpcTests{
result.put(AddSubMenu.KEY_POSITION, TestValues.GENERAL_INT);
result.put(AddSubMenu.KEY_MENU_ICON, TestValues.JSON_IMAGE);
result.put(AddSubMenu.KEY_MENU_LAYOUT, TestValues.GENERAL_MENU_LAYOUT);
+ result.put(AddSubMenu.KEY_PARENT_ID, TestValues.GENERAL_MENU_MAX_ID);
}catch(JSONException e){
fail(TestValues.JSON_FAIL);
}
@@ -77,11 +79,12 @@ public class AddSubmenuTests extends BaseRpcTests{
@Test
public void testRpcValues () {
// Test Values
- int testMenuId = ( (AddSubMenu) msg ).getMenuID();
- int testPosition = ( (AddSubMenu) msg ).getPosition();
- String testMenuName = ( (AddSubMenu) msg ).getMenuName();
- Image testMenuIcon = ( (AddSubMenu) msg ).getMenuIcon();
- MenuLayout testMenuLayout = ( (AddSubMenu) msg ).getMenuLayout();
+ int testMenuId = ((AddSubMenu) msg).getMenuID();
+ int testPosition = ((AddSubMenu) msg).getPosition();
+ String testMenuName = ((AddSubMenu) msg).getMenuName();
+ Image testMenuIcon = ((AddSubMenu) msg).getMenuIcon();
+ MenuLayout testMenuLayout = ((AddSubMenu) msg).getMenuLayout();
+ int testParentID = ((AddSubMenu) msg).getParentID();
// Valid Tests
assertEquals("Menu ID didn't match input menu ID.", TestValues.GENERAL_INT, testMenuId);
@@ -89,6 +92,7 @@ public class AddSubmenuTests extends BaseRpcTests{
assertEquals("Position didn't match input position.", TestValues.GENERAL_INT, testPosition);
assertTrue("Menu icon didn't match input icon.", Validator.validateImage(TestValues.GENERAL_IMAGE, testMenuIcon));
assertEquals("Menu layout didn't match input menu layout.", TestValues.GENERAL_MENU_LAYOUT, testMenuLayout);
+ assertEquals("Parent ID didn't match input Parent ID.", TestValues.GENERAL_MENU_MAX_ID, testParentID);
// Invalid/Null Tests
@@ -101,6 +105,7 @@ public class AddSubmenuTests extends BaseRpcTests{
assertNull(TestValues.NULL, msg.getPosition());
assertNull(TestValues.NULL, msg.getMenuIcon());
assertNull(TestValues.NULL, msg.getMenuLayout());
+ assertNull(TestValues.NULL, msg.getParentID());
}
/**
@@ -128,6 +133,7 @@ public class AddSubmenuTests extends BaseRpcTests{
assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, AddSubMenu.KEY_POSITION), cmd.getPosition());
assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, AddSubMenu.KEY_MENU_NAME), cmd.getMenuName());
assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(parameters, AddSubMenu.KEY_MENU_LAYOUT), cmd.getMenuLayout());
+ assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, AddSubMenu.KEY_PARENT_ID), cmd.getParentID());
JSONObject menuIcon = JsonUtils.readJsonObjectFromJsonObject(parameters, AddSubMenu.KEY_MENU_ICON);
Image referenceMenuIcon = new Image(JsonRPCMarshaller.deserializeJSONObject(menuIcon));
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java
index e2bd7e675..7d54aebe2 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * Copyright (c) 2017 - 2020, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -13,9 +13,9 @@
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * Neither the name of the SmartDeviceLink Consortium Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -98,6 +98,14 @@ import java.util.Hashtable;
* <td></td>
* <td>SmartDeviceLink 6.0</td>
* </tr>
+ * <tr>
+ * <td>parentID</td>
+ * <td>Integer</td>
+ * <td>unique ID of the sub menu, the command will be added to. If not provided or 0, it will be provided to the top level of the in application menu.</td>
+ * <td>N</td>
+ * <td>Min Value: 0 <p>Max Value: 2000000000</p> </td>
+ * <td>SmartDeviceLink 7.0.0</td>
+ * </tr>
* </table>
* <b>Response</b>
* <p>Indicates that the corresponding request either failed or succeeded. If the response returns with a SUCCESS result code, this means the SubMenu was added to the Command Menu successfully</p>
@@ -116,6 +124,7 @@ public class AddSubMenu extends RPCRequest {
public static final String KEY_MENU_ID = "menuID";
public static final String KEY_MENU_ICON = "menuIcon";
public static final String KEY_MENU_LAYOUT = "menuLayout";
+ public static final String KEY_PARENT_ID = "parentID";
/**
* Constructs a new AddSubMenu object
@@ -250,4 +259,26 @@ public class AddSubMenu extends RPCRequest {
public MenuLayout getMenuLayout() {
return (MenuLayout) getObject(MenuLayout.class, KEY_MENU_LAYOUT);
}
+
+ /**
+ * Sets the parentID.
+ *
+ * @param parentID unique ID of the sub menu, the command will be added to. If not provided or 0, it will be
+ * provided to the top level of the in application menu.
+ * @since SmartDeviceLink 7.0.0
+ */
+ public void setParentID(Integer parentID) {
+ setParameters(KEY_PARENT_ID, parentID);
+ }
+
+ /**
+ * Gets the parentID.
+ *
+ * @return Integer unique ID of the sub menu, the command will be added to. If not provided or 0, it will be
+ * provided to the top level of the in application menu.
+ * @since SmartDeviceLink 7.0.0
+ */
+ public Integer getParentID() {
+ return getInteger(KEY_PARENT_ID);
+ }
}