summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilal <bilal@Bilals-MBP.localdomain>2018-05-01 17:08:55 -0400
committerBilal <bilal@Bilals-MBP.localdomain>2018-05-01 17:08:55 -0400
commit4aae4a690ea02aa11d7aed135438678dd750cfdf (patch)
tree6a4e68c616a80067e7f649e465961b0f10708b1a
parent2147963ab2aba4bad0e5a7fb14112c2feea79ae0 (diff)
downloadsdl_android-4aae4a690ea02aa11d7aed135438678dd750cfdf.tar.gz
Add unit tests
-rw-r--r--sdl_android/src/androidTest/assets/json/SetMediaClockTimer.json3
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java7
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java6
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java62
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java13
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java20
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java74
7 files changed, 166 insertions, 19 deletions
diff --git a/sdl_android/src/androidTest/assets/json/SetMediaClockTimer.json b/sdl_android/src/androidTest/assets/json/SetMediaClockTimer.json
index af1671200..57fbacfa0 100644
--- a/sdl_android/src/androidTest/assets/json/SetMediaClockTimer.json
+++ b/sdl_android/src/androidTest/assets/json/SetMediaClockTimer.json
@@ -13,7 +13,8 @@
"seconds":19,
"hours":12
},
- "updateMode":"COUNTDOWN"
+ "updateMode":"COUNTDOWN",
+ "enableSeek": true
}
},
"response":{
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java
index e31aedbe7..f30febd11 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java
@@ -722,20 +722,23 @@ public class RPCRequestFactoryTests extends TestCase {
public void testBuildSetMediaClockTimer () {
Integer hours = 0, minutes = 0, seconds = 0, testCorrelationID = 0;
+ Boolean enableSeek = true;
UpdateMode testMode = UpdateMode.COUNTUP;
SetMediaClockTimer testSMCT;
// Test -- buildSetMediaClockTimer(Integer hours, Integer minutes, Integer seconds, UpdateMode updateMode, Integer correlationID)
- testSMCT = RPCRequestFactory.buildSetMediaClockTimer(hours, minutes, seconds, testMode, testCorrelationID);
+ testSMCT = RPCRequestFactory.buildSetMediaClockTimer(hours, minutes, seconds, testMode, enableSeek, testCorrelationID);
assertEquals(Test.MATCH, hours, testSMCT.getStartTime().getHours());
assertEquals(Test.MATCH, minutes, testSMCT.getStartTime().getMinutes());
assertEquals(Test.MATCH, seconds, testSMCT.getStartTime().getSeconds());
assertEquals(Test.MATCH, testMode, testSMCT.getUpdateMode());
+ assertEquals(Test.MATCH, enableSeek, testSMCT.getEnableSeek());
assertEquals(Test.MATCH, testCorrelationID, testSMCT.getCorrelationID());
- testSMCT = RPCRequestFactory.buildSetMediaClockTimer(null, null, null, null, null);
+ testSMCT = RPCRequestFactory.buildSetMediaClockTimer(null, null, null, null, null, null);
assertNull(Test.NULL, testSMCT.getStartTime());
assertNull(Test.NULL, testSMCT.getUpdateMode());
+ assertNull(Test.NULL, testSMCT.getEnableSeek());
assertNotNull(Test.NOT_NULL, testSMCT.getCorrelationID());
// Test -- buildSetMediaClockTimer(UpdateMode updateMode, Integer correlationID)
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java
index b50f6f48d..1792b6802 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java
@@ -50,6 +50,7 @@ import com.smartdevicelink.proxy.rpc.OnKeyboardInput;
import com.smartdevicelink.proxy.rpc.OnLanguageChange;
import com.smartdevicelink.proxy.rpc.OnLockScreenStatus;
import com.smartdevicelink.proxy.rpc.OnPermissionsChange;
+import com.smartdevicelink.proxy.rpc.OnSeekMediaClockTimer;
import com.smartdevicelink.proxy.rpc.OnStreamRPC;
import com.smartdevicelink.proxy.rpc.OnSystemRequest;
import com.smartdevicelink.proxy.rpc.OnTBTClientState;
@@ -619,5 +620,10 @@ public class SdlProxyBaseTests extends AndroidTestCase{
public void onSendHapticDataResponse(SendHapticDataResponse response) {
Log.i(TAG, "SendHapticDataResponse response from SDL: " + response);
}
+
+ @Override
+ public void onSeekMediaClockTimer(OnSeekMediaClockTimer notification) {
+
+ }
}
}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java
new file mode 100644
index 000000000..4c7d97b38
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSeekMediaClockTimerTests.java
@@ -0,0 +1,62 @@
+package com.smartdevicelink.test.rpc.notifications;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.OnSeekMediaClockTimer;
+import com.smartdevicelink.proxy.rpc.StartTime;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.Test;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+
+public class OnSeekMediaClockTimerTests extends BaseRpcTests {
+ @Override
+ protected RPCMessage createMessage(){
+ OnSeekMediaClockTimer msg = new OnSeekMediaClockTimer();
+ msg.setSeekTime(Test.GENERAL_STARTTIME);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_NOTIFICATION;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.ON_SEEK_MEDIA_CLOCK_TIMER.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+ try {
+ result.put(OnSeekMediaClockTimer.KEY_SEEK_TIME, Test.JSON_STARTTIME);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ StartTime seekTime = ((OnSeekMediaClockTimer) msg).getSeekTime();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STARTTIME, seekTime);
+
+ // Invalid/Null Tests
+ OnSeekMediaClockTimer msg = new OnSeekMediaClockTimer();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getSeekTime());
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java
index 7d52bb75c..27234291b 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java
@@ -19,7 +19,7 @@ import com.smartdevicelink.test.json.rpc.JsonFileReader;
/**
* This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.rpc.SetMediaClockTimer}
+ * {@link com.smartdevicelink.proxy.rpc.SetMediaClockTimer}
*/
public class SetMediaClockTimerTests extends BaseRpcTests {
@@ -30,6 +30,7 @@ public class SetMediaClockTimerTests extends BaseRpcTests {
msg.setStartTime(Test.GENERAL_STARTTIME);
msg.setEndTime(Test.GENERAL_STARTTIME);
msg.setUpdateMode(Test.GENERAL_UPDATEMODE);
+ msg.setEnableSeek(Test.GENERAL_BOOLEAN);
return msg;
}
@@ -51,7 +52,8 @@ public class SetMediaClockTimerTests extends BaseRpcTests {
try {
result.put(SetMediaClockTimer.KEY_START_TIME, Test.JSON_STARTTIME);
result.put(SetMediaClockTimer.KEY_END_TIME, Test.JSON_STARTTIME);
- result.put(SetMediaClockTimer.KEY_UPDATE_MODE, Test.GENERAL_UPDATEMODE);
+ result.put(SetMediaClockTimer.KEY_UPDATE_MODE, Test.GENERAL_UPDATEMODE);
+ result.put(SetMediaClockTimer.KEY_ENABLE_SEEK, Test.GENERAL_BOOLEAN);
} catch (JSONException e) {
fail(Test.JSON_FAIL);
}
@@ -67,12 +69,14 @@ public class SetMediaClockTimerTests extends BaseRpcTests {
StartTime testStartTime = ( (SetMediaClockTimer) msg ).getStartTime();
StartTime testEndTime = ( (SetMediaClockTimer) msg ).getEndTime();
UpdateMode testUpdateMode = ( (SetMediaClockTimer) msg ).getUpdateMode();
+ Boolean testEnableSeek = ( (SetMediaClockTimer) msg ).getEnableSeek();
// Valid Tests
assertEquals(Test.MATCH, Test.GENERAL_UPDATEMODE, testUpdateMode);
assertTrue(Test.TRUE, Validator.validateStartTime(Test.GENERAL_STARTTIME, testStartTime));
assertTrue(Test.TRUE, Validator.validateStartTime(Test.GENERAL_STARTTIME, testEndTime));
-
+ assertEquals(Test.MATCH, Boolean.valueOf(Test.GENERAL_BOOLEAN), testEnableSeek);
+
// Invalid/Null Tests
SetMediaClockTimer msg = new SetMediaClockTimer();
assertNotNull(Test.NOT_NULL, msg);
@@ -81,6 +85,7 @@ public class SetMediaClockTimerTests extends BaseRpcTests {
assertNull(Test.NULL, msg.getStartTime());
assertNull(Test.NULL, msg.getEndTime());
assertNull(Test.NULL, msg.getUpdateMode());
+ assertNull(Test.NULL, msg.getEnableSeek());
}
/**
@@ -110,6 +115,8 @@ public class SetMediaClockTimerTests extends BaseRpcTests {
StartTime referenceEndTime = new StartTime(JsonRPCMarshaller.deserializeJSONObject(endTime));
assertTrue(Test.TRUE, Validator.validateStartTime(referenceEndTime, cmd.getEndTime()));
assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, SetMediaClockTimer.KEY_UPDATE_MODE), cmd.getUpdateMode().toString());
+
+ assertEquals(Test.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SetMediaClockTimer.KEY_ENABLE_SEEK), cmd.getEnableSeek());
} catch (JSONException e) {
fail(Test.JSON_FAIL);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java
index e249839d5..80ddf36b0 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequestFactory.java
@@ -691,10 +691,10 @@ public class RPCRequestFactory {
return req;
}
-
+
public static SetMediaClockTimer buildSetMediaClockTimer(Integer hours,
- Integer minutes, Integer seconds, UpdateMode updateMode,
- Integer correlationID) {
+ Integer minutes, Integer seconds, UpdateMode updateMode,
+ Boolean enableSeek, Integer correlationID) {
SetMediaClockTimer msg = new SetMediaClockTimer();
if (hours != null || minutes != null || seconds != null) {
@@ -706,10 +706,21 @@ public class RPCRequestFactory {
}
msg.setUpdateMode(updateMode);
+ msg.setEnableSeek(enableSeek);
msg.setCorrelationID(correlationID);
return msg;
}
+
+ @Deprecated
+ public static SetMediaClockTimer buildSetMediaClockTimer(Integer hours,
+ Integer minutes, Integer seconds, UpdateMode updateMode,
+ Integer correlationID) {
+
+ SetMediaClockTimer msg = buildSetMediaClockTimer(hours, minutes, seconds, updateMode, null, correlationID);
+
+ return msg;
+ }
@Deprecated
public static SetMediaClockTimer buildSetMediaClockTimer(
@@ -717,9 +728,10 @@ public class RPCRequestFactory {
Integer hours = null;
Integer minutes = null;
Integer seconds = null;
+ Boolean enableSeek = null;
SetMediaClockTimer msg = buildSetMediaClockTimer(hours, minutes,
- seconds, updateMode, correlationID);
+ seconds, updateMode, enableSeek, correlationID);
return msg;
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
index 9b76f51cd..eaaa81ae6 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -5422,8 +5422,29 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
sendRPCRequest(req);
}
-
-
+
+ /**
+ * Sends a SetMediaClockTimer RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param hours integer for hours
+ * @param minutes integer for minutes
+ * @param seconds integer for seconds
+ * @param updateMode mode in which the media clock timer should be updated
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @param enableSeek a Boolean representing whether seek media clock timer functionality will be available
+ * @throws SdlException if an unrecoverable error is encountered
+ */
+ @SuppressWarnings("unused")
+ public void setMediaClockTimer(Integer hours,
+ Integer minutes, Integer seconds, UpdateMode updateMode,
+ Boolean enableSeek, Integer correlationID) throws SdlException {
+
+ SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(hours,
+ minutes, seconds, updateMode, null, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
/**
* Sends a SetMediaClockTimer RPCRequest to SDL. Responses are captured through callback on IProxyListener.
*
@@ -5435,19 +5456,37 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @throws SdlException if an unrecoverable error is encountered
*/
@SuppressWarnings("unused")
+ @Deprecated
public void setMediaClockTimer(Integer hours,
Integer minutes, Integer seconds, UpdateMode updateMode,
Integer correlationID) throws SdlException {
SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(hours,
- minutes, seconds, updateMode, correlationID);
+ minutes, seconds, updateMode, null, correlationID);
sendRPCRequest(msg);
}
-
+
/**
* Pauses the media clock. Responses are captured through callback on IProxyListener.
- *
+ *
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @param enableSeek a Boolean representing whether seek media clock timer functionality will be available
+ * @throws SdlException if an unrecoverable error is encountered
+ */
+ @SuppressWarnings("unused")
+ public void pauseMediaClockTimer(Integer correlationID, Boolean enableSeek)
+ throws SdlException {
+
+ SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
+ 0, 0, UpdateMode.PAUSE, enableSeek, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Pauses the media clock. Responses are captured through callback on IProxyListener.
+ *
* @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
* @throws SdlException if an unrecoverable error is encountered
*/
@@ -5456,11 +5495,28 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
throws SdlException {
SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
- 0, 0, UpdateMode.PAUSE, correlationID);
+ 0, 0, UpdateMode.PAUSE, null, correlationID);
sendRPCRequest(msg);
}
-
+
+ /**
+ * Resumes the media clock. Responses are captured through callback on IProxyListener.
+ *
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @param enableSeek a Boolean representing whether seek media clock timer functionality will be available
+ * @throws SdlException if an unrecoverable error is encountered
+ */
+ @SuppressWarnings("unused")
+ public void resumeMediaClockTimer(Integer correlationID, Boolean enableSeek)
+ throws SdlException {
+
+ SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
+ 0, 0, UpdateMode.RESUME, enableSeek, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
/**
* Resumes the media clock. Responses are captured through callback on IProxyListener.
*
@@ -5472,11 +5528,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
throws SdlException {
SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
- 0, 0, UpdateMode.RESUME, correlationID);
+ 0, 0, UpdateMode.RESUME, null, correlationID);
sendRPCRequest(msg);
}
-
+
/**
* Clears the media clock. Responses are captured through callback on IProxyListener.
*