Skip to content

Commit 33d48a4

Browse files
author
Robert Henigan
authored
Merge pull request #1503 from smartdevicelink/feature/fix_todos
Fix some todo comments
2 parents 0c80108 + b2cdeca commit 33d48a4

5 files changed

Lines changed: 31 additions & 14 deletions

File tree

android/sdl_android/src/androidTest/java/com/smartdevicelink/protocol/SdlPacketTests.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
import com.livio.BSON.BsonEncoder;
66
import com.smartdevicelink.protocol.enums.ControlFrameTags;
7+
import com.smartdevicelink.test.TestValues;
8+
import com.smartdevicelink.transport.enums.TransportType;
9+
import com.smartdevicelink.transport.utl.TransportRecord;
710

811
import org.junit.Test;
912
import org.junit.runner.RunWith;
@@ -15,7 +18,6 @@
1518

1619
@RunWith(AndroidJUnit4.class)
1720
public class SdlPacketTests {
18-
//TODO: Add tests to cover other parts of SdlPacket class
1921

2022
// Test variables
2123
private final int TEST_HASH_ID = 65537;
@@ -43,9 +45,19 @@ public void testNull(){
4345
String tag = "hello";
4446

4547
SdlPacket sdlPacket = new SdlPacket();
48+
4649
assertNull(sdlPacket.getTag(tag));
4750
sdlPacket.setPayload(testPayload);
4851
assertEquals(sdlPacket.getTag("hello"),"world");
52+
53+
assertEquals(1, sdlPacket.getVersion());
54+
55+
sdlPacket.setPriorityCoefficient(TestValues.GENERAL_INT);
56+
assertEquals(TestValues.GENERAL_INT, sdlPacket.getPrioirtyCoefficient());
57+
58+
sdlPacket.setTransportRecord(new TransportRecord(TransportType.TCP, TestValues.GENERAL_STRING));
59+
assertEquals(TransportType.TCP, sdlPacket.getTransportRecord().getType());
60+
assertEquals(TestValues.GENERAL_STRING, sdlPacket.getTransportRecord().getAddress());
4961
}
5062

5163
@Test

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/heartbeat/HeartbeatMonitorTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
* {@link com.smartdevicelink.protocol.heartbeat.HeartbeatMonitor}
1515
*/
1616
public class HeartbeatMonitorTests extends TestCase {
17-
18-
// TODO : Proper thread testing.
19-
17+
2018
private HeartbeatMonitor monitor = new HeartbeatMonitor();
2119
private Runnable testRunnable;
2220
private Timer timer;

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.smartdevicelink.proxy.RPCMessage;
66
import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse;
77
import com.smartdevicelink.proxy.rpc.VehicleDataResult;
8+
import com.smartdevicelink.proxy.rpc.enums.Result;
89
import com.smartdevicelink.proxy.rpc.enums.VehicleDataType;
910
import com.smartdevicelink.test.BaseRpcTests;
1011
import com.smartdevicelink.test.JsonUtils;
@@ -30,13 +31,12 @@
3031
* {@link com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse}
3132
*/
3233
public class SubscribeVehicleDataResponseTest extends BaseRpcTests {
33-
34-
// TODO : Test different result codes.
3534

3635
@Override
3736
protected RPCMessage createMessage() {
3837
SubscribeVehicleDataResponse msg = new SubscribeVehicleDataResponse();
3938

39+
msg.setResultCode(TestValues.GENERAL_RESULT);
4040
msg.setSpeed(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_SPEED.ordinal()));
4141
msg.setRpm(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_RPM.ordinal()));
4242
msg.setExternalTemperature(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EXTERNTEMP.ordinal()));
@@ -93,7 +93,8 @@ protected JSONObject getExpectedParameters(int sdlVersion) {
9393
// Note: If the key values stored in SubscribeVehicleDataResponse
9494
// were to be in a list then this could be easily looped through
9595
// instead of individually set.
96-
96+
97+
result.put(SubscribeVehicleDataResponse.KEY_RESULT_CODE, TestValues.GENERAL_RESULT);
9798
result.put(SubscribeVehicleDataResponse.KEY_SPEED, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_SPEED.ordinal()).serializeJSON());
9899
result.put(SubscribeVehicleDataResponse.KEY_RPM, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_RPM.ordinal()).serializeJSON());
99100
result.put(SubscribeVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EXTERNTEMP.ordinal()).serializeJSON());
@@ -140,6 +141,7 @@ protected JSONObject getExpectedParameters(int sdlVersion) {
140141
@Test
141142
public void testRpcValues () {
142143
// Test Values
144+
Result testResult = ( (SubscribeVehicleDataResponse) msg ).getResultCode();
143145
VehicleDataResult testGps = ( (SubscribeVehicleDataResponse) msg ).getGps();
144146
VehicleDataResult testOdometer = ( (SubscribeVehicleDataResponse) msg ).getOdometer();
145147
VehicleDataResult testTirePressure = ( (SubscribeVehicleDataResponse) msg ).getTirePressure();
@@ -175,6 +177,7 @@ public void testRpcValues () {
175177
VehicleDataResult testOEMCustomVehicleData = ( (SubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME);
176178

177179
// Valid Tests
180+
assertTrue(TestValues.TRUE, testResult.equals(TestValues.GENERAL_RESULT));
178181
assertTrue(TestValues.TRUE, testGps.getDataType().equals(VehicleDataType.VEHICLEDATA_GPS));
179182
assertTrue(TestValues.TRUE, testOdometer.getDataType().equals(VehicleDataType.VEHICLEDATA_ODOMETER));
180183
assertTrue(TestValues.TRUE, testTirePressure.getDataType().equals(VehicleDataType.VEHICLEDATA_TIREPRESSURE));
@@ -213,7 +216,8 @@ public void testRpcValues () {
213216
SubscribeVehicleDataResponse msg = new SubscribeVehicleDataResponse();
214217
assertNotNull("Null object creation failed.", msg);
215218
testNullBase(msg);
216-
219+
220+
assertNull(TestValues.NULL, msg.getResultCode());
217221
assertNull(TestValues.NULL, msg.getAccPedalPosition());
218222
assertNull(TestValues.NULL, msg.getAirbagStatus());
219223
assertNull(TestValues.NULL, msg.getBeltStatus());

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse;
88
import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleDataResponse;
99
import com.smartdevicelink.proxy.rpc.VehicleDataResult;
10+
import com.smartdevicelink.proxy.rpc.enums.Result;
1011
import com.smartdevicelink.proxy.rpc.enums.VehicleDataType;
1112
import com.smartdevicelink.test.BaseRpcTests;
1213
import com.smartdevicelink.test.JsonUtils;
@@ -33,12 +34,11 @@
3334
*/
3435
public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests {
3536

36-
// TODO : Test different result codes.
37-
3837
@Override
3938
protected RPCMessage createMessage() {
4039
UnsubscribeVehicleDataResponse msg = new UnsubscribeVehicleDataResponse();
4140

41+
msg.setResultCode(TestValues.GENERAL_RESULT);
4242
msg.setSpeed(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_SPEED.ordinal()));
4343
msg.setRpm(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_RPM.ordinal()));
4444
msg.setExternalTemperature(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EXTERNTEMP.ordinal()));
@@ -95,7 +95,8 @@ protected JSONObject getExpectedParameters(int sdlVersion) {
9595
// Note: If the key values stored in SubscribeVehicleDataResponse
9696
// were to be in a list then this could be easily looped through
9797
// instead of individually set.
98-
98+
99+
result.put(SubscribeVehicleDataResponse.KEY_RESULT_CODE, TestValues.GENERAL_RESULT);
99100
result.put(SubscribeVehicleDataResponse.KEY_SPEED, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_SPEED.ordinal()).serializeJSON());
100101
result.put(SubscribeVehicleDataResponse.KEY_RPM, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_RPM.ordinal()).serializeJSON());
101102
result.put(SubscribeVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EXTERNTEMP.ordinal()).serializeJSON());
@@ -143,6 +144,7 @@ protected JSONObject getExpectedParameters(int sdlVersion) {
143144
@Test
144145
public void testRpcValues () {
145146
// Test Values
147+
Result testResult = ( (UnsubscribeVehicleDataResponse) msg ).getResultCode();
146148
VehicleDataResult testGps = ( (UnsubscribeVehicleDataResponse) msg ).getGps();
147149
VehicleDataResult testOdometer = ( (UnsubscribeVehicleDataResponse) msg ).getOdometer();
148150
VehicleDataResult testTirePressure = ( (UnsubscribeVehicleDataResponse) msg ).getTirePressure();
@@ -178,6 +180,7 @@ public void testRpcValues () {
178180
VehicleDataResult testOemCustomData = ( (UnsubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME);
179181

180182
// Valid Tests
183+
assertTrue(TestValues.TRUE, testResult.equals(TestValues.GENERAL_RESULT));
181184
assertTrue(TestValues.TRUE, testGps.getDataType().equals(VehicleDataType.VEHICLEDATA_GPS));
182185
assertTrue(TestValues.TRUE, testOdometer.getDataType().equals(VehicleDataType.VEHICLEDATA_ODOMETER));
183186
assertTrue(TestValues.TRUE, testTirePressure.getDataType().equals(VehicleDataType.VEHICLEDATA_TIREPRESSURE));
@@ -216,8 +219,9 @@ public void testRpcValues () {
216219
UnsubscribeVehicleDataResponse msg = new UnsubscribeVehicleDataResponse();
217220
assertNotNull("Null object creation failed.", msg);
218221
testNullBase(msg);
219-
220-
assertNull(TestValues.NULL, msg.getAccPedalPosition());
222+
223+
assertNull(TestValues.NULL, msg.getResultCode());
224+
assertNull(TestValues.NULL, msg.getAccPedalPosition());
221225
assertNull(TestValues.NULL, msg.getAirbagStatus());
222226
assertNull(TestValues.NULL, msg.getBeltStatus());
223227
assertNull(TestValues.NULL, msg.getDriverBraking());

base/src/main/java/com/smartdevicelink/session/BaseSdlSession.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ public void onProtocolMessageReceived(ProtocolMessage msg) {
289289

290290
@Override
291291
public void onProtocolError(String info, Exception e) {
292-
//TODO is there anything to pass forward here?
293292
DebugTool.logError(TAG,"on protocol error", e);
294293
}
295294

0 commit comments

Comments
 (0)