diff options
Diffstat (limited to 'android/sdl_android/src/androidTest')
7 files changed, 93 insertions, 4 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/GridTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/GridTests.java index 32e745d10..95f94c3a7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/GridTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/GridTests.java @@ -50,6 +50,13 @@ public class GridTests extends TestCase { assertNull(Test.NULL, msg.getColumnSpan()); assertNull(Test.NULL, msg.getRowSpan()); assertNull(Test.NULL, msg.getLevelSpan()); + + //test required constructor + Grid msg2 = new Grid(Test.GENERAL_INT, Test.GENERAL_INT); + int row2 = msg2.getRow(); + int col2 = msg2.getColumn(); + assertEquals(Test.MATCH, col2, Test.GENERAL_INT); + assertEquals(Test.MATCH, row2, Test.GENERAL_INT); } public void testJson() { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ModuleInfoTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ModuleInfoTests.java index 508c216f6..282e43b4f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ModuleInfoTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ModuleInfoTests.java @@ -43,6 +43,10 @@ public class ModuleInfoTests extends TestCase { assertNull(Test.NULL, msg.getModuleLocation()); assertNull(Test.NULL, msg.getModuleServiceArea()); assertNull(Test.NULL, msg.getMultipleAccessAllowance()); + + //test required params constructor + ModuleInfo msg2 = new ModuleInfo(Test.GENERAL_STRING); + assertEquals(Test.MATCH, msg2.getModuleId(), Test.GENERAL_STRING); } public void testJson() { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java index 0f21a2076..d736e5176 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java @@ -62,6 +62,11 @@ public class GetInteriorVehicleDataConsentTests extends BaseRpcTests { assertNull(Test.NULL, msg.getModuleType()); assertNull(Test.NULL, msg.getModuleIds()); + //test require param constructor + GetInteriorVehicleDataConsent msg2 = new GetInteriorVehicleDataConsent(Test.GENERAL_MODULETYPE, Test.GENERAL_STRING_LIST); + assertEquals(Test.MATCH, Test.GENERAL_MODULETYPE, msg2.getModuleType()); + assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST, msg2.getModuleIds()); + } public void testJsonConstructor() { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReleaseInteriorVehicleDataModuleTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReleaseInteriorVehicleDataModuleTests.java index 711e4c977..c2bd3b3d6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReleaseInteriorVehicleDataModuleTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReleaseInteriorVehicleDataModuleTests.java @@ -59,6 +59,10 @@ public class ReleaseInteriorVehicleDataModuleTests extends BaseRpcTests { ReleaseInteriorVehicleDataModule msg = new ReleaseInteriorVehicleDataModule(); assertNull(Test.NULL, msg.getModuleType()); assertNull(Test.NULL, msg.getModuleId()); + + // required param tests + ReleaseInteriorVehicleDataModule msg2 = new ReleaseInteriorVehicleDataModule(Test.GENERAL_MODULETYPE); + assertEquals(Test.MATCH, Test.GENERAL_MODULETYPE, msg2.getModuleType()); } public void testJsonConstructor() { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataConsentResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataConsentResponseTests.java index b77e056c9..b96306c62 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataConsentResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataConsentResponseTests.java @@ -4,6 +4,7 @@ import com.smartdevicelink.marshal.JsonRPCMarshaller; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataConsentResponse; +import com.smartdevicelink.proxy.rpc.enums.Result; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; import com.smartdevicelink.test.Test; @@ -51,6 +52,13 @@ public class GetInteriorVehicleDataConsentResponseTests extends BaseRpcTests { assertEquals(Test.MATCH, list, Test.GENERAL_BOOLEAN_LIST); } + public void testRequiredParams(){ + GetInteriorVehicleDataConsentResponse msg = new GetInteriorVehicleDataConsentResponse(true, Result.SUCCESS, Test.GENERAL_BOOLEAN_LIST); + assertEquals(Test.MATCH, msg.getAllowances(), Test.GENERAL_BOOLEAN_LIST); + assertTrue(msg.getSuccess()); + assertEquals(Test.MATCH, msg.getResultCode(), Result.SUCCESS); + } + public void testJsonConstructor() { JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType()); assertNotNull(Test.NOT_NULL, commandJson); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/CompareUtilsTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/CompareUtilsTest.java new file mode 100644 index 000000000..5edd95ab5 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/CompareUtilsTest.java @@ -0,0 +1,47 @@ +package com.smartdevicelink.test.util; + +import com.smartdevicelink.AndroidTestCase2; +import com.smartdevicelink.test.Test; +import com.smartdevicelink.util.CompareUtils; + +public class CompareUtilsTest extends AndroidTestCase2 { + + public void testAreStringsEqual(){ + + assertTrue(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_STRING, true, true)); + assertTrue(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_STRING, false, true)); + assertTrue(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_STRING, true, false)); + assertTrue(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_STRING, false, false)); + + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_APP_ID, true, true)); + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_APP_ID, false, true)); + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_APP_ID, true, false)); + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_APP_ID, false, false)); + + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_STRING.toUpperCase(), false, false)); + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_STRING.toUpperCase(), false, true)); + assertTrue(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_STRING.toUpperCase(), true, false)); + assertTrue(CompareUtils.areStringsEqual(Test.GENERAL_STRING, Test.GENERAL_STRING.toUpperCase(), true, true)); + + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING.toUpperCase(), Test.GENERAL_STRING, false, false)); + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING.toUpperCase(), Test.GENERAL_STRING, false, true)); + assertTrue(CompareUtils.areStringsEqual(Test.GENERAL_STRING.toUpperCase(), Test.GENERAL_STRING.toUpperCase(), true, false)); + assertTrue(CompareUtils.areStringsEqual(Test.GENERAL_STRING.toUpperCase(), Test.GENERAL_STRING.toUpperCase(), true, true)); + + assertTrue(CompareUtils.areStringsEqual(null, null, true, true)); + assertFalse(CompareUtils.areStringsEqual(null, null, true, false)); + assertTrue(CompareUtils.areStringsEqual(null, null, false, true)); + assertFalse(CompareUtils.areStringsEqual(null, null, false, false)); + + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, null, true, true)); + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, null, true, false)); + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, null, false, true)); + assertFalse(CompareUtils.areStringsEqual(Test.GENERAL_STRING, null, false, false)); + + assertFalse(CompareUtils.areStringsEqual(null, Test.GENERAL_STRING, false, true)); + assertFalse(CompareUtils.areStringsEqual(null, Test.GENERAL_STRING, false, false)); + assertFalse(CompareUtils.areStringsEqual(null, Test.GENERAL_STRING, true, true)); + assertFalse(CompareUtils.areStringsEqual(null, Test.GENERAL_STRING, true, false)); + + } +} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/VersionTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/VersionTest.java index 4798de56b..f9d3b8e0a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/VersionTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/VersionTest.java @@ -5,10 +5,11 @@ import com.smartdevicelink.util.Version; public class VersionTest extends AndroidTestCase2 { - private static final String TEST_VERSION = "1.2.3"; + private static final String TEST_VERSION_STRING = "1.2.3"; + private static final Version TEST_VERSION = new Version(1,2,3); public void testConstructorCorrect(){ - Version version = new Version(TEST_VERSION); + Version version = new Version(TEST_VERSION_STRING); assertEquals(1, version.getMajor()); assertEquals(2, version.getMinor()); assertEquals(3, version.getPatch()); @@ -24,8 +25,8 @@ public class VersionTest extends AndroidTestCase2 { } public void testToString(){ - Version version = new Version(TEST_VERSION); - assertEquals(version.toString(), TEST_VERSION); + Version version = new Version(TEST_VERSION_STRING); + assertEquals(version.toString(), TEST_VERSION_STRING); } public void testisNewerThan(){ @@ -45,4 +46,17 @@ public class VersionTest extends AndroidTestCase2 { assertEquals(0,version1.isNewerThan( new Version(5,0,0))); } + + public void testIsBetween(){ + + assertEquals(TEST_VERSION.isBetween(new Version(1,0,0), new Version (2,0,0)), 1); + assertEquals(TEST_VERSION.isBetween(new Version(2,0,0), new Version (1,0,0)), -1); + assertEquals(TEST_VERSION.isBetween(new Version(2,0,0), new Version (3,0,0)), -1); + + assertEquals(TEST_VERSION.isBetween(new Version(1,0,0), new Version (1,2,3)), 0); + assertEquals(TEST_VERSION.isBetween(new Version(1,2,3), new Version (3,2,3)), 0); + + assertEquals(TEST_VERSION.isBetween(new Version(1,2,3), new Version (1,2,3)), 0); + + } } |