summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Kast <julian@livio.com>2020-07-29 20:44:54 -0400
committerJulian Kast <julian@livio.com>2020-07-29 20:44:54 -0400
commit6bbc5bd72b7758b3511e63224526b9a8a3ad235e (patch)
tree4f1ce48c954131984410c6b8a148e41aaf348023
parent7064144d3673663118de1ef1d4bea3c47719351d (diff)
downloadsdl_android-6bbc5bd72b7758b3511e63224526b9a8a3ad235e.tar.gz
Added Test class DriverDistractionCapabilityTest.java to test DriverDistractionCapability
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DriverDistractionCapabilityTest.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DriverDistractionCapabilityTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DriverDistractionCapabilityTest.java
new file mode 100644
index 000000000..2e98296a1
--- /dev/null
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DriverDistractionCapabilityTest.java
@@ -0,0 +1,65 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.DriverDistractionCapability;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.TestValues;
+import junit.framework.TestCase;
+import org.json.JSONException;
+import org.json.JSONObject;
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.proxy.rpc.DriverDistractionCapability}
+ */
+public class DriverDistractionCapabilityTest extends TestCase {
+
+ private DriverDistractionCapability msg;
+
+ @Override
+ public void setUp() {
+ msg = new DriverDistractionCapability();
+ msg.setMenuLength(TestValues.GENERAL_INT);
+ msg.setSubMenuDepth(TestValues.GENERAL_INT);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues() {
+ // Test Values
+ int menuLength = msg.getMenuLength();
+ int subMenuDepth = msg.getSubMenuDepth();
+
+ // Valid Tests
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_INT, menuLength);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_INT, subMenuDepth);
+
+ // Invalid/Null Tests
+ DriverDistractionCapability msg = new DriverDistractionCapability();
+ assertNotNull(TestValues.NOT_NULL, msg);
+
+ assertNull(TestValues.NULL, msg.getMenuLength());
+ assertNull(TestValues.NULL, msg.getSubMenuDepth());
+ }
+
+ public void testJson() {
+ JSONObject reference = new JSONObject();
+
+ try {
+ reference.put(DriverDistractionCapability.KEY_MENU_LENGTH, TestValues.GENERAL_INT);
+ reference.put(DriverDistractionCapability.KEY_SUB_MENU_DEPTH, TestValues.GENERAL_INT);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(TestValues.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+ assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ } catch (JSONException e) {
+ fail(TestValues.JSON_FAIL);
+ }
+ }
+}