diff options
author | RHenigan <heniganr1@gmail.com> | 2020-08-13 14:24:20 -0400 |
---|---|---|
committer | RHenigan <heniganr1@gmail.com> | 2020-08-13 14:24:20 -0400 |
commit | 292fe6005a1e863be1c5e6829574a3b89ba126ac (patch) | |
tree | 90e2a9ac369f7d79b143c72eef6fb1114a298b9a /android/sdl_android/src/androidTest/java/com/smartdevicelink/test | |
parent | a52d89561a7d8d144d376c0261c57066f99546b2 (diff) | |
parent | 25a849c9c1e852c24356f569f8877e7bf5193f0b (diff) | |
download | sdl_android-292fe6005a1e863be1c5e6829574a3b89ba126ac.tar.gz |
Merge branch 'develop' into feature/0268_MainMenuUpdating_Pagination
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink/test')
153 files changed, 856 insertions, 1513 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java index db9d7f5b2..a8aec30ac 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java @@ -1,6 +1,6 @@ package com.smartdevicelink.test; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.RPCRequest; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java index 11d2dbb7d..cc5b2f7ab 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java @@ -9,7 +9,7 @@ import com.smartdevicelink.transport.TCPTransportConfig; import junit.framework.TestCase; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static org.mockito.Mockito.mock; /** @@ -19,7 +19,7 @@ import static org.mockito.Mockito.mock; public class SdlSessionTests extends TestCase { public void testServiceListeners(){ - SdlSession session = new SdlSession(new MockInterfaceBroker(), new MultiplexTransportConfig(getTargetContext(),"19216801")); + SdlSession session = new SdlSession(new MockInterfaceBroker(), new MultiplexTransportConfig(getInstrumentation().getTargetContext(),"19216801")); ISdlServiceListener test = new ISdlServiceListener() { @Override public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java index f5cc9827d..b76fbade1 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java @@ -37,6 +37,7 @@ import com.smartdevicelink.proxy.rpc.DateTime; import com.smartdevicelink.proxy.rpc.DeviceInfo; import com.smartdevicelink.proxy.rpc.DisplayCapabilities; import com.smartdevicelink.proxy.rpc.DisplayCapability; +import com.smartdevicelink.proxy.rpc.DriverDistractionCapability; import com.smartdevicelink.proxy.rpc.EqualizerSettings; import com.smartdevicelink.proxy.rpc.Grid; import com.smartdevicelink.proxy.rpc.HMICapabilities; @@ -108,6 +109,8 @@ import com.smartdevicelink.proxy.rpc.WeatherData; import com.smartdevicelink.proxy.rpc.WeatherServiceData; import com.smartdevicelink.proxy.rpc.WeatherServiceManifest; import com.smartdevicelink.proxy.rpc.WindowCapability; +import com.smartdevicelink.proxy.rpc.WindowState; +import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.WindowTypeCapabilities; import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus; import com.smartdevicelink.proxy.rpc.enums.AppHMIType; @@ -294,6 +297,7 @@ public class TestValues { public static final SoftButtonType GENERAL_SOFTBUTTONTYPE = SoftButtonType.SBT_BOTH; public static final MassageZone GENERAL_MASSAGEZONE = MassageZone.LUMBAR; public static final MassageMode GENERAL_MASSAGEMODE = MassageMode.HIGH; + public static final WindowStatus GENERAL_WINDOW_STATUS = new WindowStatus(); public static final MassageCushion GENERAL_MASSAGECUSHION = MassageCushion.BACK_BOLSTERS; public static final SeatMemoryActionType GENERAL_SEATMEMORYACTIONTYPE = SeatMemoryActionType.SAVE; public static final SupportedSeat GENERAL_SUPPORTEDSEAT = SupportedSeat.DRIVER; @@ -339,6 +343,7 @@ public class TestValues { public static final AppInterfaceUnregisteredReason GENERAL_APPINTERFACEUNREGISTEREDREASON = AppInterfaceUnregisteredReason.BLUETOOTH_OFF; public static final SystemCapabilityType GENERAL_SYSTEMCAPABILITYTYPE = SystemCapabilityType.NAVIGATION; public static final NavigationCapability GENERAL_NAVIGATIONCAPABILITY = new NavigationCapability(); + public static final DriverDistractionCapability GENERAL_DRIVERDISTRACTIONCAPABILITY = new DriverDistractionCapability(); public static final PhoneCapability GENERAL_PHONECAPABILITY = new PhoneCapability(); public static final RemoteControlCapabilities GENERAL_REMOTECONTROLCAPABILITIES = new RemoteControlCapabilities(); public static final SystemCapability GENERAL_SYSTEMCAPABILITY = new SystemCapability(); @@ -435,6 +440,10 @@ public class TestValues { public static final SeatLocation GENERAL_SEAT_LOCATION = new SeatLocation(); public static final ModuleInfo GENERAL_MODULE_INFO = new ModuleInfo(); public static final WindowType GENERAL_WINDOWTYPE = WindowType.MAIN; + public static final Grid GENERAL_LOCATION_GRID = new Grid(2, 3); + public static final WindowState GENERAL_WINDOW_STATE = new WindowState(2, 3); + public static final Integer GENERAL_APPROX_POSITION = new Integer(3); + public static final Integer GENERAL_DEVIATION = new Integer(2); public static final List<Long> GENERAL_LONG_LIST = Arrays.asList(new Long[]{ 1L, 2L }); public static final List<Turn> GENERAL_TURN_LIST = new ArrayList<Turn>(); public static final List<Choice> GENERAL_CHOICE_LIST = new ArrayList<Choice>(); @@ -1115,6 +1124,8 @@ public class TestValues { GENERAL_MODULE_INFO.setModuleServiceArea(TestValues.GENERAL_GRID); GENERAL_MODULE_INFO.setMultipleAccessAllowance(TestValues.GENERAL_BOOLEAN); + GENERAL_WINDOW_STATUS.setLocation(TestValues.GENERAL_GRID); + GENERAL_WINDOW_STATUS.setState(TestValues.GENERAL_WINDOW_STATE); try { JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_ALLOWED, GENERAL_HMILEVEL_LIST); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java index cbc79c9f1..9cf1fdd85 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java @@ -1319,6 +1319,31 @@ public class Validator{ return true; } + public static boolean validateDriverDistractionCapability(DriverDistractionCapability driverDistractionCapability1, DriverDistractionCapability driverDistractionCapability2) { + if (driverDistractionCapability1 == null) { + return (driverDistractionCapability1 == null); + } + if (driverDistractionCapability2 == null) { + return (driverDistractionCapability2 == null); + } + + if (driverDistractionCapability1.getMenuLength() != driverDistractionCapability2.getMenuLength()) { + log("validateDriverDistractionCapability", + "menuLength " + driverDistractionCapability1.getMenuLength() + " didn't match menuLength " + driverDistractionCapability2.getMenuLength() + + "."); + return false; + } + + if (driverDistractionCapability1.getSubMenuDepth() != driverDistractionCapability2.getSubMenuDepth()) { + log("validateDriverDistractionCapability", + "subMenuDepth " + driverDistractionCapability1.getSubMenuDepth() + " didn't match subMenuDepth " + driverDistractionCapability2.getSubMenuDepth() + + "."); + return false; + } + + return true; + } + public static boolean validatePhoneCapability(PhoneCapability phoneCapability1, PhoneCapability phoneCapability2){ if(phoneCapability1 == null){ return ( phoneCapability2 == null ); @@ -3801,4 +3826,67 @@ public class Validator{ } return validateGrid(cap1.getGrid(), cap2.getGrid()); } + + public static boolean validateWindowStatuses(List<WindowStatus> item1, List<WindowStatus> item2) { + if (item1 == null) { + return ( item2 == null ); + } + if (item2 == null) { + return ( item1 == null ); + } + + if (item1.size() != item2.size()) { + return false; + } + + Iterator<WindowStatus> iterator1 = item1.iterator(); + Iterator<WindowStatus> iterator2 = item2.iterator(); + + while(iterator1.hasNext() && iterator2.hasNext()){ + WindowStatus windowStatus1 = iterator1.next(); + WindowStatus windowStatus2 = iterator2.next(); + + if(!validateWindowStatus(windowStatus1, windowStatus2)){ + return false; + } + } + + return true; + } + + public static boolean validateWindowStatus(WindowStatus item1, WindowStatus item2) { + if (item1 == null) { + return ( item2 == null ); + } + if (item2 == null) { + return ( item1 == null ); + } + + if (!validateWindowStates(item1.getState(), item2.getState())) { + return false; + } + if (!validateGrid(item1.getLocation(), item2.getLocation())) { + return false; + } + + return true; + } + + public static boolean validateWindowStates (WindowState item1, WindowState item2) { + if (item1 == null) { + return ( item2 == null ); + } + if (item2 == null) { + return ( item1 == null ); + } + + Integer approxPosition1 = item1.getApproximatePosition(); + Integer approxPosition2 = item2.getApproximatePosition(); + + Integer deviation1 = item1.getDeviation(); + Integer deviation2 = item2.getDeviation(); + + + return approxPosition1.equals(approxPosition2) && deviation1.equals(deviation2); + } } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java index 729f1e498..f200b46e7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java @@ -10,11 +10,14 @@ import com.smartdevicelink.proxy.rpc.EmergencyEvent; import com.smartdevicelink.proxy.rpc.FuelRange; import com.smartdevicelink.proxy.rpc.GPSData; import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse; +import com.smartdevicelink.proxy.rpc.Grid; import com.smartdevicelink.proxy.rpc.HeadLampStatus; import com.smartdevicelink.proxy.rpc.MyKey; import com.smartdevicelink.proxy.rpc.OnVehicleData; import com.smartdevicelink.proxy.rpc.SingleTireStatus; import com.smartdevicelink.proxy.rpc.TireStatus; +import com.smartdevicelink.proxy.rpc.WindowState; +import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus; import com.smartdevicelink.proxy.rpc.enums.CarModeStatus; import com.smartdevicelink.proxy.rpc.enums.CompassDirection; @@ -72,12 +75,15 @@ public class VehicleDataHelper{ public static final AirbagStatus AIRBAG_STATUS = new AirbagStatus(); public static final EmergencyEvent EMERGENCY_EVENT = new EmergencyEvent(); public static final ClusterModeStatus CLUSTER_MODE_STATUS = new ClusterModeStatus(); + public static final WindowStatus WINDOW_STATUS = new WindowStatus(); + public static final List<WindowStatus> WINDOW_STATUS_LIST = new ArrayList<>(1); public static final MyKey MY_KEY = new MyKey(); public static final FuelRange FUEL_RANGE = new FuelRange(); public static final List<FuelRange> FUEL_RANGE_LIST = new ArrayList<FuelRange>(1); public static final TurnSignal TURN_SIGNAL = TurnSignal.OFF; public static final ElectronicParkBrakeStatus ELECTRONIC_PARK_BRAKE_STATUS = ElectronicParkBrakeStatus.CLOSED; public static final String OEM_CUSTOM_VEHICLE_DATA_STATE = "oemCustomVehicleDataState"; + public static final Boolean HANDS_OFF_STEERING = Boolean.TRUE; //other variables inside some of the above objects // tire status @@ -168,7 +174,7 @@ public class VehicleDataHelper{ public static final VehicleDataEventStatus AIRBAG_STATUS_DRIVER_KNEE_DEPLOYED = VehicleDataEventStatus.NO; public static final VehicleDataEventStatus AIRBAG_STATUS_PASSENGER_SIDE_DEPLOYED = VehicleDataEventStatus.YES; public static final VehicleDataEventStatus AIRBAG_STATUS_PASSENGER_KNEE_DEPLOYED = VehicleDataEventStatus.NO; - + // emergency event public static final EmergencyEventType EMERGENCY_EVENT_TYPE = EmergencyEventType.FRONTAL; public static final FuelCutoffStatus EMERGENCY_EVENT_FUEL_CUTOFF_STATUS = FuelCutoffStatus.TERMINATE_FUEL; @@ -190,6 +196,10 @@ public class VehicleDataHelper{ public static final FuelType FUEL_RANGE_TYPE = FuelType.GASOLINE; public static final Float FUEL_RANGE_RANGE = TestValues.GENERAL_FLOAT; + // WindowStatus + public static final Grid LOCATION_GRID = TestValues.GENERAL_LOCATION_GRID; + public static final WindowState WINDOW_STATE = TestValues.GENERAL_WINDOW_STATE; + public static final JSONArray JSON_FUEL_RANGE = new JSONArray(); //the OnVehicleData which stores all the information above @@ -320,6 +330,10 @@ public class VehicleDataHelper{ FUEL_RANGE.setRange(FUEL_RANGE_RANGE); FUEL_RANGE_LIST.add(FUEL_RANGE); + //WINDOW_STATUS and WINDOW_STATUS_LIST set up + WINDOW_STATUS.setLocation(LOCATION_GRID); + WINDOW_STATUS.setState(WINDOW_STATE); + WINDOW_STATUS_LIST.add(WINDOW_STATUS); // FUEL_RANGE json array set up try { JSON_FUEL_RANGE.put(FUEL_RANGE.serializeJSON()); @@ -357,8 +371,9 @@ public class VehicleDataHelper{ VEHICLE_DATA.setFuelRange(FUEL_RANGE_LIST); VEHICLE_DATA.setTurnSignal(TURN_SIGNAL); VEHICLE_DATA.setElectronicParkBrakeStatus(ELECTRONIC_PARK_BRAKE_STATUS); + VEHICLE_DATA.setWindowStatus(WINDOW_STATUS_LIST); VEHICLE_DATA.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, OEM_CUSTOM_VEHICLE_DATA_STATE); - + VEHICLE_DATA.setHandsOffSteering(HANDS_OFF_STEERING); //set up the GetVehicleDataResponse object VEHICLE_DATA_RESPONSE.setSpeed(SPEED); VEHICLE_DATA_RESPONSE.setRpm(RPM); @@ -389,7 +404,9 @@ public class VehicleDataHelper{ VEHICLE_DATA_RESPONSE.setFuelRange(FUEL_RANGE_LIST); VEHICLE_DATA_RESPONSE.setTurnSignal(TURN_SIGNAL); VEHICLE_DATA_RESPONSE.setElectronicParkBrakeStatus(ELECTRONIC_PARK_BRAKE_STATUS); + VEHICLE_DATA_RESPONSE.setWindowStatus(WINDOW_STATUS_LIST); VEHICLE_DATA_RESPONSE.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, OEM_CUSTOM_VEHICLE_DATA_STATE); + VEHICLE_DATA_RESPONSE.setHandsOffSteering(HANDS_OFF_STEERING); } private VehicleDataHelper(){} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/BinaryFrameHeaderTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/BinaryFrameHeaderTests.java index 733192fdd..50f949e3d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/BinaryFrameHeaderTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/BinaryFrameHeaderTests.java @@ -1,6 +1,6 @@ package com.smartdevicelink.test.protocol; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.protocol.BinaryFrameHeader; import com.smartdevicelink.protocol.enums.FunctionID; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestTest.java index bcf319383..5972dc829 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestTest.java @@ -1,7 +1,7 @@ package com.smartdevicelink.test.proxy; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.proxy.rpc.GetSystemCapability; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java index 385362be8..da8b48d8c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java @@ -1,7 +1,7 @@ package com.smartdevicelink.test.proxy; import android.content.Context; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import android.telephony.TelephonyManager; import android.util.Log; @@ -46,7 +46,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; @RunWith(AndroidJUnit4.class) public class SdlProxyBaseTests { @@ -60,8 +60,8 @@ public class SdlProxyBaseTests { @Test public void testNullSdlProxyConfigurationResources() { SdlProxyALM proxy = null; - SdlProxyBuilder.Builder builder = new SdlProxyBuilder.Builder(mock(IProxyListenerALM.class), "appId", "appName", true, getTargetContext()); - SdlProxyConfigurationResources config = new SdlProxyConfigurationResources("path", (TelephonyManager) getTargetContext().getSystemService(Context.TELEPHONY_SERVICE)); + SdlProxyBuilder.Builder builder = new SdlProxyBuilder.Builder(mock(IProxyListenerALM.class), "appId", "appName", true, getInstrumentation().getTargetContext()); + SdlProxyConfigurationResources config = new SdlProxyConfigurationResources("path", (TelephonyManager) getInstrumentation().getTargetContext().getSystemService(Context.TELEPHONY_SERVICE)); //Construct with a non-null SdlProxyConfigurationResources builder.setSdlProxyConfigurationResources(config); try { @@ -127,14 +127,14 @@ public class SdlProxyBaseTests { @Test public void testRemoteDisplayStreaming(){ SdlProxyALM proxy = null; - SdlProxyBuilder.Builder builder = new SdlProxyBuilder.Builder(mock(IProxyListenerALM.class), "appId", "appName", true, getTargetContext()); + SdlProxyBuilder.Builder builder = new SdlProxyBuilder.Builder(mock(IProxyListenerALM.class), "appId", "appName", true, getInstrumentation().getTargetContext()); try{ proxy = builder.build(); // public void startRemoteDisplayStream(Context context, final Class<? extends SdlRemoteDisplay> remoteDisplay, final VideoStreamingParameters parameters, final boolean encrypted){ Method m = SdlProxyALM.class.getDeclaredMethod("startRemoteDisplayStream", Context.class, SdlRemoteDisplay.class, VideoStreamingParameters.class, boolean.class); assertNotNull(m); m.setAccessible(true); - m.invoke(proxy,getTargetContext(), SdlRemoteDisplayTest.MockRemoteDisplay.class, (VideoStreamingParameters)null, false); + m.invoke(proxy,getInstrumentation().getTargetContext(), SdlRemoteDisplayTest.MockRemoteDisplay.class, (VideoStreamingParameters)null, false); assert true; }catch (Exception e){ diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java deleted file mode 100644 index 3ddcdc519..000000000 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java +++ /dev/null @@ -1,1101 +0,0 @@ -package com.smartdevicelink.test.proxy; - -import android.support.test.runner.AndroidJUnit4; -import android.util.SparseArray; - -import com.livio.taskmaster.Taskmaster; -import com.smartdevicelink.managers.ManagerUtility; -import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.RPCMessage; -import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.proxy.SystemCapabilityManager; -import com.smartdevicelink.proxy.interfaces.IAudioStreamListener; -import com.smartdevicelink.proxy.interfaces.ISdl; -import com.smartdevicelink.proxy.interfaces.ISdlServiceListener; -import com.smartdevicelink.proxy.interfaces.IVideoStreamListener; -import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener; -import com.smartdevicelink.proxy.rpc.AppServiceCapability; -import com.smartdevicelink.proxy.rpc.AppServicesCapabilities; -import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities; -import com.smartdevicelink.proxy.rpc.ButtonCapabilities; -import com.smartdevicelink.proxy.rpc.DisplayCapabilities; -import com.smartdevicelink.proxy.rpc.DisplayCapability; -import com.smartdevicelink.proxy.rpc.GetSystemCapability; -import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse; -import com.smartdevicelink.proxy.rpc.HMICapabilities; -import com.smartdevicelink.proxy.rpc.OnHMIStatus; -import com.smartdevicelink.proxy.rpc.OnSystemCapabilityUpdated; -import com.smartdevicelink.proxy.rpc.PhoneCapability; -import com.smartdevicelink.proxy.rpc.PresetBankCapabilities; -import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse; -import com.smartdevicelink.proxy.rpc.SdlMsgVersion; -import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse; -import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities; -import com.smartdevicelink.proxy.rpc.SystemCapability; -import com.smartdevicelink.proxy.rpc.VideoStreamingCapability; -import com.smartdevicelink.proxy.rpc.WindowCapability; -import com.smartdevicelink.proxy.rpc.WindowTypeCapabilities; -import com.smartdevicelink.proxy.rpc.enums.AppServiceType; -import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState; -import com.smartdevicelink.proxy.rpc.enums.DisplayType; -import com.smartdevicelink.proxy.rpc.enums.HMILevel; -import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities; -import com.smartdevicelink.proxy.rpc.enums.ImageType; -import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat; -import com.smartdevicelink.proxy.rpc.enums.PredefinedWindows; -import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech; -import com.smartdevicelink.proxy.rpc.enums.Result; -import com.smartdevicelink.proxy.rpc.enums.ServiceUpdateReason; -import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; -import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; -import com.smartdevicelink.proxy.rpc.enums.SystemContext; -import com.smartdevicelink.proxy.rpc.enums.WindowType; -import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; -import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener; -import com.smartdevicelink.streaming.audio.AudioStreamingCodec; -import com.smartdevicelink.streaming.audio.AudioStreamingParams; -import com.smartdevicelink.streaming.video.VideoStreamingParameters; -import com.smartdevicelink.test.TestValues; -import com.smartdevicelink.test.Validator; -import com.smartdevicelink.test.utl.AppServiceFactory; -import com.smartdevicelink.util.CorrelationIdGenerator; -import com.smartdevicelink.util.Version; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.assertNull; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@RunWith(AndroidJUnit4.class) -public class SystemCapabilityManagerTests { - public static final String TAG = "SystemCapabilityManagerTests"; - public static SystemCapabilityManager systemCapabilityManager; - private SystemCapability systemCapability; - private VideoStreamingCapability videoStreamingCapability; - - @Before - public void setUp() throws Exception{ - - systemCapability = new SystemCapability(SystemCapabilityType.VIDEO_STREAMING); - videoStreamingCapability = new VideoStreamingCapability(); - videoStreamingCapability.setMaxBitrate(TestValues.GENERAL_INT); - videoStreamingCapability.setPreferredResolution(TestValues.GENERAL_IMAGERESOLUTION); - videoStreamingCapability.setSupportedFormats(TestValues.GENERAL_VIDEOSTREAMINGFORMAT_LIST); - systemCapability.setCapabilityForType(SystemCapabilityType.VIDEO_STREAMING, videoStreamingCapability); - } - - public SystemCapabilityManager createSampleManager(){ - return createSampleManager(new InternalSDLInterface()); - } - - public SystemCapabilityManager createSampleManager(InternalSDLInterface iSdl){ - SystemCapabilityManager systemCapabilityManager = new SystemCapabilityManager(iSdl); - - RegisterAppInterfaceResponse raiResponse = new RegisterAppInterfaceResponse(); - - raiResponse.setHmiCapabilities(TestValues.GENERAL_HMICAPABILITIES); - raiResponse.setDisplayCapabilities(TestValues.GENERAL_DISPLAYCAPABILITIES); - raiResponse.setAudioPassThruCapabilities(TestValues.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST); - raiResponse.setButtonCapabilities(TestValues.GENERAL_BUTTONCAPABILITIES_LIST); - raiResponse.setHmiZoneCapabilities(TestValues.GENERAL_HMIZONECAPABILITIES_LIST); - raiResponse.setPresetBankCapabilities(TestValues.GENERAL_PRESETBANKCAPABILITIES); - raiResponse.setSoftButtonCapabilities(TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST); - raiResponse.setSpeechCapabilities(TestValues.GENERAL_SPEECHCAPABILITIES_LIST); - raiResponse.setPrerecordedSpeech(TestValues.GENERAL_PRERECORDEDSPEECH_LIST); - raiResponse.setSuccess(true); - - systemCapabilityManager.parseRAIResponse(raiResponse); - return systemCapabilityManager; - } - - private List<DisplayCapability> createDisplayCapabilityList(DisplayCapabilities display, List<ButtonCapabilities> button, List<SoftButtonCapabilities> softButton) { - WindowTypeCapabilities windowTypeCapabilities = new WindowTypeCapabilities(WindowType.MAIN, 1); - - DisplayCapability displayCapability = new DisplayCapability(); - displayCapability.setDisplayName(display != null ? display.getDisplayName() : null); - displayCapability.setWindowTypeSupported(Collections.singletonList(windowTypeCapabilities)); - - WindowCapability defaultWindowCapability = new WindowCapability(); - defaultWindowCapability.setWindowID(PredefinedWindows.DEFAULT_WINDOW.getValue()); - defaultWindowCapability.setButtonCapabilities(button); - defaultWindowCapability.setSoftButtonCapabilities(softButton); - - if (display == null) { - defaultWindowCapability.setTextFields(ManagerUtility.WindowCapabilityUtility.getAllTextFields()); - defaultWindowCapability.setImageFields(ManagerUtility.WindowCapabilityUtility.getAllImageFields()); - displayCapability.setWindowCapabilities(Collections.singletonList(defaultWindowCapability)); - return Collections.singletonList(displayCapability); - } - - defaultWindowCapability.setTemplatesAvailable(display.getTemplatesAvailable()); - defaultWindowCapability.setNumCustomPresetsAvailable(display.getNumCustomPresetsAvailable()); - defaultWindowCapability.setTextFields(display.getTextFields()); - defaultWindowCapability.setImageFields(display.getImageFields()); - ArrayList<ImageType> imageTypeSupported = new ArrayList<>(); - imageTypeSupported.add(ImageType.STATIC); - if (display.getGraphicSupported()) { - imageTypeSupported.add(ImageType.DYNAMIC); - } - defaultWindowCapability.setImageTypeSupported(imageTypeSupported); - - displayCapability.setWindowCapabilities(Collections.singletonList(defaultWindowCapability)); - return Collections.singletonList(displayCapability); - } - - private DisplayCapabilities createDisplayCapabilities(String displayName, WindowCapability defaultMainWindow) { - DisplayCapabilities convertedCapabilities = new DisplayCapabilities(); - convertedCapabilities.setDisplayType(DisplayType.SDL_GENERIC); //deprecated but it is mandatory... - convertedCapabilities.setDisplayName(displayName); - convertedCapabilities.setTextFields(defaultMainWindow.getTextFields()); - convertedCapabilities.setImageFields(defaultMainWindow.getImageFields()); - convertedCapabilities.setTemplatesAvailable(defaultMainWindow.getTemplatesAvailable()); - convertedCapabilities.setNumCustomPresetsAvailable(defaultMainWindow.getNumCustomPresetsAvailable()); - convertedCapabilities.setMediaClockFormats(new ArrayList<MediaClockFormat>()); // mandatory field but can be empty - convertedCapabilities.setGraphicSupported(defaultMainWindow.getImageTypeSupported().contains(ImageType.DYNAMIC)); - - return convertedCapabilities; - } - - @Test - public void testParseRAI() { - systemCapabilityManager = createSampleManager(); - - List<DisplayCapability> displayCapabilityList = createDisplayCapabilityList(TestValues.GENERAL_DISPLAYCAPABILITIES, TestValues.GENERAL_BUTTONCAPABILITIES_LIST, TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST); - assertTrue(TestValues.TRUE, - Validator.validateDisplayCapabilityList(displayCapabilityList, (List<DisplayCapability>) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS))); - assertTrue(TestValues.TRUE, - Validator.validateHMICapabilities(TestValues.GENERAL_HMICAPABILITIES, (HMICapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.HMI))); - assertTrue(TestValues.TRUE, - Validator.validateDisplayCapabilities(TestValues.GENERAL_DISPLAYCAPABILITIES, (DisplayCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY))); - assertTrue(TestValues.TRUE, - Validator.validateAudioPassThruCapabilities(TestValues.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST, (List<AudioPassThruCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.AUDIO_PASSTHROUGH))); - assertTrue(TestValues.TRUE, - Validator.validateButtonCapabilities(TestValues.GENERAL_BUTTONCAPABILITIES_LIST, (List<ButtonCapabilities> )systemCapabilityManager.getCapability(SystemCapabilityType.BUTTON))); - assertTrue(TestValues.TRUE, - Validator.validateHMIZoneCapabilities(TestValues.GENERAL_HMIZONECAPABILITIES_LIST, (List<HmiZoneCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.HMI_ZONE))); - assertTrue(TestValues.TRUE, - Validator.validatePresetBankCapabilities(TestValues.GENERAL_PRESETBANKCAPABILITIES, (PresetBankCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.PRESET_BANK))); - assertTrue(TestValues.TRUE, - Validator.validateSoftButtonCapabilities(TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST, (List<SoftButtonCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON))); - assertTrue(TestValues.TRUE, - Validator.validateSpeechCapabilities(TestValues.GENERAL_SPEECHCAPABILITIES_LIST, (List<SpeechCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.SPEECH))); - assertTrue(TestValues.TRUE, - Validator.validatePreRecordedSpeechCapabilities(TestValues.GENERAL_PRERECORDEDSPEECH_LIST, (List<PrerecordedSpeech>) systemCapabilityManager.getCapability(SystemCapabilityType.PRERECORDED_SPEECH))); - - } - - @Test - public void testNullDisplayCapabilitiesEnablesAllTextAndImageFields() { - List<DisplayCapability> displayCapabilityList = createDisplayCapabilityList(null, TestValues.GENERAL_BUTTONCAPABILITIES_LIST, TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST); - assertEquals(displayCapabilityList.get(0).getWindowCapabilities().get(0).getTextFields().size(), 29); - assertEquals(displayCapabilityList.get(0).getWindowCapabilities().get(0).getImageFields().size(), 15); - } - - @Test - public void testGetVSCapability(){ - VideoStreamingCapability vsCapability = new VideoStreamingCapability(); - vsCapability.setMaxBitrate(TestValues.GENERAL_INT); - vsCapability.setPreferredResolution(TestValues.GENERAL_IMAGERESOLUTION); - vsCapability.setSupportedFormats(TestValues.GENERAL_VIDEOSTREAMINGFORMAT_LIST); - - SystemCapability cap = new SystemCapability(); - cap.setSystemCapabilityType(SystemCapabilityType.VIDEO_STREAMING); - cap.setCapabilityForType(SystemCapabilityType.VIDEO_STREAMING, vsCapability); - - final SystemCapability referenceCapability = cap; - - systemCapabilityManager = new SystemCapabilityManager(new InternalSDLInterface() { - @Override - public void sendRPC(RPCMessage message) { - GetSystemCapabilityResponse response = new GetSystemCapabilityResponse(); - response.setSystemCapability(referenceCapability); - response.setSuccess(true); - if (message instanceof RPCRequest) { - RPCRequest request = (RPCRequest) message; - request.getOnRPCResponseListener().onResponse(CorrelationIdGenerator.generateId(), response); - } - } - - @Override - public void addOnRPCListener(FunctionID messageId, OnRPCListener listener) { - listener.onReceived(new OnHMIStatus(HMILevel.HMI_FULL, AudioStreamingState.NOT_AUDIBLE, SystemContext.SYSCTXT_MAIN)); - } - }); - - systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING, new OnSystemCapabilityListener() { - @Override - public void onCapabilityRetrieved(Object capability) { - assertTrue(TestValues.TRUE, - Validator.validateVideoStreamingCapability( - (VideoStreamingCapability) referenceCapability.getCapabilityForType(SystemCapabilityType.VIDEO_STREAMING), - (VideoStreamingCapability) capability)); - } - - @Override - public void onError(String info) { - assertTrue(false); - } - }); - } - - private Answer<Void> createOnHMIStatusAnswer(final HMILevel hmiLevel){ - Answer<Void> onHMIStatusAnswer = new Answer<Void>() { - @Override - public Void answer(InvocationOnMock invocation) { - Object[] args = invocation.getArguments(); - OnRPCListener onHMIStatusListener = (OnRPCListener) args[1]; - OnHMIStatus onHMIStatusFakeNotification = new OnHMIStatus(); - onHMIStatusFakeNotification.setHmiLevel(hmiLevel); - onHMIStatusListener.onReceived(onHMIStatusFakeNotification); - return null; - } - }; - return onHMIStatusAnswer; - } - - private Answer<Void> createOnSendGetSystemCapabilityAnswer (final boolean success, final Boolean subscribe) { - Answer<Void> onSendGetSystemCapabilityAnswer = new Answer<Void>() { - @Override - public Void answer(InvocationOnMock invocation) { - Object[] args = invocation.getArguments(); - GetSystemCapability getSystemCapability = (GetSystemCapability) args[0]; - if (subscribe != null) { - assertEquals(subscribe, getSystemCapability.getSubscribe()); - } - GetSystemCapabilityResponse response; - if (success) { - response = new GetSystemCapabilityResponse(Result.SUCCESS, true); - } else { - response = new GetSystemCapabilityResponse(Result.REJECTED, false); - } - response.setSystemCapability(systemCapability); - getSystemCapability.getOnRPCResponseListener().onResponse(CorrelationIdGenerator.generateId(), response); - return null; - } - }; - return onSendGetSystemCapabilityAnswer; - } - - @Test - public void testGetCapability() { - ISdl internalInterface; - SystemCapabilityManager scm; - OnSystemCapabilityListener onSystemCapabilityListener; - VideoStreamingCapability retrievedCapability; - - - // Test case 1 (capability not cached, listener not null, forceUpdate false) - internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - scm = new SystemCapabilityManager(internalInterface); - onSystemCapabilityListener = mock(OnSystemCapabilityListener.class); - doAnswer(createOnSendGetSystemCapabilityAnswer(true, null)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, null); - retrievedCapability = (VideoStreamingCapability) scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener, false); - assertNull(retrievedCapability); - verify(internalInterface, times(1)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Test case 2 (capability cached, listener not null, forceUpdate true) - internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - scm = new SystemCapabilityManager(internalInterface); - onSystemCapabilityListener = mock(OnSystemCapabilityListener.class); - doAnswer(createOnSendGetSystemCapabilityAnswer(true, null)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, videoStreamingCapability); - retrievedCapability = (VideoStreamingCapability) scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener, true); - assertTrue(TestValues.TRUE, Validator.validateVideoStreamingCapability((VideoStreamingCapability) systemCapability.getCapabilityForType(SystemCapabilityType.VIDEO_STREAMING), retrievedCapability)); - verify(internalInterface, times(1)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Test case 3 (capability cached, listener null, forceUpdate true) - internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - scm = new SystemCapabilityManager(internalInterface); - onSystemCapabilityListener = null; - doAnswer(createOnSendGetSystemCapabilityAnswer(true, null)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, videoStreamingCapability); - retrievedCapability = (VideoStreamingCapability) scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener, true); - assertTrue(TestValues.TRUE, Validator.validateVideoStreamingCapability((VideoStreamingCapability) systemCapability.getCapabilityForType(SystemCapabilityType.VIDEO_STREAMING), retrievedCapability)); - verify(internalInterface, times(1)).sendRPC(any(GetSystemCapability.class)); - - - // Test case 4 (capability cached, listener null, forceUpdate false) - internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - scm = new SystemCapabilityManager(internalInterface); - onSystemCapabilityListener = null; - doAnswer(createOnSendGetSystemCapabilityAnswer(true, null)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, videoStreamingCapability); - retrievedCapability = (VideoStreamingCapability) scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener, false); - assertTrue(TestValues.TRUE, Validator.validateVideoStreamingCapability((VideoStreamingCapability) systemCapability.getCapabilityForType(SystemCapabilityType.VIDEO_STREAMING), retrievedCapability)); - verify(internalInterface, times(0)).sendRPC(any(GetSystemCapability.class)); - } - - @Test - public void testGetCapabilityHmiNone() { - ISdl internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_NONE)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - SystemCapabilityManager scm = new SystemCapabilityManager(internalInterface); - OnSystemCapabilityListener onSystemCapabilityListener = mock(OnSystemCapabilityListener.class); - doAnswer(createOnSendGetSystemCapabilityAnswer(true, null)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, null); - VideoStreamingCapability retrievedCapability = (VideoStreamingCapability) scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener, false); - assertNull(retrievedCapability); - verify(internalInterface, times(0)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener, times(0)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener, times(1)).onError(any(String.class)); - } - - @Test - public void testAddOnSystemCapabilityListenerWithSubscriptionsSupportedAndCapabilityCached() { - SdlMsgVersion sdlMsgVersion = new SdlMsgVersion(6, 0); // This version supports capability subscriptions - sdlMsgVersion.setPatchVersion(0); - ISdl internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - when(internalInterface.getSdlMsgVersion()).thenReturn(sdlMsgVersion); - SystemCapabilityManager scm = new SystemCapabilityManager(internalInterface); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, videoStreamingCapability); - - - // Add listener1 - // When the first listener is added, GetSystemCapability request should go out with subscribe=true - OnSystemCapabilityListener onSystemCapabilityListener1 = mock(OnSystemCapabilityListener.class); - doAnswer(createOnSendGetSystemCapabilityAnswer(true, true)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - verify(internalInterface, times(1)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener2 - OnSystemCapabilityListener onSystemCapabilityListener2 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - verify(onSystemCapabilityListener2, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener3 - OnSystemCapabilityListener onSystemCapabilityListener3 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(onSystemCapabilityListener3, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Remove listener1 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - - - // Remove listener2 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - - - // Remove listener3 - // When the last listener is removed, GetSystemCapability request should go out with subscribe=false - doAnswer(createOnSendGetSystemCapabilityAnswer(true, false)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(internalInterface, times(2)).sendRPC(any(GetSystemCapability.class)); - } - - @Test - public void testAddOnSystemCapabilityListenerWithSubscriptionsSupportedAndCapabilityNotCached() { - SdlMsgVersion sdlMsgVersion = new SdlMsgVersion(6, 0); // This version supports capability subscriptions - sdlMsgVersion.setPatchVersion(0); - ISdl internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - when(internalInterface.getSdlMsgVersion()).thenReturn(sdlMsgVersion); - SystemCapabilityManager scm = new SystemCapabilityManager(internalInterface); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, null); - - - // Add listener1 - // When the first listener is added, GetSystemCapability request should go out with subscribe=true - OnSystemCapabilityListener onSystemCapabilityListener1 = mock(OnSystemCapabilityListener.class); - doAnswer(createOnSendGetSystemCapabilityAnswer(true, true)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - verify(internalInterface, times(1)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener2 - OnSystemCapabilityListener onSystemCapabilityListener2 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - verify(onSystemCapabilityListener2, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener3 - OnSystemCapabilityListener onSystemCapabilityListener3 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(onSystemCapabilityListener3, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Remove listener1 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - - - // Remove listener2 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - - - // Remove listener3 - // When the last listener is removed, GetSystemCapability request should go out with subscribe=false - doAnswer(createOnSendGetSystemCapabilityAnswer(true, false)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(internalInterface, times(2)).sendRPC(any(GetSystemCapability.class)); - } - - @Test - public void testAddOnSystemCapabilityListenerWithSubscriptionsNotSupportedAndCapabilityCached() { - SdlMsgVersion sdlMsgVersion = new SdlMsgVersion(5, 0); // This version doesn't support capability subscriptions - sdlMsgVersion.setPatchVersion(0); - ISdl internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - when(internalInterface.getSdlMsgVersion()).thenReturn(sdlMsgVersion); - SystemCapabilityManager scm = new SystemCapabilityManager(internalInterface); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, videoStreamingCapability); - - - // Add listener1 - // When the first listener is added, GetSystemCapability request should not go out because subscription is not supported and the capability is cached - OnSystemCapabilityListener onSystemCapabilityListener1 = mock(OnSystemCapabilityListener.class); - doAnswer(createOnSendGetSystemCapabilityAnswer(true, true)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - verify(internalInterface, times(0)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener2 - OnSystemCapabilityListener onSystemCapabilityListener2 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - verify(onSystemCapabilityListener2, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener3 - OnSystemCapabilityListener onSystemCapabilityListener3 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(onSystemCapabilityListener3, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Remove listener1 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - - - // Remove listener2 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - - - // Remove listener3 - // When the last listener is removed, GetSystemCapability request should not go out because subscription is not supported - doAnswer(createOnSendGetSystemCapabilityAnswer(true, false)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(internalInterface, times(0)).sendRPC(any(GetSystemCapability.class)); - } - - @Test - public void testAddOnSystemCapabilityListenerWithSubscriptionsNotSupportedAndCapabilityNotCached() { - SdlMsgVersion sdlMsgVersion = new SdlMsgVersion(5, 0); // This version doesn't support capability subscriptions - sdlMsgVersion.setPatchVersion(0); - ISdl internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - when(internalInterface.getSdlMsgVersion()).thenReturn(sdlMsgVersion); - SystemCapabilityManager scm = new SystemCapabilityManager(internalInterface); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, null); - - - // Add listener1 - // When the first listener is added, GetSystemCapability request should out because because capability is not cached - OnSystemCapabilityListener onSystemCapabilityListener1 = mock(OnSystemCapabilityListener.class); - doAnswer(createOnSendGetSystemCapabilityAnswer(true, false)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - verify(internalInterface, times(1)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener2 - OnSystemCapabilityListener onSystemCapabilityListener2 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - verify(onSystemCapabilityListener2, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener3 - OnSystemCapabilityListener onSystemCapabilityListener3 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(onSystemCapabilityListener3, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Remove listener1 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - - - // Remove listener2 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - - - // Remove listener3 - // When the last listener is removed, GetSystemCapability request should not go out because subscription is not supported - doAnswer(createOnSendGetSystemCapabilityAnswer(true, false)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(internalInterface, times(1)).sendRPC(any(GetSystemCapability.class)); - } - - @Test - public void testAddOnSystemCapabilityListenerThenGetCapabilityWhenSubscriptionsAreNotSupported() { - SdlMsgVersion sdlMsgVersion = new SdlMsgVersion(5, 0); // This version doesn't support capability subscriptions - sdlMsgVersion.setPatchVersion(0); - ISdl internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - when(internalInterface.getSdlMsgVersion()).thenReturn(sdlMsgVersion); - SystemCapabilityManager scm = new SystemCapabilityManager(internalInterface); - scm.setCapability(SystemCapabilityType.VIDEO_STREAMING, videoStreamingCapability); - - - // Add listener1 - // When the first listener is added, GetSystemCapability request should go out with subscribe=false - OnSystemCapabilityListener onSystemCapabilityListener1 = mock(OnSystemCapabilityListener.class); - doAnswer(createOnSendGetSystemCapabilityAnswer(true, false)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - verify(internalInterface, times(0)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Get Capability (should notify listener1 again) - scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, null, true); - verify(internalInterface, times(1)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(2)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener2 - OnSystemCapabilityListener onSystemCapabilityListener2 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - verify(onSystemCapabilityListener2, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Get Capability (should notify listener1 & listener2 again) - scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, null, true); - verify(internalInterface, times(2)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(3)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener2, times(2)).onCapabilityRetrieved(any(Object.class)); - - - // Add listener3 - OnSystemCapabilityListener onSystemCapabilityListener3 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(onSystemCapabilityListener3, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Get Capability (should notify listener1 & listener2 & listener3 again) - scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, null, true); - verify(internalInterface, times(3)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(4)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener2, times(3)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener3, times(2)).onCapabilityRetrieved(any(Object.class)); - - - // Remove listener1 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener1); - - - // Get Capability (should notify listener2 & listener3 again) - scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, null, true); - verify(internalInterface, times(4)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(4)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener2, times(4)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener3, times(3)).onCapabilityRetrieved(any(Object.class)); - - - // Remove listener2 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener2); - - - // Get Capability (should notify listener3 again) - scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, null, true); - verify(internalInterface, times(5)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(4)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener2, times(4)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener3, times(4)).onCapabilityRetrieved(any(Object.class)); - - - // Remove listener3 - scm.removeOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, onSystemCapabilityListener3); - verify(internalInterface, times(5)).sendRPC(any(GetSystemCapability.class)); - - - // Get Capability (should not notify any listener again because they are all removed) - scm.getCapability(SystemCapabilityType.VIDEO_STREAMING, null, true); - verify(internalInterface, times(6)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(4)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener2, times(4)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener3, times(4)).onCapabilityRetrieved(any(Object.class)); - } - - @Test - public void testGetAndAddListenerForDisplaysCapability() { - ISdl internalInterface; - SystemCapabilityManager scm; - OnSystemCapabilityListener onSystemCapabilityListener; - DisplayCapabilities retrievedCapability; - - - // Test case 1 (capability cached, listener not null, forceUpdate true) - internalInterface = mock(ISdl.class); - doAnswer(createOnHMIStatusAnswer(HMILevel.HMI_FULL)).when(internalInterface).addOnRPCListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCListener.class)); - scm = new SystemCapabilityManager(internalInterface); - onSystemCapabilityListener = mock(OnSystemCapabilityListener.class); - doAnswer(createOnSendGetSystemCapabilityAnswer(true, null)).when(internalInterface).sendRPC(any(GetSystemCapability.class)); - scm.setCapability(SystemCapabilityType.DISPLAYS, new DisplayCapabilities()); - retrievedCapability = (DisplayCapabilities) scm.getCapability(SystemCapabilityType.DISPLAYS, onSystemCapabilityListener, true); - assertNotNull(retrievedCapability); - verify(internalInterface, times(0)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener, times(1)).onCapabilityRetrieved(any(Object.class)); - verify(onSystemCapabilityListener, times(0)).onError(any(String.class)); - - - // Test case 2 (Add listener) - // When the first DISPLAYS listener is added, GetSystemCapability request should not go out - OnSystemCapabilityListener onSystemCapabilityListener1 = mock(OnSystemCapabilityListener.class); - scm.addOnSystemCapabilityListener(SystemCapabilityType.DISPLAYS, onSystemCapabilityListener1); - verify(internalInterface, times(0)).sendRPC(any(GetSystemCapability.class)); - verify(onSystemCapabilityListener1, times(1)).onCapabilityRetrieved(any(Object.class)); - - - // Test case 3 (Remove listener) - // When the last DISPLAYS listener is removed, GetSystemCapability request should not go out - scm.removeOnSystemCapabilityListener(SystemCapabilityType.DISPLAYS, onSystemCapabilityListener1); - verify(internalInterface, times(0)).sendRPC(any(GetSystemCapability.class)); - } - - @Test - public void testListConversion(){ - SystemCapabilityManager systemCapabilityManager = createSampleManager(); - Object capability = systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON); - assertNotNull(capability); - List<SoftButtonCapabilities> list = SystemCapabilityManager.convertToList(capability, SoftButtonCapabilities.class); - assertNotNull(list); - } - - @Test - public void testFalsePositive(){ - SystemCapabilityManager systemCapabilityManager = createSampleManager(); - systemCapabilityManager.setCapability(SystemCapabilityType.AUDIO_PASSTHROUGH, null); - assertFalse(systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.AUDIO_PASSTHROUGH)); - } - - @Test - public void testOnSystemCapabilityUpdateWithNoExistingCap(){ - InternalSDLInterface iSDL = new InternalSDLInterface(); - SystemCapabilityManager systemCapabilityManager = createSampleManager(iSDL); - OnRPCListener scmRpcListener = iSDL.rpcListeners.get(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED.getId()).get(0); - assertNotNull(scmRpcListener); - - assertNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES)); - - /* PERFORM A NOTIFICATION SEND THROUGH THE SCM */ - AppServiceCapability addServiceID = AppServiceFactory.createAppServiceCapability(AppServiceType.NAVIGATION, "test", "3453", true, null); - AppServicesCapabilities serviceIdASC = new AppServicesCapabilities(); - serviceIdASC.setAppServices(Collections.singletonList(addServiceID)); - - SystemCapability systemCapability = new SystemCapability(); - systemCapability.setSystemCapabilityType(SystemCapabilityType.APP_SERVICES); - systemCapability.setCapabilityForType(SystemCapabilityType.APP_SERVICES, serviceIdASC); - - OnSystemCapabilityUpdated onSystemCapabilityUpdated = new OnSystemCapabilityUpdated(); - onSystemCapabilityUpdated.setSystemCapability(systemCapability); - - scmRpcListener.onReceived(onSystemCapabilityUpdated); - - assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES)); - } - - @Test - public void testOnSystemCapabilityUpdatedForDISPLAYS() { - InternalSDLInterface iSDL = new InternalSDLInterface(); - SystemCapabilityManager systemCapabilityManager = createSampleManager(iSDL); - OnRPCListener scmRpcListener = iSDL.rpcListeners.get(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED.getId()).get(0); - assertNotNull(scmRpcListener); - - assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS)); - assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY)); - - List<DisplayCapability> newCaps = createDisplayCapabilityList(TestValues.GENERAL_DISPLAYCAPABILITIES, TestValues.GENERAL_BUTTONCAPABILITIES_LIST, TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST);; - - SystemCapability systemCapability = new SystemCapability(); - systemCapability.setSystemCapabilityType(SystemCapabilityType.DISPLAYS); - systemCapability.setCapabilityForType(SystemCapabilityType.DISPLAYS, newCaps); - - OnSystemCapabilityUpdated onSystemCapabilityUpdated = new OnSystemCapabilityUpdated(); - onSystemCapabilityUpdated.setSystemCapability(systemCapability); - - scmRpcListener.onReceived(onSystemCapabilityUpdated); - - List<DisplayCapability> appliedCaps = (List<DisplayCapability>)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS); - assertNotNull(appliedCaps); - assertTrue(Validator.validateDisplayCapabilityList(newCaps, appliedCaps)); - - DisplayCapabilities appliedConvertedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY); - assertNotNull(appliedConvertedCaps); - DisplayCapabilities testConvertedCaps = createDisplayCapabilities(newCaps.get(0).getDisplayName(), newCaps.get(0).getWindowCapabilities().get(0)); - assertTrue(Validator.validateDisplayCapabilities(appliedConvertedCaps, testConvertedCaps)); - } - - @Test - public void testOnSystemCapabilityUpdated(){ - InternalSDLInterface iSDL = new InternalSDLInterface(); - String baseName = "NavTest", baseID = "37F98053AE"; - AppServiceCapability capability1 = AppServiceFactory.createAppServiceCapability(AppServiceType.NAVIGATION, baseName, null, true, null); - - AppServicesCapabilities appServicesCapabilities = new AppServicesCapabilities(); - appServicesCapabilities.setAppServices(Collections.singletonList(capability1)); - - SystemCapabilityManager systemCapabilityManager = createSampleManager(iSDL); - assertNotNull(iSDL.rpcListeners.get(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED.getId())); - OnRPCListener scmRpcListener = iSDL.rpcListeners.get(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED.getId()).get(0); - assertNotNull(scmRpcListener); - - /* CONFIRM THE CAP DOESN'T EXIST IN SCM */ - AppServicesCapabilities cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); - assertNull(cachedCap); - - /* ADD THE CAP IN SCM */ - systemCapabilityManager.setCapability(SystemCapabilityType.APP_SERVICES, appServicesCapabilities); - /* CONFIRM THE CAP DOES EXIST IN SCM */ - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); - assertNotNull(cachedCap); - /* CONFIRM THE CAP IN SCM EQUALS ORIGINAL*/ - assertEquals(cachedCap, appServicesCapabilities); - assertNull(cachedCap.getAppServices().get(0).getUpdatedAppServiceRecord().getServiceID()); - - /* PERFORM A NOTIFICATION SEND THROUGH THE SCM */ - AppServiceCapability addServiceID = AppServiceFactory.createAppServiceCapability(AppServiceType.NAVIGATION, baseName, baseID, true, null); - AppServicesCapabilities serviceIdASC = new AppServicesCapabilities(); - serviceIdASC.setAppServices(Collections.singletonList(addServiceID)); - - SystemCapability systemCapability = new SystemCapability(); - systemCapability.setSystemCapabilityType(SystemCapabilityType.APP_SERVICES); - systemCapability.setCapabilityForType(SystemCapabilityType.APP_SERVICES, serviceIdASC); - - OnSystemCapabilityUpdated onSystemCapabilityUpdated = new OnSystemCapabilityUpdated(); - onSystemCapabilityUpdated.setSystemCapability(systemCapability); - - scmRpcListener.onReceived(onSystemCapabilityUpdated); - - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); - assertNotNull(cachedCap); - - assertTrue(cachedCap.getAppServices().get(0).getUpdatedAppServiceRecord().getServiceID().equals(baseID)); - - appServicesCapabilities.updateAppServices(Collections.singletonList(addServiceID)); - assertTrue(serviceIdASC.getAppServices().get(0).getUpdatedAppServiceRecord().getServiceID().equalsIgnoreCase(appServicesCapabilities.getAppServices().get(0).getUpdatedAppServiceRecord().getServiceID())); - - assertEquals(cachedCap, appServicesCapabilities); - - - /* PERFORM A NOTIFICATION SEND THROUGH AN UPDATED SERVICE NAME */ - AppServiceCapability newServiceName = AppServiceFactory.createAppServiceCapability(AppServiceType.NAVIGATION, "TestNav", baseID, true, null); - AppServicesCapabilities newServiceNameASC = new AppServicesCapabilities(); - newServiceNameASC.setAppServices(Collections.singletonList(newServiceName)); - - systemCapability = new SystemCapability(); - systemCapability.setSystemCapabilityType(SystemCapabilityType.APP_SERVICES); - systemCapability.setCapabilityForType(SystemCapabilityType.APP_SERVICES, newServiceNameASC); - - onSystemCapabilityUpdated = new OnSystemCapabilityUpdated(); - onSystemCapabilityUpdated.setSystemCapability(systemCapability); - - scmRpcListener.onReceived(onSystemCapabilityUpdated); - - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); - assertNotNull(cachedCap); - assertEquals(cachedCap.getAppServices().size(), 1); - - - /* PERFORM A NOTIFICATION SEND THROUGH THE SCM WITH DIFFERENT SERVICE */ - AppServiceCapability newService = AppServiceFactory.createAppServiceCapability(AppServiceType.NAVIGATION, "NewNav", "eeeeeeeee", false, null); - AppServicesCapabilities newServiceASC = new AppServicesCapabilities(); - newServiceASC.setAppServices(Collections.singletonList(newService)); - - systemCapability = new SystemCapability(); - systemCapability.setSystemCapabilityType(SystemCapabilityType.APP_SERVICES); - systemCapability.setCapabilityForType(SystemCapabilityType.APP_SERVICES, newServiceASC); - - onSystemCapabilityUpdated = new OnSystemCapabilityUpdated(); - onSystemCapabilityUpdated.setSystemCapability(systemCapability); - - scmRpcListener.onReceived(onSystemCapabilityUpdated); - - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); - assertNotNull(cachedCap); - assertEquals(cachedCap.getAppServices().size(), 2); - - /* PERFORM A NOTIFICATION SEND THROUGH THE SCM WITH A REMOVED SERVICE */ - AppServiceCapability removedService = AppServiceFactory.createAppServiceCapability(AppServiceType.NAVIGATION, "NewNav", "eeeeeeeee", false, null); - removedService.setUpdateReason(ServiceUpdateReason.REMOVED); - AppServicesCapabilities removedServiceASC = new AppServicesCapabilities(); - removedServiceASC.setAppServices(Collections.singletonList(removedService)); - - systemCapability = new SystemCapability(); - systemCapability.setSystemCapabilityType(SystemCapabilityType.APP_SERVICES); - systemCapability.setCapabilityForType(SystemCapabilityType.APP_SERVICES, removedServiceASC); - - onSystemCapabilityUpdated = new OnSystemCapabilityUpdated(); - onSystemCapabilityUpdated.setSystemCapability(systemCapability); - - scmRpcListener.onReceived(onSystemCapabilityUpdated); - - cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES); - assertNotNull(cachedCap); - assertEquals(cachedCap.getAppServices().size(), 1); - - } - - - @Test - public void testOnSystemCapabilityUpdatedOverwrite(){ - InternalSDLInterface iSDL = new InternalSDLInterface(); - SystemCapabilityManager systemCapabilityManager = createSampleManager(iSDL); - OnRPCListener scmRpcListener = iSDL.rpcListeners.get(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED.getId()).get(0); - assertNotNull(scmRpcListener); - systemCapabilityManager.setCapability(SystemCapabilityType.PHONE_CALL, TestValues.GENERAL_PHONECAPABILITY); - - PhoneCapability phoneCapability = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL); - assertNotNull(phoneCapability); - assertEquals(phoneCapability, TestValues.GENERAL_PHONECAPABILITY); - - phoneCapability.setDialNumberEnabled(!TestValues.GENERAL_PHONECAPABILITY.getDialNumberEnabled()); //Flip it - SystemCapability systemCapability = new SystemCapability(); - systemCapability.setSystemCapabilityType(SystemCapabilityType.PHONE_CALL); - systemCapability.setCapabilityForType(SystemCapabilityType.PHONE_CALL, phoneCapability); - OnSystemCapabilityUpdated onSystemCapabilityUpdated = new OnSystemCapabilityUpdated(); - onSystemCapabilityUpdated.setSystemCapability(systemCapability); - - scmRpcListener.onReceived(onSystemCapabilityUpdated); - - PhoneCapability phoneCapabilityUpdated = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL); - assertNotNull(phoneCapabilityUpdated); - assertFalse(phoneCapabilityUpdated.getDialNumberEnabled()); - assertEquals(phoneCapability, phoneCapabilityUpdated); - } - - @Test - public void testOnSetDisplayLayout() { - InternalSDLInterface iSDL = new InternalSDLInterface(); - SystemCapabilityManager systemCapabilityManager = createSampleManager(iSDL); - OnRPCListener dlRpcListener = iSDL.rpcListeners.get(FunctionID.SET_DISPLAY_LAYOUT.getId()).get(0); - assertNotNull(dlRpcListener); - - SetDisplayLayoutResponse newLayout = new SetDisplayLayoutResponse(); - newLayout.setDisplayCapabilities(TestValues.GENERAL_DISPLAYCAPABILITIES); - newLayout.setButtonCapabilities(TestValues.GENERAL_BUTTONCAPABILITIES_LIST); - newLayout.setSoftButtonCapabilities(TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST); - newLayout.setPresetBankCapabilities(TestValues.GENERAL_PRESETBANKCAPABILITIES); - newLayout.setSuccess(true); - newLayout.setResultCode(Result.SUCCESS); - - dlRpcListener.onReceived(newLayout); - - - DisplayCapabilities appliedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY); - assertNotNull(appliedCaps); - assertTrue(Validator.validateDisplayCapabilities(newLayout.getDisplayCapabilities(), appliedCaps)); - - List<DisplayCapability> convertedCaps = (List<DisplayCapability>)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS); - assertNotNull(convertedCaps); - List<DisplayCapability> testCaps = createDisplayCapabilityList(newLayout.getDisplayCapabilities(), newLayout.getButtonCapabilities(), newLayout.getSoftButtonCapabilities()); - assertTrue(Validator.validateDisplayCapabilityList(convertedCaps, testCaps)); - - WindowCapability matchWindowCapability = testCaps.get(0).getWindowCapabilities().get(0); - WindowCapability testWindowCapability = systemCapabilityManager.getDefaultMainWindowCapability(); - assertTrue(Validator.validateWindowCapability(matchWindowCapability, testWindowCapability)); - assertNull(systemCapabilityManager.getWindowCapability(42)); - } - - @Test - public void testManagerBeforeDisplayUpdate() { - InternalSDLInterface iSDL = new InternalSDLInterface(); - SystemCapabilityManager systemCapabilityManager = new SystemCapabilityManager(iSDL); - assertNull(systemCapabilityManager.getDefaultMainWindowCapability()); - assertNull(systemCapabilityManager.getWindowCapability(PredefinedWindows.DEFAULT_WINDOW.getValue())); - assertNull(systemCapabilityManager.getWindowCapability(PredefinedWindows.PRIMARY_WIDGET.getValue())); - } - - private class InternalSDLInterface implements ISdl{ - private final Object RPC_LISTENER_LOCK = new Object(); - SparseArray<CopyOnWriteArrayList<OnRPCListener>> rpcListeners = new SparseArray<>(); - - @Override - public void start(){} - - @Override - public void stop() {} - - @Override - public boolean isConnected() {return false; } - - @Override - public void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) {} - - @Override - public void removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) {} - - @Override - public void startVideoService(VideoStreamingParameters parameters, boolean encrypted) { } - - @Override - public void stopVideoService() {} - - @Override - public void stopAudioService() {} - - @Override - public void sendRPCRequest(RPCRequest message) {} - - @Override - public void sendRPC(RPCMessage message) {} - - @Override - public void sendRequests(List<? extends RPCRequest> rpcs, OnMultipleRequestListener listener) { - - } - - @Override - public void sendRPCs(List<? extends RPCMessage> rpcs, OnMultipleRequestListener listener) { - - } - - @Override - public void sendSequentialRPCs(List<? extends RPCMessage> rpcs, OnMultipleRequestListener listener) { - - } - - @Override - public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) { - - } - - @Override - public boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {return false;} - - @Override - public void addOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) { - - } - - @Override - public boolean removeOnRPCRequestListener(FunctionID functionID, OnRPCRequestListener listener) { - return false; - } - @Override - public void addOnRPCListener(FunctionID messageId, OnRPCListener listener){ - synchronized(RPC_LISTENER_LOCK){ - if(messageId != null && listener != null){ - if(rpcListeners.indexOfKey(messageId.getId()) < 0 ){ - rpcListeners.put(messageId.getId(),new CopyOnWriteArrayList<OnRPCListener>()); - } - rpcListeners.get(messageId.getId()).add(listener); - } - } - } - @Override - public boolean removeOnRPCListener(FunctionID messageId, OnRPCListener listener){ - synchronized(RPC_LISTENER_LOCK){ - if(rpcListeners!= null - && messageId != null - && listener != null - && rpcListeners.indexOfKey(messageId.getId()) >= 0){ - return rpcListeners.get(messageId.getId()).remove(listener); - } - } - return false; - } - - @Override - public Object getCapability(SystemCapabilityType systemCapabilityType){return null;} - - @Override - public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) { - } - - @Override - public RegisterAppInterfaceResponse getRegisterAppInterfaceResponse() { - return null; - } - - @Override - public Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate) { - return null; - } - - @Override - public SdlMsgVersion getSdlMsgVersion() { - return null; - } - - @Override - public Version getProtocolVersion() { - return new Version(1,0,0); - } - - - @Override - public boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType){ - return false; - } - - @Override - public void addOnSystemCapabilityListener(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener listener) { } - - @Override - public boolean removeOnSystemCapabilityListener(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener listener) { return false; } - - @Override - public boolean isTransportForServiceAvailable(SessionType serviceType) { - return false; - } - - @Override - public void startAudioService(boolean isEncrypted, AudioStreamingCodec codec, - AudioStreamingParams params) {} - - @Override - public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters){ - return null; - } - - @Override - public IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec, - AudioStreamingParams params) { - return null; - } - - @Override - public void startAudioService(boolean encrypted){} - - @Override - public void startRPCEncryption() {} - - @Override - public Taskmaster getTaskmaster() { - return null; - } - } -} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java index 20944a117..64f22a673 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java @@ -1,7 +1,7 @@ package com.smartdevicelink.test.rpc; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Before; import org.junit.Test; @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertTrue; /** @@ -61,7 +61,7 @@ public class RPCConstructorsTests { private Map<String, List<Parameter>> getRPCMandatoryParamsMap(String fileName) { Map<String, List<Parameter>> rpcMandatoryParamsMap = new HashMap<>(); try { - InputStream stream = getTargetContext().getAssets().open(fileName); + InputStream stream = getInstrumentation().getTargetContext().getAssets().open(fileName); XmlPullParserFactory xmlFactoryObject = XmlPullParserFactory.newInstance(); XmlPullParser myParser = xmlFactoryObject.newPullParser(); myParser.setInput(stream, null); 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); + } + } +} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HMICapabilitiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HMICapabilitiesTests.java index 87c83cb74..40c873285 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HMICapabilitiesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HMICapabilitiesTests.java @@ -9,6 +9,7 @@ import junit.framework.TestCase; import org.json.JSONException; import org.json.JSONObject; +import static com.smartdevicelink.proxy.rpc.HMICapabilities.KEY_DRIVER_DISTRACTION; import static com.smartdevicelink.proxy.rpc.HMICapabilities.KEY_NAVIGATION; import static com.smartdevicelink.proxy.rpc.HMICapabilities.KEY_PHONE_CALL; import static com.smartdevicelink.proxy.rpc.HMICapabilities.KEY_VIDEO_STREAMING; @@ -22,7 +23,8 @@ public class HMICapabilitiesTests extends TestCase { msg.setNavigationAvilable(TestValues.GENERAL_BOOLEAN); msg.setPhoneCallAvilable(TestValues.GENERAL_BOOLEAN); - msg.setVideoStreamingAvailable(TestValues.GENERAL_BOOLEAN); + msg.setVideoStreamingAvailable(TestValues.GENERAL_BOOLEAN); + msg.setDriverDistraction(TestValues.GENERAL_BOOLEAN); } /** @@ -32,12 +34,14 @@ public class HMICapabilitiesTests extends TestCase { // Test Values Boolean navAvail = msg.isNavigationAvailable(); Boolean phoneAvail = msg.isPhoneCallAvailable(); - Boolean vidStreamAvail = msg.isVideoStreamingAvailable(); + Boolean vidStreamAvail = msg.isVideoStreamingAvailable(); + Boolean driverDistractionAvail = msg.isDriverDistractionAvailable(); // Valid Tests assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, navAvail); assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, phoneAvail); assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, vidStreamAvail); + assertEquals(TestValues.MATCH, (Boolean) TestValues.GENERAL_BOOLEAN, driverDistractionAvail); // Invalid/Null Tests HMICapabilities msg = new HMICapabilities(); @@ -45,7 +49,9 @@ public class HMICapabilitiesTests extends TestCase { assertFalse(msg.isNavigationAvailable()); assertFalse(msg.isPhoneCallAvailable()); - assertFalse(msg.isVideoStreamingAvailable()); + assertFalse(msg.isVideoStreamingAvailable()); + assertFalse(msg.isDriverDistractionAvailable()); + } public void testJson(){ @@ -54,7 +60,8 @@ public class HMICapabilitiesTests extends TestCase { try{ reference.put(KEY_NAVIGATION, TestValues.GENERAL_BOOLEAN); reference.put(HMICapabilities.KEY_PHONE_CALL, TestValues.GENERAL_BOOLEAN); - reference.put(HMICapabilities.KEY_VIDEO_STREAMING, TestValues.GENERAL_BOOLEAN); + reference.put(HMICapabilities.KEY_VIDEO_STREAMING, TestValues.GENERAL_BOOLEAN); + reference.put(KEY_DRIVER_DISTRACTION, TestValues.GENERAL_BOOLEAN); JSONObject underTest = msg.serializeJSON(); assertEquals(TestValues.MATCH, reference.length(), underTest.length()); @@ -65,8 +72,11 @@ public class HMICapabilitiesTests extends TestCase { assertEquals(TestValues.MATCH, JsonUtils.readStringListFromJsonObject(reference, KEY_PHONE_CALL), JsonUtils.readStringListFromJsonObject(underTest, KEY_PHONE_CALL)); - assertEquals(TestValues.MATCH, JsonUtils.readStringListFromJsonObject(reference, KEY_VIDEO_STREAMING), + assertEquals(TestValues.MATCH, JsonUtils.readStringListFromJsonObject(reference, KEY_VIDEO_STREAMING), JsonUtils.readStringListFromJsonObject(underTest, KEY_VIDEO_STREAMING)); + assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(reference, KEY_DRIVER_DISTRACTION), + JsonUtils.readStringFromJsonObject(underTest, KEY_DRIVER_DISTRACTION)); + } catch(JSONException e){ fail(TestValues.JSON_FAIL); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SystemCapabilityTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SystemCapabilityTests.java index 0a02b6543..4ba99dda0 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SystemCapabilityTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SystemCapabilityTests.java @@ -5,6 +5,8 @@ import android.util.Log; import com.smartdevicelink.marshal.JsonRPCMarshaller; import com.smartdevicelink.proxy.rpc.AppServicesCapabilities; import com.smartdevicelink.proxy.rpc.DisplayCapability; +import com.smartdevicelink.proxy.rpc.DriverDistractionCapability; +import com.smartdevicelink.proxy.rpc.HMICapabilities; import com.smartdevicelink.proxy.rpc.NavigationCapability; import com.smartdevicelink.proxy.rpc.PhoneCapability; import com.smartdevicelink.proxy.rpc.RemoteControlCapabilities; @@ -42,6 +44,8 @@ public class SystemCapabilityTests extends TestCase { msg.setCapabilityForType(SystemCapabilityType.REMOTE_CONTROL, TestValues.GENERAL_REMOTECONTROLCAPABILITIES); msg.setCapabilityForType(SystemCapabilityType.APP_SERVICES, TestValues.GENERAL_APP_SERVICE_CAPABILITIES); msg.setCapabilityForType(SystemCapabilityType.DISPLAYS, TestValues.GENERAL_DISPLAYCAPABILITY_LIST); + msg.setCapabilityForType(SystemCapabilityType.DRIVER_DISTRACTION, TestValues.GENERAL_DRIVERDISTRACTIONCAPABILITY); + } /** @@ -55,6 +59,7 @@ public class SystemCapabilityTests extends TestCase { RemoteControlCapabilities testRemoteControlCapabilities = (RemoteControlCapabilities) msg.getCapabilityForType(SystemCapabilityType.REMOTE_CONTROL); AppServicesCapabilities testAppServicesCapabilities = (AppServicesCapabilities) msg.getCapabilityForType(SystemCapabilityType.APP_SERVICES); List<DisplayCapability> displayCapabilities = (List<DisplayCapability>) msg.getCapabilityForType(SystemCapabilityType.DISPLAYS); + DriverDistractionCapability testDriverDistractionCapability = (DriverDistractionCapability) msg.getCapabilityForType(SystemCapabilityType.DRIVER_DISTRACTION); // Valid Tests assertEquals(TestValues.MATCH, TestValues.GENERAL_SYSTEMCAPABILITYTYPE, testType); @@ -62,6 +67,8 @@ public class SystemCapabilityTests extends TestCase { assertTrue(TestValues.TRUE, Validator.validatePhoneCapability(TestValues.GENERAL_PHONECAPABILITY, testPhoneCapability)); assertTrue(TestValues.TRUE, Validator.validateRemoteControlCapabilities(TestValues.GENERAL_REMOTECONTROLCAPABILITIES, testRemoteControlCapabilities)); assertTrue(TestValues.TRUE, Validator.validateAppServiceCapabilities(TestValues.GENERAL_APP_SERVICE_CAPABILITIES, testAppServicesCapabilities)); + assertTrue(TestValues.TRUE, Validator.validateDriverDistractionCapability(TestValues.GENERAL_DRIVERDISTRACTIONCAPABILITY, testDriverDistractionCapability)); + for(int i = 0; i < TestValues.GENERAL_DISPLAYCAPABILITY_LIST.size(); i++){ assertTrue(TestValues.TRUE, Validator.validateDisplayCapability(TestValues.GENERAL_DISPLAYCAPABILITY_LIST.get(i), displayCapabilities.get(i))); @@ -77,6 +84,13 @@ public class SystemCapabilityTests extends TestCase { assertNull(TestValues.NULL, msg.getCapabilityForType(SystemCapabilityType.REMOTE_CONTROL)); assertNull(TestValues.NULL, msg.getCapabilityForType(SystemCapabilityType.APP_SERVICES)); assertNull(TestValues.NULL, msg.getCapabilityForType(SystemCapabilityType.DISPLAYS)); + assertNull(TestValues.NULL, msg.getCapabilityForType(SystemCapabilityType.DRIVER_DISTRACTION)); + + // Testing Setting an HMICapability as a SystemCapability + HMICapabilities hmiCapabilities = new HMICapabilities(); + msg.setCapabilityForType(SystemCapabilityType.HMI, hmiCapabilities); + assertNull(TestValues.NULL, msg.getCapabilityForType(SystemCapabilityType.HMI)); + } public void testJson() { @@ -89,6 +103,7 @@ public class SystemCapabilityTests extends TestCase { reference.put(SystemCapability.KEY_REMOTE_CONTROL_CAPABILITY, JsonRPCMarshaller.serializeHashtable(TestValues.GENERAL_REMOTECONTROLCAPABILITIES.getStore())); reference.put(SystemCapability.KEY_APP_SERVICES_CAPABILITIES, JsonRPCMarshaller.serializeHashtable(TestValues.GENERAL_APP_SERVICE_CAPABILITIES.getStore())); reference.put(SystemCapability.KEY_DISPLAY_CAPABILITIES, TestValues.JSON_DISPLAYCAPABILITY_LIST); + reference.put(SystemCapability.KEY_DRIVER_DISTRACTION_CAPABILITY, JsonRPCMarshaller.serializeHashtable(TestValues.GENERAL_DRIVERDISTRACTIONCAPABILITY.getStore())); JSONObject underTest = msg.serializeJSON(); assertEquals(TestValues.MATCH, reference.length(), underTest.length()); @@ -133,7 +148,13 @@ public class SystemCapabilityTests extends TestCase { Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray.getJSONObject(i)); assertTrue(TestValues.TRUE, Validator.validateDisplayCapability(new DisplayCapability(hashReference), new DisplayCapability(hashTest))); } - } else{ + } else if (key.equals(SystemCapability.KEY_DRIVER_DISTRACTION_CAPABILITY)) { + JSONObject objectEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key); + JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key); + Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals); + Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals); + assertTrue(TestValues.TRUE, Validator.validateDriverDistractionCapability(new DriverDistractionCapability(hashReference), new DriverDistractionCapability(hashTest))); + } else { assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); } } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStateTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStateTests.java new file mode 100644 index 000000000..3289f1190 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStateTests.java @@ -0,0 +1,52 @@ +package com.smartdevicelink.test.rpc.datatypes; + +import com.smartdevicelink.marshal.JsonRPCMarshaller; +import com.smartdevicelink.proxy.rpc.WindowState; +import com.smartdevicelink.test.TestValues; +import com.smartdevicelink.test.Validator; + +import junit.framework.TestCase; + +import org.json.JSONException; +import org.json.JSONObject; + +public class WindowStateTests extends TestCase { + private WindowState msg; + + @Override + protected void setUp() throws Exception { + msg = new WindowState(); + msg.setApproximatePosition(TestValues.GENERAL_APPROX_POSITION); + msg.setDeviation(TestValues.GENERAL_DEVIATION); + } + + public void testRpcValues() { + Integer approxPosition = msg.getApproximatePosition(); + Integer deviation = msg.getDeviation(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_APPROX_POSITION, approxPosition); + assertEquals(TestValues.MATCH, TestValues.GENERAL_DEVIATION, deviation); + } + + public void testJson() { + JSONObject reference = new JSONObject(); + + try { + reference.put(WindowState.KEY_APPROXIMATE_POSITION, TestValues.GENERAL_APPROX_POSITION); + reference.put(WindowState.KEY_DEVIATION, TestValues.GENERAL_DEVIATION); + + JSONObject underTest = msg.serializeJSON(); + assertEquals(TestValues.MATCH, reference.length(), underTest.length()); + + assertTrue(Validator.validateWindowStates( + new WindowState(JsonRPCMarshaller.deserializeJSONObject(reference)), + new WindowState(JsonRPCMarshaller.deserializeJSONObject(underTest))) + ); + + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); + } + } +} + diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStatusTests.java new file mode 100644 index 000000000..27fa8102c --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStatusTests.java @@ -0,0 +1,53 @@ +package com.smartdevicelink.test.rpc.datatypes; + +import com.smartdevicelink.marshal.JsonRPCMarshaller; +import com.smartdevicelink.proxy.rpc.Grid; +import com.smartdevicelink.proxy.rpc.WindowState; +import com.smartdevicelink.proxy.rpc.WindowStatus; +import com.smartdevicelink.test.TestValues; +import com.smartdevicelink.test.Validator; + +import junit.framework.TestCase; + +import org.json.JSONException; +import org.json.JSONObject; + +public class WindowStatusTests extends TestCase { + private WindowStatus msg; + + @Override + protected void setUp() throws Exception { + msg = new WindowStatus(); + msg.setState(TestValues.GENERAL_WINDOW_STATE); + msg.setLocation(TestValues.GENERAL_LOCATION_GRID); + } + + public void testRpcValues() { + WindowState state = msg.getState(); + Grid locationGrid = msg.getLocation(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_WINDOW_STATE, state); + assertEquals(TestValues.MATCH, TestValues.GENERAL_LOCATION_GRID, locationGrid); + } + + public void testJson() { + JSONObject reference = new JSONObject(); + + try { + reference.put(WindowStatus.KEY_STATE, TestValues.GENERAL_WINDOW_STATE); + reference.put(WindowStatus.KEY_LOCATION, TestValues.GENERAL_LOCATION_GRID); + + JSONObject underTest = msg.serializeJSON(); + assertEquals(TestValues.MATCH, reference.length(), underTest.length()); + + assertTrue(Validator.validateWindowStatus( + new WindowStatus(JsonRPCMarshaller.deserializeJSONObject(reference)), + new WindowStatus(JsonRPCMarshaller.deserializeJSONObject(underTest))) + ); + + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); + } + } +} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java index 85c74e8e4..af0881ad6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java @@ -42,6 +42,8 @@ public class AppHmiTypeTests extends TestCase { AppHMIType enumSystem = AppHMIType.valueForString(example); example = "REMOTE_CONTROL"; AppHMIType enumRemoteControl = AppHMIType.valueForString(example); + example = "WEB_VIEW"; + AppHMIType enumWebView = AppHMIType.valueForString(example); assertNotNull("DEFAULT returned null", enumDefault); assertNotNull("COMMUNICATION returned null", enumCommunication); @@ -55,6 +57,7 @@ public class AppHmiTypeTests extends TestCase { assertNotNull("TESTING returned null", enumTesting); assertNotNull("SYSTEM returned null", enumSystem); assertNotNull("REMOTE_CONTROL returned null", enumRemoteControl); + assertNotNull("WEB_VIEW returned null", enumWebView); } /** @@ -104,6 +107,7 @@ public class AppHmiTypeTests extends TestCase { enumTestList.add(AppHMIType.TESTING); enumTestList.add(AppHMIType.SYSTEM); enumTestList.add(AppHMIType.REMOTE_CONTROL); + enumTestList.add(AppHMIType.WEB_VIEW); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppInterfaceUnregisteredReasonTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppInterfaceUnregisteredReasonTests.java index cc59924d4..bf1d5e65b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppInterfaceUnregisteredReasonTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppInterfaceUnregisteredReasonTests.java @@ -44,6 +44,8 @@ public class AppInterfaceUnregisteredReasonTests extends TestCase { AppInterfaceUnregisteredReason enumProtocolViolation = AppInterfaceUnregisteredReason.valueForString(example); example = "UNSUPPORTED_HMI_RESOURCE"; AppInterfaceUnregisteredReason enumUnsupportedHMIResource = AppInterfaceUnregisteredReason.valueForString(example); + example = "RESOURCE_CONSTRAINT"; + AppInterfaceUnregisteredReason enumResourceConstraint = AppInterfaceUnregisteredReason.valueForString(example); assertNotNull("USER_EXIT returned null", enumUserExit); assertNotNull("IGNITION_OFF returned null", enumIgnitionOff); @@ -58,6 +60,7 @@ public class AppInterfaceUnregisteredReasonTests extends TestCase { assertNotNull("APP_UNAUTHORIZED returned null", enumAppAuthorized); assertNotNull("PROTOCOL_VIOLATION returned null", enumProtocolViolation); assertNotNull("UNSUPPORTED_HMI_RESOURCE returned null", enumUnsupportedHMIResource); + assertNotNull("RESOURCE_CONSTRAINT returned null", enumResourceConstraint); } /** @@ -108,6 +111,7 @@ public class AppInterfaceUnregisteredReasonTests extends TestCase { enumTestList.add(AppInterfaceUnregisteredReason.APP_UNAUTHORIZED); enumTestList.add(AppInterfaceUnregisteredReason.PROTOCOL_VIOLATION); enumTestList.add(AppInterfaceUnregisteredReason.UNSUPPORTED_HMI_RESOURCE); + enumTestList.add(AppInterfaceUnregisteredReason.RESOURCE_CONSTRAINT); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CharacterSetTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CharacterSetTests.java index fa5e36f3f..78a1325f3 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CharacterSetTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CharacterSetTests.java @@ -26,11 +26,20 @@ public class CharacterSetTests extends TestCase { CharacterSet enumCid1Set = CharacterSet.valueForString(example); example = "CID2SET"; CharacterSet enumCid2Set = CharacterSet.valueForString(example); - + example = "ASCII"; + CharacterSet enumAsciiSet = CharacterSet.valueForString(example); + example = "ISO_8859_1"; + CharacterSet enumIsoSet = CharacterSet.valueForString(example); + example = "UTF_8"; + CharacterSet enumUtfSet = CharacterSet.valueForString(example); + assertNotNull("TYPE2SET returned null", enumType2Set); assertNotNull("TYPE5SET returned null", enumType5Set); assertNotNull("CID1SET returned null", enumCid1Set); assertNotNull("CID2SET returned null", enumCid2Set); + assertNotNull("ASCII returned null", enumAsciiSet); + assertNotNull("ISO_8859_1 returned null", enumIsoSet); + assertNotNull("UTF_8 returned null", enumUtfSet); } /** @@ -72,6 +81,9 @@ public class CharacterSetTests extends TestCase { enumTestList.add(CharacterSet.TYPE5SET); enumTestList.add(CharacterSet.CID1SET); enumTestList.add(CharacterSet.CID2SET); + enumTestList.add(CharacterSet.ASCII); + enumTestList.add(CharacterSet.ISO_8859_1); + enumTestList.add(CharacterSet.UTF_8); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/PredefinedLayoutTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/PredefinedLayoutTests.java index 26b32d08b..4c5526eec 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/PredefinedLayoutTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/PredefinedLayoutTests.java @@ -58,6 +58,8 @@ public class PredefinedLayoutTests extends TestCase { PredefinedLayout double_graphic_with_softbuttons = PredefinedLayout.valueForString(example); example = "LARGE_GRAPHIC_ONLY"; PredefinedLayout large_graphic_only = PredefinedLayout.valueForString(example); + example = "WEB_VIEW"; + PredefinedLayout web_view = PredefinedLayout.valueForString(example); assertNotNull("DEFAULT returned null", defaultenum); assertNotNull("MEDIA returned null", media); @@ -79,6 +81,7 @@ public class PredefinedLayoutTests extends TestCase { assertNotNull("LARGE_GRAPHIC_WITH_SOFTBUTTONS returned null", large_graphic_with_softbuttons); assertNotNull("DOUBLE_GRAPHIC_WITH_SOFTBUTTONS returned null", double_graphic_with_softbuttons); assertNotNull("LARGE_GRAPHIC_ONLY returned null", large_graphic_only); + assertNotNull("WEB_VIEW returned null", web_view); } /** @@ -137,6 +140,7 @@ public class PredefinedLayoutTests extends TestCase { enumTestList.add(PredefinedLayout.LARGE_GRAPHIC_WITH_SOFTBUTTONS); enumTestList.add(PredefinedLayout.DOUBLE_GRAPHIC_WITH_SOFTBUTTONS); enumTestList.add(PredefinedLayout.LARGE_GRAPHIC_ONLY); + enumTestList.add(PredefinedLayout.WEB_VIEW); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SdlDisconnectedReasonTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SdlDisconnectedReasonTests.java index d4c22354e..3f2ee110d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SdlDisconnectedReasonTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SdlDisconnectedReasonTests.java @@ -64,7 +64,9 @@ public class SdlDisconnectedReasonTests extends TestCase { SdlDisconnectedReason enumLegacyMode = SdlDisconnectedReason.valueForString(example); example = "RPC_SESSION_ENDED"; SdlDisconnectedReason enumRpcSessionEnded = SdlDisconnectedReason.valueForString(example); - + example = "RESOURCE_CONSTRAINT"; + SdlDisconnectedReason resourceConstraint = SdlDisconnectedReason.valueForString(example); + assertNotNull("USER_EXIT returned null", enumUserExit); assertNotNull("IGNITION_OFF returned null", enumIgnitionOff); assertNotNull("BLUETOOTH_OFF returned null", enumBluetoothOff); @@ -87,6 +89,7 @@ public class SdlDisconnectedReasonTests extends TestCase { assertNotNull("GENERIC_ERROR returned null", enumGenericError); assertNotNull("LEGACY_BLUETOOTH_MODE_ENABLED returned null", enumLegacyMode); assertNotNull("RPC_SESSION_ENDED returned null", enumRpcSessionEnded); + assertNotNull("RESOURCE_CONSTRAINT returned null", resourceConstraint); } /** @@ -149,6 +152,7 @@ public class SdlDisconnectedReasonTests extends TestCase { enumTestList.add(SdlDisconnectedReason.PRIMARY_TRANSPORT_CYCLE_REQUEST); enumTestList.add(SdlDisconnectedReason.MINIMUM_PROTOCOL_VERSION_HIGHER_THAN_SUPPORTED); enumTestList.add(SdlDisconnectedReason.MINIMUM_RPC_VERSION_HIGHER_THAN_SUPPORTED); + enumTestList.add(SdlDisconnectedReason.RESOURCE_CONSTRAINT); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); @@ -156,7 +160,7 @@ public class SdlDisconnectedReasonTests extends TestCase { /** * Verifies the valid returns of the conversion method, - * {@link com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason#convertAppInterfaceunregisteredReason(AppInterfaceUnregisteredReason)} + * {@link com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason#convertAppInterfaceUnregisteredReason(AppInterfaceUnregisteredReason)} */ public void testConvertMethod () { assertEquals(TestValues.MATCH, SdlDisconnectedReason.DEFAULT, SdlDisconnectedReason.convertAppInterfaceUnregisteredReason(AppInterfaceUnregisteredReason.APP_UNAUTHORIZED)); @@ -170,6 +174,7 @@ public class SdlDisconnectedReasonTests extends TestCase { assertEquals(TestValues.MATCH, SdlDisconnectedReason.TOO_MANY_REQUESTS, SdlDisconnectedReason.convertAppInterfaceUnregisteredReason(AppInterfaceUnregisteredReason.TOO_MANY_REQUESTS)); assertEquals(TestValues.MATCH, SdlDisconnectedReason.USB_DISCONNECTED, SdlDisconnectedReason.convertAppInterfaceUnregisteredReason(AppInterfaceUnregisteredReason.USB_DISCONNECTED)); assertEquals(TestValues.MATCH, SdlDisconnectedReason.USER_EXIT, SdlDisconnectedReason.convertAppInterfaceUnregisteredReason(AppInterfaceUnregisteredReason.USER_EXIT)); + assertEquals(TestValues.MATCH, SdlDisconnectedReason.RESOURCE_CONSTRAINT, SdlDisconnectedReason.convertAppInterfaceUnregisteredReason(AppInterfaceUnregisteredReason.RESOURCE_CONSTRAINT)); assertNull(TestValues.MATCH, SdlDisconnectedReason.convertAppInterfaceUnregisteredReason(null)); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SystemCapabilityTypeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SystemCapabilityTypeTests.java index f453cb985..94617493c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SystemCapabilityTypeTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SystemCapabilityTypeTests.java @@ -54,6 +54,8 @@ public class SystemCapabilityTypeTests extends TestCase { SystemCapabilityType enumPrerecordedSpeech = SystemCapabilityType.valueForString(example); example = "DISPLAYS"; SystemCapabilityType enumDisplays = SystemCapabilityType.valueForString(example); + example = "DRIVER_DISTRACTION"; + SystemCapabilityType enumDriverDistraction = SystemCapabilityType.valueForString(example); assertNotNull("NAVIGATION returned null", enumNavigation); assertNotNull("PHONE_CALL returned null", enumPhoneCall); @@ -73,6 +75,8 @@ public class SystemCapabilityTypeTests extends TestCase { assertNotNull("SEAT_LOCATION return null", enumSeatLocation); assertNotNull("PRERECORDED_SPEECH", enumPrerecordedSpeech); assertNotNull("DISPLAYS", enumDisplays); + assertNotNull("DRIVER_DISTRACTION", enumDriverDistraction); + } /** @@ -128,6 +132,8 @@ public class SystemCapabilityTypeTests extends TestCase { enumTestList.add(SystemCapabilityType.SEAT_LOCATION); enumTestList.add(SystemCapabilityType.PRERECORDED_SPEECH); enumTestList.add(SystemCapabilityType.DISPLAYS); + enumTestList.add(SystemCapabilityType.DRIVER_DISTRACTION); + assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java index dbce8b5e7..6b6b8a144 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java @@ -82,7 +82,12 @@ public class VehicleDataTypeTests extends TestCase { VehicleDataType enumVehicleCloudAppVehicleId = VehicleDataType.valueForString(example); example = "VEHICLEDATA_OEM_CUSTOM_DATA"; VehicleDataType enumVehicleDataOemVehicleDataType= VehicleDataType.valueForString(example); - + example = "VEHICLEDATA_HANDSOFFSTEERING"; + VehicleDataType enumVehicleDataHandsOffSteeringType= VehicleDataType.valueForString(example); + + example = "VEHICLEDATA_WINDOWSTATUS"; + VehicleDataType enumVehicleDataTypeWindowStatus= VehicleDataType.valueForString(example); + assertNotNull("VEHICLEDATA_GPS returned null", enumVehicleDataGps); assertNotNull("VEHICLEDATA_SPEED returned null", enumVehicleDataSpeed); assertNotNull("VEHICLEDATA_RPM returned null", enumVehicleDataRpm); @@ -115,6 +120,8 @@ public class VehicleDataTypeTests extends TestCase { assertNotNull("VEHICLEDATA_ELECTRONICPARKBRAKESTATUS returned null", enumVehicleDataElectronicParkBrakeStatus); assertNotNull("VEHICLEDATA_CLOUDAPPVEHICLEID returned null", enumVehicleCloudAppVehicleId); assertNotNull("VEHICLEDATA_OEM_CUSTOM_DATA returned null", enumVehicleDataOemVehicleDataType); + assertNotNull("VEHICLEDATA_HANDSOFFSTEERING returned null", enumVehicleDataHandsOffSteeringType); + assertNotNull("VEHICLEDATA_WINDOWSTATUS returned null", enumVehicleDataTypeWindowStatus); } /** @@ -184,6 +191,8 @@ public class VehicleDataTypeTests extends TestCase { enumTestList.add(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS); enumTestList.add(VehicleDataType.VEHICLEDATA_CLOUDAPPVEHICLEID); enumTestList.add(VehicleDataType.VEHICLEDATA_OEM_CUSTOM_DATA); + enumTestList.add(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING); + enumTestList.add(VehicleDataType.VEHICLEDATA_WINDOWSTATUS); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSystemRequestTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSystemRequestTests.java index 6ee431ea9..580cbd9a7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSystemRequestTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSystemRequestTests.java @@ -138,4 +138,27 @@ public class OnSystemRequestTests extends BaseRpcTests{ assertNull(TestValues.NULL, msg.getRequestType()); assertNull(TestValues.NULL, msg.getRequestSubType()); } + + @Test + public void testUrlParam(){ + + OnSystemRequest msg = new OnSystemRequest(); + + StringBuilder longUrl = new StringBuilder("https://test.url"); + while (longUrl.length() < 10000) { + longUrl.append("/test"); + } + + msg.setUrl(longUrl.toString()); + + // test url length has not changed + assertEquals(TestValues.MATCH, msg.getUrl().length(), longUrl.length()); + + // test empty url + msg.setUrl(""); + assertEquals(TestValues.MATCH, msg.getUrl(), ""); + + msg.setUrl(longUrl.substring(0, 1000)); + assertEquals(TestValues.MATCH, msg.getUrl().length(), 1000); + } }
\ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java index 76a7675a1..45c3b29ee 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java @@ -17,6 +17,7 @@ import com.smartdevicelink.proxy.rpc.MyKey; import com.smartdevicelink.proxy.rpc.OnVehicleData; import com.smartdevicelink.proxy.rpc.SingleTireStatus; import com.smartdevicelink.proxy.rpc.TireStatus; +import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus; import com.smartdevicelink.proxy.rpc.enums.ElectronicParkBrakeStatus; import com.smartdevicelink.proxy.rpc.enums.PRNDL; @@ -99,6 +100,8 @@ public class OnVehicleDataTests extends BaseRpcTests{ result.put(OnVehicleData.KEY_FUEL_RANGE, VehicleDataHelper.JSON_FUEL_RANGE); result.put(OnVehicleData.KEY_TURN_SIGNAL, VehicleDataHelper.TURN_SIGNAL); result.put(OnVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); + result.put(OnVehicleData.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); + result.put(OnVehicleData.KEY_WINDOW_STATUS, VehicleDataHelper.WINDOW_STATUS_LIST); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); } catch(JSONException e) { fail(TestValues.JSON_FAIL); @@ -111,7 +114,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ * Tests the expected values of the RPC message. */ @Test - public void testRpcValues () { + public void testRpcValues () { // Test Values Double speed = ( (OnVehicleData) msg).getSpeed(); int rpm = ( (OnVehicleData) msg).getRpm(); @@ -140,10 +143,11 @@ public class OnVehicleDataTests extends BaseRpcTests{ ClusterModeStatus cluster = ( (OnVehicleData) msg).getClusterModeStatus(); MyKey key = ( (OnVehicleData) msg).getMyKey(); List<FuelRange> fuelRangeList = ( (OnVehicleData) msg).getFuelRange(); + List<WindowStatus> windowStatusList = ( (OnVehicleData) msg).getWindowStatus(); TurnSignal turnSignal = ( (OnVehicleData) msg).getTurnSignal(); ElectronicParkBrakeStatus electronicParkBrakeStatus = ( (OnVehicleData) msg).getElectronicParkBrakeStatus(); Object oemCustomVehicleData = ( (OnVehicleData) msg).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); - + Boolean handsOffSteering = ( (OnVehicleData) msg).getHandsOffSteering(); // Valid Tests assertEquals(TestValues.MATCH, VehicleDataHelper.SPEED, speed); assertEquals(TestValues.MATCH, VehicleDataHelper.RPM, rpm); @@ -172,10 +176,11 @@ public class OnVehicleDataTests extends BaseRpcTests{ assertTrue(TestValues.TRUE, Validator.validateClusterModeStatus(VehicleDataHelper.CLUSTER_MODE_STATUS, cluster)); assertTrue(TestValues.TRUE, Validator.validateMyKey(VehicleDataHelper.MY_KEY, key)); assertTrue(TestValues.TRUE, Validator.validateFuelRange(VehicleDataHelper.FUEL_RANGE_LIST, fuelRangeList)); + assertTrue(TestValues.TRUE, Validator.validateWindowStatuses(VehicleDataHelper.WINDOW_STATUS_LIST, windowStatusList)); assertEquals(TestValues.MATCH, VehicleDataHelper.TURN_SIGNAL, turnSignal); assertEquals(TestValues.MATCH, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); assertEquals(TestValues.MATCH, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE, oemCustomVehicleData); - + assertEquals(TestValues.MATCH, VehicleDataHelper.HANDS_OFF_STEERING, handsOffSteering); // Invalid/Null Tests OnVehicleData msg = new OnVehicleData(); assertNotNull(TestValues.NOT_NULL, msg); @@ -210,6 +215,8 @@ public class OnVehicleDataTests extends BaseRpcTests{ assertNull(TestValues.NULL, msg.getFuelRange()); assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); + assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -230,8 +237,10 @@ public class OnVehicleDataTests extends BaseRpcTests{ JSONObject clusterModeStatusObj = new JSONObject(); JSONObject myKeyObj = new JSONObject(); JSONObject fuelRangeObj = new JSONObject(); + JSONObject windowStatusObj = new JSONObject(); JSONArray fuelRangeArrayObj = new JSONArray(); - + JSONArray windowStatusArrayObj = new JSONArray(); + try { //Set up the JSONObject to represent OnVehicleData: @@ -357,6 +366,11 @@ public class OnVehicleDataTests extends BaseRpcTests{ fuelRangeObj.put(FuelRange.KEY_RANGE, VehicleDataHelper.FUEL_RANGE_RANGE); fuelRangeArrayObj.put(fuelRangeObj); + // WINDOW_STATUS + windowStatusObj.put(WindowStatus.KEY_LOCATION, VehicleDataHelper.LOCATION_GRID); + windowStatusObj.put(WindowStatus.KEY_STATE, VehicleDataHelper.WINDOW_STATE); + windowStatusArrayObj.put(windowStatusObj); + reference.put(OnVehicleData.KEY_SPEED, VehicleDataHelper.SPEED); reference.put(OnVehicleData.KEY_RPM, VehicleDataHelper.RPM); reference.put(OnVehicleData.KEY_EXTERNAL_TEMPERATURE, VehicleDataHelper.EXTERNAL_TEMPERATURE); @@ -386,6 +400,8 @@ public class OnVehicleDataTests extends BaseRpcTests{ reference.put(OnVehicleData.KEY_FUEL_RANGE, fuelRangeArrayObj); reference.put(OnVehicleData.KEY_TURN_SIGNAL, VehicleDataHelper.TURN_SIGNAL); reference.put(OnVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); + reference.put(OnVehicleData.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); + reference.put(OnVehicleData.KEY_WINDOW_STATUS, windowStatusArrayObj); reference.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); JSONObject underTest = msg.serializeJSON(); @@ -484,6 +500,9 @@ public class OnVehicleDataTests extends BaseRpcTests{ else if (key.equals(OnVehicleData.KEY_ENGINE_OIL_LIFE)) { assertEquals(JsonUtils.readDoubleFromJsonObject(reference, key), JsonUtils.readDoubleFromJsonObject(underTest, key)); } + else if (key.equals(OnVehicleData.KEY_HANDS_OFF_STEERING)) { + assertEquals(JsonUtils.readBooleanFromJsonObject(reference, key), JsonUtils.readBooleanFromJsonObject(underTest, key)); + } else if (key.equals(OnVehicleData.KEY_FUEL_RANGE)) { JSONArray fuelRangeArrayObjReference = JsonUtils.readJsonArrayFromJsonObject(reference, key); List<FuelRange> fuelRangeRefereceList = new ArrayList<FuelRange>(); @@ -502,6 +521,25 @@ public class OnVehicleDataTests extends BaseRpcTests{ assertTrue(TestValues.TRUE, Validator.validateFuelRange( fuelRangeRefereceList, fuelRangeUnderTestList)); + } else if (key.equals(OnVehicleData.KEY_WINDOW_STATUS)) { + JSONArray windowStatusArrayObjReference = JsonUtils.readJsonArrayFromJsonObject(reference, key); + List<WindowStatus> windowStatusReferenceList = new ArrayList<>(); + for (int index = 0; index < windowStatusArrayObjReference.length(); index++) { + WindowStatus windowStatus = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArrayObjReference.get(index) )); + windowStatusReferenceList.add(windowStatus); + } + + JSONArray windowStatusArrayObjTest = JsonUtils.readJsonArrayFromJsonObject(underTest, key); + List<WindowStatus> windowStatusUnderTestList = new ArrayList<>(); + for (int index = 0; index < windowStatusArrayObjTest.length(); index++) { + WindowStatus windowStatus = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArrayObjTest.get(index) )); + windowStatusUnderTestList.add(windowStatus); + } + + assertTrue("JSON value didn't match expected value for key \"" + key + "\".", + Validator.validateWindowStatuses( + windowStatusReferenceList, + windowStatusUnderTestList)); } else { assertEquals(TestValues.TRUE, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddCommandTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddCommandTests.java index d31ff4464..88d22cd8d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddCommandTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddCommandTests.java @@ -18,7 +18,7 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertTrue; @@ -108,7 +108,7 @@ public class AddCommandTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java index da2bbfab8..74efd59e9 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java @@ -23,7 +23,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -40,6 +40,7 @@ public class AddSubmenuTests extends BaseRpcTests{ msg.setPosition(TestValues.GENERAL_INT); msg.setMenuIcon(TestValues.GENERAL_IMAGE); msg.setMenuLayout(TestValues.GENERAL_MENU_LAYOUT); + msg.setParentID(TestValues.GENERAL_MENU_MAX_ID); return msg; } @@ -64,6 +65,7 @@ public class AddSubmenuTests extends BaseRpcTests{ result.put(AddSubMenu.KEY_POSITION, TestValues.GENERAL_INT); result.put(AddSubMenu.KEY_MENU_ICON, TestValues.JSON_IMAGE); result.put(AddSubMenu.KEY_MENU_LAYOUT, TestValues.GENERAL_MENU_LAYOUT); + result.put(AddSubMenu.KEY_PARENT_ID, TestValues.GENERAL_MENU_MAX_ID); }catch(JSONException e){ fail(TestValues.JSON_FAIL); } @@ -77,11 +79,12 @@ public class AddSubmenuTests extends BaseRpcTests{ @Test public void testRpcValues () { // Test Values - int testMenuId = ( (AddSubMenu) msg ).getMenuID(); - int testPosition = ( (AddSubMenu) msg ).getPosition(); - String testMenuName = ( (AddSubMenu) msg ).getMenuName(); - Image testMenuIcon = ( (AddSubMenu) msg ).getMenuIcon(); - MenuLayout testMenuLayout = ( (AddSubMenu) msg ).getMenuLayout(); + int testMenuId = ((AddSubMenu) msg).getMenuID(); + int testPosition = ((AddSubMenu) msg).getPosition(); + String testMenuName = ((AddSubMenu) msg).getMenuName(); + Image testMenuIcon = ((AddSubMenu) msg).getMenuIcon(); + MenuLayout testMenuLayout = ((AddSubMenu) msg).getMenuLayout(); + int testParentID = ((AddSubMenu) msg).getParentID(); // Valid Tests assertEquals("Menu ID didn't match input menu ID.", TestValues.GENERAL_INT, testMenuId); @@ -89,6 +92,7 @@ public class AddSubmenuTests extends BaseRpcTests{ assertEquals("Position didn't match input position.", TestValues.GENERAL_INT, testPosition); assertTrue("Menu icon didn't match input icon.", Validator.validateImage(TestValues.GENERAL_IMAGE, testMenuIcon)); assertEquals("Menu layout didn't match input menu layout.", TestValues.GENERAL_MENU_LAYOUT, testMenuLayout); + assertEquals("Parent ID didn't match input Parent ID.", TestValues.GENERAL_MENU_MAX_ID, testParentID); // Invalid/Null Tests @@ -101,6 +105,7 @@ public class AddSubmenuTests extends BaseRpcTests{ assertNull(TestValues.NULL, msg.getPosition()); assertNull(TestValues.NULL, msg.getMenuIcon()); assertNull(TestValues.NULL, msg.getMenuLayout()); + assertNull(TestValues.NULL, msg.getParentID()); } /** @@ -108,7 +113,7 @@ public class AddSubmenuTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { @@ -128,6 +133,7 @@ public class AddSubmenuTests extends BaseRpcTests{ assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, AddSubMenu.KEY_POSITION), cmd.getPosition()); assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, AddSubMenu.KEY_MENU_NAME), cmd.getMenuName()); assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(parameters, AddSubMenu.KEY_MENU_LAYOUT), cmd.getMenuLayout()); + assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, AddSubMenu.KEY_PARENT_ID), cmd.getParentID()); JSONObject menuIcon = JsonUtils.readJsonObjectFromJsonObject(parameters, AddSubMenu.KEY_MENU_ICON); Image referenceMenuIcon = new Image(JsonRPCMarshaller.deserializeJSONObject(menuIcon)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertManeuverTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertManeuverTests.java index f7c2c3218..2fef7e829 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertManeuverTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertManeuverTests.java @@ -26,7 +26,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -95,7 +95,7 @@ public class AlertManeuverTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertTests.java index e9a455ce5..2224191dd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertTests.java @@ -27,7 +27,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -136,7 +136,7 @@ public class AlertTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ButtonPressTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ButtonPressTests.java index 63a411fe6..f593f2325 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ButtonPressTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ButtonPressTests.java @@ -18,7 +18,7 @@ import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -101,7 +101,7 @@ public class ButtonPressTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CancelInteractionTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CancelInteractionTests.java index bed52225c..d2e41f85e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CancelInteractionTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CancelInteractionTests.java @@ -53,7 +53,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -120,7 +120,7 @@ public class CancelInteractionTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ChangeRegistrationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ChangeRegistrationTests.java index 05c8dddd5..a2e0cadf0 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ChangeRegistrationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ChangeRegistrationTests.java @@ -16,7 +16,7 @@ import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -89,7 +89,7 @@ public class ChangeRegistrationTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CloseApplicationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CloseApplicationTests.java index 99428fae2..62a92acfc 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CloseApplicationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CloseApplicationTests.java @@ -52,7 +52,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -96,7 +96,7 @@ public class CloseApplicationTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateInteractionChoiceSetTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateInteractionChoiceSetTests.java index 0d6ab0e2a..3e8e533e2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateInteractionChoiceSetTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateInteractionChoiceSetTests.java @@ -24,7 +24,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -96,7 +96,7 @@ public class CreateInteractionChoiceSetTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateWindowTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateWindowTests.java index 3e2ddee64..733932efb 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateWindowTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateWindowTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -104,7 +104,7 @@ public class CreateWindowTests extends BaseRpcTests { */ @Test public void testJsonConstructor() { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java index 4e485e8ff..20d5fe591 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java @@ -19,7 +19,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -83,7 +83,7 @@ public class DeleteCommandTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java index c95b85536..5174f9789 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java @@ -19,7 +19,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -83,7 +83,7 @@ public class DeleteFileTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteInteractionChoiceSetTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteInteractionChoiceSetTests.java index c4ac6db5d..0fb31ba25 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteInteractionChoiceSetTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteInteractionChoiceSetTests.java @@ -19,7 +19,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -83,7 +83,7 @@ public class DeleteInteractionChoiceSetTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteSubMenuTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteSubMenuTests.java index 12e982b94..68adc14fa 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteSubMenuTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteSubMenuTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -82,7 +82,7 @@ public class DeleteSubMenuTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteWindowTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteWindowTests.java index 1f1b2ab89..c442395bd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteWindowTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteWindowTests.java @@ -18,7 +18,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -82,7 +82,7 @@ public class DeleteWindowTests extends BaseRpcTests { */ @Test public void testJsonConstructor() { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DiagnosticMessageTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DiagnosticMessageTests.java index 41accb797..7b0ecacf9 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DiagnosticMessageTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DiagnosticMessageTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -100,7 +100,7 @@ public class DiagnosticMessageTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java index fc0db6117..88e9fbffd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java @@ -18,7 +18,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * Created by austinkirk on 6/6/17. @@ -83,7 +83,7 @@ public class DialNumberTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/EndAudioPassThruTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/EndAudioPassThruTests.java index 7694da1e6..d97bc0f32 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/EndAudioPassThruTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/EndAudioPassThruTests.java @@ -18,7 +18,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -62,7 +62,7 @@ public class EndAudioPassThruTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetAppServiceDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetAppServiceDataTests.java index 2a9ab6641..f5e7bba89 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetAppServiceDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetAppServiceDataTests.java @@ -19,7 +19,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class GetAppServiceDataTests extends BaseRpcTests { @@ -93,7 +93,7 @@ public class GetAppServiceDataTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetDTCsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetDTCsTests.java index 930debec5..73d15ad6d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetDTCsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetDTCsTests.java @@ -19,7 +19,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -88,7 +88,7 @@ public class GetDTCsTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetFileTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetFileTests.java index df19fa3de..450dcba1e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetFileTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetFileTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class GetFileTests extends BaseRpcTests { @@ -113,7 +113,7 @@ public class GetFileTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { 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 a6def432b..2aa7dc593 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 @@ -16,7 +16,7 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -77,7 +77,7 @@ public class GetInteriorVehicleDataConsentTests extends BaseRpcTests { @Test public void testJsonConstructor() { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java index 4ab5f5e6a..4c7f5f461 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -94,7 +94,7 @@ public class GetInteriorVehicleDataTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java index f65473c3f..533ff8c50 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class GetSystemCapabilityTests extends BaseRpcTests { @@ -85,7 +85,7 @@ public class GetSystemCapabilityTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java index 7ce293942..67bfb42ec 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -61,6 +61,8 @@ public class GetVehicleDataTests extends BaseRpcTests { msg.setFuelRange(TestValues.GENERAL_BOOLEAN); msg.setTurnSignal(TestValues.GENERAL_BOOLEAN); msg.setElectronicParkBrakeStatus(TestValues.GENERAL_BOOLEAN); + msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN); + msg.setWindowStatus(TestValues.GENERAL_BOOLEAN); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); return msg; @@ -110,6 +112,8 @@ public class GetVehicleDataTests extends BaseRpcTests { result.put(GetVehicleData.KEY_FUEL_RANGE, TestValues.GENERAL_BOOLEAN); result.put(GetVehicleData.KEY_TURN_SIGNAL, TestValues.GENERAL_BOOLEAN); result.put(GetVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_BOOLEAN); + result.put(GetVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN); + result.put(GetVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); }catch(JSONException e){ fail(TestValues.JSON_FAIL); @@ -122,7 +126,7 @@ public class GetVehicleDataTests extends BaseRpcTests { * Tests the expected values of the RPC message. */ @Test - public void testRpcValues () { + public void testRpcValues () { // Valid Tests assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getSpeed()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getRpm()); @@ -154,6 +158,8 @@ public class GetVehicleDataTests extends BaseRpcTests { assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getFuelRange()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getTurnSignal()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getElectronicParkBrakeStatus()); + assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getHandsOffSteering()); + assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getWindowStatus()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -190,6 +196,8 @@ public class GetVehicleDataTests extends BaseRpcTests { assertNull(TestValues.NULL, msg.getFuelRange()); assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); + assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -198,7 +206,7 @@ public class GetVehicleDataTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { @@ -242,6 +250,8 @@ public class GetVehicleDataTests extends BaseRpcTests { assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_FUEL_RANGE), cmd.getFuelRange()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_TURN_SIGNAL), cmd.getTurnSignal()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_WINDOW_STATUS), cmd.getWindowStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } catch (JSONException e) { fail(TestValues.JSON_FAIL); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java index 4037eb53d..a52d1a644 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * Created by austinkirk on 6/6/17. @@ -83,7 +83,7 @@ public class GetWayPointsTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ListFilesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ListFilesTests.java index ac51ca8aa..92e7286e4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ListFilesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ListFilesTests.java @@ -18,7 +18,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -62,7 +62,7 @@ public class ListFilesTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAppServiceInteractionTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAppServiceInteractionTests.java index 0085f0f30..9a9b7b375 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAppServiceInteractionTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAppServiceInteractionTests.java @@ -19,7 +19,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class PerformAppServiceInteractionTests extends BaseRpcTests { @@ -110,7 +110,7 @@ public class PerformAppServiceInteractionTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAudioPassThruTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAudioPassThruTests.java index 65c4b00dd..abbe3d644 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAudioPassThruTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAudioPassThruTests.java @@ -28,7 +28,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -129,7 +129,7 @@ public class PerformAudioPassThruTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformInteractionTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformInteractionTests.java index f363e06a2..176cc3ec5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformInteractionTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformInteractionTests.java @@ -28,7 +28,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -138,7 +138,7 @@ public class PerformInteractionTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PublishAppServiceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PublishAppServiceTests.java index fecad8073..9d0c3ed94 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PublishAppServiceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PublishAppServiceTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class PublishAppServiceTests extends BaseRpcTests { @@ -92,7 +92,7 @@ public class PublishAppServiceTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PutFileTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PutFileTests.java index d5834414d..b70c83794 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PutFileTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PutFileTests.java @@ -21,7 +21,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -130,7 +130,7 @@ public class PutFileTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReadDidTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReadDidTests.java index f528e34ce..151f5cc3e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReadDidTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReadDidTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -91,7 +91,7 @@ public class ReadDidTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/RegisterAppInterfaceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/RegisterAppInterfaceTests.java index 74035cb7c..665a3dc80 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/RegisterAppInterfaceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/RegisterAppInterfaceTests.java @@ -31,7 +31,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -169,7 +169,7 @@ public class RegisterAppInterfaceTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { 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 280e4f11b..e786d1786 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 @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class ReleaseInteriorVehicleDataModuleTests extends BaseRpcTests { @@ -75,7 +75,7 @@ public class ReleaseInteriorVehicleDataModuleTests extends BaseRpcTests { @Test public void testJsonConstructor() { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ResetGlobalPropertiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ResetGlobalPropertiesTests.java index 89cef762e..68448c5a6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ResetGlobalPropertiesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ResetGlobalPropertiesTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -89,7 +89,7 @@ public class ResetGlobalPropertiesTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ScrollableMessageTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ScrollableMessageTests.java index 632769924..e6d8b146d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ScrollableMessageTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ScrollableMessageTests.java @@ -25,7 +25,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -108,7 +108,7 @@ public class ScrollableMessageTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendLocationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendLocationTests.java index c92eac6ec..99a74dfae 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendLocationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendLocationTests.java @@ -23,7 +23,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -117,7 +117,7 @@ public class SendLocationTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull("Command object is null", commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetAppIconTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetAppIconTests.java index e4df0a44b..5878aad7c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetAppIconTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetAppIconTests.java @@ -19,7 +19,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -83,7 +83,7 @@ public class SetAppIconTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetDisplayLayoutTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetDisplayLayoutTests.java index 56f0dc0bc..22118bdb1 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetDisplayLayoutTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetDisplayLayoutTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -97,7 +97,7 @@ public class SetDisplayLayoutTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java index 51adf5c7c..379b1c1ee 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java @@ -29,7 +29,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -128,7 +128,7 @@ public class SetGlobalPropertiesTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java index ecffe1b21..1285acafd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -86,7 +86,7 @@ public class SetInteriorVehicleDataTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java index 5e97d8633..a60709dba 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java @@ -24,7 +24,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -169,7 +169,7 @@ public class SetMediaClockTimerTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowAppMenuTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowAppMenuTests.java index eb2526e54..3e486bc6a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowAppMenuTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowAppMenuTests.java @@ -54,7 +54,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -116,7 +116,7 @@ public class ShowAppMenuTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowConstantTbtTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowConstantTbtTests.java index 4a3034eee..85c830214 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowConstantTbtTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowConstantTbtTests.java @@ -26,7 +26,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -140,7 +140,7 @@ public class ShowConstantTbtTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java index de39d2733..742d23ff4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java @@ -29,7 +29,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -156,7 +156,7 @@ public class ShowTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(),getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(),getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SliderTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SliderTests.java index c375d2d4d..32f60d4e5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SliderTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SliderTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -111,7 +111,7 @@ public class SliderTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SpeakTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SpeakTests.java index 4681975fe..f0214c78c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SpeakTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SpeakTests.java @@ -25,7 +25,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class SpeakTests extends BaseRpcTests { @@ -85,7 +85,7 @@ public class SpeakTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeButtonTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeButtonTests.java index 534e65576..19b192b31 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeButtonTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeButtonTests.java @@ -15,7 +15,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -83,7 +83,7 @@ public class SubscribeButtonTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java index d319d1b11..c7b5b9678 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -60,6 +60,8 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { msg.setFuelRange(TestValues.GENERAL_BOOLEAN); msg.setTurnSignal(TestValues.GENERAL_BOOLEAN); msg.setElectronicParkBrakeStatus(TestValues.GENERAL_BOOLEAN); + msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN); + msg.setWindowStatus(TestValues.GENERAL_BOOLEAN); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); return msg; @@ -108,6 +110,8 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { result.put(SubscribeVehicleData.KEY_FUEL_RANGE, TestValues.GENERAL_BOOLEAN); result.put(SubscribeVehicleData.KEY_TURN_SIGNAL, TestValues.GENERAL_BOOLEAN); result.put(SubscribeVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_BOOLEAN); + result.put(SubscribeVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN); + result.put(SubscribeVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); } catch (JSONException e) { fail(TestValues.JSON_FAIL); @@ -151,6 +155,8 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getFuelRange()); assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getTurnSignal()); assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getElectronicParkBrakeStatus()); + assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getHandsOffSteering()); + assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getWindowStatus()); assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -186,6 +192,8 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { assertNull(TestValues.NULL, msg.getFuelRange()); assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); + assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -194,7 +202,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { @@ -237,6 +245,8 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_FUEL_RANGE), cmd.getFuelRange()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_TURN_SIGNAL), cmd.getTurnSignal()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_WINDOW_STATUS), cmd.getWindowStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } catch (JSONException e) { fail(TestValues.JSON_FAIL); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java index 894ef026e..2ce400e55 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java @@ -18,7 +18,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * Created by austinkirk on 6/7/17. @@ -61,7 +61,7 @@ public class SubscribeWayPointsTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SystemRequestTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SystemRequestTests.java index 217e4da58..aeb061dc6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SystemRequestTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SystemRequestTests.java @@ -23,7 +23,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -104,7 +104,7 @@ public class SystemRequestTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnpublishAppServiceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnpublishAppServiceTests.java index f038121a7..796fe2a25 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnpublishAppServiceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnpublishAppServiceTests.java @@ -54,7 +54,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -128,7 +128,7 @@ public class UnpublishAppServiceTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnregisterAppInterfaceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnregisterAppInterfaceTests.java index e400ff73b..dec7b0376 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnregisterAppInterfaceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnregisterAppInterfaceTests.java @@ -18,7 +18,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -62,7 +62,7 @@ public class UnregisterAppInterfaceTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeButtonTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeButtonTests.java index 9b786cb7d..97833ce02 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeButtonTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeButtonTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -85,7 +85,7 @@ public class UnsubscribeButtonTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java index 0f2098c54..98eaf599c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java @@ -21,7 +21,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -63,6 +63,8 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { msg.setTurnSignal(TestValues.GENERAL_BOOLEAN); msg.setElectronicParkBrakeStatus(TestValues.GENERAL_BOOLEAN); msg.setCloudAppVehicleID(TestValues.GENERAL_BOOLEAN); + msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN); + msg.setWindowStatus(TestValues.GENERAL_BOOLEAN); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); return msg; @@ -112,6 +114,8 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { result.put(UnsubscribeVehicleData.KEY_TURN_SIGNAL, TestValues.GENERAL_BOOLEAN); result.put(UnsubscribeVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_BOOLEAN); result.put(UnsubscribeVehicleData.KEY_CLOUD_APP_VEHICLE_ID, TestValues.GENERAL_BOOLEAN); + result.put(UnsubscribeVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN); + result.put(UnsubscribeVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); } catch (JSONException e) { fail(TestValues.JSON_FAIL); @@ -124,7 +128,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { * Tests the expected values of the RPC message. */ @Test - public void testRpcValues(){ + public void testRpcValues(){ // Valid Tests assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getSpeed()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getRpm()); @@ -155,8 +159,9 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getTurnSignal()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getElectronicParkBrakeStatus()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getCloudAppVehicleID()); + assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getHandsOffSteering()); + assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getWindowStatus()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); - // Invalid/Null Tests UnsubscribeVehicleData msg = new UnsubscribeVehicleData(); assertNotNull(TestValues.NOT_NULL, msg); @@ -191,6 +196,8 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); assertNull(TestValues.NULL, msg.getCloudAppVehicleID()); + assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -199,7 +206,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { @@ -243,6 +250,8 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_TURN_SIGNAL), cmd.getTurnSignal()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_CLOUD_APP_VEHICLE_ID), cmd.getCloudAppVehicleID()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_WINDOW_STATUS), cmd.getWindowStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java index d595b8ec9..5d20c8454 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; @@ -60,7 +60,7 @@ public class UnsubscribeWayPointsTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UpdateTurnListTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UpdateTurnListTests.java index 3f2e37a03..53dc91fc6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UpdateTurnListTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UpdateTurnListTests.java @@ -26,7 +26,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -98,7 +98,7 @@ public class UpdateTurnListTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java index 94346fdb2..e4d69e79f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java @@ -15,7 +15,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -61,7 +61,7 @@ public class AddCommandResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java index ec355539d..861de0d37 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class AddSubmenuResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java index f26a09f4a..01805fce6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class AlertManeuverResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java index ff260f23f..d8f554c53 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java @@ -19,7 +19,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -83,7 +83,7 @@ public class AlertResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java index 25b8140c4..2c4bfc651 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class ButtonPressResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CancelInteractionResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CancelInteractionResponseTests.java index e1fb2746a..a981719e9 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CancelInteractionResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CancelInteractionResponseTests.java @@ -48,7 +48,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -94,7 +94,7 @@ public class CancelInteractionResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java index 60996445c..6888c589d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java @@ -17,7 +17,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -61,7 +61,7 @@ public class ChangeRegistrationResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CloseApplicationResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CloseApplicationResponseTests.java index 9bf867391..6eb9a09a5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CloseApplicationResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CloseApplicationResponseTests.java @@ -48,7 +48,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -94,7 +94,7 @@ public class CloseApplicationResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CreateWindowResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CreateWindowResponseTest.java index 56e8fc257..a06af985b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CreateWindowResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CreateWindowResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class CreateWindowResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor() { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java index 2318a4e46..b2e6e27a9 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class DeleteCommandResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java index d5ca5d0c1..0e529dc69 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -82,7 +82,7 @@ public class DeleteFileResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java index 7a313531c..24ce266d1 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class DeleteInteractionChoiceSetResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java index e70402ecd..8392f915b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class DeleteSubMenuResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteWindowResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteWindowResponseTest.java index bfa2df5aa..347db5ea6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteWindowResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteWindowResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class DeleteWindowResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor() { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java index d42a1e53e..7bfefbeea 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java @@ -16,7 +16,7 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -91,7 +91,7 @@ public class DiagnosticMessageResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java index 9625cf3d5..ff23c5ad7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class DialNumberResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java index 9d999e1b7..f68a6837b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class EndAudioPassThruResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetAppServiceDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetAppServiceDataResponseTests.java index 243c9ab3b..3e1d1f136 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetAppServiceDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetAppServiceDataResponseTests.java @@ -15,7 +15,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -66,7 +66,7 @@ public class GetAppServiceDataResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java index 464efa60c..ea4d48790 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -90,7 +90,7 @@ public class GetDTCsResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetFileResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetFileResponseTests.java index 6b62d3200..a4abf011d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetFileResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetFileResponseTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -101,7 +101,7 @@ public class GetFileResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { 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 48cea8f69..411691bd0 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 @@ -16,7 +16,7 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertTrue; @@ -68,7 +68,7 @@ public class GetInteriorVehicleDataConsentResponseTests extends BaseRpcTests { @Test public void testJsonConstructor() { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java index fd3e793f5..80185c05c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java @@ -16,7 +16,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -91,7 +91,7 @@ public class GetInteriorVehicleDataResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java index 80a0a8b8d..ee2b24d1f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java @@ -20,7 +20,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class GetSystemCapabilityResponseTests extends BaseRpcTests { @@ -80,7 +80,7 @@ public class GetSystemCapabilityResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java index d09494913..001bf54f2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java @@ -17,6 +17,7 @@ import com.smartdevicelink.proxy.rpc.HeadLampStatus; import com.smartdevicelink.proxy.rpc.MyKey; import com.smartdevicelink.proxy.rpc.SingleTireStatus; import com.smartdevicelink.proxy.rpc.TireStatus; +import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.enums.TurnSignal; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; @@ -40,7 +41,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -98,6 +99,8 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ result.put(GetVehicleDataResponse.KEY_FUEL_RANGE, VehicleDataHelper.JSON_FUEL_RANGE); result.put(GetVehicleDataResponse.KEY_TURN_SIGNAL, VehicleDataHelper.TURN_SIGNAL); result.put(GetVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); + result.put(GetVehicleDataResponse.KEY_WINDOW_STATUS, VehicleDataHelper.WINDOW_STATUS_LIST); + result.put(GetVehicleDataResponse.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); } catch(JSONException e){ fail(TestValues.JSON_FAIL); @@ -123,8 +126,10 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ JSONObject clusterModeStatusObj = new JSONObject(); JSONObject myKeyObj = new JSONObject(); JSONObject fuelRangeObj = new JSONObject(); + JSONObject windowStatusObj = new JSONObject(); JSONArray fuelRangeArrayObj = new JSONArray(); - + JSONArray windowStatusArrayObj = new JSONArray(); + try { //set up the JSONObject to represent GetVehicleDataResponse //TIRE_PRESSURE @@ -249,6 +254,11 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ fuelRangeObj.put(FuelRange.KEY_RANGE, VehicleDataHelper.FUEL_RANGE_RANGE); fuelRangeArrayObj.put(fuelRangeObj); + // WINDOW_STATUS + windowStatusObj.put(WindowStatus.KEY_LOCATION, VehicleDataHelper.LOCATION_GRID); + windowStatusObj.put(WindowStatus.KEY_STATE, VehicleDataHelper.WINDOW_STATE); + windowStatusArrayObj.put(windowStatusObj); + reference.put(GetVehicleDataResponse.KEY_SPEED, VehicleDataHelper.SPEED); reference.put(GetVehicleDataResponse.KEY_RPM, VehicleDataHelper.RPM); reference.put(GetVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE, VehicleDataHelper.EXTERNAL_TEMPERATURE); @@ -278,8 +288,10 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ reference.put(GetVehicleDataResponse.KEY_FUEL_RANGE, fuelRangeArrayObj); reference.put(GetVehicleDataResponse.KEY_TURN_SIGNAL, TurnSignal.OFF); reference.put(GetVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); + reference.put(GetVehicleDataResponse.KEY_WINDOW_STATUS, windowStatusArrayObj); + reference.put(GetVehicleDataResponse.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); reference.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); - + JSONObject underTest = msg.serializeJSON(); //go inside underTest and only return the JSONObject inside the parameters key inside the response key @@ -416,6 +428,26 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ fuelRangeRefereceList, fuelRangeUnderTestList)); } + else if (key.equals(GetVehicleDataResponse.KEY_WINDOW_STATUS)) { + JSONArray windowStatusArrayObjReference = JsonUtils.readJsonArrayFromJsonObject(reference, key); + List<WindowStatus> windowStatusReferenceList = new ArrayList<>(); + for (int index = 0; index < windowStatusArrayObjReference.length(); index++) { + WindowStatus windowStatus = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArrayObjReference.get(index) )); + windowStatusReferenceList.add(windowStatus); + } + + JSONArray windowStatusArrayObjTest = JsonUtils.readJsonArrayFromJsonObject(underTest, key); + List<WindowStatus> windowStatusUnderTestList = new ArrayList<>(); + for (int index = 0; index < windowStatusArrayObjTest.length(); index++) { + WindowStatus windowStatus = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArrayObjTest.get(index) )); + windowStatusUnderTestList.add(windowStatus); + } + + assertTrue("JSON value didn't match expected value for key \"" + key + "\".", + Validator.validateWindowStatuses( + windowStatusReferenceList, + windowStatusUnderTestList)); + } else { assertEquals("JSON value didn't match expected value for key \"" + key + "\".", JsonUtils.readObjectFromJsonObject(reference, key), @@ -433,7 +465,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ * Tests the expected values of the RPC message. */ @Test - public void testRpcValues(){ + public void testRpcValues(){ // Valid Tests assertEquals(TestValues.MATCH, VehicleDataHelper.SPEED, ( (GetVehicleDataResponse) msg ).getSpeed()); assertEquals(TestValues.MATCH, (Integer) VehicleDataHelper.RPM, ( (GetVehicleDataResponse) msg ).getRpm()); @@ -462,6 +494,8 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ assertEquals(TestValues.MATCH, VehicleDataHelper.MY_KEY, ( (GetVehicleDataResponse) msg ).getMyKey()); assertEquals(TestValues.MATCH, VehicleDataHelper.TURN_SIGNAL, ( (GetVehicleDataResponse) msg ).getTurnSignal()); assertEquals(TestValues.MATCH, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS, ( (GetVehicleDataResponse) msg ).getElectronicParkBrakeStatus()); + assertEquals(TestValues.MATCH, VehicleDataHelper.WINDOW_STATUS_LIST, ( (GetVehicleDataResponse) msg ).getWindowStatus()); + assertEquals(TestValues.MATCH, VehicleDataHelper.HANDS_OFF_STEERING, ( (GetVehicleDataResponse) msg ).getHandsOffSteering()); assertEquals(TestValues.MATCH, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE, ( (GetVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -496,6 +530,8 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ assertNull(TestValues.NULL, msg.getMyKey()); assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); + assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -505,7 +541,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { @@ -526,7 +562,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ assertEquals(TestValues.MATCH, JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_FUEL_LEVEL), cmd.getFuelLevel()); assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_VIN), cmd.getVin()); assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_PRNDL), cmd.getPrndl().toString()); - + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleDataResponse.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); JSONObject tireStatusObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_TIRE_PRESSURE); TireStatus tireStatus = new TireStatus(JsonRPCMarshaller.deserializeJSONObject(tireStatusObj)); assertTrue(TestValues.TRUE, Validator.validateTireStatus(tireStatus, cmd.getTirePressure()) ); @@ -584,6 +620,15 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ MyKey myKey = new MyKey(JsonRPCMarshaller.deserializeJSONObject(myKeyObj)); assertTrue(TestValues.TRUE, Validator.validateMyKey(myKey, cmd.getMyKey()) ); + JSONArray windowStatusArray = JsonUtils.readJsonArrayFromJsonObject(parameters, GetVehicleDataResponse.KEY_WINDOW_STATUS); + + List<WindowStatus> windowStatus = new ArrayList<>(); + for (int index = 0; index < windowStatusArray.length(); index++) { + WindowStatus status = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArray.get(index)) ); + windowStatus.add(status); + } + assertTrue(TestValues.TRUE, Validator.validateWindowStatuses(windowStatus, cmd.getWindowStatus()) ); + assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_TURN_SIGNAL), cmd.getTurnSignal().toString()); assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus().toString()); assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java index f133e2bed..fb123bef4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java @@ -18,7 +18,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -98,7 +98,7 @@ public class GetWayPointsResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java index 432562631..7b7bd20ec 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -93,7 +93,7 @@ public class ListFilesResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAppServiceInteractionResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAppServiceInteractionResponseTests.java index 58663a888..4280902e2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAppServiceInteractionResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAppServiceInteractionResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -84,7 +84,7 @@ public class PerformAppServiceInteractionResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java index 3fb489fca..7cff8e766 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class PerformAudioPassThruResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java index dd81627b4..32c42c16c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java @@ -15,7 +15,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -93,7 +93,7 @@ public class PerformInteractionResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PublishAppServiceResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PublishAppServiceResponseTests.java index 9659c992b..5bb6f923a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PublishAppServiceResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PublishAppServiceResponseTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -87,7 +87,7 @@ public class PublishAppServiceResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java index 90faa7291..e95285db8 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -82,7 +82,7 @@ public class PutFileResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java index 5948eb3f5..aec63227d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java @@ -19,7 +19,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -89,7 +89,7 @@ public class ReadDIDResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java index 4a12bc5b3..862ed5342 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java @@ -36,7 +36,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -176,7 +176,7 @@ public class RegisterAppInterfaceResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReleaseInteriorVehicleDataModuleResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReleaseInteriorVehicleDataModuleResponseTests.java index 760623916..965980a0d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReleaseInteriorVehicleDataModuleResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReleaseInteriorVehicleDataModuleResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; @@ -44,7 +44,7 @@ public class ReleaseInteriorVehicleDataModuleResponseTests extends BaseRpcTests @Test public void testJsonConstructor() { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java index eb8ab1ae2..e8d3576e6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class ResetGlobalPropertiesResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java index e7ec116d4..4e12cb78c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class ScrollableMessageResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java index bf9461328..7208eeff4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -61,7 +61,7 @@ public class SendLocationResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java index dd850f46b..e6f0bf140 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class SetAppIconResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java index b6e7be537..63d63dab9 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java @@ -28,7 +28,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -113,7 +113,7 @@ public class SetDisplayLayoutResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java index 04e099304..9765dcfba 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -61,7 +61,7 @@ public class SetGlobalPropertiesResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java index cdb59146c..7abcdcecc 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -87,7 +87,7 @@ public class SetInteriorVehicleDataResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java index 981f4e3f0..d8f699b5a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java @@ -17,7 +17,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -61,7 +61,7 @@ public class SetMediaClockTimerResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowAppMenuResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowAppMenuResponseTests.java index a4b1dda0b..1cfafd319 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowAppMenuResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowAppMenuResponseTests.java @@ -49,7 +49,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -91,7 +91,7 @@ public class ShowAppMenuResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java index 06bb43dba..aa44a190b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -61,7 +61,7 @@ public class ShowConstantTbtResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java index 6e6140068..ebd5f41b6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java @@ -17,7 +17,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -62,7 +62,7 @@ public class ShowResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java index 8d288c73b..f454af9eb 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; @@ -81,7 +81,7 @@ public class SliderResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java index 196c06f21..f2880d3eb 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class SpeakResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/StreamRPCResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/StreamRPCResponseTests.java index 252a34aab..2dcfb0509 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/StreamRPCResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/StreamRPCResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -72,7 +72,7 @@ public class StreamRPCResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java index 023fd8869..1c58b13bc 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java @@ -17,7 +17,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -62,7 +62,7 @@ public class SubscribeButtonResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java index 6694886d9..def395e1e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java @@ -22,7 +22,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.fail; /** @@ -65,6 +65,8 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { msg.setFuelRange(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELRANGE.ordinal())); msg.setTurnSignal(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal())); msg.setElectronicParkBrakeStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal())); + msg.setHandsOffSteering(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal())); + msg.setWindowStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal())); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA); return msg; @@ -117,7 +119,9 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { result.put(SubscribeVehicleDataResponse.KEY_MY_KEY, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_MYKEY.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_FUEL_RANGE, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELRANGE.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_TURN_SIGNAL, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_WINDOW_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal()).serializeJSON()); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA.serializeJSON()); } catch (JSONException e) { fail(TestValues.JSON_FAIL); @@ -130,7 +134,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { * Tests the expected values of the RPC message. */ @Test - public void testRpcValues () { + public void testRpcValues () { // Test Values VehicleDataResult testGps = ( (SubscribeVehicleDataResponse) msg ).getGps(); VehicleDataResult testOdometer = ( (SubscribeVehicleDataResponse) msg ).getOdometer(); @@ -160,6 +164,8 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult testFuelRange = ( (SubscribeVehicleDataResponse) msg ).getFuelRange(); VehicleDataResult testTurnSignal = ( (SubscribeVehicleDataResponse) msg ).getTurnSignal(); VehicleDataResult testEBrakeStatus = ( (SubscribeVehicleDataResponse) msg ).getElectronicParkBrakeStatus(); + VehicleDataResult testHOffSteering = ( (SubscribeVehicleDataResponse) msg ).getHandsOffSteering(); + VehicleDataResult testWindowStatus = ( (SubscribeVehicleDataResponse) msg ).getWindowStatus(); VehicleDataResult testOEMCustomVehicleData = ( (SubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); // Valid Tests @@ -191,6 +197,8 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { assertTrue(TestValues.TRUE, testFuelRange.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELRANGE)); assertTrue(TestValues.TRUE, testTurnSignal.getDataType().equals(VehicleDataType.VEHICLEDATA_TURNSIGNAL)); assertTrue(TestValues.TRUE, testEBrakeStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS)); + assertTrue(TestValues.TRUE, testHOffSteering.getDataType().equals(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING)); + assertTrue(TestValues.TRUE, testWindowStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_WINDOWSTATUS)); assertTrue(TestValues.TRUE, testOEMCustomVehicleData.getOEMCustomVehicleDataType().equals(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -226,6 +234,8 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { assertNull(TestValues.NULL, msg.getFuelRange()); assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); + assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -234,7 +244,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { @@ -362,6 +372,14 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult referenceEBrakeStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(electronicParkBrakeStatus)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceEBrakeStatus, cmd.getElectronicParkBrakeStatus())); + JSONObject handsOffSteering = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_HANDS_OFF_STEERING); + VehicleDataResult referenceHandsOffSteering = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(handsOffSteering)); + assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceHandsOffSteering, cmd.getHandsOffSteering())); + + JSONObject windowStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_WINDOW_STATUS); + VehicleDataResult referenceWindowStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(windowStatus)); + assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceWindowStatus, cmd.getWindowStatus())); + JSONObject oemCustomVehicleDataName = JsonUtils.readJsonObjectFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); VehicleDataResult referenceOemCustomData = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(oemCustomVehicleDataName)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceOemCustomData, cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME))); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java index 817414ae1..239702805 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -59,7 +59,7 @@ public class SubscribeWaypointsResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java index 3ccae2288..9f4e464f4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class SystemRequestResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnpublishAppServiceResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnpublishAppServiceResponseTests.java index 62264a884..7536dd2a7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnpublishAppServiceResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnpublishAppServiceResponseTests.java @@ -49,7 +49,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -95,7 +95,7 @@ public class UnpublishAppServiceResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java index cb461a563..01aad979c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class UnregisterAppInterfaceResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java index afdedbdd0..3cf7d6491 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java @@ -17,7 +17,7 @@ import java.util.Hashtable; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -62,7 +62,7 @@ public class UnsubscribeButtonResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java index f79b18b30..b79ddc4cf 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java @@ -25,7 +25,7 @@ import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -67,6 +67,8 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { msg.setFuelRange(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELRANGE.ordinal())); msg.setTurnSignal(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal())); msg.setElectronicParkBrakeStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal())); + msg.setWindowStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal())); + msg.setHandsOffSteering(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal())); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA); return msg; @@ -120,6 +122,8 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { result.put(SubscribeVehicleDataResponse.KEY_FUEL_RANGE, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELRANGE.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_TURN_SIGNAL, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_WINDOW_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal()).serializeJSON()); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA.serializeJSON()); } catch (JSONException e) { fail(TestValues.JSON_FAIL); @@ -132,7 +136,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { * Tests the expected values of the RPC message. */ @Test - public void testRpcValues () { + public void testRpcValues () { // Test Values VehicleDataResult testGps = ( (UnsubscribeVehicleDataResponse) msg ).getGps(); VehicleDataResult testOdometer = ( (UnsubscribeVehicleDataResponse) msg ).getOdometer(); @@ -162,6 +166,8 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult testFuelRange = ( (UnsubscribeVehicleDataResponse) msg ).getFuelRange(); VehicleDataResult testTurnSignal = ( (UnsubscribeVehicleDataResponse) msg ).getTurnSignal(); VehicleDataResult testEBrakeStatus = ( (UnsubscribeVehicleDataResponse) msg ).getElectronicParkBrakeStatus(); + VehicleDataResult testHOffSteering = ( (UnsubscribeVehicleDataResponse) msg ).getHandsOffSteering(); + VehicleDataResult testWindowStatus = ( (UnsubscribeVehicleDataResponse) msg ).getWindowStatus(); VehicleDataResult testOemCustomData = ( (UnsubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); // Valid Tests @@ -193,6 +199,8 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { assertTrue(TestValues.TRUE, testFuelRange.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELRANGE)); assertTrue(TestValues.TRUE, testTurnSignal.getDataType().equals(VehicleDataType.VEHICLEDATA_TURNSIGNAL)); assertTrue(TestValues.TRUE, testEBrakeStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS)); + assertTrue(TestValues.TRUE, testHOffSteering.getDataType().equals(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING)); + assertTrue(TestValues.TRUE, testWindowStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_WINDOWSTATUS)); assertTrue(TestValues.TRUE, testOemCustomData.getOEMCustomVehicleDataType().equals(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -228,6 +236,8 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { assertNull(TestValues.NULL, msg.getFuelRange()); assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); + assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -236,7 +246,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { @@ -364,6 +374,14 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult referenceEBrakeStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(eBrakeStatus)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceEBrakeStatus, cmd.getElectronicParkBrakeStatus())); + JSONObject handsOffSteering = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_HANDS_OFF_STEERING); + VehicleDataResult referenceHandsOffSteering = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(handsOffSteering)); + assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceHandsOffSteering, cmd.getHandsOffSteering())); + + JSONObject windowStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_WINDOW_STATUS); + VehicleDataResult referenceWindowStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(windowStatus)); + assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceWindowStatus, cmd.getWindowStatus())); + JSONObject oemCustomData = JsonUtils.readJsonObjectFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); VehicleDataResult referenceOemCustomData = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(oemCustomData)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceOemCustomData, cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME))); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java index 49017109a..5360c023c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -59,7 +59,7 @@ public class UnsubscribeWayPointsResponseTests extends BaseRpcTests{ */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java index 603565803..47951d34c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java @@ -14,7 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -60,7 +60,7 @@ public class UpdateTurnListResponseTests extends BaseRpcTests { */ @Test public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); assertNotNull(TestValues.NOT_NULL, commandJson); try { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java index 685b8cbf5..aeb73e3de 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java @@ -1,17 +1,13 @@ package com.smartdevicelink.test.security; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.smartdevicelink.SdlConnection.ISdlConnectionListener; import com.smartdevicelink.SdlConnection.SdlSession; -import com.smartdevicelink.protocol.ProtocolMessage; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.security.SdlSecurityBase; import com.smartdevicelink.test.TestValues; -import com.smartdevicelink.transport.BTTransportConfig; -import com.smartdevicelink.transport.BaseTransportConfig; +import com.smartdevicelink.test.streaming.MockInterfaceBroker; import com.smartdevicelink.transport.MultiplexTransportConfig; -import com.smartdevicelink.transport.TCPTransportConfig; import org.junit.Test; import org.junit.runner.RunWith; @@ -19,7 +15,7 @@ import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.List; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; @@ -61,65 +57,6 @@ public class SdlSecurityBaseTest { startServiceList = list; } } - - class MockInterfaceBroker implements ISdlConnectionListener { - public MockInterfaceBroker () { } - @Override - public void onTransportDisconnected(String info) { - - } - - @Override - public void onTransportDisconnected(String info, boolean availablePrimary, BaseTransportConfig transportConfig) { - - } - - @Override - public void onTransportError(String info, Exception e) { - - } - @Override - public void onProtocolMessageReceived(ProtocolMessage msg) { - - } - @Override - public void onProtocolSessionStartedNACKed(SessionType sessionType, - byte sessionID, byte version, String correlationID, List<String> rejectedParams) { - - } - @Override - public void onProtocolSessionStarted(SessionType sessionType, - byte sessionID, byte version, String correlationID, int hashID, - boolean isEncrypted) { - - } - @Override - public void onProtocolSessionEnded(SessionType sessionType, byte sessionID, - String correlationID) { - - } - @Override - public void onProtocolSessionEndedNACKed(SessionType sessionType, - byte sessionID, String correlationID) { - - } - @Override - public void onProtocolError(String info, Exception e) { - - } - @Override - public void onHeartbeatTimedOut(byte sessionID) { - - } - @Override - public void onProtocolServiceDataACK(SessionType sessionType, int dataSize, - byte sessionID) { - - } - @Override - public void onAuthTokenReceived(String token, byte bytes){} - - } @Test public void testMakeListSetAndGet(){ @@ -142,7 +79,7 @@ public class SdlSecurityBaseTest { byte testWiproVersion = (byte) 0x0B; boolean testInitResult = true; MockInterfaceBroker interfaceBroker = new MockInterfaceBroker(); - MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getTargetContext(),"19216801"); + MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getInstrumentation().getTargetContext(),"19216801"); MockSdlSecurityBase mockSdlSecurityBase = new MockSdlSecurityBase(); SdlSession testSdlSession = new SdlSession(interfaceBroker, transportConfig); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java index f487ac927..e5e47f3a5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java @@ -17,7 +17,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -46,7 +46,7 @@ public class AbstractPacketizerTests extends TestCase { try { testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes())); MockInterfaceBroker interfaceBroker = new MockInterfaceBroker(); - MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getTargetContext(),"19216801"); + MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getInstrumentation().getTargetContext(),"19216801"); testSdlSession = new SdlSession(interfaceBroker, transportConfig); testPacketizer1 = new MockPacketizer(testListener, testInputStream, testSessionType, testSessionId, testSdlSession); testPacketizer2 = new MockPacketizer(null, null, null, testSessionId, testSdlSession); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java index f3bcc38ee..1c7005012 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java @@ -1,22 +1,16 @@ package com.smartdevicelink.test.streaming; -import com.smartdevicelink.SdlConnection.ISdlConnectionListener; -import com.smartdevicelink.protocol.ProtocolMessage; -import com.smartdevicelink.protocol.enums.SessionType; +import com.smartdevicelink.SdlConnection.ISdlSessionListener; +import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.transport.BaseTransportConfig; - -import java.util.List; +import com.smartdevicelink.util.Version; /** * This is a mock class for testing the following : * {@link com.smartdevicelink.streaming.AbstractPacketizer} */ -public class MockInterfaceBroker implements ISdlConnectionListener { +public class MockInterfaceBroker implements ISdlSessionListener { public MockInterfaceBroker () { } - @Override - public void onTransportDisconnected(String info) { - - } @Override public void onTransportDisconnected(String info, boolean availablePrimary, BaseTransportConfig transportConfig) { @@ -24,47 +18,22 @@ public class MockInterfaceBroker implements ISdlConnectionListener { } @Override - public void onTransportError(String info, Exception e) { + public void onRPCMessageReceived(RPCMessage rpcMessage) { } - @Override - public void onProtocolMessageReceived(ProtocolMessage msg) { - } @Override - public void onProtocolSessionStartedNACKed(SessionType sessionType, - byte sessionID, byte version, String correlationID, List<String> rejectedParams) { + public void onSessionStarted(int sessionID, Version version) { } - @Override - public void onProtocolSessionStarted(SessionType sessionType, - byte sessionID, byte version, String correlationID, int hashID, - boolean isEncrypted) { - } @Override - public void onProtocolSessionEnded(SessionType sessionType, byte sessionID, - String correlationID) { + public void onSessionEnded(int sessionID) { } - @Override - public void onProtocolSessionEndedNACKed(SessionType sessionType, - byte sessionID, String correlationID) { - } - @Override - public void onProtocolError(String info, Exception e) { - - } @Override - public void onHeartbeatTimedOut(byte sessionID) { + public void onAuthTokenReceived(String authToken, int sessionID) { } - @Override - public void onProtocolServiceDataACK(SessionType sessionType, int dataSize, - byte sessionID) { - - } - @Override - public void onAuthTokenReceived(String token, byte bytes){} } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java index fdfcce8cf..736798d67 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java @@ -21,7 +21,7 @@ import java.io.InputStream; import java.nio.ByteBuffer; import java.util.Arrays; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -131,7 +131,7 @@ public class StreamPacketizerTests extends TestCase { byte testWiproVersion = (byte) 0x0B; IStreamListener testListener = new MockStreamListener(); MockInterfaceBroker interfaceBroker = new MockInterfaceBroker(); - MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getTargetContext(),"19216801"); + MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getInstrumentation().getTargetContext(),"19216801"); SdlSession testSdlSession = new SdlSession(interfaceBroker, transportConfig); try { testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes())); @@ -414,7 +414,7 @@ public class StreamPacketizerTests extends TestCase { private SdlSession createTestSession() { - return new SdlSession(new MockInterfaceBroker(), new MultiplexTransportConfig(getTargetContext(),"19216801")); + return new SdlSession(new MockInterfaceBroker(), new MultiplexTransportConfig(getInstrumentation().getTargetContext(),"19216801")); } private class StreamReceiver implements IStreamListener { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java index 638d3f636..561cc1ef7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java @@ -18,7 +18,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -41,7 +41,7 @@ public class StreamRPCPacketizerTests extends TestCase { IStreamListener testListener = new MockStreamListener(); MockInterfaceBroker interfaceBroker = new MockInterfaceBroker(); - MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getTargetContext(),"19216801"); + MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getInstrumentation().getTargetContext(),"19216801"); SdlSession testSdlSession = new SdlSession(interfaceBroker, transportConfig); try { testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes())); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java index b2b863490..60fa6fb80 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java @@ -31,7 +31,7 @@ package com.smartdevicelink.test.streaming.video; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.SdlConnection.SdlSession; import com.smartdevicelink.protocol.ProtocolMessage; @@ -52,7 +52,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This class includes a unit test for {@link RTPH264Packetizer}. @@ -551,7 +551,7 @@ public class RTPH264PacketizerTest extends TestCase { } private SdlSession createTestSession() { - return new SdlSession(new MockInterfaceBroker(), new MultiplexTransportConfig(getTargetContext(), "41146")); + return new SdlSession(new MockInterfaceBroker(), new MultiplexTransportConfig(getInstrumentation().getTargetContext(), "41146")); } private class StreamVerifier implements IStreamListener { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java index 453239bca..e5b07930e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java @@ -4,7 +4,7 @@ import android.annotation.TargetApi; import android.content.Context; import android.os.Bundle; import android.os.Looper; -import android.support.test.InstrumentationRegistry; +import androidx.test.platform.app.InstrumentationRegistry; import android.view.Display; import android.view.MotionEvent; import android.widget.RelativeLayout; @@ -37,7 +37,7 @@ public class SdlRemoteDisplayTest extends TestCase { assertNotNull(encoder); - SdlRemoteDisplay.Creator creator = new SdlRemoteDisplay.Creator(InstrumentationRegistry.getContext(), encoder.getVirtualDisplay(), null, MockRemoteDisplay.class, rdCallback); + SdlRemoteDisplay.Creator creator = new SdlRemoteDisplay.Creator(InstrumentationRegistry.getInstrumentation().getContext(), encoder.getVirtualDisplay(), null, MockRemoteDisplay.class, rdCallback); assertNotNull(creator); FutureTask<Boolean> fTask = new FutureTask<Boolean>(creator); Thread showPresentation = new Thread(fTask); @@ -48,7 +48,7 @@ public class SdlRemoteDisplayTest extends TestCase { public void testConstructor(){ VirtualDisplayEncoder encoder = createVDE(); assertNotNull(encoder); - MockRemoteDisplay remoteDisplay = new MockRemoteDisplay(InstrumentationRegistry.getContext(), encoder.getVirtualDisplay()); + MockRemoteDisplay remoteDisplay = new MockRemoteDisplay(InstrumentationRegistry.getInstrumentation().getContext(), encoder.getVirtualDisplay()); assertNotNull(remoteDisplay); encoder.shutDown(); @@ -59,7 +59,7 @@ public class SdlRemoteDisplayTest extends TestCase { public void testTouchEvents(){ VirtualDisplayEncoder encoder = createVDE(); assertNotNull(encoder); - MockRemoteDisplay remoteDisplay = new MockRemoteDisplay(InstrumentationRegistry.getContext(), encoder.getVirtualDisplay()); + MockRemoteDisplay remoteDisplay = new MockRemoteDisplay(InstrumentationRegistry.getInstrumentation().getContext(), encoder.getVirtualDisplay()); assertNotNull(remoteDisplay); remoteDisplay.show(); @@ -79,7 +79,7 @@ public class SdlRemoteDisplayTest extends TestCase { public VirtualDisplayEncoder createVDE(){ try{ VirtualDisplayEncoder displayEncoder = new VirtualDisplayEncoder(); - displayEncoder.init(InstrumentationRegistry.getContext(), new MockVideoStreamListener(), new VideoStreamingParameters()); + displayEncoder.init(InstrumentationRegistry.getInstrumentation().getContext(), new MockVideoStreamListener(), new VideoStreamingParameters()); displayEncoder.start(); return displayEncoder; }catch (Exception e ){ diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java index 8aa8ac5e8..5867fee7f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java @@ -1,6 +1,6 @@ package com.smartdevicelink.test.streaming.video; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.proxy.rpc.ImageResolution; import com.smartdevicelink.proxy.rpc.VideoStreamingCapability; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexTransportConfigTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexTransportConfigTests.java index 8fae50a8b..53fe30114 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexTransportConfigTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexTransportConfigTests.java @@ -1,13 +1,13 @@ package com.smartdevicelink.test.transport; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.transport.MultiplexTransportConfig; import org.junit.Test; import org.junit.runner.RunWith; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; @RunWith(AndroidJUnit4.class) @@ -15,16 +15,16 @@ public class MultiplexTransportConfigTests { @Test public void testDefaultSecurity(){ - MultiplexTransportConfig config = new MultiplexTransportConfig(getTargetContext(), "2341"); + MultiplexTransportConfig config = new MultiplexTransportConfig(getInstrumentation().getTargetContext(), "2341"); assertEquals(config.getSecurityLevel(), MultiplexTransportConfig.FLAG_MULTI_SECURITY_MED); } @Test public void testSettingSecurity(){ - MultiplexTransportConfig config = new MultiplexTransportConfig(getTargetContext(), "2341", MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH); + MultiplexTransportConfig config = new MultiplexTransportConfig(getInstrumentation().getTargetContext(), "2341", MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH); assertEquals(config.getSecurityLevel(), MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH); - config = new MultiplexTransportConfig(getTargetContext(), "2341"); + config = new MultiplexTransportConfig(getInstrumentation().getTargetContext(), "2341"); config.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH); assertEquals(config.getSecurityLevel(), MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH); } 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 index 17929e909..044d22f2d 100644 --- 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 @@ -1,6 +1,6 @@ package com.smartdevicelink.test.util; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.test.TestValues; import com.smartdevicelink.util.CompareUtils; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlAppInfoTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlAppInfoTests.java index c1cf90e8c..35ad87cce 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlAppInfoTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlAppInfoTests.java @@ -38,7 +38,7 @@ import android.content.pm.PackageInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.os.Bundle; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.R; import com.smartdevicelink.util.SdlAppInfo; @@ -50,7 +50,7 @@ import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static android.support.test.InstrumentationRegistry.getContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertNotNull; @@ -70,7 +70,7 @@ public class SdlAppInfoTests { @Before public void setUp() throws Exception { - context = getContext(); + context = getInstrumentation().getContext(); defaultResolveInfo = createResolveInfo(context.getResources().getInteger(R.integer.sdl_router_service_version_value), "com.smartdevicelink.test", "com.smartdevicelink.test.SdlRouterService",false); defaultServiceInfo = defaultResolveInfo.serviceInfo; defaultBundle = defaultServiceInfo.metaData; 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 9f462e3f4..2dab00ccd 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 @@ -1,6 +1,6 @@ package com.smartdevicelink.test.util; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.util.Version; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/utl/AndroidToolsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/utl/AndroidToolsTests.java index 8b0389dbb..601895b1c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/utl/AndroidToolsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/utl/AndroidToolsTests.java @@ -1,7 +1,7 @@ package com.smartdevicelink.test.utl; import android.content.ComponentName; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.util.AndroidTools; @@ -10,7 +10,7 @@ import junit.framework.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import static android.support.test.InstrumentationRegistry.getTargetContext; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; @RunWith(AndroidJUnit4.class) public class AndroidToolsTests { @@ -19,7 +19,7 @@ public class AndroidToolsTests { public void testIsServiceExportedNormal(){ try{ - AndroidTools.isServiceExported(getTargetContext(), new ComponentName(getTargetContext(), "test")); + AndroidTools.isServiceExported(getInstrumentation().getTargetContext(), new ComponentName(getInstrumentation().getTargetContext(), "test")); }catch(Exception e){ Assert.fail("Exception during normal test: " + e.getMessage()); } @@ -29,7 +29,7 @@ public class AndroidToolsTests { public void testIsServiceExportedNull(){ try{ - AndroidTools.isServiceExported(getTargetContext(), null); + AndroidTools.isServiceExported(getInstrumentation().getTargetContext(), null); Assert.fail("Proccessed null data"); }catch(Exception e){ |