diff options
author | RHenigan <heniganr1@gmail.com> | 2020-08-14 11:42:40 -0400 |
---|---|---|
committer | RHenigan <heniganr1@gmail.com> | 2020-08-14 11:42:40 -0400 |
commit | 07035805658f5656239d46d3316a9f4d0e0d1f6b (patch) | |
tree | 5378ef038212b26b01a256f029825400556a1eae | |
parent | dafdc05c00bb4f39fd48eacb603bd7728b832465 (diff) | |
download | sdl_android-07035805658f5656239d46d3316a9f4d0e0d1f6b.tar.gz |
Add new test files for new notifications
2 files changed, 151 insertions, 0 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateFileTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateFileTest.java new file mode 100644 index 000000000..96eea8361 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateFileTest.java @@ -0,0 +1,73 @@ +package com.smartdevicelink.test.rpc.notifications; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.rpc.OnUpdateFile; +import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.TestValues; + +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.Test; + +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.OnUpdateFile} + */ +public class OnUpdateFileTest extends BaseRpcTests { + @Override + protected RPCMessage createMessage() { + OnUpdateFile msg = new OnUpdateFile(); + + msg.setFileName(TestValues.GENERAL_STRING); + + return msg; + } + + @Override + protected String getMessageType() { + return RPCMessage.KEY_NOTIFICATION; + } + + @Override + protected String getCommandType() { + return FunctionID.ON_UPDATE_FILE.toString(); + } + + @Override + protected JSONObject getExpectedParameters(int sdlVersion) { + JSONObject result = new JSONObject(); + + try{ + result.put(OnUpdateFile.KEY_FILE_NAME, TestValues.GENERAL_STRING); + }catch(JSONException e){ + fail(TestValues.JSON_FAIL); + } + + return result; + } + + /** + * Tests the expected values of the RPC message. + */ + @Test + public void testRpcValues () { + // Test Values + String fileName = ( (OnUpdateFile) msg).getFileName(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, fileName); + + // Invalid/Null Tests + OnUpdateFile msg = new OnUpdateFile(); + assertNotNull(TestValues.NOT_NULL, msg); + testNullBase(msg); + + assertNull(TestValues.NULL, msg.getFileName()); + } +} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateSubMenuTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateSubMenuTest.java new file mode 100644 index 000000000..4e7ff9748 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnUpdateSubMenuTest.java @@ -0,0 +1,78 @@ +package com.smartdevicelink.test.rpc.notifications; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.rpc.OnUpdateSubMenu; +import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.TestValues; + +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.Test; + +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.OnUpdateSubMenu} + */ +public class OnUpdateSubMenuTest extends BaseRpcTests { + @Override + protected RPCMessage createMessage() { + OnUpdateSubMenu msg = new OnUpdateSubMenu(); + + msg.setMenuID(TestValues.GENERAL_INT); + msg.setUpdateSubCells(TestValues.GENERAL_BOOLEAN); + + return msg; + } + + @Override + protected String getMessageType() { + return RPCMessage.KEY_NOTIFICATION; + } + + @Override + protected String getCommandType() { + return FunctionID.ON_UPDATE_SUB_MENU.toString(); + } + + @Override + protected JSONObject getExpectedParameters(int sdlVersion) { + JSONObject result = new JSONObject(); + + try{ + result.put(OnUpdateSubMenu.KEY_MENU_ID, TestValues.GENERAL_INT); + result.put(OnUpdateSubMenu.KEY_UPDATE_SUB_CELLS, TestValues.GENERAL_BOOLEAN); + }catch(JSONException e){ + fail(TestValues.JSON_FAIL); + } + + return result; + } + + /** + * Tests the expected values of the RPC message. + */ + @Test + public void testRpcValues () { + // Test Values + int menuId = ( (OnUpdateSubMenu) msg ).getMenuID(); + boolean updateSubCells = ( (OnUpdateSubMenu) msg ).getUpdateSubCells(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_INT, menuId); + assertEquals(TestValues.MATCH, TestValues.GENERAL_BOOLEAN, updateSubCells); + + // Invalid/Null Tests + OnUpdateSubMenu msg = new OnUpdateSubMenu(); + assertNotNull(TestValues.NOT_NULL, msg); + testNullBase(msg); + + assertNull(TestValues.NULL, msg.getMenuID()); + assertNull(TestValues.NULL, msg.getUpdateSubCells()); + } +} |