summaryrefslogtreecommitdiff
path: root/android/sdl_android/src/androidTest/java/com/smartdevicelink
diff options
context:
space:
mode:
authorBilal Alsharifi <bilal.alsharifi@gmail.com>2020-09-09 11:22:00 -0400
committerBilal Alsharifi <bilal.alsharifi@gmail.com>2020-09-09 11:22:00 -0400
commite297e68fd68e2302dc2d6fcd7b86798a863f7177 (patch)
tree29dd95b56a7e329b7dd66f8247f21c1919f5eb49 /android/sdl_android/src/androidTest/java/com/smartdevicelink
parent78e07684d89737c41607aeea466666ea2990930a (diff)
parentaefca54cd5adfcfd4b74fd899d4df56f3e3b31e5 (diff)
downloadsdl_android-e297e68fd68e2302dc2d6fcd7b86798a863f7177.tar.gz
Merge branch 'develop' into feature/issue_1448_generate_deprecated_javadoc
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink')
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java206
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java25
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java76
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java26
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java111
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenConfigTests.java2
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenManagerTests.java1
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java9
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/SoftButtonManagerTests.java10
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java605
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java902
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/video/VideoStreamManagerTests.java32
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java21
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java62
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java21
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/enums/FrameDataTests.java116
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/InternalProxyMessageTests.java35
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java1102
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java298
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/TTSChunkFactoryTests.java100
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java339
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java662
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCStructTests.java48
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/FuelRangeTests.java24
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/StabilityControlsStatusTests.java58
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CapacityUnitTests.java71
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java4
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnErrorTests.java40
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyClosedTests.java44
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyOpenedTests.java29
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java32
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java5
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java5
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java5
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java38
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java9
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java11
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java23
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java9
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java2
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java57
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java17
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BTTransportConfigTests.java43
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BaseTransportConfigTests.java5
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java6
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java24
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java65
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java8
48 files changed, 2428 insertions, 3015 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java
new file mode 100644
index 000000000..fe7d402b9
--- /dev/null
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java
@@ -0,0 +1,206 @@
+package com.smartdevicelink.managers;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.smartdevicelink.proxy.rpc.ImageField;
+import com.smartdevicelink.proxy.rpc.TextField;
+import com.smartdevicelink.proxy.rpc.WindowCapability;
+import com.smartdevicelink.proxy.rpc.enums.CharacterSet;
+import com.smartdevicelink.proxy.rpc.enums.FileType;
+import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
+import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
+
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertTrue;
+import static junit.framework.TestCase.assertFalse;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library manager class :
+ * {@link ManagerUtility}
+ */
+@RunWith(AndroidJUnit4.class)
+public class ManagerUtilityTests {
+
+
+ @Before
+ public void setUp() throws Exception{
+
+ }
+
+ // TESTS
+
+ @Test
+ public void testGetAllImageFields(){
+
+ List<ImageField> fields = ManagerUtility.WindowCapabilityUtility.getAllImageFields();
+ assertNotNull(fields);
+ int size = fields.size();
+ assertEquals(ImageFieldName.values().length, size);
+
+ ImageFieldName[] names = ImageFieldName.values();
+
+ boolean found;
+ for (ImageFieldName name : names) {
+ found = false;
+ for(ImageField field : fields) {
+ if(field != null
+ && field.getName() != null
+ && field.getName().equals(name)) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+
+ }
+
+ @Test
+ public void testGetAllTextFields(){
+
+ List<TextField> fields = ManagerUtility.WindowCapabilityUtility.getAllTextFields();
+ assertNotNull(fields);
+ int size = fields.size();
+ assertEquals(TextFieldName.values().length, size);
+
+ TextFieldName[] names = TextFieldName.values();
+
+ boolean found;
+ for (TextFieldName name : names) {
+ found = false;
+ for(TextField field : fields) {
+ if(field != null
+ && field.getName() != null
+ && field.getName().equals(name)) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+
+ }
+
+ @Test
+ public void testHasTextFieldOfName() {
+ WindowCapability capability = new WindowCapability();
+ List<TextField> textFieldList = new ArrayList<>();
+ textFieldList.add(new TextField(TextFieldName.mainField1, CharacterSet.UTF_8, 500, 8));
+ capability.setTextFields(textFieldList);
+
+ assertTrue(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.mainField1));
+ assertFalse(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.alertText3));
+
+ textFieldList.add(new TextField(TextFieldName.alertText3, CharacterSet.UTF_8, 500, 8));
+ capability.setTextFields(textFieldList);
+ assertTrue(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.mainField1));
+ assertTrue(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.alertText3));
+
+ textFieldList.clear();
+ textFieldList.add(null);
+ capability.setTextFields(textFieldList);
+ assertFalse(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.mainField1));
+ assertFalse(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.alertText3));
+
+ textFieldList.add(new TextField(TextFieldName.alertText3, CharacterSet.UTF_8, 500, 8));
+ capability.setTextFields(textFieldList);
+ assertFalse(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.mainField1));
+ assertTrue(ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName(capability, TextFieldName.alertText3));
+
+ }
+
+ @Test
+ public void testHasImageFieldOfName() {
+
+ WindowCapability capability = new WindowCapability();
+ List<FileType> allImageFileTypes = Arrays.asList(FileType.GRAPHIC_BMP, FileType.GRAPHIC_JPEG, FileType.GRAPHIC_PNG);
+
+ List<ImageField> imageFieldList = new ArrayList<>();
+ imageFieldList.add(new ImageField(ImageFieldName.graphic, allImageFileTypes));
+ capability.setImageFields(imageFieldList);
+
+ assertTrue(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.graphic));
+ assertFalse(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.alertIcon));
+
+ imageFieldList.add(new ImageField(ImageFieldName.alertIcon, allImageFileTypes));
+ capability.setImageFields(imageFieldList);
+ assertTrue(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.graphic));
+ assertTrue(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.alertIcon));;
+
+ imageFieldList.clear();
+ imageFieldList.add(null);
+ capability.setImageFields(imageFieldList);
+ assertFalse(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.graphic));
+ assertFalse(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.alertIcon));
+
+ imageFieldList.add(new ImageField(ImageFieldName.alertIcon, allImageFileTypes));
+ capability.setImageFields(imageFieldList);
+ assertFalse(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.graphic));
+ assertTrue(ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName(capability, ImageFieldName.alertIcon));
+
+ }
+
+
+ @Test
+ public void testGetMaxNumberOfMainFieldLines() {
+
+ WindowCapability capability = new WindowCapability();
+ capability.setTextFields(ManagerUtility.WindowCapabilityUtility.getAllTextFields());
+
+ int maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability);
+
+ assertEquals(4, maxNumerOfLines);
+
+ //Single line
+ List<TextField> singleLineList = new ArrayList<>();
+ singleLineList.add(new TextField(TextFieldName.mainField1, CharacterSet.UTF_8, 500, 8));
+ capability.setTextFields(singleLineList);
+ maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability);
+ assertEquals(1, maxNumerOfLines);
+
+ singleLineList.add(new TextField(TextFieldName.mainField2, CharacterSet.UTF_8, 500, 8));
+ capability.setTextFields(singleLineList);
+ maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability);
+ assertEquals(2, maxNumerOfLines);
+
+ singleLineList.add(new TextField(TextFieldName.mainField3, CharacterSet.UTF_8, 500, 8));
+ capability.setTextFields(singleLineList);
+ maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability);
+ assertEquals(3, maxNumerOfLines);
+
+ singleLineList.add(new TextField(TextFieldName.mainField4, CharacterSet.UTF_8, 500, 8));
+ capability.setTextFields(singleLineList);
+ maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability);
+ assertEquals(4, maxNumerOfLines);
+
+ List<TextField> nullList = new ArrayList<>();
+ nullList.add(null);
+ assertNotNull(nullList);
+ capability.setTextFields(nullList);
+ assertNotNull(capability);
+ assertNotNull(capability.getTextFields());
+
+ maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability);
+ assertEquals(0, maxNumerOfLines);
+
+ nullList.add(new TextField(TextFieldName.mainField4, CharacterSet.UTF_8, 500, 8));
+ assertNotNull(nullList);
+ capability.setTextFields(nullList);
+ assertNotNull(capability);
+ assertNotNull(capability.getTextFields());
+ maxNumerOfLines = ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(capability);
+ assertEquals(4, maxNumerOfLines);
+
+ }
+}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java
index 7c4fb11ff..97361adc9 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java
@@ -112,11 +112,6 @@ public class SdlManagerTests {
}
@Override
- public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language) {
- return null;
- }
-
- @Override
public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage) {
return null;
}
@@ -222,7 +217,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY);
sdlManager.getFileManager().transitionToState(BaseSubManager.READY);
sdlManager.getScreenManager().transitionToState(BaseSubManager.READY);
- sdlManager.getLockScreenConfig().setEnabled(true);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.READY);
sdlManager.checkState();
assertEquals(BaseSubManager.READY, sdlManager.getState());
@@ -232,7 +227,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY);
sdlManager.getFileManager().transitionToState(BaseSubManager.READY);
sdlManager.getScreenManager().transitionToState(BaseSubManager.READY);
- sdlManager.getLockScreenConfig().setEnabled(false);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP);
sdlManager.checkState();
assertEquals(BaseSubManager.READY, sdlManager.getState());
@@ -242,7 +237,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.ERROR);
sdlManager.getFileManager().transitionToState(BaseSubManager.ERROR);
sdlManager.getScreenManager().transitionToState(BaseSubManager.ERROR);
- sdlManager.getLockScreenConfig().setEnabled(true);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.ERROR);
sdlManager.checkState();
assertEquals(BaseSubManager.ERROR, sdlManager.getState());
@@ -252,7 +247,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.ERROR);
sdlManager.getFileManager().transitionToState(BaseSubManager.ERROR);
sdlManager.getScreenManager().transitionToState(BaseSubManager.ERROR);
- sdlManager.getLockScreenConfig().setEnabled(false);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP);
sdlManager.checkState();
assertEquals(BaseSubManager.ERROR, sdlManager.getState());
@@ -262,7 +257,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.ERROR);
sdlManager.getFileManager().transitionToState(BaseSubManager.READY);
sdlManager.getScreenManager().transitionToState(BaseSubManager.SETTING_UP);
- sdlManager.getLockScreenConfig().setEnabled(true);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.LIMITED);
sdlManager.checkState();
assertEquals(BaseSubManager.SETTING_UP, sdlManager.getState());
@@ -272,7 +267,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.ERROR);
sdlManager.getFileManager().transitionToState(BaseSubManager.READY);
sdlManager.getScreenManager().transitionToState(BaseSubManager.SETTING_UP);
- sdlManager.getLockScreenConfig().setEnabled(false);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP);
sdlManager.checkState();
assertEquals(BaseSubManager.SETTING_UP, sdlManager.getState());
@@ -282,7 +277,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY);
sdlManager.getFileManager().transitionToState(BaseSubManager.ERROR);
sdlManager.getScreenManager().transitionToState(BaseSubManager.READY);
- sdlManager.getLockScreenConfig().setEnabled(true);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.READY);
sdlManager.checkState();
assertEquals(BaseSubManager.LIMITED, sdlManager.getState());
@@ -292,7 +287,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY);
sdlManager.getFileManager().transitionToState(BaseSubManager.ERROR);
sdlManager.getScreenManager().transitionToState(BaseSubManager.READY);
- sdlManager.getLockScreenConfig().setEnabled(false);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP);
sdlManager.checkState();
assertEquals(BaseSubManager.LIMITED, sdlManager.getState());
@@ -302,7 +297,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY);
sdlManager.getFileManager().transitionToState(BaseSubManager.LIMITED);
sdlManager.getScreenManager().transitionToState(BaseSubManager.ERROR);
- sdlManager.getLockScreenConfig().setEnabled(true);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.READY);
sdlManager.checkState();
assertEquals(BaseSubManager.LIMITED, sdlManager.getState());
@@ -312,7 +307,7 @@ public class SdlManagerTests {
sdlManager.getPermissionManager().transitionToState(BaseSubManager.READY);
sdlManager.getFileManager().transitionToState(BaseSubManager.LIMITED);
sdlManager.getScreenManager().transitionToState(BaseSubManager.ERROR);
- sdlManager.getLockScreenConfig().setEnabled(false);
+ sdlManager.getLockScreenConfig().setDisplayMode(LockScreenConfig.DISPLAY_MODE_NEVER);
sdlManager.getLockScreenManager().transitionToState(BaseSubManager.SETTING_UP);
sdlManager.checkState();
assertEquals(BaseSubManager.LIMITED, sdlManager.getState());
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java
index 3fd5cd943..1d5d12059 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/audio/AudioStreamManagerTest.java
@@ -5,12 +5,15 @@ import android.media.AudioFormat;
import android.media.MediaFormat;
import android.media.MediaPlayer;
import android.os.Build;
-import androidx.test.platform.app.InstrumentationRegistry;
import android.util.Log;
+import androidx.test.platform.app.InstrumentationRegistry;
+
import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.managers.CompletionListener;
import com.smartdevicelink.managers.audio.AudioStreamManager.SampleType;
+import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener;
+import com.smartdevicelink.managers.lifecycle.SystemCapabilityManager;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.interfaces.IAudioStreamListener;
import com.smartdevicelink.proxy.interfaces.ISdl;
@@ -38,7 +41,9 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -64,9 +69,11 @@ public class AudioStreamManagerTest extends TestCase {
public void testCreatingAudioStreamManager() {
ISdl internalInterface = mock(ISdl.class);
+ SystemCapabilityManager systemCapabilityManager = mock(SystemCapabilityManager.class);
+ doReturn(systemCapabilityManager).when(internalInterface).getSystemCapabilityManager();
AudioPassThruCapabilities audioCapabilities = new AudioPassThruCapabilities(SamplingRate._16KHZ, BitsPerSample._16_BIT, AudioType.PCM);
doReturn(true).when(internalInterface).isConnected();
- doReturn(audioCapabilities).when(internalInterface).getCapability(SystemCapabilityType.PCM_STREAMING);
+ doReturn(audioCapabilities).when(systemCapabilityManager).getCapability(eq(SystemCapabilityType.PCM_STREAMING), (OnSystemCapabilityListener) isNull(), anyBoolean());
new AudioStreamManager(internalInterface, mContext);
}
@@ -93,10 +100,6 @@ public class AudioStreamManagerTest extends TestCase {
Boolean encrypted = (Boolean) args[0];
serviceListener.onServiceStarted(mockSession, SessionType.PCM, encrypted);
break;
- case "stopAudioService":
- // parameters ()
- serviceListener.onServiceEnded(mockSession, SessionType.PCM);
- break;
}
return null;
@@ -104,12 +107,13 @@ public class AudioStreamManagerTest extends TestCase {
};
ISdl internalInterface = mock(ISdl.class);
+ SystemCapabilityManager systemCapabilityManager = mock(SystemCapabilityManager.class);
+ doReturn(systemCapabilityManager).when(internalInterface).getSystemCapabilityManager();
AudioPassThruCapabilities audioCapabilities = new AudioPassThruCapabilities(SamplingRate._16KHZ, BitsPerSample._16_BIT, AudioType.PCM);
doReturn(true).when(internalInterface).isConnected();
- doReturn(audioCapabilities).when(internalInterface).getCapability(SystemCapabilityType.PCM_STREAMING);
+ doReturn(audioCapabilities).when(systemCapabilityManager).getCapability(eq(SystemCapabilityType.PCM_STREAMING), (OnSystemCapabilityListener) isNull(), anyBoolean());
doAnswer(audioServiceAnswer).when(internalInterface).addServiceListener(any(SessionType.class), any(ISdlServiceListener.class));
doAnswer(audioServiceAnswer).when(internalInterface).startAudioService(any(Boolean.class));
- doAnswer(audioServiceAnswer).when(internalInterface).stopAudioService();
CompletionListener completionListener = new CompletionListener() {
@Override
@@ -228,7 +232,7 @@ public class AudioStreamManagerTest extends TestCase {
testFullAudioManagerDecodeFlowCorrectCounter = 0;
testFullAudioManagerDecodeFlowWrongCounter = 0;
- IAudioStreamListener audioStreamListener = new IAudioStreamListener() {
+ final IAudioStreamListener audioStreamListener = new IAudioStreamListener() {
@Override
public void sendAudio(byte[] data, int offset, int length, long presentationTimeUs) throws ArrayIndexOutOfBoundsException {
ByteBuffer buffer = ByteBuffer.wrap(data, offset, length);
@@ -236,11 +240,6 @@ public class AudioStreamManagerTest extends TestCase {
}
@Override
- public void sendAudio(ByteBuffer data, long presentationTimeUs) {
- sendAudio(data, presentationTimeUs, null);
- }
-
- @Override
public void sendAudio(ByteBuffer data, long presentationTimeUs, CompletionListener listener) {
SampleBuffer samples = SampleBuffer.wrap(data, sampleType, presentationTimeUs);
double timeUs = presentationTimeUs;
@@ -270,7 +269,6 @@ public class AudioStreamManagerTest extends TestCase {
};
final SdlSession mockSession = mock(SdlSession.class);
- doReturn(audioStreamListener).when(mockSession).startAudioStream();
Answer<Void> audioServiceAnswer = new Answer<Void>() {
ISdlServiceListener serviceListener = null;
@@ -292,10 +290,6 @@ public class AudioStreamManagerTest extends TestCase {
Boolean encrypted = (Boolean) args[0];
serviceListener.onServiceStarted(mockSession, SessionType.PCM, encrypted);
break;
- case "stopAudioService":
- // parameters ()
- serviceListener.onServiceEnded(mockSession, SessionType.PCM);
- break;
}
return null;
@@ -303,11 +297,12 @@ public class AudioStreamManagerTest extends TestCase {
};
ISdl internalInterface = mock(ISdl.class);
+ SystemCapabilityManager systemCapabilityManager = mock(SystemCapabilityManager.class);
+ doReturn(systemCapabilityManager).when(internalInterface).getSystemCapabilityManager();
doReturn(true).when(internalInterface).isConnected();
- doReturn(audioCapabilities).when(internalInterface).getCapability(any(SystemCapabilityType.class));
+ doReturn(audioCapabilities).when(systemCapabilityManager).getCapability(any(SystemCapabilityType.class), (OnSystemCapabilityListener) isNull(), anyBoolean());
doAnswer(audioServiceAnswer).when(internalInterface).addServiceListener(any(SessionType.class), any(ISdlServiceListener.class));
doAnswer(audioServiceAnswer).when(internalInterface).startAudioService(any(Boolean.class));
- doAnswer(audioServiceAnswer).when(internalInterface).stopAudioService();
CompletionListener fileCompletionListener = new CompletionListener() {
@Override
@@ -325,7 +320,12 @@ public class AudioStreamManagerTest extends TestCase {
final CompletionListener mockFileListener = spy(fileCompletionListener);
- final AudioStreamManager manager = new AudioStreamManager(internalInterface, mContext);
+ final AudioStreamManager manager = new AudioStreamManager(internalInterface, mContext) {
+ @Override
+ public IAudioStreamListener startAudioStream(SdlSession session) {
+ return audioStreamListener;
+ }
+ };
manager.startAudioStream(false, new CompletionListener() {
@Override
public void onComplete(boolean success) {
@@ -483,11 +483,6 @@ public class AudioStreamManagerTest extends TestCase {
}
@Override
- public void sendAudio(ByteBuffer data, long presentationTimeUs) {
- sendAudio(data, presentationTimeUs, null);
- }
-
- @Override
public void sendAudio(ByteBuffer data, long presentationTimeUs, CompletionListener listener) {
try {
long length = data.limit();
@@ -504,7 +499,6 @@ public class AudioStreamManagerTest extends TestCase {
};
final SdlSession mockSession = mock(SdlSession.class);
- doReturn(audioStreamListener).when(mockSession).startAudioStream();
Answer<Void> audioServiceAnswer = new Answer<Void>() {
ISdlServiceListener serviceListener = null;
@@ -526,10 +520,6 @@ public class AudioStreamManagerTest extends TestCase {
Boolean encrypted = (Boolean) args[0];
serviceListener.onServiceStarted(mockSession, SessionType.PCM, encrypted);
break;
- case "stopAudioService":
- // parameters ()
- serviceListener.onServiceEnded(mockSession, SessionType.PCM);
- break;
}
return null;
@@ -537,11 +527,12 @@ public class AudioStreamManagerTest extends TestCase {
};
ISdl internalInterface = mock(ISdl.class);
+ SystemCapabilityManager systemCapabilityManager = mock(SystemCapabilityManager.class);
+ doReturn(systemCapabilityManager).when(internalInterface).getSystemCapabilityManager();
doReturn(true).when(internalInterface).isConnected();
- doReturn(audioCapabilities).when(internalInterface).getCapability(any(SystemCapabilityType.class));
+ doReturn(audioCapabilities).when(systemCapabilityManager).getCapability(any(SystemCapabilityType.class), (OnSystemCapabilityListener) isNull(), anyBoolean());
doAnswer(audioServiceAnswer).when(internalInterface).addServiceListener(any(SessionType.class), any(ISdlServiceListener.class));
doAnswer(audioServiceAnswer).when(internalInterface).startAudioService(any(Boolean.class));
- doAnswer(audioServiceAnswer).when(internalInterface).stopAudioService();
final MediaPlayer.OnCompletionListener mockPlayerCompletionListener = mock(MediaPlayer.OnCompletionListener.class);
final MediaPlayer player = new MediaPlayer();
@@ -583,14 +574,11 @@ public class AudioStreamManagerTest extends TestCase {
public void testPlayRawAudio() {
AudioPassThruCapabilities audioCapabilities = new AudioPassThruCapabilities(SamplingRate._16KHZ, BitsPerSample._16_BIT, AudioType.PCM);
- IAudioStreamListener audioStreamListener = mock(IAudioStreamListener.class);
-
+ final IAudioStreamListener audioStreamListener = mock(IAudioStreamListener.class);
final CompletionListener completionListener = mock(CompletionListener.class);
final SdlSession mockSession = mock(SdlSession.class);
- doReturn(audioStreamListener).when(mockSession).startAudioStream();
-
Answer<Void> audioServiceAnswer = new Answer<Void>() {
ISdlServiceListener serviceListener = null;
@@ -618,12 +606,20 @@ public class AudioStreamManagerTest extends TestCase {
};
ISdl internalInterface = mock(ISdl.class);
+ SystemCapabilityManager systemCapabilityManager = mock(SystemCapabilityManager.class);
+ doReturn(systemCapabilityManager).when(internalInterface).getSystemCapabilityManager();
doReturn(true).when(internalInterface).isConnected();
- doReturn(audioCapabilities).when(internalInterface).getCapability(any(SystemCapabilityType.class));
+ doReturn(audioCapabilities).when(systemCapabilityManager).getCapability(any(SystemCapabilityType.class), (OnSystemCapabilityListener) isNull(), anyBoolean());
doAnswer(audioServiceAnswer).when(internalInterface).addServiceListener(any(SessionType.class), any(ISdlServiceListener.class));
doAnswer(audioServiceAnswer).when(internalInterface).startAudioService(any(Boolean.class));
- final AudioStreamManager manager = new AudioStreamManager(internalInterface, mContext);
+ final AudioStreamManager manager = new AudioStreamManager(internalInterface, mContext) {
+ @Override
+ public IAudioStreamListener startAudioStream(SdlSession session) {
+ return audioStreamListener;
+ }
+ };
+
manager.startAudioStream(false, new CompletionListener() {
@Override
public void onComplete(boolean success) {
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java
index 8908346d2..34cc6bf2a 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java
@@ -248,7 +248,7 @@ public class FileManagerTests {
final ISdl internalInterface = mock(ISdl.class);
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
- doAnswer(onListDeleteRequestSuccess).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ doAnswer(onListDeleteRequestSuccess).when(internalInterface).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
final List<String> fileNames = new ArrayList<>();
fileNames.add("Julian");
@@ -280,7 +280,7 @@ public class FileManagerTests {
final ISdl internalInterface = mock(ISdl.class);
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
- doAnswer(onListDeleteRequestFail).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ doAnswer(onListDeleteRequestFail).when(internalInterface).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
final List<String> fileNames = new ArrayList<>();
fileNames.add("Julian");
@@ -403,7 +403,7 @@ public class FileManagerTests {
final ISdl internalInterface = mock(ISdl.class);
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
- doAnswer(onSendRequestsFailOnError).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ doAnswer(onSendRequestsFailOnError).when(internalInterface).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
SdlFile validFile2 = new SdlFile();
validFile2.setName(TestValues.GENERAL_STRING + "2");
@@ -434,7 +434,7 @@ public class FileManagerTests {
}
});
- verify(internalInterface, times(5)).sendRequests(any(List.class),any(OnMultipleRequestListener.class));
+ verify(internalInterface, times(5)).sendRPCs(any(List.class),any(OnMultipleRequestListener.class));
}
/**
@@ -552,7 +552,7 @@ public class FileManagerTests {
ISdl internalInterface = mock(ISdl.class);
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
- doAnswer(onListFileUploadSuccess).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ doAnswer(onListFileUploadSuccess).when(internalInterface).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
FileManagerConfig fileManagerConfig = new FileManagerConfig();
final FileManager fileManager = new FileManager(internalInterface, mTestContext, fileManagerConfig);
@@ -573,7 +573,7 @@ public class FileManagerTests {
});
}
});
- verify(internalInterface, times(0)).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ verify(internalInterface, times(0)).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
}
/**
@@ -584,7 +584,7 @@ public class FileManagerTests {
ISdl internalInterface = mock(ISdl.class);
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
- doAnswer(onListFileUploadSuccess).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ doAnswer(onListFileUploadSuccess).when(internalInterface).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
FileManagerConfig fileManagerConfig = new FileManagerConfig();
final FileManager fileManager = new FileManager(internalInterface, mTestContext, fileManagerConfig);
@@ -606,7 +606,7 @@ public class FileManagerTests {
});
}
});
- verify(internalInterface, times(1)).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ verify(internalInterface, times(1)).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
}
/**
@@ -702,7 +702,7 @@ public class FileManagerTests {
ISdl internalInterface = mock(ISdl.class);
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
- doAnswer(onListFileUploadSuccess).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ doAnswer(onListFileUploadSuccess).when(internalInterface).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
FileManagerConfig fileManagerConfig = new FileManagerConfig();
@@ -739,7 +739,7 @@ public class FileManagerTests {
ISdl internalInterface = mock(ISdl.class);
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
- doAnswer(onSendRequestsFailPartialOnError).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ doAnswer(onSendRequestsFailPartialOnError).when(internalInterface).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
SdlFile validFile2 = new SdlFile();
validFile2.setName(TestValues.GENERAL_STRING + "2");
@@ -788,7 +788,7 @@ public class FileManagerTests {
ISdl internalInterface = mock(ISdl.class);
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
- doAnswer(onListFileUploadSuccess).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ doAnswer(onListFileUploadSuccess).when(internalInterface).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
FileManagerConfig fileManagerConfig = new FileManagerConfig();
final FileManager fileManager = new FileManager(internalInterface, mTestContext, fileManagerConfig);
@@ -908,7 +908,7 @@ public class FileManagerTests {
final ISdl internalInterface = mock(ISdl.class);
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
- doAnswer(onListFileUploadSuccess).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ doAnswer(onListFileUploadSuccess).when(internalInterface).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
final SdlFile validFile2 = new SdlFile();
validFile2.setName(TestValues.GENERAL_STRING + "2");
@@ -944,7 +944,7 @@ public class FileManagerTests {
}
});
- verify(internalInterface, times(1)).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
+ verify(internalInterface, times(1)).sendRPCs(any(List.class), any(OnMultipleRequestListener.class));
}
/**
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java
index 4c1981099..a14e98383 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/SystemCapabilityManagerTests.java
@@ -183,25 +183,25 @@ public class SystemCapabilityManagerTests {
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)));
+ Validator.validateDisplayCapabilityList(displayCapabilityList, (List<DisplayCapability>) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS, null, false)));
assertTrue(TestValues.TRUE,
- Validator.validateHMICapabilities(TestValues.GENERAL_HMICAPABILITIES, (HMICapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.HMI)));
+ Validator.validateHMICapabilities(TestValues.GENERAL_HMICAPABILITIES, (HMICapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.HMI, null, false)));
assertTrue(TestValues.TRUE,
- Validator.validateDisplayCapabilities(TestValues.GENERAL_DISPLAYCAPABILITIES, (DisplayCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY)));
+ Validator.validateDisplayCapabilities(TestValues.GENERAL_DISPLAYCAPABILITIES, (DisplayCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY, null, false)));
assertTrue(TestValues.TRUE,
- Validator.validateAudioPassThruCapabilities(TestValues.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST, (List<AudioPassThruCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.AUDIO_PASSTHROUGH)));
+ Validator.validateAudioPassThruCapabilities(TestValues.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST, (List<AudioPassThruCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.AUDIO_PASSTHROUGH, null, false)));
assertTrue(TestValues.TRUE,
- Validator.validateButtonCapabilities(TestValues.GENERAL_BUTTONCAPABILITIES_LIST, (List<ButtonCapabilities> )systemCapabilityManager.getCapability(SystemCapabilityType.BUTTON)));
+ Validator.validateButtonCapabilities(TestValues.GENERAL_BUTTONCAPABILITIES_LIST, (List<ButtonCapabilities> )systemCapabilityManager.getCapability(SystemCapabilityType.BUTTON, null, false)));
assertTrue(TestValues.TRUE,
- Validator.validateHMIZoneCapabilities(TestValues.GENERAL_HMIZONECAPABILITIES_LIST, (List<HmiZoneCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.HMI_ZONE)));
+ Validator.validateHMIZoneCapabilities(TestValues.GENERAL_HMIZONECAPABILITIES_LIST, (List<HmiZoneCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.HMI_ZONE, null, false)));
assertTrue(TestValues.TRUE,
- Validator.validatePresetBankCapabilities(TestValues.GENERAL_PRESETBANKCAPABILITIES, (PresetBankCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.PRESET_BANK)));
+ Validator.validatePresetBankCapabilities(TestValues.GENERAL_PRESETBANKCAPABILITIES, (PresetBankCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.PRESET_BANK, null, false)));
assertTrue(TestValues.TRUE,
- Validator.validateSoftButtonCapabilities(TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST, (List<SoftButtonCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON)));
+ Validator.validateSoftButtonCapabilities(TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST, (List<SoftButtonCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON, null, false)));
assertTrue(TestValues.TRUE,
- Validator.validateSpeechCapabilities(TestValues.GENERAL_SPEECHCAPABILITIES_LIST, (List<SpeechCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.SPEECH)));
+ Validator.validateSpeechCapabilities(TestValues.GENERAL_SPEECHCAPABILITIES_LIST, (List<SpeechCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.SPEECH, null, false)));
assertTrue(TestValues.TRUE,
- Validator.validatePreRecordedSpeechCapabilities(TestValues.GENERAL_PRERECORDEDSPEECH_LIST, (List<PrerecordedSpeech>) systemCapabilityManager.getCapability(SystemCapabilityType.PRERECORDED_SPEECH)));
+ Validator.validatePreRecordedSpeechCapabilities(TestValues.GENERAL_PRERECORDEDSPEECH_LIST, (List<PrerecordedSpeech>) systemCapabilityManager.getCapability(SystemCapabilityType.PRERECORDED_SPEECH, null, false)));
}
@@ -256,7 +256,7 @@ public class SystemCapabilityManagerTests {
public void onError(String info) {
assertTrue(false);
}
- });
+ }, false);
}
private Answer<Void> createOnHMIStatusAnswer(final HMILevel hmiLevel){
@@ -687,7 +687,7 @@ public class SystemCapabilityManagerTests {
@Test
public void testListConversion(){
SystemCapabilityManager systemCapabilityManager = createSampleManager();
- Object capability = systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON);
+ Object capability = systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON, null, false);
assertNotNull(capability);
List<SoftButtonCapabilities> list = SystemCapabilityManager.convertToList(capability, SoftButtonCapabilities.class);
assertNotNull(list);
@@ -707,7 +707,7 @@ public class SystemCapabilityManagerTests {
OnRPCListener scmRpcListener = iSDL.rpcListeners.get(FunctionID.ON_SYSTEM_CAPABILITY_UPDATED.getId()).get(0);
assertNotNull(scmRpcListener);
- assertNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES));
+ assertNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false));
/* PERFORM A NOTIFICATION SEND THROUGH THE SCM */
AppServiceCapability addServiceID = AppServiceFactory.createAppServiceCapability(AppServiceType.NAVIGATION, "test", "3453", true, null);
@@ -723,7 +723,7 @@ public class SystemCapabilityManagerTests {
scmRpcListener.onReceived(onSystemCapabilityUpdated);
- assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES));
+ assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false));
}
@Test
@@ -733,8 +733,8 @@ public class SystemCapabilityManagerTests {
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));
+ assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS, null, false));
+ assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY, null, false));
List<DisplayCapability> newCaps = createDisplayCapabilityList(TestValues.GENERAL_DISPLAYCAPABILITIES, TestValues.GENERAL_BUTTONCAPABILITIES_LIST, TestValues.GENERAL_SOFTBUTTONCAPABILITIES_LIST);;
@@ -747,11 +747,11 @@ public class SystemCapabilityManagerTests {
scmRpcListener.onReceived(onSystemCapabilityUpdated);
- List<DisplayCapability> appliedCaps = (List<DisplayCapability>)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS);
+ List<DisplayCapability> appliedCaps = (List<DisplayCapability>)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS, null, false);
assertNotNull(appliedCaps);
assertTrue(Validator.validateDisplayCapabilityList(newCaps, appliedCaps));
- DisplayCapabilities appliedConvertedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY);
+ DisplayCapabilities appliedConvertedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY, null, false);
assertNotNull(appliedConvertedCaps);
DisplayCapabilities testConvertedCaps = createDisplayCapabilities(newCaps.get(0).getDisplayName(), newCaps.get(0).getWindowCapabilities().get(0));
assertTrue(Validator.validateDisplayCapabilities(appliedConvertedCaps, testConvertedCaps));
@@ -772,13 +772,13 @@ public class SystemCapabilityManagerTests {
assertNotNull(scmRpcListener);
/* CONFIRM THE CAP DOESN'T EXIST IN SCM */
- AppServicesCapabilities cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES);
+ AppServicesCapabilities cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false);
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);
+ cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false);
assertNotNull(cachedCap);
/* CONFIRM THE CAP IN SCM EQUALS ORIGINAL*/
assertEquals(cachedCap, appServicesCapabilities);
@@ -798,7 +798,7 @@ public class SystemCapabilityManagerTests {
scmRpcListener.onReceived(onSystemCapabilityUpdated);
- cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES);
+ cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false);
assertNotNull(cachedCap);
assertTrue(cachedCap.getAppServices().get(0).getUpdatedAppServiceRecord().getServiceID().equals(baseID));
@@ -823,7 +823,7 @@ public class SystemCapabilityManagerTests {
scmRpcListener.onReceived(onSystemCapabilityUpdated);
- cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES);
+ cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false);
assertNotNull(cachedCap);
assertEquals(cachedCap.getAppServices().size(), 1);
@@ -842,7 +842,7 @@ public class SystemCapabilityManagerTests {
scmRpcListener.onReceived(onSystemCapabilityUpdated);
- cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES);
+ cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false);
assertNotNull(cachedCap);
assertEquals(cachedCap.getAppServices().size(), 2);
@@ -861,7 +861,7 @@ public class SystemCapabilityManagerTests {
scmRpcListener.onReceived(onSystemCapabilityUpdated);
- cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES);
+ cachedCap = (AppServicesCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false);
assertNotNull(cachedCap);
assertEquals(cachedCap.getAppServices().size(), 1);
@@ -876,7 +876,7 @@ public class SystemCapabilityManagerTests {
assertNotNull(scmRpcListener);
systemCapabilityManager.setCapability(SystemCapabilityType.PHONE_CALL, TestValues.GENERAL_PHONECAPABILITY);
- PhoneCapability phoneCapability = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL);
+ PhoneCapability phoneCapability = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL, null, false);
assertNotNull(phoneCapability);
assertEquals(phoneCapability, TestValues.GENERAL_PHONECAPABILITY);
@@ -889,7 +889,7 @@ public class SystemCapabilityManagerTests {
scmRpcListener.onReceived(onSystemCapabilityUpdated);
- PhoneCapability phoneCapabilityUpdated = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL);
+ PhoneCapability phoneCapabilityUpdated = (PhoneCapability)systemCapabilityManager.getCapability(SystemCapabilityType.PHONE_CALL, null, false);
assertNotNull(phoneCapabilityUpdated);
assertFalse(phoneCapabilityUpdated.getDialNumberEnabled());
assertEquals(phoneCapability, phoneCapabilityUpdated);
@@ -913,11 +913,11 @@ public class SystemCapabilityManagerTests {
dlRpcListener.onReceived(newLayout);
- DisplayCapabilities appliedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY);
+ DisplayCapabilities appliedCaps = (DisplayCapabilities)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY, null, false);
assertNotNull(appliedCaps);
assertTrue(Validator.validateDisplayCapabilities(newLayout.getDisplayCapabilities(), appliedCaps));
- List<DisplayCapability> convertedCaps = (List<DisplayCapability>)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS);
+ List<DisplayCapability> convertedCaps = (List<DisplayCapability>)systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAYS, null, false);
assertNotNull(convertedCaps);
List<DisplayCapability> testCaps = createDisplayCapabilityList(newLayout.getDisplayCapabilities(), newLayout.getButtonCapabilities(), newLayout.getSoftButtonCapabilities());
assertTrue(Validator.validateDisplayCapabilityList(convertedCaps, testCaps));
@@ -960,23 +960,9 @@ public class SystemCapabilityManagerTests {
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) {
}
@@ -1027,12 +1013,6 @@ public class SystemCapabilityManagerTests {
return false;
}
- @Override
- public Object getCapability(SystemCapabilityType systemCapabilityType){return null;}
-
- @Override
- public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) {
- }
@Override
public RegisterAppInterfaceResponse getRegisterAppInterfaceResponse() {
@@ -1040,11 +1020,6 @@ public class SystemCapabilityManagerTests {
}
@Override
- public Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate) {
- return null;
- }
-
- @Override
public SdlMsgVersion getSdlMsgVersion() {
return null;
}
@@ -1054,46 +1029,24 @@ public class SystemCapabilityManagerTests {
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) {}
+ public void startAudioService(boolean encrypted){}
@Override
- public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters){
- return null;
- }
+ public void startRPCEncryption() {}
@Override
- public IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec,
- AudioStreamingParams params) {
+ public Taskmaster getTaskmaster() {
return null;
}
@Override
- public void startAudioService(boolean encrypted){}
-
- @Override
- public void startRPCEncryption() {}
-
- @Override
- public Taskmaster getTaskmaster() {
+ public SystemCapabilityManager getSystemCapabilityManager() {
return null;
}
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenConfigTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenConfigTests.java
index 84a4e52ef..500680e02 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenConfigTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenConfigTests.java
@@ -30,7 +30,6 @@ public class LockScreenConfigTests {
lockScreenConfig.setAppIcon(TestValues.GENERAL_INT);
lockScreenConfig.setBackgroundColor(TestValues.GENERAL_INT);
lockScreenConfig.showDeviceLogo(true);
- lockScreenConfig.setEnabled(true);
lockScreenConfig.setDisplayMode(LockScreenConfig.DISPLAY_MODE_OPTIONAL_OR_REQUIRED);
}
@@ -41,7 +40,6 @@ public class LockScreenConfigTests {
assertEquals(TestValues.GENERAL_INT, lockScreenConfig.getCustomView());
assertEquals(TestValues.GENERAL_INT, lockScreenConfig.getAppIcon());
assertEquals(TestValues.GENERAL_INT, lockScreenConfig.getBackgroundColor());
- assertTrue(lockScreenConfig.isEnabled());
assertTrue(lockScreenConfig.isDeviceLogoEnabled());
assertEquals(LockScreenConfig.DISPLAY_MODE_OPTIONAL_OR_REQUIRED, lockScreenConfig.getDisplayMode());
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenManagerTests.java
index 2509a2298..6baf9f7ee 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenManagerTests.java
@@ -60,7 +60,6 @@ public class LockScreenManagerTests {
lockScreenConfig.setAppIcon(TestValues.GENERAL_INT);
lockScreenConfig.setBackgroundColor(TestValues.GENERAL_INT);
lockScreenConfig.showDeviceLogo(true);
- lockScreenConfig.setEnabled(true);
lockScreenConfig.setDisplayMode(LockScreenConfig.DISPLAY_MODE_OPTIONAL_OR_REQUIRED);
lockScreenManager = new LockScreenManager(lockScreenConfig, context, internalInterface);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java
index f1e68e9b3..11d8472c2 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java
@@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.List;
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.mockito.Mockito.mock;
@@ -99,14 +98,11 @@ public class ScreenManagerTests {
screenManager.setPrimaryGraphic(testArtwork);
assertEquals(screenManager.getPrimaryGraphic(), testArtwork);
}
-
@Test
public void testSetPrimaryGraphicWithBlankImage() {
screenManager.setPrimaryGraphic(null);
- assertNotNull(screenManager.getPrimaryGraphic());
- assertEquals(screenManager.getPrimaryGraphic().getName(), "blankArtwork");
+ assertNull(screenManager.getPrimaryGraphic());
}
-
@Test
public void testSetSecondaryGraphic() {
screenManager.setSecondaryGraphic(testArtwork);
@@ -116,8 +112,7 @@ public class ScreenManagerTests {
@Test
public void testSetSecondaryGraphicWithBlankImage() {
screenManager.setSecondaryGraphic(null);
- assertNotNull(screenManager.getSecondaryGraphic());
- assertEquals(screenManager.getSecondaryGraphic().getName(), "blankArtwork");
+ assertNull(screenManager.getSecondaryGraphic());
}
@Test
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/SoftButtonManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/SoftButtonManagerTests.java
index e5daf375b..b43be2af6 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/SoftButtonManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/SoftButtonManagerTests.java
@@ -3,12 +3,12 @@ package com.smartdevicelink.managers.screen;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import com.smartdevicelink.managers.CompletionListener;
import com.livio.taskmaster.Taskmaster;
import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.file.MultipleFileCompletionListener;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener;
+import com.smartdevicelink.managers.lifecycle.SystemCapabilityManager;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.interfaces.ISdl;
import com.smartdevicelink.proxy.rpc.DisplayCapability;
@@ -51,6 +51,7 @@ import static org.junit.Assert.assertNotEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -89,7 +90,7 @@ public class SoftButtonManagerTests {
doAnswer(onHMIStatusAnswer).when(internalInterface).addOnRPCNotificationListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCNotificationListener.class));
- // When internalInterface.addOnSystemCapabilityListener(SystemCapabilityType.DISPLAYS, onSystemCapabilityListener) is called
+ // When internalInterface.getSystemCapabilityManager().addOnSystemCapabilityListener(SystemCapabilityType.DISPLAYS, onSystemCapabilityListener) is called
// inside SoftButtonManager, respond with a fake response to let the SoftButtonManager continue working.
Answer<Void> onSystemCapabilityAnswer = new Answer<Void>() {
@Override
@@ -108,8 +109,9 @@ public class SoftButtonManagerTests {
return null;
}
};
- doAnswer(onSystemCapabilityAnswer).when(internalInterface).addOnSystemCapabilityListener(eq(SystemCapabilityType.DISPLAYS), any(OnSystemCapabilityListener.class));
-
+ SystemCapabilityManager systemCapabilityManager = mock(SystemCapabilityManager.class);
+ doAnswer(onSystemCapabilityAnswer).when(systemCapabilityManager).addOnSystemCapabilityListener(eq(SystemCapabilityType.DISPLAYS), any(OnSystemCapabilityListener.class));
+ doReturn(systemCapabilityManager).when(internalInterface).getSystemCapabilityManager();
// When fileManager.uploadArtworks() is called inside the SoftButtonManager, respond with
// a fake onComplete() callback to let the SoftButtonManager continue working.
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java
index 439b7ebe9..e5deb7f30 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java
@@ -4,28 +4,35 @@ import android.content.Context;
import android.net.Uri;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import com.livio.taskmaster.Task;
+import com.livio.taskmaster.Taskmaster;
import com.smartdevicelink.managers.BaseSubManager;
import com.smartdevicelink.managers.ManagerUtility;
import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
+import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener;
+import com.smartdevicelink.managers.lifecycle.SystemCapabilityManager;
+import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.interfaces.ISdl;
-import com.smartdevicelink.proxy.rpc.MetadataTags;
-import com.smartdevicelink.proxy.rpc.Show;
+import com.smartdevicelink.proxy.rpc.DisplayCapability;
+import com.smartdevicelink.proxy.rpc.OnHMIStatus;
import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.WindowCapability;
import com.smartdevicelink.proxy.rpc.enums.FileType;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
-import com.smartdevicelink.proxy.rpc.enums.MetadataType;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
-import org.json.JSONException;
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.Arrays;
+import java.util.Collections;
import java.util.List;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
@@ -33,7 +40,13 @@ import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertNull;
+import static junit.framework.TestCase.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
/**
* This is a unit test class for the SmartDeviceLink library manager class :
@@ -49,6 +62,7 @@ public class TextAndGraphicManagerTests {
@Before
public void setUp() throws Exception{
Context mTestContext = getInstrumentation().getContext();
+
// mock things
ISdl internalInterface = mock(ISdl.class);
FileManager fileManager = mock(FileManager.class);
@@ -60,6 +74,40 @@ public class TextAndGraphicManagerTests {
testArtwork.setUri(uri);
testArtwork.setType(FileType.GRAPHIC_PNG);
+ Taskmaster taskmaster = new Taskmaster.Builder().build();
+ taskmaster.start();
+ when(internalInterface.getTaskmaster()).thenReturn(taskmaster);
+
+ Answer<Void> onHMIStatusAnswer = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ OnRPCNotificationListener onHMIStatusListener = (OnRPCNotificationListener) args[1];
+ OnHMIStatus onHMIStatusFakeNotification = new OnHMIStatus();
+ onHMIStatusFakeNotification.setHmiLevel(HMILevel.HMI_FULL);
+ onHMIStatusListener.onNotified(onHMIStatusFakeNotification);
+ return null;
+ }
+ };
+ doAnswer(onHMIStatusAnswer).when(internalInterface).addOnRPCNotificationListener(eq(FunctionID.ON_HMI_STATUS), any(OnRPCNotificationListener.class));
+
+ Answer<Void> onSystemCapabilityAnswer = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ OnSystemCapabilityListener onSystemCapabilityListener = (OnSystemCapabilityListener) args[1];
+ WindowCapability windowCapability = getWindowCapability(4);
+ DisplayCapability displayCapability = new DisplayCapability();
+ displayCapability.setWindowCapabilities(Collections.singletonList(windowCapability));
+ List<DisplayCapability> capabilities = Collections.singletonList(displayCapability);
+ onSystemCapabilityListener.onCapabilityRetrieved(capabilities);
+ return null;
+ }
+ };
+ SystemCapabilityManager systemCapabilityManager = mock(SystemCapabilityManager.class);
+ doAnswer(onSystemCapabilityAnswer).when(systemCapabilityManager).addOnSystemCapabilityListener(eq(SystemCapabilityType.DISPLAYS), any(OnSystemCapabilityListener.class));
+ doReturn(systemCapabilityManager).when(internalInterface).getSystemCapabilityManager();
+
textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager, softButtonManager);
}
@@ -122,13 +170,9 @@ public class TextAndGraphicManagerTests {
assertNull(textAndGraphicManager.getTextField2Type());
assertNull(textAndGraphicManager.getTextField3Type());
assertNull(textAndGraphicManager.getTextField4Type());
-
assertNotNull(textAndGraphicManager.currentScreenData);
- assertNull(textAndGraphicManager.inProgressUpdate);
- assertNull(textAndGraphicManager.queuedImageUpdate);
- assertFalse(textAndGraphicManager.hasQueuedUpdate);
- assertNull(textAndGraphicManager.defaultMainWindowCapability);
- assertEquals(textAndGraphicManager.currentHMILevel, HMILevel.HMI_NONE);
+ assertNotNull(textAndGraphicManager.defaultMainWindowCapability);
+ assertEquals(textAndGraphicManager.currentHMILevel, HMILevel.HMI_FULL);
assertFalse(textAndGraphicManager.isDirty);
assertEquals(textAndGraphicManager.getState(), BaseSubManager.SETTING_UP);
assertNotNull(textAndGraphicManager.getBlankArtwork());
@@ -153,494 +197,6 @@ public class TextAndGraphicManagerTests {
}
@Test
- public void testAssemble1Line(){
-
- Show inputShow = new Show();
-
- // Force it to return display with support for only 1 line of text
- textAndGraphicManager.defaultMainWindowCapability = getWindowCapability(1);
-
- textAndGraphicManager.setTextField1("It is");
- textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY);
-
- Show assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
-
- // test tags (just 1)
- MetadataTags tags = assembledShow.getMetadataTags();
- List<MetadataType> tagsList = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- assertEquals(tags.getMainField1(), tagsList);
-
- textAndGraphicManager.setTextField2("Wednesday");
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is - Wednesday");
-
- textAndGraphicManager.setTextField3("My");
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My");
-
- textAndGraphicManager.setTextField4("Dudes");
- textAndGraphicManager.setTextField4Type(MetadataType.CURRENT_TEMPERATURE);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My - Dudes");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList.add(MetadataType.CURRENT_TEMPERATURE);
- assertEquals(tags.getMainField1(), tagsList);
-
- // For some obscurity, lets try setting just fields 2 and 4 for a 1 line display
- textAndGraphicManager.setTextField1(null);
- textAndGraphicManager.setTextField3(null);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "Wednesday - Dudes");
- }
-
- @Test
- public void testAssemble2Lines() {
-
- Show inputShow = new Show();
-
- // Force it to return display with support for only 2 lines of text
- textAndGraphicManager.defaultMainWindowCapability = getWindowCapability(2);
-
- textAndGraphicManager.setTextField1("It is");
- textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY);
-
- Show assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
-
- // test tags
- MetadataTags tags = assembledShow.getMetadataTags();
- List<MetadataType> tagsList = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- assertEquals(tags.getMainField1(), tagsList);
-
- textAndGraphicManager.setTextField2("Wednesday");
- textAndGraphicManager.setTextField2Type(MetadataType.CURRENT_TEMPERATURE);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- List<MetadataType> tagsList2 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
-
- textAndGraphicManager.setTextField3("My");
- textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_ALBUM);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is - Wednesday");
- assertEquals(assembledShow.getMainField2(), "My");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList2 = new ArrayList<>();
- tagsList.add(MetadataType.CURRENT_TEMPERATURE);
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.MEDIA_ALBUM);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
-
- textAndGraphicManager.setTextField4("Dudes");
- textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_STATION);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is - Wednesday");
- assertEquals(assembledShow.getMainField2(), "My - Dudes");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList2 = new ArrayList<>();
- tagsList.add(MetadataType.CURRENT_TEMPERATURE);
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.MEDIA_STATION);
- tagsList2.add(MetadataType.MEDIA_ALBUM);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
-
- // For some obscurity, lets try setting just fields 2 and 4 for a 2 line display
- textAndGraphicManager.setTextField1(null);
- textAndGraphicManager.setTextField3(null);
- textAndGraphicManager.setTextField1Type(null);
- textAndGraphicManager.setTextField3Type(null);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "Wednesday");
- assertEquals(assembledShow.getMainField2(), "Dudes");
-
- // And 3 fields without setting 1
- textAndGraphicManager.setTextField3("My");
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "Wednesday");
- assertEquals(assembledShow.getMainField2(), "My - Dudes");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList2 = new ArrayList<>();
- tagsList.add(MetadataType.CURRENT_TEMPERATURE);
- tagsList2.add(MetadataType.MEDIA_STATION);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
- }
-
- @Test
- public void testAssemble3Lines() {
-
- Show inputShow = new Show();
-
- // Force it to return display with support for only 3 lines of text
- textAndGraphicManager.defaultMainWindowCapability = getWindowCapability(3);
-
- textAndGraphicManager.setTextField1("It is");
- textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY);
-
- Show assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "");
- assertEquals(assembledShow.getMainField3(), "");
-
- // test tags
- MetadataTags tags = assembledShow.getMetadataTags();
- List<MetadataType> tagsList = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- assertEquals(tags.getMainField1(), tagsList);
-
- textAndGraphicManager.setTextField2("Wednesday");
- textAndGraphicManager.setTextField2Type(MetadataType.CURRENT_TEMPERATURE);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- List<MetadataType> tagsList2 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
-
- textAndGraphicManager.setTextField3("My");
- textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_ALBUM);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "My");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList2 = new ArrayList<>();
- List<MetadataType> tagsList3 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- tagsList3.add(MetadataType.MEDIA_ALBUM);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
- assertEquals(tags.getMainField3(), tagsList3);
-
- textAndGraphicManager.setTextField4("Dudes");
- textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_STATION);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "My - Dudes");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList2 = new ArrayList<>();
- tagsList3 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- tagsList3.add(MetadataType.MEDIA_ALBUM);
- tagsList3.add(MetadataType.MEDIA_STATION);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
- assertEquals(tags.getMainField3(), tagsList3);
-
- // Someone might not want to set the fields in order? We should handle that
- textAndGraphicManager.setTextField1(null);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- try {
- System.out.println(assembledShow.serializeJSON().toString());
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "My - Dudes");
- }
-
- @Test
- public void testAssemble4Lines() {
-
- Show inputShow = new Show();
-
- textAndGraphicManager.defaultMainWindowCapability = getWindowCapability(4);
- TextField tx1 = new TextField();
- TextField tx2 = new TextField();
- TextField tx3 = new TextField();
- TextField tx4 = new TextField();
- TextField tx5 = new TextField();
- TextField tx6 = new TextField();
-
- tx1.setName(TextFieldName.mainField1);
- tx2.setName(TextFieldName.mainField2);
- tx3.setName(TextFieldName.mainField3);
- tx4.setName(TextFieldName.mainField4);
- tx5.setName(TextFieldName.mediaTrack);
- tx6.setName(TextFieldName.templateTitle);
-
- List<TextField> textFieldNames = Arrays.asList(tx1,tx2,tx3,tx4,tx5,tx6);
- textAndGraphicManager.defaultMainWindowCapability.setTextFields(textFieldNames);
-
- textAndGraphicManager.setMediaTrackTextField("HI");
- textAndGraphicManager.setTitle("bye");
-
- // Force it to return display with support for only 4 lines of text
-
- textAndGraphicManager.setTextField1("It is");
- textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY);
-
- Show assembledShow = textAndGraphicManager.assembleShowText(inputShow);
-
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "");
- assertEquals(assembledShow.getMainField3(), "");
- assertEquals(assembledShow.getMainField4(), "");
- assertEquals(assembledShow.getMediaTrack(), "HI");
- assertEquals(assembledShow.getTemplateTitle(), "bye");
-
- // test tags
- MetadataTags tags = assembledShow.getMetadataTags();
- List<MetadataType> tagsList = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- assertEquals(tags.getMainField1(), tagsList);
-
- textAndGraphicManager.setTextField2("Wednesday");
- textAndGraphicManager.setTextField2Type(MetadataType.CURRENT_TEMPERATURE);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "");
- assertEquals(assembledShow.getMainField4(), "");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- List<MetadataType> tagsList2 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
-
- textAndGraphicManager.setTextField3("My");
- textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_ALBUM);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "My");
- assertEquals(assembledShow.getMainField4(), "");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList2 = new ArrayList<>();
- List<MetadataType> tagsList3 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- tagsList3.add(MetadataType.MEDIA_ALBUM);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
- assertEquals(tags.getMainField3(), tagsList3);
-
- textAndGraphicManager.setTextField4("Dudes");
- textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_STATION);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "My");
- assertEquals(assembledShow.getMainField4(), "Dudes");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList2 = new ArrayList<>();
- tagsList3 = new ArrayList<>();
- List<MetadataType> tagsList4 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- tagsList3.add(MetadataType.MEDIA_ALBUM);
- tagsList4.add(MetadataType.MEDIA_STATION);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
- assertEquals(tags.getMainField3(), tagsList3);
- assertEquals(tags.getMainField4(), tagsList4);
-
- // try just setting line 1 and 4
- textAndGraphicManager.setTextField2(null);
- textAndGraphicManager.setTextField3(null);
- textAndGraphicManager.setTextField2Type(null);
- textAndGraphicManager.setTextField3Type(null);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "");
- assertEquals(assembledShow.getMainField3(), "");
- assertEquals(assembledShow.getMainField4(), "Dudes");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList4 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList4.add(MetadataType.MEDIA_STATION);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField4(), tagsList4);
- }
-
- /**
- * Testing if WindowCapability is null, TextFields should still update.
- */
- @Test
- public void testAssemble4LinesNullWindowCapability() {
-
- Show inputShow = new Show();
-
- textAndGraphicManager.setMediaTrackTextField("HI");
- textAndGraphicManager.setTitle("bye");
-
- textAndGraphicManager.setTextField1("It is");
- textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY);
-
- Show assembledShow = textAndGraphicManager.assembleShowText(inputShow);
-
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "");
- assertEquals(assembledShow.getMainField3(), "");
- assertEquals(assembledShow.getMainField4(), "");
- assertEquals(assembledShow.getMediaTrack(), "HI");
- assertEquals(assembledShow.getTemplateTitle(), "bye");
-
- // test tags
- MetadataTags tags = assembledShow.getMetadataTags();
- List<MetadataType> tagsList = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- assertEquals(tags.getMainField1(), tagsList);
-
- textAndGraphicManager.setTextField2("Wednesday");
- textAndGraphicManager.setTextField2Type(MetadataType.CURRENT_TEMPERATURE);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "");
- assertEquals(assembledShow.getMainField4(), "");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- List<MetadataType> tagsList2 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
-
- textAndGraphicManager.setTextField3("My");
- textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_ALBUM);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "My");
- assertEquals(assembledShow.getMainField4(), "");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList2 = new ArrayList<>();
- List<MetadataType> tagsList3 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- tagsList3.add(MetadataType.MEDIA_ALBUM);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
- assertEquals(tags.getMainField3(), tagsList3);
-
- textAndGraphicManager.setTextField4("Dudes");
- textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_STATION);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "Wednesday");
- assertEquals(assembledShow.getMainField3(), "My");
- assertEquals(assembledShow.getMainField4(), "Dudes");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList2 = new ArrayList<>();
- tagsList3 = new ArrayList<>();
- List<MetadataType> tagsList4 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
- tagsList3.add(MetadataType.MEDIA_ALBUM);
- tagsList4.add(MetadataType.MEDIA_STATION);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField2(), tagsList2);
- assertEquals(tags.getMainField3(), tagsList3);
- assertEquals(tags.getMainField4(), tagsList4);
-
- // try just setting line 1 and 4
- textAndGraphicManager.setTextField2(null);
- textAndGraphicManager.setTextField3(null);
- textAndGraphicManager.setTextField2Type(null);
- textAndGraphicManager.setTextField3Type(null);
-
- assembledShow = textAndGraphicManager.assembleShowText(inputShow);
- assertEquals(assembledShow.getMainField1(), "It is");
- assertEquals(assembledShow.getMainField2(), "");
- assertEquals(assembledShow.getMainField3(), "");
- assertEquals(assembledShow.getMainField4(), "Dudes");
-
- // test tags
- tags = assembledShow.getMetadataTags();
- tagsList = new ArrayList<>();
- tagsList4 = new ArrayList<>();
- tagsList.add(MetadataType.HUMIDITY);
- tagsList4.add(MetadataType.MEDIA_STATION);
- assertEquals(tags.getMainField1(), tagsList);
- assertEquals(tags.getMainField4(), tagsList4);
- }
-
- @Test
public void testMediaTrackTextField() {
String songTitle = "Wild For The Night";
@@ -663,22 +219,6 @@ public class TextAndGraphicManagerTests {
assertEquals(textAndGraphicManager.getTextAlignment(), TextAlignment.LEFT_ALIGNED);
}
- @Test
- public void testExtractTextFromShow(){
-
- Show mainShow = new Show();
- mainShow.setMainField1("test");
- mainShow.setMainField3("Sauce");
- mainShow.setMainField4("");
-
- Show newShow = textAndGraphicManager.extractTextFromShow(mainShow);
-
- assertEquals(newShow.getMainField1(), "test");
- assertEquals(newShow.getMainField3(), "Sauce");
- assertEquals(newShow.getMainField4(), "");
- assertNull(newShow.getMainField2());
- }
-
// TEST IMAGES
@Test
@@ -714,11 +254,40 @@ public class TextAndGraphicManagerTests {
assertNull(textAndGraphicManager.getTitle());
assertNotNull(textAndGraphicManager.getBlankArtwork());
assertNull(textAndGraphicManager.currentScreenData);
- assertNull(textAndGraphicManager.inProgressUpdate);
- assertNull(textAndGraphicManager.queuedImageUpdate);
- assertFalse(textAndGraphicManager.hasQueuedUpdate);
assertNull(textAndGraphicManager.defaultMainWindowCapability);
assertFalse(textAndGraphicManager.isDirty);
assertEquals(textAndGraphicManager.getState(), BaseSubManager.SHUTDOWN);
}
+
+ @Test
+ public void testOperationManagement() {
+ textAndGraphicManager.isDirty = true;
+ textAndGraphicManager.updateOperation = null;
+ textAndGraphicManager.update(null);
+ assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 1);
+
+ textAndGraphicManager.transactionQueue.clear();
+ textAndGraphicManager.updateOperation = null;
+
+ assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 0);
+
+ textAndGraphicManager.isDirty = true;
+ textAndGraphicManager.update(null);
+
+ assertEquals(textAndGraphicManager.transactionQueue.getTasksAsList().size(), 1);
+
+ assertTrue(textAndGraphicManager.transactionQueue.getTasksAsList().get(0).getState() == Task.READY);
+ }
+
+ @Test
+ public void testHasData() {
+ assertFalse(textAndGraphicManager.hasData());
+
+ textAndGraphicManager.setTextField1("HI");
+ assertTrue(textAndGraphicManager.hasData());
+
+ textAndGraphicManager.setTextField1(null);
+ textAndGraphicManager.setPrimaryGraphic(testArtwork);
+ assertTrue(textAndGraphicManager.hasData());
+ }
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java
new file mode 100644
index 000000000..cdfab186c
--- /dev/null
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java
@@ -0,0 +1,902 @@
+package com.smartdevicelink.managers.screen;
+
+import android.content.Context;
+import android.net.Uri;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.smartdevicelink.R;
+import com.smartdevicelink.managers.CompletionListener;
+import com.smartdevicelink.managers.ManagerUtility;
+import com.smartdevicelink.managers.file.FileManager;
+import com.smartdevicelink.managers.file.MultipleFileCompletionListener;
+import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
+import com.smartdevicelink.managers.file.filetypes.SdlFile;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.rpc.ImageField;
+import com.smartdevicelink.proxy.rpc.MetadataTags;
+import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
+import com.smartdevicelink.proxy.rpc.Show;
+import com.smartdevicelink.proxy.rpc.ShowResponse;
+import com.smartdevicelink.proxy.rpc.TextField;
+import com.smartdevicelink.proxy.rpc.WindowCapability;
+import com.smartdevicelink.proxy.rpc.enums.FileType;
+import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
+import com.smartdevicelink.proxy.rpc.enums.MetadataType;
+import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
+import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
+
+import org.json.JSONException;
+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.Arrays;
+import java.util.List;
+
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+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 TextAndGraphicUpdateOperationTest {
+
+ private TextAndGraphicUpdateOperation textAndGraphicUpdateOperation;
+ private String textField1, textField2, textField3, textField4, mediaTrackField, title;
+ private MetadataType textField1Type, textField2Type, textField3Type, textField4Type;
+ private SdlArtwork testArtwork1, testArtwork2, testArtwork3, testArtwork4;
+ private TextAlignment textAlignment;
+ private WindowCapability defaultMainWindowCapability;
+ private Show currentScreenData;
+ private CompletionListener listener;
+ private TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdatedListener;
+ private SdlArtwork blankArtwork;
+ ISdl internalInterface;
+ FileManager fileManager;
+
+ private Answer<Void> onShowSuccess = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ RPCRequest message = (RPCRequest) args[0];
+ if (message instanceof Show) {
+ int correlationId = message.getCorrelationID();
+ ShowResponse showResponse = new ShowResponse();
+ showResponse.setSuccess(true);
+ message.getOnRPCResponseListener().onResponse(correlationId, showResponse);
+ }
+ return null;
+ }
+ };
+
+ private Answer<Void> onShowSuccessCanceled = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ RPCRequest message = (RPCRequest) args[0];
+ if (message instanceof Show) {
+ int correlationId = message.getCorrelationID();
+ textAndGraphicUpdateOperation.cancelTask();
+ ShowResponse showResponse = new ShowResponse();
+ showResponse.setSuccess(true);
+ message.getOnRPCResponseListener().onResponse(correlationId, showResponse);
+ }
+ return null;
+ }
+ };
+
+
+ private Answer<Void> onImageUploadSuccessTaskCanceled = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ Object[] args = invocation.getArguments();
+ MultipleFileCompletionListener listener = (MultipleFileCompletionListener) args[1];
+ textAndGraphicUpdateOperation.cancelTask();
+ listener.onComplete(null);
+ return null;
+ }
+ };
+
+ private Answer<Void> onArtworkUploadSuccess = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ MultipleFileCompletionListener listener = (MultipleFileCompletionListener) args[1];
+ when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true);
+ listener.onComplete(null);
+ return null;
+ }
+ };
+
+
+ @Before
+ public void setUp() throws Exception {
+ Context mTestContext = getInstrumentation().getContext();
+ // mock things
+ internalInterface = mock(ISdl.class);
+ fileManager = mock(FileManager.class);
+ setUpCompletionListener();
+ textField1 = "It is";
+ textField2 = "Wednesday";
+ textField3 = "My";
+ textField4 = "Dudes";
+ mediaTrackField = "dudes";
+ title = "dudes";
+
+ blankArtwork = new SdlArtwork();
+ blankArtwork.setType(FileType.GRAPHIC_PNG);
+ blankArtwork.setName("blankArtwork");
+ blankArtwork.setResourceId(R.drawable.transparent);
+
+ textField1Type = MetadataType.MEDIA_TITLE;
+ textField2Type = MetadataType.MEDIA_TITLE;
+ textField3Type = MetadataType.MEDIA_TITLE;
+ textField4Type = MetadataType.MEDIA_TITLE;
+
+
+ textAlignment = TextAlignment.CENTERED;
+
+ testArtwork1 = new SdlArtwork();
+ testArtwork1.setName("testFile1");
+ Uri uri1 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl");
+ testArtwork1.setUri(uri1);
+ testArtwork1.setType(FileType.GRAPHIC_PNG);
+
+ testArtwork2 = new SdlArtwork();
+ testArtwork2.setName("testFile2");
+ Uri uri2 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl");
+ testArtwork2.setUri(uri2);
+ testArtwork2.setType(FileType.GRAPHIC_PNG);
+
+ testArtwork3 = new SdlArtwork();
+ testArtwork3.setName("testFile3");
+ Uri uri3 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl");
+ testArtwork3.setUri(uri3);
+ testArtwork3.setType(FileType.GRAPHIC_PNG);
+
+ testArtwork4 = new SdlArtwork();
+ testArtwork4.setName("testFile4");
+ Uri uri4 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl");
+ testArtwork4.setUri(uri4);
+ testArtwork4.setType(FileType.GRAPHIC_PNG);
+
+ currentScreenData = new Show();
+ currentScreenData.setMainField1("Old");
+ currentScreenData.setMainField2("Text");
+ currentScreenData.setMainField3("Not");
+ currentScreenData.setMainField4("Important");
+
+ currentScreenData.setGraphic(testArtwork1.getImageRPC());
+ currentScreenData.setSecondaryGraphic(testArtwork2.getImageRPC());
+
+ currentScreenDataUpdatedListener = new TextAndGraphicManager.CurrentScreenDataUpdatedListener() {
+ @Override
+ public void onUpdate(Show show) {
+
+ }
+ };
+
+ defaultMainWindowCapability = getWindowCapability(4);
+
+ TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+ }
+
+
+ private void setUpCompletionListener() {
+ listener = new CompletionListener() {
+ @Override
+ public void onComplete(boolean success) {
+
+ }
+ };
+
+ }
+
+ private WindowCapability getWindowCapability(int numberOfMainFields) {
+
+ TextField mainField1 = new TextField();
+ mainField1.setName(TextFieldName.mainField1);
+ TextField mainField2 = new TextField();
+ mainField2.setName(TextFieldName.mainField2);
+ TextField mainField3 = new TextField();
+ mainField3.setName(TextFieldName.mainField3);
+ TextField mainField4 = new TextField();
+ mainField4.setName(TextFieldName.mainField4);
+
+ List<TextField> textFieldList = new ArrayList<>();
+
+ textFieldList.add(mainField1);
+ textFieldList.add(mainField2);
+ textFieldList.add(mainField3);
+ textFieldList.add(mainField4);
+
+ List<TextField> returnList = new ArrayList<>();
+
+ if (numberOfMainFields > 0) {
+ for (int i = 0; i < numberOfMainFields; i++) {
+ returnList.add(textFieldList.get(i));
+ }
+ }
+
+ WindowCapability windowCapability = new WindowCapability();
+ windowCapability.setTextFields(returnList);
+
+ ImageField imageField = new ImageField();
+ imageField.setName(ImageFieldName.graphic);
+ ImageField imageField2 = new ImageField();
+ imageField2.setName(ImageFieldName.secondaryGraphic);
+ List<ImageField> imageFieldList = new ArrayList<>();
+ imageFieldList.add(imageField);
+ imageFieldList.add(imageField2);
+ windowCapability.setImageFields(imageFieldList);
+
+ windowCapability.setImageFields(imageFieldList);
+
+ return windowCapability;
+ }
+
+ /**
+ * Used to simulate WindowCapability having no capabilities set
+ *
+ * @return windowCapability that has no capabilities set
+ */
+ private WindowCapability getNullVarWindowCapability() {
+
+ WindowCapability windowCapability = new WindowCapability();
+ return windowCapability;
+ }
+
+ @Test
+ public void testUploads() {
+ doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class));
+ doAnswer(onArtworkUploadSuccess).when(fileManager).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class));
+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(4, 0));
+
+ // Test Images need to be uploaded, sending text and uploading images
+ textAndGraphicUpdateOperation.onExecute();
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField2(), textField2);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField3(), textField3);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField4(), textField4);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getAlignment(), textAlignment);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getGraphic(), testArtwork3.getImageRPC());
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getSecondaryGraphic(), testArtwork4.getImageRPC());
+
+
+ // Test The files to be updated are already uploaded, send the full show immediately
+ String textField11 = "It's not";
+ TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField11, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork1, testArtwork2, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+ textAndGraphicUpdateOperation.onExecute();
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField11);
+
+ //Test: If there are no images to update, just send the text
+ TextsAndGraphicsState textsAndGraphicsStateNullImages = new TextsAndGraphicsState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, blankArtwork, blankArtwork, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsStateNullImages, listener, currentScreenDataUpdatedListener);
+ textAndGraphicUpdateOperation.onExecute();
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1);
+
+ // Verifies that uploadArtworks gets called only with the fist textAndGraphicsUpdateOperation.onExecute call
+ verify(fileManager, times(1)).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class));
+ }
+
+ @Test
+ public void testCanceledRightAway() {
+ textAndGraphicUpdateOperation.cancelTask();
+ textAndGraphicUpdateOperation.onExecute();
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), "Old");
+ }
+
+ @Test
+ public void testTaskCanceledAfterImageUpload() {
+ doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class));
+ doAnswer(onImageUploadSuccessTaskCanceled).when(fileManager).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class));
+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 0));
+
+ // Test Canceled after Image upload
+ textAndGraphicUpdateOperation.onExecute();
+ verify(internalInterface, times(1)).sendRPC(any(Show.class));
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1);
+
+ }
+
+ @Test
+ public void testTaskCanceledAfterTextSent() {
+ doAnswer(onShowSuccessCanceled).when(internalInterface).sendRPC(any(Show.class));
+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 0));
+
+ textAndGraphicUpdateOperation.onExecute();
+ verify(fileManager, times(0)).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class));
+
+ }
+
+ /**
+ * Test getting number of lines available to be set based off of windowCapability
+ */
+ @Test
+ public void testGetMainLines() {
+
+ // We want to test that the looping works. By default, it will return 4 if display cap is null
+ textAndGraphicUpdateOperation.defaultMainWindowCapability = getNullVarWindowCapability();
+
+ // Null test
+ assertEquals(0, ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(textAndGraphicUpdateOperation.defaultMainWindowCapability));
+
+ // The tests.java class has an example of this, but we must build it to do what
+ // we need it to do. Build display cap w/ 3 main fields and test that it returns 3
+ textAndGraphicUpdateOperation.defaultMainWindowCapability = getWindowCapability(3);
+ assertEquals(ManagerUtility.WindowCapabilityUtility.getMaxNumberOfMainFieldLines(textAndGraphicUpdateOperation.defaultMainWindowCapability), 3);
+ }
+
+
+ @Test
+ public void testAssemble1Line() {
+
+ Show inputShow = new Show();
+
+ TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+
+ // test tags (just 1)
+ MetadataTags tags = assembledShow.getMetadataTags();
+ List<MetadataType> tagsList = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ assertEquals(tags.getMainField1(), tagsList);
+
+ textsAndGraphicsState.setTextField2(textField2);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is - Wednesday");
+
+ textsAndGraphicsState.setTextField3(textField3);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My");
+
+ textsAndGraphicsState.setTextField4(textField4);
+ textsAndGraphicsState.setTextField4Type(MetadataType.CURRENT_TEMPERATURE);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is - Wednesday - My - Dudes");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList.add(MetadataType.CURRENT_TEMPERATURE);
+ assertEquals(tags.getMainField1(), tagsList);
+
+ // For some obscurity, lets try setting just fields 2 and 4 for a 1 line display
+ textsAndGraphicsState.setTextField1(null);
+ textsAndGraphicsState.setTextField3(null);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "Wednesday - Dudes");
+ }
+
+ @Test
+ public void testAssemble2Lines() {
+
+ Show inputShow = new Show();
+ defaultMainWindowCapability = getWindowCapability(2);
+
+ // Force it to return display with support for only 2 lines of text
+ TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+
+ // test tags
+ MetadataTags tags = assembledShow.getMetadataTags();
+ List<MetadataType> tagsList = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ assertEquals(tags.getMainField1(), tagsList);
+
+ textsAndGraphicsState.setTextField2(textField2);
+ textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ List<MetadataType> tagsList2 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+
+ textsAndGraphicsState.setTextField3(textField3);
+ textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is - Wednesday");
+ assertEquals(assembledShow.getMainField2(), "My");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList2 = new ArrayList<>();
+ tagsList.add(MetadataType.CURRENT_TEMPERATURE);
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.MEDIA_ALBUM);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+
+ textsAndGraphicsState.setTextField4(textField4);
+ textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is - Wednesday");
+ assertEquals(assembledShow.getMainField2(), "My - Dudes");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList2 = new ArrayList<>();
+ tagsList.add(MetadataType.CURRENT_TEMPERATURE);
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.MEDIA_STATION);
+ tagsList2.add(MetadataType.MEDIA_ALBUM);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+
+ // For some obscurity, lets try setting just fields 2 and 4 for a 2 line display
+ textsAndGraphicsState.setTextField1(null);
+ textsAndGraphicsState.setTextField3(null);
+ textsAndGraphicsState.setTextField1Type(null);
+ textsAndGraphicsState.setTextField3Type(null);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "Wednesday");
+ assertEquals(assembledShow.getMainField2(), "Dudes");
+
+ // And 3 fields without setting 1
+ textsAndGraphicsState.setTextField3(textField3);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(2), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "Wednesday");
+ assertEquals(assembledShow.getMainField2(), "My - Dudes");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList2 = new ArrayList<>();
+ tagsList.add(MetadataType.CURRENT_TEMPERATURE);
+ tagsList2.add(MetadataType.MEDIA_STATION);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+ }
+
+ @Test
+ public void testAssemble3Lines() {
+
+ Show inputShow = new Show();
+
+ // Force it to return display with support for only 3 lines of text
+ defaultMainWindowCapability = getWindowCapability(3);
+ TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "");
+ assertEquals(assembledShow.getMainField3(), "");
+
+ // test tags
+ MetadataTags tags = assembledShow.getMetadataTags();
+ List<MetadataType> tagsList = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ assertEquals(tags.getMainField1(), tagsList);
+
+ textsAndGraphicsState.setTextField2(textField2);
+ textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ List<MetadataType> tagsList2 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+
+ textsAndGraphicsState.setTextField3(textField3);
+ textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "My");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList2 = new ArrayList<>();
+ List<MetadataType> tagsList3 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ tagsList3.add(MetadataType.MEDIA_ALBUM);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+ assertEquals(tags.getMainField3(), tagsList3);
+
+ textsAndGraphicsState.setTextField4(textField4);
+ textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "My - Dudes");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList2 = new ArrayList<>();
+ tagsList3 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ tagsList3.add(MetadataType.MEDIA_ALBUM);
+ tagsList3.add(MetadataType.MEDIA_STATION);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+ assertEquals(tags.getMainField3(), tagsList3);
+
+ // Someone might not want to set the fields in order? We should handle that
+ textsAndGraphicsState.setTextField1(null);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ try {
+ System.out.println(assembledShow.serializeJSON().toString());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "My - Dudes");
+ }
+
+ @Test
+ public void testAssemble4Lines() {
+
+ Show inputShow = new Show();
+
+ defaultMainWindowCapability = getWindowCapability(4);
+ TextField tx1 = new TextField();
+ TextField tx2 = new TextField();
+ TextField tx3 = new TextField();
+ TextField tx4 = new TextField();
+ TextField tx5 = new TextField();
+ TextField tx6 = new TextField();
+
+ tx1.setName(TextFieldName.mainField1);
+ tx2.setName(TextFieldName.mainField2);
+ tx3.setName(TextFieldName.mainField3);
+ tx4.setName(TextFieldName.mainField4);
+ tx5.setName(TextFieldName.mediaTrack);
+ tx6.setName(TextFieldName.templateTitle);
+
+ List<TextField> textFieldNames = Arrays.asList(tx1, tx2, tx3, tx4, tx5, tx6);
+ defaultMainWindowCapability.setTextFields(textFieldNames);
+
+ TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+ textsAndGraphicsState.setMediaTrackTextField("HI");
+ textsAndGraphicsState.setTitle("bye");
+
+ // Force it to return display with support for only 4 lines of text
+ Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "");
+ assertEquals(assembledShow.getMainField3(), "");
+ assertEquals(assembledShow.getMainField4(), "");
+ assertEquals(assembledShow.getMediaTrack(), "HI");
+ assertEquals(assembledShow.getTemplateTitle(), "bye");
+
+ // test tags
+ MetadataTags tags = assembledShow.getMetadataTags();
+ List<MetadataType> tagsList = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ assertEquals(tags.getMainField1(), tagsList);
+
+ textsAndGraphicsState.setTextField2("Wednesday");
+ textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "");
+ assertEquals(assembledShow.getMainField4(), "");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ List<MetadataType> tagsList2 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+
+ textsAndGraphicsState.setTextField3("My");
+ textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "My");
+ assertEquals(assembledShow.getMainField4(), "");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList2 = new ArrayList<>();
+ List<MetadataType> tagsList3 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ tagsList3.add(MetadataType.MEDIA_ALBUM);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+ assertEquals(tags.getMainField3(), tagsList3);
+
+ textsAndGraphicsState.setTextField4("Dudes");
+ textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "My");
+ assertEquals(assembledShow.getMainField4(), "Dudes");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList2 = new ArrayList<>();
+ tagsList3 = new ArrayList<>();
+ List<MetadataType> tagsList4 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ tagsList3.add(MetadataType.MEDIA_ALBUM);
+ tagsList4.add(MetadataType.MEDIA_STATION);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+ assertEquals(tags.getMainField3(), tagsList3);
+ assertEquals(tags.getMainField4(), tagsList4);
+
+ // try just setting line 1 and 4
+ textsAndGraphicsState.setTextField2(null);
+ textsAndGraphicsState.setTextField3(null);
+ textsAndGraphicsState.setTextField2Type(null);
+ textsAndGraphicsState.setTextField3Type(null);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "");
+ assertEquals(assembledShow.getMainField3(), "");
+ assertEquals(assembledShow.getMainField4(), "Dudes");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList4 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList4.add(MetadataType.MEDIA_STATION);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField4(), tagsList4);
+ }
+
+ /**
+ * Testing if WindowCapability is null, TextFields should still update.
+ */
+ @Test
+ public void testAssemble4LinesNullWindowCapability() {
+
+ Show inputShow = new Show();
+
+ TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+
+ textsAndGraphicsState.setMediaTrackTextField("HI");
+ textsAndGraphicsState.setTitle("bye");
+
+ textsAndGraphicsState.setTextField1("It is");
+ textsAndGraphicsState.setTextField1Type(MetadataType.HUMIDITY);
+
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "");
+ assertEquals(assembledShow.getMainField3(), "");
+ assertEquals(assembledShow.getMainField4(), "");
+ assertEquals(assembledShow.getMediaTrack(), "HI");
+ assertEquals(assembledShow.getTemplateTitle(), "bye");
+
+ // test tags
+ MetadataTags tags = assembledShow.getMetadataTags();
+ List<MetadataType> tagsList = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ assertEquals(tags.getMainField1(), tagsList);
+
+ textsAndGraphicsState.setTextField2("Wednesday");
+ textsAndGraphicsState.setTextField2Type(MetadataType.CURRENT_TEMPERATURE);
+
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "");
+ assertEquals(assembledShow.getMainField4(), "");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ List<MetadataType> tagsList2 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+
+ textsAndGraphicsState.setTextField3("My");
+ textsAndGraphicsState.setTextField3Type(MetadataType.MEDIA_ALBUM);
+
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "My");
+ assertEquals(assembledShow.getMainField4(), "");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList2 = new ArrayList<>();
+ List<MetadataType> tagsList3 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ tagsList3.add(MetadataType.MEDIA_ALBUM);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+ assertEquals(tags.getMainField3(), tagsList3);
+
+ textsAndGraphicsState.setTextField4("Dudes");
+ textsAndGraphicsState.setTextField4Type(MetadataType.MEDIA_STATION);
+
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "Wednesday");
+ assertEquals(assembledShow.getMainField3(), "My");
+ assertEquals(assembledShow.getMainField4(), "Dudes");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList2 = new ArrayList<>();
+ tagsList3 = new ArrayList<>();
+ List<MetadataType> tagsList4 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList2.add(MetadataType.CURRENT_TEMPERATURE);
+ tagsList3.add(MetadataType.MEDIA_ALBUM);
+ tagsList4.add(MetadataType.MEDIA_STATION);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField2(), tagsList2);
+ assertEquals(tags.getMainField3(), tagsList3);
+ assertEquals(tags.getMainField4(), tagsList4);
+
+ // try just setting line 1 and 4
+ textsAndGraphicsState.setTextField2(null);
+ textsAndGraphicsState.setTextField3(null);
+ textsAndGraphicsState.setTextField2Type(null);
+ textsAndGraphicsState.setTextField3Type(null);
+
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, null, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+
+ assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
+ assertEquals(assembledShow.getMainField1(), "It is");
+ assertEquals(assembledShow.getMainField2(), "");
+ assertEquals(assembledShow.getMainField3(), "");
+ assertEquals(assembledShow.getMainField4(), "Dudes");
+
+ // test tags
+ tags = assembledShow.getMetadataTags();
+ tagsList = new ArrayList<>();
+ tagsList4 = new ArrayList<>();
+ tagsList.add(MetadataType.HUMIDITY);
+ tagsList4.add(MetadataType.MEDIA_STATION);
+ assertEquals(tags.getMainField1(), tagsList);
+ assertEquals(tags.getMainField4(), tagsList4);
+ }
+
+ @Test
+ public void testExtractTextFromShow() {
+ Show mainShow = new Show();
+ mainShow.setMainField1("test");
+ mainShow.setMainField3("Sauce");
+ mainShow.setMainField4("");
+
+ Show newShow = textAndGraphicUpdateOperation.extractTextFromShow(mainShow);
+
+ assertEquals(newShow.getMainField1(), "test");
+ assertEquals(newShow.getMainField3(), "Sauce");
+ assertEquals(newShow.getMainField4(), "");
+ assertNull(newShow.getMainField2());
+ }
+
+ @Test
+ public void testCreateImageOnlyShowWithPrimaryArtwork() {
+ // Test null
+ Show testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(null, null);
+ assertNull(testShow);
+
+ // Test when artwork hasn't been uploaded
+ when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(false);
+ TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+ testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(testArtwork1, testArtwork2);
+ assertNull(testShow);
+
+ // Test when artwork has been uploaded
+ when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true);
+ textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+ testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(testArtwork1, testArtwork2);
+ assertEquals(testShow.getGraphic(), testArtwork1.getImageRPC());
+ assertEquals(testShow.getSecondaryGraphic(), testArtwork2.getImageRPC());
+ }
+
+}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/video/VideoStreamManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/video/VideoStreamManagerTests.java
index a393bf34f..2a09311e9 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/video/VideoStreamManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/video/VideoStreamManagerTests.java
@@ -2,20 +2,21 @@ package com.smartdevicelink.managers.video;
import android.content.Context;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
import com.smartdevicelink.managers.CompletionListener;
import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener;
+import com.smartdevicelink.managers.lifecycle.SystemCapabilityManager;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.interfaces.ISdl;
import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
-import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
import com.smartdevicelink.proxy.rpc.ImageResolution;
import com.smartdevicelink.proxy.rpc.OnHMIStatus;
import com.smartdevicelink.proxy.rpc.OnTouchEvent;
@@ -39,13 +40,13 @@ import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+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;
@@ -54,11 +55,11 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
/**
* This is a unit test class for the SmartDeviceLink video streaming manager class :
@@ -139,6 +140,9 @@ public class VideoStreamManagerTests {
public void testHMILevelNotFull(){
final ISdl internalInterface = mock(ISdl.class);
+ SystemCapabilityManager systemCapabilityManager = mock(SystemCapabilityManager.class);
+ doReturn(systemCapabilityManager).when(internalInterface).getSystemCapabilityManager();
+
when(internalInterface.getProtocolVersion()).thenReturn((new Version(5,0,0)));
RegisterAppInterfaceResponse mockRegisterAppInterfaceResponse = new RegisterAppInterfaceResponse();
@@ -147,7 +151,7 @@ public class VideoStreamManagerTests {
mockRegisterAppInterfaceResponse.setVehicleType(mockVehicleType);
when(internalInterface.getRegisterAppInterfaceResponse()).thenReturn(mockRegisterAppInterfaceResponse);
- when(internalInterface.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)).thenReturn(true);
+ when(systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)).thenReturn(true);
final VideoStreamManager videoStreamManager = new VideoStreamManager(internalInterface);
videoStreamManager.start(new CompletionListener() {
@@ -174,7 +178,10 @@ public class VideoStreamManagerTests {
final Set<Object> listenerSet = new HashSet<>();
when(internalInterface.getProtocolVersion()).thenReturn(new Version(5,0,0));
- when(internalInterface.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)).thenReturn(true);
+
+ SystemCapabilityManager systemCapabilityManager = mock(SystemCapabilityManager.class);
+ doReturn(systemCapabilityManager).when(internalInterface).getSystemCapabilityManager();
+ when(systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)).thenReturn(true);
Answer<Void> onGetCapability = new Answer<Void>() {
@Override
@@ -186,7 +193,7 @@ public class VideoStreamManagerTests {
}
};
- doAnswer(onGetCapability).when(internalInterface).getCapability(eq(SystemCapabilityType.VIDEO_STREAMING), any(OnSystemCapabilityListener.class));
+ doAnswer(onGetCapability).when(systemCapabilityManager).getCapability(eq(SystemCapabilityType.VIDEO_STREAMING), any(OnSystemCapabilityListener.class), anyBoolean());
Answer<Void> onAddServiceListener = new Answer<Void>() {
@Override
@@ -247,14 +254,7 @@ public class VideoStreamManagerTests {
doAnswer(onRemoveServiceListener).when(internalInterface).removeServiceListener(eq(SessionType.NAV), any(ISdlServiceListener.class));
- when(internalInterface.startVideoStream(anyBoolean(), any(VideoStreamingParameters.class))).thenReturn(new IVideoStreamListener() {
- @Override
- public void sendFrame(byte[] data, int offset, int length, long presentationTimeUs) throws ArrayIndexOutOfBoundsException {}
- @Override
- public void sendFrame(ByteBuffer data, long presentationTimeUs) {}
- });
-
- when(internalInterface.getCapability(SystemCapabilityType.VIDEO_STREAMING)).thenReturn(TestValues.GENERAL_VIDEOSTREAMINGCAPABILITY);
+ when(systemCapabilityManager.getCapability(eq(SystemCapabilityType.VIDEO_STREAMING), any(OnSystemCapabilityListener.class), anyBoolean())).thenReturn(TestValues.GENERAL_VIDEOSTREAMINGCAPABILITY);
final VideoStreamManager videoStreamManager = new VideoStreamManager(internalInterface);
videoStreamManager.start(new CompletionListener() {
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 05d0327a7..16c1c9613 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
@@ -6,6 +6,7 @@ import android.util.Log;
import com.smartdevicelink.R;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
+import com.smartdevicelink.managers.lifecycle.LifecycleManager;
import com.smartdevicelink.managers.lockscreen.LockScreenConfig;
import com.smartdevicelink.managers.screen.choiceset.ChoiceCell;
import com.smartdevicelink.managers.screen.menu.MenuCell;
@@ -15,8 +16,6 @@ import com.smartdevicelink.managers.screen.menu.VoiceCommand;
import com.smartdevicelink.managers.screen.menu.VoiceCommandSelectionListener;
import com.smartdevicelink.protocol.SdlProtocol;
import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.SdlProxyBase;
-import com.smartdevicelink.proxy.TTSChunkFactory;
import com.smartdevicelink.proxy.rpc.AppInfo;
import com.smartdevicelink.proxy.rpc.AppServiceCapability;
import com.smartdevicelink.proxy.rpc.AppServiceData;
@@ -89,6 +88,7 @@ import com.smartdevicelink.proxy.rpc.SingleTireStatus;
import com.smartdevicelink.proxy.rpc.SisData;
import com.smartdevicelink.proxy.rpc.SoftButton;
import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
+import com.smartdevicelink.proxy.rpc.StabilityControlsStatus;
import com.smartdevicelink.proxy.rpc.StartTime;
import com.smartdevicelink.proxy.rpc.StationIDNumber;
import com.smartdevicelink.proxy.rpc.SystemCapability;
@@ -125,6 +125,7 @@ import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
import com.smartdevicelink.proxy.rpc.enums.ButtonEventMode;
import com.smartdevicelink.proxy.rpc.enums.ButtonName;
import com.smartdevicelink.proxy.rpc.enums.ButtonPressMode;
+import com.smartdevicelink.proxy.rpc.enums.CapacityUnit;
import com.smartdevicelink.proxy.rpc.enums.CarModeStatus;
import com.smartdevicelink.proxy.rpc.enums.CharacterSet;
import com.smartdevicelink.proxy.rpc.enums.CompassDirection;
@@ -224,7 +225,7 @@ import java.util.Vector;
public class TestValues {
//Versions
- public static final Version MAX_RPC_VERSION_SUPPORTED = SdlProxyBase.MAX_SUPPORTED_RPC_VERSION;
+ public static final Version MAX_RPC_VERSION_SUPPORTED = LifecycleManager.MAX_SUPPORTED_RPC_VERSION;
/**
* @see SdlProtocol
*/
@@ -335,6 +336,7 @@ public class TestValues {
public static final VehicleDataResultCode GENERAL_VEHICLEDATARESULTCODE = VehicleDataResultCode.IGNORED;
public static final ComponentVolumeStatus GENERAL_COMPONENTVOLUMESTATUS = ComponentVolumeStatus.LOW;
public static final PresetBankCapabilities GENERAL_PRESETBANKCAPABILITIES = new PresetBankCapabilities();
+ public static final CapacityUnit GENERAL_CAPACITYUNIT = CapacityUnit.KILOGRAMS;
public static final VehicleDataEventStatus GENERAL_VEHCILEDATAEVENTSTATUS = VehicleDataEventStatus.YES;
public static final VehicleDataEventStatus GENERAL_VEHICLEDATAEVENTSTATUS = VehicleDataEventStatus.YES;
public static final TouchEventCapabilities GENERAL_TOUCHEVENTCAPABILITIES = new TouchEventCapabilities();
@@ -444,6 +446,9 @@ public class TestValues {
public static final Grid GENERAL_GRID = new Grid();
public static final SeatLocation GENERAL_SEAT_LOCATION = new SeatLocation();
public static final ModuleInfo GENERAL_MODULE_INFO = new ModuleInfo();
+ public static final StabilityControlsStatus GENERAL_STABILITY_CONTROL_STATUS = new StabilityControlsStatus();
+ public static final VehicleDataStatus GENERAL_ESC_SYSTEM = VehicleDataStatus.ON;
+ public static final VehicleDataStatus GENERAL_S_WAY_CONTROL = VehicleDataStatus.OFF;
public static final WindowType GENERAL_WINDOWTYPE = WindowType.MAIN;
public static final GearStatus GENERAL_GEAR_STATUS = new GearStatus();
public static final PRNDL GENERAL_USER_SELECTED_GEAR = PRNDL.NEUTRAL;
@@ -488,7 +493,7 @@ public class TestValues {
public static final List<ClimateControlCapabilities> GENERAL_CLIMATECONTROLCAPABILITIES_LIST = new ArrayList<ClimateControlCapabilities>(1);
public static final List<RadioControlCapabilities> GENERAL_RADIOCONTROLCAPABILITIES_LIST = new ArrayList<RadioControlCapabilities>(1);
public static final Vector<String> GENERAL_VECTOR_STRING = new Vector<>(Arrays.asList(new String[] { "a", "b"}));
- public static final Vector<TTSChunk> GENERAL_VECTOR_TTS_CHUNKS = new Vector<>(Arrays.asList(TTSChunkFactory.createChunk(SpeechCapabilities.TEXT, "Welcome to the jungle")));
+ public static final Vector<TTSChunk> GENERAL_VECTOR_TTS_CHUNKS = new Vector<>(Arrays.asList(new TTSChunk("Welcome to the jungle", SpeechCapabilities.TEXT)));
public static final List<SeatControlCapabilities> GENERAL_SEATCONTROLCAPABILITIES_LIST = new ArrayList<SeatControlCapabilities>(1);
public static final List<EqualizerSettings> GENERAL_EQUALIZERSETTINGS_LIST = new ArrayList<EqualizerSettings>(1);
public static final List<LightCapabilities> GENERAL_LIGHTCAPABILITIES_LIST = new ArrayList<LightCapabilities>(1);
@@ -788,8 +793,8 @@ public class TestValues {
GENERAL_VRHELPITEM.setPosition(100);
GENERAL_VRHELPITEM_LIST.add(GENERAL_VRHELPITEM);
- GENERAL_TTSCHUNK_LIST.add(TTSChunkFactory.createChunk(SpeechCapabilities.TEXT, "Welcome to the jungle"));
- GENERAL_TTSCHUNK_LIST.add(TTSChunkFactory.createChunk(SpeechCapabilities.TEXT, "Say a command"));
+ GENERAL_TTSCHUNK_LIST.add(new TTSChunk("Welcome to the jungle", SpeechCapabilities.TEXT));
+ GENERAL_TTSCHUNK_LIST.add(new TTSChunk("Say a command", SpeechCapabilities.TEXT));
GENERAL_KEYBOARDPROPERTIES.setAutoCompleteText(GENERAL_STRING);
GENERAL_KEYBOARDPROPERTIES.setKeypressMode(KeypressMode.SINGLE_KEYPRESS);
@@ -1025,7 +1030,7 @@ public class TestValues {
GENERAL_LOCKSCREENCONFIG.setAppIcon(R.drawable.sdl_lockscreen_icon);
GENERAL_LOCKSCREENCONFIG.setBackgroundColor(Color.BLUE);
- GENERAL_LOCKSCREENCONFIG.setEnabled(true);
+ GENERAL_LOCKSCREENCONFIG.setDisplayMode(LockScreenConfig.DISPLAY_MODE_ALWAYS);
GENERAL_LOCKSCREENCONFIG.setCustomView(R.layout.activity_sdllock_screen);
GENERAL_CLOUDAPPPROPERTIES.setNicknames(GENERAL_STRING_LIST);
GENERAL_CLOUDAPPPROPERTIES.setAppID(GENERAL_STRING);
@@ -1143,6 +1148,8 @@ public class TestValues {
GENERAL_WINDOW_STATUS.setLocation(TestValues.GENERAL_GRID);
GENERAL_WINDOW_STATUS.setState(TestValues.GENERAL_WINDOW_STATE);
+ GENERAL_STABILITY_CONTROL_STATUS.setEscSystem(GENERAL_ESC_SYSTEM);
+ GENERAL_STABILITY_CONTROL_STATUS.setTrailerSwayControl(GENERAL_S_WAY_CONTROL);
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 d34bfea07..da99ac3fd 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
@@ -1,7 +1,6 @@
package com.smartdevicelink.test;
import com.smartdevicelink.managers.file.filetypes.SdlFile;
-import com.smartdevicelink.protocol.enums.FrameData;
import com.smartdevicelink.protocol.enums.FrameDataControlFrameType;
import com.smartdevicelink.protocol.enums.FrameType;
import com.smartdevicelink.protocol.enums.SessionType;
@@ -146,28 +145,7 @@ public class Validator{
return true;
}
-
- public static boolean validateFrameDataArray (FrameData[] array1, FrameData[] array2) {
- if (array1 == null) {
- return (array2 == null);
- }
-
- if (array2 == null) {
- return (array1 == null);
- }
-
- if (array1.length != array2.length) {
- return false;
- }
-
- for (int i = 0; i < array1.length; i++) {
- if (array1[i] != array2[i]) {
- return false;
- }
- }
-
- return true;
- }
+
public static boolean validateImage(Image image1, Image image2){
if(image1 == null){
@@ -2343,7 +2321,23 @@ public class Validator{
if (item1.get(i).getType() != item2.get(i).getType()) {
return false;
}
- if (item1.get(i).getRange() != item2.get(i).getRange()) {
+ if (!item1.get(i).getRange().equals(item2.get(i).getRange())) {
+ return false;
+ }
+
+ if (!item1.get(i).getCapacity().equals(item2.get(i).getCapacity())) {
+ return false;
+ }
+
+ if (!item1.get(i).getCapacityUnit().equals(item2.get(i).getCapacityUnit())) {
+ return false;
+ }
+
+ if (!item1.get(i).getLevel().equals(item2.get(i).getLevel())) {
+ return false;
+ }
+
+ if (!item1.get(i).getLevelState().equals(item2.get(i).getLevelState())) {
return false;
}
}
@@ -3913,4 +3907,24 @@ public class Validator{
return approxPosition1.equals(approxPosition2) && deviation1.equals(deviation2);
}
+
+ public static boolean validateStabilityControlStatus(StabilityControlsStatus status1, StabilityControlsStatus status2) {
+ if (status1 == null) {
+ return (status2 == null);
+ }
+ if (status2 == null) {
+ return (status2 == null);
+ }
+ return status1.getEscSystem().equals(status2.getEscSystem()) && status1.getTrailerSwayControl().equals(status2.getTrailerSwayControl());
+ }
+
+ public static boolean validateStabilityControlStatus(VehicleDataResult status1, VehicleDataResult status2) {
+ if (status1 == null) {
+ return (status2 == null);
+ }
+ if (status2 == null) {
+ return (status2 == null);
+ }
+ return status1.getDataType().equals(status2.getDataType()) && status1.getResultCode().equals(status2.getResultCode());
+ }
}
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 542cf28c3..569b13b13 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
@@ -16,10 +16,12 @@ 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.StabilityControlsStatus;
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.CapacityUnit;
import com.smartdevicelink.proxy.rpc.enums.CarModeStatus;
import com.smartdevicelink.proxy.rpc.enums.CompassDirection;
import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
@@ -84,6 +86,7 @@ public class VehicleDataHelper{
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 StabilityControlsStatus STABILITY_CONTROLS_STATUS = new StabilityControlsStatus();
public static final String OEM_CUSTOM_VEHICLE_DATA_STATE = "oemCustomVehicleDataState";
public static final Boolean HANDS_OFF_STEERING = Boolean.TRUE;
@@ -197,6 +200,10 @@ public class VehicleDataHelper{
// fuel range
public static final FuelType FUEL_RANGE_TYPE = FuelType.GASOLINE;
public static final Float FUEL_RANGE_RANGE = TestValues.GENERAL_FLOAT;
+ public static final Float FUEL_RANGE_CAPACITY = TestValues.GENERAL_FLOAT;
+ public static final CapacityUnit FUEL_RANGE_CAPACITY_UNIT = TestValues.GENERAL_CAPACITYUNIT;
+ public static final Float FUEL_RANGE_LEVEL = TestValues.GENERAL_FLOAT;
+ public static final ComponentVolumeStatus FUEL_RANGE_LEVEL_STATE = TestValues.GENERAL_COMPONENTVOLUMESTATUS;
// Gear status
public static final GearStatus GEAR_STATUS = new GearStatus();
@@ -208,6 +215,10 @@ public class VehicleDataHelper{
public static final Grid LOCATION_GRID = TestValues.GENERAL_LOCATION_GRID;
public static final WindowState WINDOW_STATE = TestValues.GENERAL_WINDOW_STATE;
+ // stability control status
+ public static final VehicleDataStatus ESC_SYSTEM = VehicleDataStatus.ON;
+ public static final VehicleDataStatus S_WAY_TRAILER = VehicleDataStatus.OFF;
+
public static final JSONArray JSON_FUEL_RANGE = new JSONArray();
//the OnVehicleData which stores all the information above
@@ -336,6 +347,10 @@ public class VehicleDataHelper{
// FUEL_RANGE and FUEL_RANGE_LIST set up
FUEL_RANGE.setType(FUEL_RANGE_TYPE);
FUEL_RANGE.setRange(FUEL_RANGE_RANGE);
+ FUEL_RANGE.setCapacity(FUEL_RANGE_CAPACITY);
+ FUEL_RANGE.setCapacityUnit(FUEL_RANGE_CAPACITY_UNIT);
+ FUEL_RANGE.setLevel(FUEL_RANGE_LEVEL);
+ FUEL_RANGE.setLevelState(FUEL_RANGE_LEVEL_STATE);
FUEL_RANGE_LIST.add(FUEL_RANGE);
//WINDOW_STATUS and WINDOW_STATUS_LIST set up
@@ -349,6 +364,10 @@ public class VehicleDataHelper{
e.printStackTrace();
}
+ // STABILITY_CONTROLS_STATUS
+ STABILITY_CONTROLS_STATUS.setEscSystem(VehicleDataStatus.ON);
+ STABILITY_CONTROLS_STATUS.setTrailerSwayControl(VehicleDataStatus.OFF);
+
// GEAR_STATUS
GEAR_STATUS.setTransmissionType(TRANSMISSION_TYPE);
GEAR_STATUS.setUserSelectedGear(USER_SELECTED_GEAR);
@@ -386,6 +405,7 @@ public class VehicleDataHelper{
VEHICLE_DATA.setElectronicParkBrakeStatus(ELECTRONIC_PARK_BRAKE_STATUS);
VEHICLE_DATA.setGearStatus(GEAR_STATUS);
VEHICLE_DATA.setWindowStatus(WINDOW_STATUS_LIST);
+ VEHICLE_DATA.setStabilityControlsStatus(STABILITY_CONTROLS_STATUS);
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
@@ -420,6 +440,7 @@ public class VehicleDataHelper{
VEHICLE_DATA_RESPONSE.setElectronicParkBrakeStatus(ELECTRONIC_PARK_BRAKE_STATUS);
VEHICLE_DATA_RESPONSE.setGearStatus(GEAR_STATUS);
VEHICLE_DATA_RESPONSE.setWindowStatus(WINDOW_STATUS_LIST);
+ VEHICLE_DATA_RESPONSE.setStabilityControlsStatus(STABILITY_CONTROLS_STATUS);
VEHICLE_DATA_RESPONSE.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, OEM_CUSTOM_VEHICLE_DATA_STATE);
VEHICLE_DATA_RESPONSE.setHandsOffSteering(HANDS_OFF_STEERING);
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/enums/FrameDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/enums/FrameDataTests.java
deleted file mode 100644
index e2ad1ea3a..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/protocol/enums/FrameDataTests.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package com.smartdevicelink.test.protocol.enums;
-
-import com.smartdevicelink.protocol.enums.FrameData;
-import com.smartdevicelink.test.Validator;
-
-import junit.framework.TestCase;
-
-import java.util.Vector;
-
-public class FrameDataTests extends TestCase {
-
- private Vector<FrameData> list = FrameData.getList();
-
- // Verifies the values are not null upon valid assignment.
- // These are not actual enums for packeting reasons so testing is different.
- public void testValidEnums () {
-
- final byte START_SESSION_BYTE = (byte) 0x01;
- final String START_SESSION_STRING = "StartSession";
-
- final byte START_SESSION_ACK_BYTE = (byte) 0x02;
- final String START_SESSION_ACK_STRING = "StartSessionACK";
-
- final byte START_SESSION_NACK_BYTE = (byte) 0x03;
- final String START_SESSION_NACK_STRING = "StartSessionNACK";
-
- final byte END_SESSION_BYTE = (byte) 0x04;
- final String END_SESSION_STRING = "EndSession";
-
- try {
-
- assertNotNull("FrameData list returned null", list);
-
- // Check the byte values
- FrameData enumSS = (FrameData) FrameData.get(list, START_SESSION_BYTE);
- FrameData enumSSACK = (FrameData) FrameData.get(list, START_SESSION_ACK_BYTE);
- FrameData enumSSNACK = (FrameData) FrameData.get(list, START_SESSION_NACK_BYTE);
- FrameData enumES = (FrameData) FrameData.get(list, END_SESSION_BYTE);
-
- assertNotNull("Start session byte match returned null", enumSS);
- assertNotNull("Single byte match returned null", enumSSACK);
- assertNotNull("First byte match returned null", enumSSNACK);
- assertNotNull("Consecutive byte match returned null", enumES);
-
- // Check the string values
- enumSS = (FrameData) FrameData.get(list, START_SESSION_STRING);
- enumSSACK = (FrameData) FrameData.get(list, START_SESSION_ACK_STRING);
- enumSSNACK = (FrameData) FrameData.get(list, START_SESSION_NACK_STRING);
- enumES = (FrameData) FrameData.get(list, END_SESSION_STRING);
-
- assertNotNull("Start session string match returned null", enumSS);
- assertNotNull("Single string match returned null", enumSSACK);
- assertNotNull("First string match returned null", enumSSNACK);
- assertNotNull("Consecutive string match returned null", enumES);
-
- } catch (NullPointerException exception) {
- fail("Null enum list throws NullPointerException.");
- }
- }
-
- // Verifies that an invalid assignment is null.
- public void testInvalidEnum () {
-
- final byte INVALID_BYTE = (byte) 0xAB;
- final String INVALID_STRING = "Invalid";
-
- try {
-
- // Check the byte value
- FrameData enumInvalid = (FrameData) FrameData.get(list, INVALID_BYTE);
- assertNull("Invalid byte match didn't return null", enumInvalid);
-
- // Check the string value
- enumInvalid = (FrameData) FrameData.get(list, INVALID_STRING);
- assertNull("Invalid string match didn't return null", enumInvalid);
-
- } catch (IllegalArgumentException exception) {
- fail("Invalid enum throws IllegalArgumentException.");
- }
- }
-
- // Verifies that a null assignment is invalid.
- public void testNullEnum () {
- try {
-
- // Check null string lookup
- FrameData enumNull = (FrameData) FrameData.get(list, null);
- assertNull("Null lookup returns a value", enumNull);
-
- } catch (NullPointerException exception) {
- fail("Null string throws NullPointerException.");
- }
- }
-
- // Verifies the possible enum values of FrameType.
- public void testListEnum () {
- // Test Vector
- Vector<FrameData> enumTestList = new Vector<FrameData>();
- enumTestList.add(FrameData.StartSession);
- enumTestList.add(FrameData.StartSessionACK);
- enumTestList.add(FrameData.StartSessionNACK);
- enumTestList.add(FrameData.EndSession);
-
- assertTrue("List does not match enum test list.",
- list.containsAll(enumTestList) &&
- enumTestList.containsAll(list));
-
- // Test Array
- FrameData[] enumValueArray = FrameData.values();
- FrameData[] enumTestArray = { FrameData.StartSession, FrameData.StartSessionACK,
- FrameData.StartSessionNACK, FrameData.EndSession };
-
- assertTrue("Array does not match enum values array.",
- Validator.validateFrameDataArray(enumValueArray, enumTestArray));
- }
-} \ No newline at end of file
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/InternalProxyMessageTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/InternalProxyMessageTests.java
deleted file mode 100644
index ec64ed99d..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/InternalProxyMessageTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.smartdevicelink.test.proxy;
-
-import com.smartdevicelink.proxy.callbacks.InternalProxyMessage;
-import com.smartdevicelink.test.TestValues;
-
-import junit.framework.TestCase;
-
-/**
- * This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.proxy.callbacks.InternalProxyMessage}
- */
-public class InternalProxyMessageTests extends TestCase {
-
- /**
- * This is a unit test for the following methods :
- * {@link com.smartdevicelink.proxy.callbacks.InternalProxyMessage#InternalProxyMessage(String)}
- */
- public void testValues () {
- // Valid Tests
- String test = "functionName";
- InternalProxyMessage testIPM = new InternalProxyMessage(test);
- assertEquals(TestValues.MATCH, test, testIPM.getFunctionName());
-
- test = "OnProxyError";
- assertEquals(TestValues.MATCH, test, InternalProxyMessage.OnProxyError);
- test = "OnProxyOpened";
- assertEquals(TestValues.MATCH, test, InternalProxyMessage.OnProxyOpened);
- test = "OnProxyClosed";
- assertEquals(TestValues.MATCH, test, InternalProxyMessage.OnProxyClosed);
-
- // Invalid/Null Tests
- testIPM = new InternalProxyMessage(null);
- assertNull(TestValues.NULL, testIPM.getFunctionName());
- }
-} \ No newline at end of file
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java
deleted file mode 100644
index 8c66446af..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java
+++ /dev/null
@@ -1,1102 +0,0 @@
-package com.smartdevicelink.test.proxy;
-
-import com.smartdevicelink.proxy.RPCRequestFactory;
-import com.smartdevicelink.proxy.TTSChunkFactory;
-import com.smartdevicelink.proxy.rpc.AddCommand;
-import com.smartdevicelink.proxy.rpc.AddSubMenu;
-import com.smartdevicelink.proxy.rpc.Alert;
-import com.smartdevicelink.proxy.rpc.ChangeRegistration;
-import com.smartdevicelink.proxy.rpc.Choice;
-import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSet;
-import com.smartdevicelink.proxy.rpc.DeleteCommand;
-import com.smartdevicelink.proxy.rpc.DeleteFile;
-import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSet;
-import com.smartdevicelink.proxy.rpc.DeleteSubMenu;
-import com.smartdevicelink.proxy.rpc.DeviceInfo;
-import com.smartdevicelink.proxy.rpc.EndAudioPassThru;
-import com.smartdevicelink.proxy.rpc.GetVehicleData;
-import com.smartdevicelink.proxy.rpc.Image;
-import com.smartdevicelink.proxy.rpc.ListFiles;
-import com.smartdevicelink.proxy.rpc.PerformAudioPassThru;
-import com.smartdevicelink.proxy.rpc.PerformInteraction;
-import com.smartdevicelink.proxy.rpc.PutFile;
-import com.smartdevicelink.proxy.rpc.RegisterAppInterface;
-import com.smartdevicelink.proxy.rpc.ScrollableMessage;
-import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
-import com.smartdevicelink.proxy.rpc.SetAppIcon;
-import com.smartdevicelink.proxy.rpc.SetDisplayLayout;
-import com.smartdevicelink.proxy.rpc.SetGlobalProperties;
-import com.smartdevicelink.proxy.rpc.SetMediaClockTimer;
-import com.smartdevicelink.proxy.rpc.Show;
-import com.smartdevicelink.proxy.rpc.Slider;
-import com.smartdevicelink.proxy.rpc.SoftButton;
-import com.smartdevicelink.proxy.rpc.Speak;
-import com.smartdevicelink.proxy.rpc.SubscribeButton;
-import com.smartdevicelink.proxy.rpc.SubscribeVehicleData;
-import com.smartdevicelink.proxy.rpc.SystemRequest;
-import com.smartdevicelink.proxy.rpc.TTSChunk;
-import com.smartdevicelink.proxy.rpc.UnregisterAppInterface;
-import com.smartdevicelink.proxy.rpc.UnsubscribeButton;
-import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleData;
-import com.smartdevicelink.proxy.rpc.VrHelpItem;
-import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
-import com.smartdevicelink.proxy.rpc.enums.AudioType;
-import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
-import com.smartdevicelink.proxy.rpc.enums.ButtonName;
-import com.smartdevicelink.proxy.rpc.enums.FileType;
-import com.smartdevicelink.proxy.rpc.enums.ImageType;
-import com.smartdevicelink.proxy.rpc.enums.InteractionMode;
-import com.smartdevicelink.proxy.rpc.enums.Language;
-import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
-import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
-import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
-import com.smartdevicelink.test.NullValues;
-import com.smartdevicelink.test.TestValues;
-import com.smartdevicelink.test.Validator;
-
-import junit.framework.TestCase;
-
-import java.util.Vector;
-
-/**
- * This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.proxy.RPCRequestFactory}
- */
-public class RPCRequestFactoryTests extends TestCase {
-
- public void testBuildSystemRequest () {
-
- String testData;
- Integer testInt;
- SystemRequest testBSR;
- Vector<String> testVData;
-
- // Test -- buildSystemRequest(String data, Integer correlationID)
- testData = "test";
- testInt = 0;
- testBSR = RPCRequestFactory.buildSystemRequest(testData, testInt);
- assertNotNull(TestValues.NOT_NULL, testBSR.getBulkData());
- assertEquals(TestValues.MATCH, testInt, testBSR.getCorrelationID());
-
- testBSR = RPCRequestFactory.buildSystemRequest(testData, null);
- assertNotNull(TestValues.NULL, testBSR.getCorrelationID());
-
- testBSR = RPCRequestFactory.buildSystemRequest(null, testInt);
- assertNull(TestValues.NULL, testBSR);
-
- // Test -- buildSystemRequestLegacy(Vector<String> data, Integer correlationID)
- testVData = new Vector<String>();
- testVData.add("Test A");
- testVData.add("Test B");
- testVData.add("Test C");
- testBSR = RPCRequestFactory.buildSystemRequestLegacy(testVData, testInt);
- assertEquals(TestValues.MATCH, testVData, new Vector<String>(testBSR.getLegacyData()));
- assertEquals(TestValues.MATCH, testInt, testBSR.getCorrelationID());
-
- testBSR = RPCRequestFactory.buildSystemRequestLegacy(testVData, null);
- assertNotNull(TestValues.NOT_NULL, testBSR.getCorrelationID());
-
- testBSR = RPCRequestFactory.buildSystemRequestLegacy(null, testInt);
- assertNull(TestValues.NULL, testBSR);
-
- // Issue #166 -- Null values within the Vector<String> parameter.
- // TODO: Once resolved, add the following test.
- //testVData = new Vector<String>();
- //testVData.add("Test A");
- //testVData.add("Test B");
- //testVData.add(null);
- //testBSR = RPCRequestFactory.buildSystemRequestLegacy(testVData, testInt);
- //assertNull(Test.NULL, testBSR);
- }
-
- public void testBuildAddCommand () {
-
- Image testImage;
- String testMenuText, testIconValue;
- Integer testCommandID, testParentID, testPosition, testCorrelationID;
- ImageType testIconType;
- AddCommand testBAC;
- Vector<String> testVrCommands;
-
- // Test -- buildAddCommand(Integer commandID, String menuText, Integer parentID, Integer position,Vector<String> vrCommands, Image cmdIcon, Integer correlationID)
- testImage = new Image();
- testMenuText = "menu";
- testPosition = 1;
- testParentID = 2;
- testCommandID = 3;
- testCorrelationID = 4;
- testVrCommands = new Vector<String>();
- testImage.setImageType(ImageType.STATIC);
- testImage.setValue("image");
- testVrCommands.add("Test A");
- testVrCommands.add("Test B");
- testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testParentID, testPosition, testVrCommands, testImage, testCorrelationID);
- assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID());
- assertEquals(TestValues.MATCH, testMenuText, testBAC.getMenuParams().getMenuName());
- assertEquals(TestValues.MATCH, testParentID, testBAC.getMenuParams().getParentID());
- assertEquals(TestValues.MATCH, testPosition, testBAC.getMenuParams().getPosition());
- assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands());
- assertTrue(TestValues.TRUE, Validator.validateImage(testImage, testBAC.getCmdIcon()));
- assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID());
-
- testBAC = RPCRequestFactory.buildAddCommand(null, null, null, null, null, null, null);
- assertNull(TestValues.NULL, testBAC.getCmdID());
- assertNull(TestValues.NULL, testBAC.getMenuParams());
- assertNull(TestValues.NULL, testBAC.getVrCommands());
- assertNull(TestValues.NULL, testBAC.getCmdIcon());
- assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID());
-
- // Test -- buildAddCommand(Integer commandID, String menuText, Integer parentID, Integer position, Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
- testIconValue = "icon";
- testIconType = ImageType.STATIC;
- testImage = new Image();
- testImage.setValue(testIconValue);
- testImage.setImageType(testIconType);
- testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testParentID, testPosition, testVrCommands, testIconValue, testIconType, testCorrelationID);
- assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID());
- assertEquals(TestValues.MATCH, testMenuText, testBAC.getMenuParams().getMenuName());
- assertEquals(TestValues.MATCH, testParentID, testBAC.getMenuParams().getParentID());
- assertEquals(TestValues.MATCH, testPosition, testBAC.getMenuParams().getPosition());
- assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands());
- assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID());
- assertTrue(TestValues.TRUE, Validator.validateImage(testImage, testBAC.getCmdIcon()));
-
- testBAC = RPCRequestFactory.buildAddCommand(null, null, null, null, null, null, null, null);
- assertNull(TestValues.NULL, testBAC.getCmdID());
- assertNull(TestValues.NULL, testBAC.getMenuParams());
- assertNull(TestValues.NULL, testBAC.getVrCommands());
- assertNull(TestValues.NULL, testBAC.getCmdIcon());
- assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID());
-
- // Test -- buildAddCommand(Integer commandID, String menuText, Integer parentID, Integer position, Vector<String> vrCommands, Integer correlationID)
- testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testParentID, testPosition, testVrCommands, testCorrelationID);
- assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID());
- assertEquals(TestValues.MATCH, testMenuText, testBAC.getMenuParams().getMenuName());
- assertEquals(TestValues.MATCH, testParentID, testBAC.getMenuParams().getParentID());
- assertEquals(TestValues.MATCH, testPosition, testBAC.getMenuParams().getPosition());
- assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands());
- assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID());
-
- testBAC = RPCRequestFactory.buildAddCommand(null, null, null, null, null, null);
- assertNull(TestValues.NULL, testBAC.getCmdID());
- assertNull(TestValues.NULL, testBAC.getMenuParams());
- assertNull(TestValues.NULL, testBAC.getVrCommands());
- assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID());
-
- // Test -- buildAddCommand(Integer commandID, String menuText, Vector<String> vrCommands, Integer correlationID)
- testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testVrCommands, testCorrelationID);
- assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID());
- assertEquals(TestValues.MATCH, testMenuText, testBAC.getMenuParams().getMenuName());
- assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands());
- assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID());
-
- testBAC = RPCRequestFactory.buildAddCommand(null, null, null, null);
- assertNull(TestValues.NULL, testBAC.getCmdID());
- assertNull(TestValues.NULL, testBAC.getMenuParams());
- assertNull(TestValues.NULL, testBAC.getVrCommands());
- assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID());
-
- // Test -- buildAddCommand(Integer commandID, Vector<String> vrCommands, Integer correlationID)
- testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testVrCommands, testCorrelationID);
- assertEquals(TestValues.MATCH, testCommandID, testBAC.getCmdID());
- assertEquals(TestValues.MATCH, testVrCommands, testBAC.getVrCommands());
- assertEquals(TestValues.MATCH, testCorrelationID, testBAC.getCorrelationID());
-
- testBAC = RPCRequestFactory.buildAddCommand(null, null, null);
- assertNull(TestValues.NULL, testBAC.getCmdID());
- assertNull(TestValues.NULL, testBAC.getVrCommands());
- assertNotNull(TestValues.NOT_NULL, testBAC.getCorrelationID());
- }
-
- public void testBuildAddSubMenu () {
-
- Integer testMenuID, testCorrelationID, testPosition;
- String testMenuName;
- AddSubMenu testBASM;
-
- // Test -- buildAddSubMenu(Integer menuID, String menuName, Integer correlationID)
- // ^ Calls another build method.
- // Test -- buildAddSubMenu(Integer menuID, String menuName, Integer position, Integer correlationID)
- testMenuID = 0;
- testMenuName = "name";
- testPosition = 1;
- testCorrelationID = 2;
- testBASM = RPCRequestFactory.buildAddSubMenu(testMenuID, testMenuName, testPosition, testCorrelationID);
- assertEquals(TestValues.MATCH, testMenuID, testBASM.getMenuID());
- assertEquals(TestValues.MATCH, testMenuName, testBASM.getMenuName());
- assertEquals(TestValues.MATCH, testPosition, testBASM.getPosition());
- assertEquals(TestValues.MATCH, testCorrelationID, testBASM.getCorrelationID());
-
- testBASM = RPCRequestFactory.buildAddSubMenu(null, null, null, null);
- assertNull(TestValues.NULL, testBASM.getMenuID());
- assertNull(TestValues.NULL, testBASM.getMenuName());
- assertNull(TestValues.NULL, testBASM.getPosition());
- assertNotNull(TestValues.NOT_NULL, testBASM.getCorrelationID());
- }
-
- public void testBuildAlert () {
-
- Alert testAlert;
- String testTTSText, testAlertText1, testAlertText2, testAlertText3;
- Integer testCorrelationID, testDuration;
- Boolean testPlayTone;
- Vector<SoftButton> testSoftButtons;
- Vector<TTSChunk> testTtsChunks;
-
- // Test -- buildAlert(String ttsText, Boolean playTone, Vector<SoftButton> softButtons, Integer correlationID)
- testTTSText = "simple test";
- testCorrelationID = 0;
- testPlayTone = true;
- testSoftButtons = new Vector<SoftButton>();
- SoftButton test1 = new SoftButton();
- test1.setText("test 1");
- SoftButton test2 = new SoftButton();
- test2.setText("test 2");
- testSoftButtons.add(test1);
- testSoftButtons.add(test2);
- testAlert = RPCRequestFactory.buildAlert(testTTSText, testPlayTone, testSoftButtons, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(TTSChunkFactory.createSimpleTTSChunks(testTTSText), testAlert.getTtsChunks()));
- // ^ Calls another build method.
-
- // Test -- buildAlert(String alertText1, String alertText2, String alertText3, Integer duration, Vector<SoftButton> softButtons, Integer correlationID)
- testAlertText1 = "test 1";
- testAlertText2 = "test 2";
- testAlertText3 = "test 3";
- testDuration = 1;
- // ^ Calls another build method.
-
- // Test -- buildAlert(String ttsText, String alertText1, String alertText2, String alertText3, Boolean playTone, Integer duration, Vector<SoftButton> softButtons, Integer correlationID)
- testAlert = RPCRequestFactory.buildAlert(testTTSText, testAlertText1, testAlertText2, testAlertText3, testPlayTone, testDuration, testSoftButtons, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(TTSChunkFactory.createSimpleTTSChunks(testTTSText), testAlert.getTtsChunks()));
- // ^ Calls another build method.
-
- // Test -- buildAlert(Vector<TTSChunk> chunks, Boolean playTone, Vector<SoftButton> softButtons, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildAlert(Vector<TTSChunk> ttsChunks, String alertText1, String alertText2, String alertText3, Boolean playTone, Integer duration, Vector<SoftButton> softButtons, Integer correlationID)
- testTtsChunks = TTSChunkFactory.createSimpleTTSChunks(testTTSText);
- testAlert = RPCRequestFactory.buildAlert(testTtsChunks, testAlertText1, testAlertText2, testAlertText3, testPlayTone, testDuration, testSoftButtons, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTtsChunks, testAlert.getTtsChunks()));
- assertEquals(TestValues.MATCH, testAlertText1, testAlert.getAlertText1());
- assertEquals(TestValues.MATCH, testAlertText2, testAlert.getAlertText2());
- assertEquals(TestValues.MATCH, testAlertText3, testAlert.getAlertText3());
- assertEquals(TestValues.MATCH, testPlayTone, testAlert.getPlayTone());
- assertEquals(TestValues.MATCH, testDuration, testAlert.getDuration());
- assertTrue(TestValues.TRUE, Validator.validateSoftButtons(testSoftButtons, testAlert.getSoftButtons()));
- assertEquals(TestValues.MATCH, testCorrelationID, testAlert.getCorrelationID());
-
- testAlert = RPCRequestFactory.buildAlert((Vector<TTSChunk>) null, null, null, null, null, null, null, null);
- assertNull(TestValues.NULL, testAlert.getTtsChunks());
- assertNull(TestValues.NULL, testAlert.getAlertText1());
- assertNull(TestValues.NULL, testAlert.getAlertText2());
- assertNull(TestValues.NULL, testAlert.getAlertText3());
- assertNull(TestValues.NULL, testAlert.getPlayTone());
- assertNull(TestValues.NULL, testAlert.getDuration());
- assertNull(TestValues.NULL, testAlert.getSoftButtons());
- assertNotNull(TestValues.NOT_NULL, testAlert.getCorrelationID());
-
- // Test -- buildAlert(String ttsText, Boolean playTone, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildAlert(String alertText1, String alertText2, Integer duration, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildAlert(String ttsText, String alertText1, String alertText2, Boolean playTone, Integer duration, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildAlert(Vector<TTSChunk> chunks, Boolean playTone, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildAlert(Vector<TTSChunk> ttsChunks, String alertText1, String alertText2, Boolean playTone, Integer duration, Integer correlationID)
- testAlert = RPCRequestFactory.buildAlert(testTtsChunks, testAlertText1, testAlertText2, testPlayTone, testDuration, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTtsChunks, testAlert.getTtsChunks()));
- assertEquals(TestValues.MATCH, testAlertText1, testAlert.getAlertText1());
- assertEquals(TestValues.MATCH, testAlertText2, testAlert.getAlertText2());
- assertEquals(TestValues.MATCH, testPlayTone, testAlert.getPlayTone());
- assertEquals(TestValues.MATCH, testDuration, testAlert.getDuration());
- assertEquals(TestValues.MATCH, testCorrelationID, testAlert.getCorrelationID());
-
- testAlert = RPCRequestFactory.buildAlert((Vector<TTSChunk>) null, null, null, null, null, null);
- assertNull(TestValues.NULL, testAlert.getTtsChunks());
- assertNull(TestValues.NULL, testAlert.getAlertText1());
- assertNull(TestValues.NULL, testAlert.getAlertText2());
- assertNull(TestValues.NULL, testAlert.getPlayTone());
- assertNull(TestValues.NULL, testAlert.getDuration());
- assertNotNull(TestValues.NOT_NULL, testAlert.getCorrelationID());
- }
-
- public void testBuildCreateInteractionChoiceSet () {
-
- Integer testICSID, testCorrelationID;
- Vector<Choice> testChoiceSet;
- CreateInteractionChoiceSet testBCICS;
-
- // Test --buildCreateInteractionChoiceSet(Vector<Choice> choiceSet, Integer interactionChoiceSetID, Integer correlationID)
- testICSID = 0;
- testCorrelationID = 1;
- testChoiceSet = new Vector<Choice>();
- Choice testChoice = new Choice();
- testChoiceSet.add(testChoice);
- testBCICS = RPCRequestFactory.buildCreateInteractionChoiceSet(testChoiceSet, testICSID, testCorrelationID);
- assertEquals(TestValues.MATCH, testChoiceSet, testBCICS.getChoiceSet());
- assertEquals(TestValues.MATCH, testICSID, testBCICS.getInteractionChoiceSetID());
- assertEquals(TestValues.MATCH, testCorrelationID, testBCICS.getCorrelationID());
-
- testBCICS = RPCRequestFactory.buildCreateInteractionChoiceSet(null, null, null);
- assertNull(TestValues.NULL, testBCICS.getChoiceSet());
- assertNull(TestValues.NULL, testBCICS.getInteractionChoiceSetID());
- assertNotNull(TestValues.NOT_NULL, testBCICS.getCorrelationID());
- }
-
- public void testBuildDeleteCommand () {
-
- Integer testCID, testCorrelationID;
- DeleteCommand testDC;
-
- // Test -- buildDeleteCommand(Integer commandID, Integer correlationID)
- testCID = 0;
- testCorrelationID = 1;
- testDC = RPCRequestFactory.buildDeleteCommand(testCID, testCorrelationID);
- assertEquals(TestValues.MATCH, testCID, testDC.getCmdID());
- assertEquals(TestValues.MATCH, testCorrelationID, testDC.getCorrelationID());
-
- testDC = RPCRequestFactory.buildDeleteCommand(null, null);
- assertNull(TestValues.NULL, testDC.getCmdID());
- assertNotNull(TestValues.NOT_NULL, testDC.getCorrelationID());
-
- }
-
- public void testBuildDeleteFile () {
-
- Integer testCorrelationID;
- String testFileName;
- DeleteFile testDF;
-
- // Test --buildDeleteFile(String sdlFileName, Integer correlationID)
- testCorrelationID = 0;
- testFileName = "test";
- testDF = RPCRequestFactory.buildDeleteFile(testFileName, testCorrelationID);
- assertEquals(TestValues.MATCH, testCorrelationID, testDF.getCorrelationID());
- assertEquals(TestValues.MATCH, testFileName, testDF.getSdlFileName());
-
- testDF = RPCRequestFactory.buildDeleteFile(null, null);
- assertNotNull(TestValues.NOT_NULL, testDF.getCorrelationID());
- assertNull(TestValues.NULL, testDF.getSdlFileName());
-
- }
-
- public void testBuildDeleteInteractionChoiceSet () {
-
- Integer testICSID, testCorrelationID;
- DeleteInteractionChoiceSet testDICS;
-
- // Test -- buildDeleteInteractionChoiceSet(Integer interactionChoiceSetID, Integer correlationID)
- testICSID = 0;
- testCorrelationID = 1;
- testDICS = RPCRequestFactory.buildDeleteInteractionChoiceSet(testICSID, testCorrelationID);
- assertEquals(TestValues.MATCH, testICSID, testDICS.getInteractionChoiceSetID());
- assertEquals(TestValues.MATCH, testCorrelationID, testDICS.getCorrelationID());
-
- testDICS = RPCRequestFactory.buildDeleteInteractionChoiceSet(null, null);
- assertNull(TestValues.NULL, testDICS.getInteractionChoiceSetID());
- assertNotNull(TestValues.NOT_NULL, testDICS.getCorrelationID());
- }
-
- public void testBuildDeleteSubMenu () {
-
- Integer testMenuID, testCorrelationID;
- DeleteSubMenu testDSM;
-
- // Test -- buildDeleteSubMenu(Integer menuID, Integer correlationID)
- testMenuID = 0;
- testCorrelationID = 1;
- testDSM = RPCRequestFactory.buildDeleteSubMenu(testMenuID, testCorrelationID);
- assertEquals(TestValues.MATCH, testMenuID, testDSM.getMenuID());
- assertEquals(TestValues.MATCH, testCorrelationID, testDSM.getCorrelationID());
-
- testDSM = RPCRequestFactory.buildDeleteSubMenu(null, null);
- assertNull(TestValues.NULL, testDSM.getMenuID());
- assertNotNull(TestValues.NOT_NULL, testDSM.getCorrelationID());
- }
-
- public void testBuildListFiles () {
-
- Integer testCorrelationID = 0;
- ListFiles testLF;
-
- // Test -- buildListFiles(Integer correlationID)
- testLF = RPCRequestFactory.buildListFiles(testCorrelationID);
- assertEquals(TestValues.MATCH, testCorrelationID, testLF.getCorrelationID());
-
- testLF = RPCRequestFactory.buildListFiles(null);
- assertNotNull(TestValues.NOT_NULL, testLF.getCorrelationID());
- }
-
- @SuppressWarnings("deprecation")
- public void testBuildPerformInteraction () {
-
- String testDisplayText = "test";
- Integer testTimeout = 1, testCorrelationID = 0;
- InteractionMode testIM = InteractionMode.BOTH;
- Vector<TTSChunk> testInitChunks, testHelpChunks, testTimeoutChunks;
- Vector<Integer> testCSIDs;
- Vector<VrHelpItem> testVrHelpItems;
- PerformInteraction testPI;
-
- // Test -- buildPerformInteraction(Vector<TTSChunk> initChunks, String displayText, Vector<Integer> interactionChoiceSetIDList, Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks, InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp, Integer correlationID)
- testInitChunks = TTSChunkFactory.createSimpleTTSChunks("init chunks");
- testHelpChunks = TTSChunkFactory.createSimpleTTSChunks("help items");
- testTimeoutChunks = TTSChunkFactory.createSimpleTTSChunks("timeout");
- testVrHelpItems = new Vector<VrHelpItem>();
- VrHelpItem testItem = new VrHelpItem();
- testItem.setPosition(0);
- testItem.setText("text");
- Image image = new Image();
- image.setValue("value");
- image.setImageType(ImageType.DYNAMIC);
- testItem.setImage(image);
- testVrHelpItems.add(testItem);
- testCSIDs = new Vector<Integer>();
- testCSIDs.add(0);
- testCSIDs.add(1);
- testPI = RPCRequestFactory.buildPerformInteraction(testInitChunks, testDisplayText, testCSIDs, testHelpChunks, testTimeoutChunks, testIM, testTimeout, testVrHelpItems, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testInitChunks, testPI.getInitialPrompt()));
- assertEquals(TestValues.MATCH, testDisplayText, testPI.getInitialText());
- assertTrue(TestValues.TRUE, Validator.validateIntegerList(testCSIDs, testPI.getInteractionChoiceSetIDList()));
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testPI.getHelpPrompt()));
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTimeoutChunks, testPI.getTimeoutPrompt()));
- assertEquals(TestValues.MATCH, testIM, testPI.getInteractionMode());
- assertEquals(TestValues.MATCH, testTimeout, testPI.getTimeout());
- assertTrue(TestValues.TRUE, Validator.validateVrHelpItems(testVrHelpItems, testPI.getVrHelp()));
- assertEquals(TestValues.MATCH, testCorrelationID, testPI.getCorrelationID());
-
- testPI = RPCRequestFactory.buildPerformInteraction((Vector<TTSChunk>) null, null, null, null, null, null, null, null, null);
- assertNull(TestValues.NULL, testPI.getInitialPrompt());
- assertNull(TestValues.NULL, testPI.getInitialText());
- assertNull(TestValues.NULL, testPI.getInteractionChoiceSetIDList());
- assertNull(TestValues.NULL, testPI.getHelpPrompt());
- assertNull(TestValues.NULL, testPI.getTimeoutPrompt());
- assertNull(TestValues.NULL, testPI.getInteractionMode());
- assertNull(TestValues.NULL, testPI.getTimeout());
- assertNull(TestValues.NULL, testPI.getVrHelp());
- assertNotNull(TestValues.NOT_NULL, testPI.getCorrelationID());
-
- // Test -- buildPerformInteraction(String initPrompt, String displayText, Vector<Integer> interactionChoiceSetIDList, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildPerformInteraction(String initPrompt, String displayText, Integer interactionChoiceSetID, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildPerformInteraction(String initPrompt, String displayText, Integer interactionChoiceSetID, Vector<VrHelpItem> vrHelp, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildPerformInteraction(Vector<TTSChunk> initChunks, String displayText, Vector<Integer> interactionChoiceSetIDList, Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks, InteractionMode interactionMode, Integer timeout, Integer correlationID)
- testPI = RPCRequestFactory.buildPerformInteraction(testInitChunks, testDisplayText, testCSIDs, testHelpChunks, testTimeoutChunks, testIM, testTimeout, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testInitChunks, testPI.getInitialPrompt()));
- assertEquals(TestValues.MATCH, testDisplayText, testPI.getInitialText());
- assertTrue(TestValues.TRUE, Validator.validateIntegerList(testCSIDs, testPI.getInteractionChoiceSetIDList()));
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testPI.getHelpPrompt()));
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTimeoutChunks, testPI.getTimeoutPrompt()));
- assertEquals(TestValues.MATCH, testIM, testPI.getInteractionMode());
- assertEquals(TestValues.MATCH, testTimeout, testPI.getTimeout());
- assertEquals(TestValues.MATCH, testCorrelationID, testPI.getCorrelationID());
-
- testPI = RPCRequestFactory.buildPerformInteraction((Vector<TTSChunk>) null, null, null, null, null, null, null, null);
- assertNull(TestValues.NULL, testPI.getInitialPrompt());
- assertNull(TestValues.NULL, testPI.getInitialText());
- assertNull(TestValues.NULL, testPI.getInteractionChoiceSetIDList());
- assertNull(TestValues.NULL, testPI.getHelpPrompt());
- assertNull(TestValues.NULL, testPI.getTimeoutPrompt());
- assertNull(TestValues.NULL, testPI.getInteractionMode());
- assertNull(TestValues.NULL, testPI.getTimeout());
- assertNotNull(TestValues.NOT_NULL, testPI.getCorrelationID());
-
- // Test -- buildPerformInteraction(String initPrompt, String displayText, Vector<Integer> interactionChoiceSetIDList, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildPerformInteraction(String initPrompt, String displayText, Integer interactionChoiceSetID, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildPerformInteraction(String initPrompt, String displayText, Integer interactionChoiceSetID, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildPerformInteraction(Vector<TTSChunk> initChunks, String displayText, Vector<Integer> interactionChoiceSetIDList, Vector<TTSChunk> helpChunks, InteractionMode interactionMode, Integer timeout, Integer correlationID)
- testPI = RPCRequestFactory.buildPerformInteraction(testInitChunks, testDisplayText, testCSIDs, testHelpChunks, testIM, testTimeout, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testInitChunks, testPI.getInitialPrompt()));
- assertEquals(TestValues.MATCH, testDisplayText, testPI.getInitialText());
- assertTrue(TestValues.TRUE, Validator.validateIntegerList(testCSIDs, testPI.getInteractionChoiceSetIDList()));
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testPI.getHelpPrompt()));
- assertEquals(TestValues.MATCH, testIM, testPI.getInteractionMode());
- assertEquals(TestValues.MATCH, testTimeout, testPI.getTimeout());
- assertEquals(TestValues.MATCH, testCorrelationID, testPI.getCorrelationID());
-
- testPI = RPCRequestFactory.buildPerformInteraction((Vector<TTSChunk>) null, null, null, null, null, null, null);
- assertNull(TestValues.NULL, testPI.getInitialPrompt());
- assertNull(TestValues.NULL, testPI.getInitialText());
- assertNull(TestValues.NULL, testPI.getInteractionChoiceSetIDList());
- assertNull(TestValues.NULL, testPI.getHelpPrompt());
- assertNull(TestValues.NULL, testPI.getInteractionMode());
- assertNull(TestValues.NULL, testPI.getTimeout());
- assertNotNull(TestValues.NOT_NULL, testPI.getCorrelationID());
-
- // Test -- buildPerformInteraction(String initPrompt, String displayText, Vector<Integer> interactionChoiceSetIDList, String helpPrompt, InteractionMode interactionMode, Integer timeout, Integer correlationID)
- // ^ Calls another build method.
- }
-
- public void testBuildPutFiles () {
-
- String testFileName = "test";
- Boolean testPFile = true, testSystemFile = true;
- Integer testCorrelationID = 0;
- Long testOffset = 1L, testLength = 2L;
- FileType testFileType = FileType.BINARY;
- byte[] testFileData = {(byte) 0x00, (byte) 0x01, (byte) 0x02 };
- PutFile testPF;
-
- // Test -- buildPutFile(String sdlFileName, FileType fileType, Boolean persistentFile, byte[] fileData, Integer correlationID)
- testPF = RPCRequestFactory.buildPutFile(testFileName, testFileType, testPFile, testFileData, testCorrelationID);
- assertEquals(TestValues.MATCH, testFileName, testPF.getSdlFileName());
- assertEquals(TestValues.MATCH, testFileType, testPF.getFileType());
- assertEquals(TestValues.MATCH, testPFile, testPF.getPersistentFile());
- assertTrue(TestValues.TRUE, Validator.validateBulkData(testFileData, testPF.getFileData()));
- assertEquals(TestValues.MATCH, testCorrelationID, testPF.getCorrelationID());
-
- testPF = RPCRequestFactory.buildPutFile(null, null, null, null, null);
- assertNull(TestValues.NULL, testPF.getSdlFileName());
- assertNull(TestValues.NULL, testPF.getFileType());
- assertNull(TestValues.NULL, testPF.getPersistentFile());
- assertNull(TestValues.NULL, testPF.getFileData());
- assertNotNull(TestValues.NOT_NULL, testPF.getCorrelationID());
-
- // Test -- buildPutFile(String sdlFileName, Integer iOffset, Integer iLength)
- testPF = RPCRequestFactory.buildPutFile(testFileName, testOffset, testLength);
- assertEquals(TestValues.MATCH, testFileName, testPF.getSdlFileName());
- assertEquals(TestValues.MATCH, testOffset, testPF.getOffset());
- assertEquals(TestValues.MATCH, testLength, testPF.getLength());
-
- testPF = RPCRequestFactory.buildPutFile(NullValues.STRING, NullValues.INTEGER, NullValues.INTEGER);
- assertNull(TestValues.NULL, testPF.getSdlFileName());
- assertNull(TestValues.NULL, testPF.getOffset());
- assertNull(TestValues.NULL, testPF.getLength());
-
- // Test -- buildPutFile(String syncFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile)
- testPF = RPCRequestFactory.buildPutFile(testFileName, testOffset, testLength, testFileType, testPFile, testSystemFile);
- assertEquals(TestValues.MATCH, testFileName, testPF.getSdlFileName());
- assertEquals(TestValues.MATCH, testOffset, testPF.getOffset());
- assertEquals(TestValues.MATCH, testLength, testPF.getLength());
- assertTrue(TestValues.TRUE, testPF.getPersistentFile());
- assertEquals(TestValues.MATCH, testSystemFile, testPF.getSystemFile());
-
- testPF = RPCRequestFactory.buildPutFile(NullValues.STRING, NullValues.INTEGER, NullValues.INTEGER, null, NullValues.BOOLEAN, NullValues.BOOLEAN);
- assertNull(TestValues.NULL, testPF.getSdlFileName());
- assertNull(TestValues.NULL, testPF.getOffset());
- assertNull(TestValues.NULL, testPF.getLength());
- assertNull(TestValues.NULL, testPF.getFileType());
- assertNull(TestValues.NULL, testPF.getPersistentFile());
- assertNull(TestValues.NULL, testPF.getSystemFile());
- }
-
- public void testBuildRegisterAppInterface () {
-
- SdlMsgVersion testSMV = new SdlMsgVersion();
- testSMV.setMajorVersion(1);
- testSMV.setMinorVersion(0);
- String testAppName = "test", testNGN = "ngn", testAppID = "id";
- Vector<TTSChunk> testTTSName = TTSChunkFactory.createSimpleTTSChunks("name");
- Vector<String> testSynonyms = new Vector<String>();
- testSynonyms.add("examine");
- Boolean testIMA = false;
- Integer testCorrelationID = 0;
- Language testLang = Language.EN_US, testHMILang = Language.EN_GB;
- Vector<AppHMIType> testHMIType = new Vector<AppHMIType>();
- testHMIType.add(AppHMIType.DEFAULT);
- DeviceInfo testDI = RPCRequestFactory.BuildDeviceInfo(null);
- RegisterAppInterface testRAI;
-
- // Test -- buildRegisterAppInterface(String appName, String appID)
- // ^ Calls another build method.
-
- // Test -- buildRegisterAppInterface(String appName, Boolean isMediaApp, String appID)
- // ^ Calls another build method.
-
- // Test -- buildRegisterAppInterface(SdlMsgVersion sdlMsgVersion, String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp, Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType, String appID, Integer correlationID)
- testRAI = RPCRequestFactory.buildRegisterAppInterface(testSMV, testAppName, testTTSName, testNGN, testSynonyms, testIMA, testLang, testHMILang, testHMIType, testAppID, testCorrelationID,testDI);
- assertTrue(TestValues.TRUE, Validator.validateSdlMsgVersion(testSMV, testRAI.getSdlMsgVersion()));
- assertEquals(TestValues.MATCH, testAppName, testRAI.getAppName());
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTTSName, testRAI.getTtsName()));
- assertEquals(TestValues.MATCH, testNGN, testRAI.getNgnMediaScreenAppName());
- assertTrue(TestValues.TRUE, Validator.validateStringList(testSynonyms, testRAI.getVrSynonyms()));
- assertEquals(TestValues.MATCH, testIMA, testRAI.getIsMediaApplication());
- assertEquals(TestValues.MATCH, testLang, testRAI.getLanguageDesired());
- assertEquals(TestValues.MATCH, testHMILang, testRAI.getHmiDisplayLanguageDesired());
- assertEquals(TestValues.MATCH, AppHMIType.DEFAULT, testRAI.getAppHMIType().get(0));
- assertEquals(TestValues.MATCH, testAppID, testRAI.getAppID());
- assertEquals(TestValues.MATCH, testCorrelationID, testRAI.getCorrelationID());
- assertEquals(TestValues.MATCH, testDI, testRAI.getDeviceInfo());
-
-
- testRAI = RPCRequestFactory.buildRegisterAppInterface(null, null, null, null, null, null, null, null, null, null, null,null);
- assertEquals(TestValues.MATCH, (Integer) 1, testRAI.getCorrelationID());
- assertEquals(TestValues.MATCH, testSMV.getMajorVersion(), testRAI.getSdlMsgVersion().getMajorVersion());
- assertEquals(TestValues.MATCH, testSMV.getMinorVersion(), testRAI.getSdlMsgVersion().getMinorVersion());
- assertNull(TestValues.NULL, testRAI.getAppName());
- assertNull(TestValues.NULL, testRAI.getTtsName());
- assertNull(TestValues.NULL, testRAI.getNgnMediaScreenAppName());
- assertNull(TestValues.NULL, testRAI.getVrSynonyms());
- assertNull(TestValues.NULL, testRAI.getIsMediaApplication());
- assertNotNull(TestValues.NOT_NULL, testRAI.getLanguageDesired());
- assertNotNull(TestValues.NOT_NULL, testRAI.getHmiDisplayLanguageDesired());
- assertNull(TestValues.NULL, testRAI.getAppHMIType());
- assertNull(TestValues.NULL, testRAI.getAppID());
- assertNull(TestValues.NULL, testRAI.getDeviceInfo());
- }
-
- public void testBuildSetAppIcon () {
-
- String testFileName = "test";
- Integer testCorrelationID = 0;
- SetAppIcon testSAI;
-
- // Test -- buildSetAppIcon(String sdlFileName, Integer correlationID)
- testSAI = RPCRequestFactory.buildSetAppIcon(testFileName, testCorrelationID);
- assertEquals(TestValues.MATCH, testFileName, testSAI.getSdlFileName());
- assertEquals(TestValues.MATCH, testCorrelationID, testSAI.getCorrelationID());
-
- testSAI = RPCRequestFactory.buildSetAppIcon(null, null);
- assertNull(TestValues.NULL, testSAI.getSdlFileName());
- assertNotNull(TestValues.NOT_NULL, testSAI.getCorrelationID());
-
- }
-
- public void testBuildSetGlobalProperties () {
-
- Vector<TTSChunk> testHelpChunks = TTSChunkFactory.createSimpleTTSChunks("test"),
- testTimeoutChunks = TTSChunkFactory.createSimpleTTSChunks("timeout");
- Vector<VrHelpItem> testVrHelp = new Vector<VrHelpItem>();
- VrHelpItem testItem = new VrHelpItem();
- testItem.setPosition(0);
- testItem.setText("text");
- Image image = new Image();
- image.setValue("value");
- image.setImageType(ImageType.DYNAMIC);
- testItem.setImage(image);
- testVrHelp.add(testItem);
- Integer testCorrelationID = 0;
- String testHelpTitle = "help";
- SetGlobalProperties testSBP;
-
- // Test -- buildSetGlobalProperties(String helpPrompt, String timeoutPrompt, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildSetGlobalProperties(Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks, Integer correlationID)
- testSBP = RPCRequestFactory.buildSetGlobalProperties(testHelpChunks, testTimeoutChunks, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testSBP.getHelpPrompt()));
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTimeoutChunks, testSBP.getTimeoutPrompt()));
- assertEquals(TestValues.MATCH, testCorrelationID, testSBP.getCorrelationID());
-
- testSBP = RPCRequestFactory.buildSetGlobalProperties((Vector<TTSChunk>) null, null, null);
- assertNull(TestValues.NULL, testSBP.getHelpPrompt());
- assertNull(TestValues.NULL, testSBP.getTimeoutPrompt());
- assertNotNull(TestValues.NOT_NULL, testSBP.getCorrelationID());
-
- // Test -- buildSetGlobalProperties(String helpPrompt, String timeoutPrompt, String vrHelpTitle, Vector<VrHelpItem> vrHelp, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildSetGlobalProperties(Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks, String vrHelpTitle, Vector<VrHelpItem> vrHelp, Integer correlationID)
- testSBP = RPCRequestFactory.buildSetGlobalProperties(testHelpChunks, testTimeoutChunks, testHelpTitle, testVrHelp, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testHelpChunks, testSBP.getHelpPrompt()));
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTimeoutChunks, testSBP.getTimeoutPrompt()));
- assertEquals(TestValues.MATCH, testHelpTitle, testSBP.getVrHelpTitle());
- assertTrue(TestValues.TRUE, Validator.validateVrHelpItems(testVrHelp, testSBP.getVrHelp()));
- assertEquals(TestValues.MATCH, testCorrelationID, testSBP.getCorrelationID());
-
- testSBP = RPCRequestFactory.buildSetGlobalProperties((Vector<TTSChunk>) null, null, null, null, null);
- assertNull(TestValues.NULL, testSBP.getHelpPrompt());
- assertNull(TestValues.NULL, testSBP.getTimeoutPrompt());
- assertNull(TestValues.NULL, testSBP.getVrHelpTitle());
- assertNull(TestValues.NULL, testSBP.getVrHelp());
- assertNotNull(TestValues.NOT_NULL, testSBP.getCorrelationID());
- }
-
- public void testBuildSetMediaClockTimer () {
-
- Integer hours = 0, minutes = 0, seconds = 0, testCorrelationID = 0;
- UpdateMode testMode = UpdateMode.COUNTUP;
- SetMediaClockTimer testSMCT;
-
- // Test -- buildSetMediaClockTimer(Integer hours, Integer minutes, Integer seconds, UpdateMode updateMode, Integer correlationID)
- testSMCT = RPCRequestFactory.buildSetMediaClockTimer(hours, minutes, seconds, testMode, testCorrelationID);
- assertEquals(TestValues.MATCH, hours, testSMCT.getStartTime().getHours());
- assertEquals(TestValues.MATCH, minutes, testSMCT.getStartTime().getMinutes());
- assertEquals(TestValues.MATCH, seconds, testSMCT.getStartTime().getSeconds());
- assertEquals(TestValues.MATCH, testMode, testSMCT.getUpdateMode());
- assertEquals(TestValues.MATCH, testCorrelationID, testSMCT.getCorrelationID());
-
- testSMCT = RPCRequestFactory.buildSetMediaClockTimer(null, null, null, null, null);
- assertNull(TestValues.NULL, testSMCT.getStartTime());
- assertNull(TestValues.NULL, testSMCT.getUpdateMode());
- assertNotNull(TestValues.NOT_NULL, testSMCT.getCorrelationID());
-
- // Test -- buildSetMediaClockTimer(UpdateMode updateMode, Integer correlationID)
- // ^ Calls another build method.
- }
-
- @SuppressWarnings("deprecation")
- public void testBuildShow () {
-
- Image testGraphic = new Image();
- testGraphic.setImageType(ImageType.STATIC);
- testGraphic.setValue("test");
- String testText1 = "test1", testText2 = "test2", testText3 = "test3", testText4 = "test4", testStatusBar = "status", testMediaClock = "media", testMediaTrack = "track";
- Vector<SoftButton> testSoftButtons = new Vector<SoftButton>();
- testSoftButtons.add(new SoftButton());
- Vector<String> testCustomPresets = new Vector<String>();
- testCustomPresets.add("Test");
- TextAlignment testAlignment = TextAlignment.CENTERED;
- Integer testCorrelationID = 0;
- Show testShow;
-
- // Test -- buildShow(String mainText1, String mainText2, String mainText3, String mainText4, String statusBar, String mediaClock, String mediaTrack, Image graphic, Vector<SoftButton> softButtons, Vector <String> customPresets, TextAlignment alignment, Integer correlationID)
- testShow = RPCRequestFactory.buildShow(testText1, testText2, testText3, testText4, testStatusBar, testMediaClock, testMediaTrack, testGraphic, testSoftButtons, testCustomPresets, testAlignment, testCorrelationID);
- assertEquals(TestValues.MATCH, testText1, testShow.getMainField1());
- assertEquals(TestValues.MATCH, testText2, testShow.getMainField2());
- assertEquals(TestValues.MATCH, testText3, testShow.getMainField3());
- assertEquals(TestValues.MATCH, testText4, testShow.getMainField4());
- assertEquals(TestValues.MATCH, testStatusBar, testShow.getStatusBar());
- assertEquals(TestValues.MATCH, testMediaClock, testShow.getMediaClock());
- assertEquals(TestValues.MATCH, testMediaTrack, testShow.getMediaTrack());
- assertTrue(TestValues.TRUE, Validator.validateImage(testGraphic, testShow.getGraphic()));
- assertTrue(TestValues.TRUE, Validator.validateSoftButtons(testSoftButtons, testShow.getSoftButtons()));
- assertTrue(TestValues.TRUE, Validator.validateStringList(testCustomPresets, testShow.getCustomPresets()));
- assertEquals(TestValues.MATCH, testAlignment, testShow.getAlignment());
- assertEquals(TestValues.MATCH, testCorrelationID, testShow.getCorrelationID());
-
- testShow = RPCRequestFactory.buildShow(null, null, null, null, null, null, null, null, null, null, null, null);
- assertNull(TestValues.NULL, testShow.getMainField1());
- assertNull(TestValues.NULL, testShow.getMainField2());
- assertNull(TestValues.NULL, testShow.getMainField3());
- assertNull(TestValues.NULL, testShow.getMainField4());
- assertNull(TestValues.NULL, testShow.getStatusBar());
- assertNull(TestValues.NULL, testShow.getMediaClock());
- assertNull(TestValues.NULL, testShow.getMediaTrack());
- assertNull(TestValues.NULL, testShow.getGraphic());
- assertNull(TestValues.NULL, testShow.getSoftButtons());
- assertNull(TestValues.NULL, testShow.getCustomPresets());
- assertNull(TestValues.NULL, testShow.getAlignment());
- assertNotNull(TestValues.NOT_NULL, testShow.getCorrelationID());
- // Test -- buildShow(String mainText1, String mainText2, String mainText3, String mainText4, TextAlignment alignment, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- buildShow(String mainText1, String mainText2, String statusBar, String mediaClock, String mediaTrack, TextAlignment alignment, Integer correlationID)
- testShow = RPCRequestFactory.buildShow(testText1, testText2, testStatusBar, testMediaClock, testMediaTrack, testAlignment, testCorrelationID);
- assertEquals(TestValues.MATCH, testText1, testShow.getMainField1());
- assertEquals(TestValues.MATCH, testText2, testShow.getMainField2());
- assertEquals(TestValues.MATCH, testStatusBar, testShow.getStatusBar());
- assertEquals(TestValues.MATCH, testMediaClock, testShow.getMediaClock());
- assertEquals(TestValues.MATCH, testMediaTrack, testShow.getMediaTrack());
- assertEquals(TestValues.MATCH, testAlignment, testShow.getAlignment());
- assertEquals(TestValues.MATCH, testCorrelationID, testShow.getCorrelationID());
-
- testShow = RPCRequestFactory.buildShow(null, null, null, null, null, null, null);
- assertNull(TestValues.NULL, testShow.getMainField1());
- assertNull(TestValues.NULL, testShow.getMainField2());
- assertNull(TestValues.NULL, testShow.getStatusBar());
- assertNull(TestValues.NULL, testShow.getMediaClock());
- assertNull(TestValues.NULL, testShow.getMediaTrack());
- assertNull(TestValues.NULL, testShow.getAlignment());
- assertNotNull(TestValues.NOT_NULL, testShow.getCorrelationID());
-
- // Test -- buildShow(String mainText1, String mainText2, TextAlignment alignment, Integer correlationID)
- // ^ Calls another build method.
- }
-
- public void testBuildSpeak () {
-
- String testTTSText = "test";
- Integer testCorrelationID = 0;
- Vector<TTSChunk> testTTSChunks = TTSChunkFactory.createSimpleTTSChunks(testTTSText);
- Speak testSpeak;
-
- // Test -- buildSpeak(String ttsText, Integer correlationID)
- testSpeak = RPCRequestFactory.buildSpeak(testTTSText, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTTSChunks, testSpeak.getTtsChunks()));
- assertEquals(TestValues.MATCH, testCorrelationID, testSpeak.getCorrelationID());
-
- testSpeak = RPCRequestFactory.buildSpeak((String) null, null);
- assertNull(TestValues.NULL, testSpeak.getTtsChunks());
- assertNotNull(TestValues.NOT_NULL, testSpeak.getCorrelationID());
-
- // Test -- buildSpeak(Vector<TTSChunk> ttsChunks, Integer correlationID)
- testSpeak = RPCRequestFactory.buildSpeak(testTTSChunks, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testTTSChunks, testSpeak.getTtsChunks()));
- assertEquals(TestValues.MATCH, testCorrelationID, testSpeak.getCorrelationID());
-
- testSpeak = RPCRequestFactory.buildSpeak((Vector<TTSChunk>) null, null);
- assertNull(TestValues.NULL, testSpeak.getTtsChunks());
- assertNotNull(TestValues.NOT_NULL, testSpeak.getCorrelationID());
- }
-
- public void testBuildSubscribeButton () {
-
- ButtonName testButtonName = ButtonName.CUSTOM_BUTTON;
- Integer testCorrelationID = 0;
- SubscribeButton testSB;
-
- // Test -- buildSubscribeButton(ButtonName buttonName, Integer correlationID)
- testSB = RPCRequestFactory.buildSubscribeButton(testButtonName, testCorrelationID);
- assertEquals(TestValues.MATCH, testButtonName, testSB.getButtonName());
- assertEquals(TestValues.MATCH, testCorrelationID, testSB.getCorrelationID());
-
- testSB = RPCRequestFactory.buildSubscribeButton(null, null);
- assertNull(TestValues.NULL, testSB.getButtonName());
- assertNotNull(TestValues.NOT_NULL, testSB.getCorrelationID());
-
- }
-
- public void testBuildUnregisterAppInterface () {
-
- Integer testCorrelationID = 0;
- UnregisterAppInterface testUAI;
-
- // Test -- buildUnregisterAppInterface(Integer correlationID)
- testUAI = RPCRequestFactory.buildUnregisterAppInterface(testCorrelationID);
- assertEquals(TestValues.MATCH, testCorrelationID, testUAI.getCorrelationID());
-
- testUAI = RPCRequestFactory.buildUnregisterAppInterface(null);
- assertNotNull(TestValues.NOT_NULL, testUAI.getCorrelationID());
- }
-
- public void testBuildUnsubscribeButton () {
-
- ButtonName testButtonName = ButtonName.CUSTOM_BUTTON;
- Integer testCorrelationID = 0;
- UnsubscribeButton testUB;
-
- // Test -- buildUnsubscribeButton(ButtonName buttonName, Integer correlationID)
- testUB = RPCRequestFactory.buildUnsubscribeButton(testButtonName, testCorrelationID);
- assertEquals(TestValues.MATCH, testButtonName, testUB.getButtonName());
- assertEquals(TestValues.MATCH, testCorrelationID, testUB.getCorrelationID());
-
- testUB = RPCRequestFactory.buildUnsubscribeButton(null, null);
- assertNull(TestValues.NULL, testUB.getButtonName());
- assertNotNull(TestValues.NOT_NULL, testUB.getCorrelationID());
-
- }
-
- public void testBuildSubscribeVehicleData () {
-
- boolean testGPS = true, testSpeed = true, testRPM = true, testFuelLevel = true, testFuelLevelState = true, testInstantFuelConsumption = true, testExternalTemperature = true, testPRNDL = true, testTirePressure = true, testOdometer = true, testBeltStatus = true, testBodyInformation = true, testDeviceStatus = true, testDriverBraking = true;
- Integer testCorrelationID = 0;
- SubscribeVehicleData testSVD;
-
- // Test -- BuildSubscribeVehicleData(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, boolean driverBraking, Integer correlationID)
- testSVD = RPCRequestFactory.BuildSubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, testCorrelationID);
- assertTrue(TestValues.TRUE, testSVD.getGps());
- assertTrue(TestValues.TRUE, testSVD.getSpeed());
- assertTrue(TestValues.TRUE, testSVD.getRpm());
- assertTrue(TestValues.TRUE, testSVD.getFuelLevel());
- assertTrue(TestValues.TRUE, testSVD.getFuelLevelState());
- assertTrue(TestValues.TRUE, testSVD.getInstantFuelConsumption());
- assertTrue(TestValues.TRUE, testSVD.getExternalTemperature());
- assertTrue(TestValues.TRUE, testSVD.getPrndl());
- assertTrue(TestValues.TRUE, testSVD.getTirePressure());
- assertTrue(TestValues.TRUE, testSVD.getOdometer());
- assertTrue(TestValues.TRUE, testSVD.getBeltStatus());
- assertTrue(TestValues.TRUE, testSVD.getBodyInformation());
- assertTrue(TestValues.TRUE, testSVD.getDeviceStatus());
- assertTrue(TestValues.TRUE, testSVD.getDriverBraking());
- assertEquals(TestValues.MATCH, testCorrelationID, testSVD.getCorrelationID());
-
- testSVD = RPCRequestFactory.BuildSubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, null);
- assertNotNull(TestValues.NULL, testSVD.getCorrelationID());
- }
-
- public void testBuildUnsubscribeVehicleData () {
-
- boolean testGPS = true, testSpeed = true, testRPM = true, testFuelLevel = true, testFuelLevelState = true, testInstantFuelConsumption = true, testExternalTemperature = true, testPRNDL = true, testTirePressure = true, testOdometer = true, testBeltStatus = true, testBodyInformation = true, testDeviceStatus = true, testDriverBraking = true;
- Integer testCorrelationID = 0;
- UnsubscribeVehicleData testUVD;
-
- // Test -- BuildUnsubscribeVehicleData(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure, boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, boolean driverBraking, Integer correlationID)
- testUVD = RPCRequestFactory.BuildUnsubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, testCorrelationID);
- assertTrue(TestValues.TRUE, testUVD.getGps());
- assertTrue(TestValues.TRUE, testUVD.getSpeed());
- assertTrue(TestValues.TRUE, testUVD.getRpm());
- assertTrue(TestValues.TRUE, testUVD.getFuelLevel());
- assertTrue(TestValues.TRUE, testUVD.getFuelLevelState());
- assertTrue(TestValues.TRUE, testUVD.getInstantFuelConsumption());
- assertTrue(TestValues.TRUE, testUVD.getExternalTemperature());
- assertTrue(TestValues.TRUE, testUVD.getPrndl());
- assertTrue(TestValues.TRUE, testUVD.getTirePressure());
- assertTrue(TestValues.TRUE, testUVD.getOdometer());
- assertTrue(TestValues.TRUE, testUVD.getBeltStatus());
- assertTrue(TestValues.TRUE, testUVD.getBodyInformation());
- assertTrue(TestValues.TRUE, testUVD.getDeviceStatus());
- assertTrue(TestValues.TRUE, testUVD.getDriverBraking());
- assertEquals(TestValues.MATCH, testCorrelationID, testUVD.getCorrelationID());
-
- testUVD = RPCRequestFactory.BuildUnsubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, null);
- assertNotNull(TestValues.NULL, testUVD.getCorrelationID());
- }
-
- public void testBuildGetVehicleData () {
-
- boolean testGPS = true, testSpeed = true, testRPM = true, testFuelLevel = true, testFuelLevelState = true, testInstantFuelConsumption = true, testExternalTemperature = true, testVIN = true, testPRNDL = true, testTirePressure = true, testOdometer = true, testBeltStatus = true, testBodyInformation = true, testDeviceStatus = true, testDriverBraking = true;
- Integer testCorrelationID = 0;
- GetVehicleData testGVD;
-
- // Test -- BuildGetVehicleData(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State, boolean instantFuelConsumption, boolean externalTemperature, boolean vin, boolean prndl, boolean tirePressure, boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus, boolean driverBraking, Integer correlationID)
- testGVD = RPCRequestFactory.BuildGetVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testVIN, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, testCorrelationID);
- assertTrue(TestValues.TRUE, testGVD.getGps());
- assertTrue(TestValues.TRUE, testGVD.getSpeed());
- assertTrue(TestValues.TRUE, testGVD.getRpm());
- assertTrue(TestValues.TRUE, testGVD.getFuelLevel());
- assertTrue(TestValues.TRUE, testGVD.getFuelLevelState());
- assertTrue(TestValues.TRUE, testGVD.getInstantFuelConsumption());
- assertTrue(TestValues.TRUE, testGVD.getExternalTemperature());
- assertTrue(TestValues.TRUE, testGVD.getPrndl());
- assertTrue(TestValues.TRUE, testGVD.getTirePressure());
- assertTrue(TestValues.TRUE, testGVD.getOdometer());
- assertTrue(TestValues.TRUE, testGVD.getBeltStatus());
- assertTrue(TestValues.TRUE, testGVD.getBodyInformation());
- assertTrue(TestValues.TRUE, testGVD.getDeviceStatus());
- assertTrue(TestValues.TRUE, testGVD.getDriverBraking());
- assertTrue(TestValues.TRUE, testGVD.getVin());
- assertEquals(TestValues.MATCH, testCorrelationID, testGVD.getCorrelationID());
-
- testGVD = RPCRequestFactory.BuildGetVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testVIN, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, null);
- assertNotNull(TestValues.NULL, testGVD.getCorrelationID());
- }
-
- public void testBuildScrollableMessage () {
-
- String testSMB = "test";
- Integer testTimeout = 1, testCorrelationID = 0;
- Vector<SoftButton> testSoftButtons = new Vector<SoftButton>();
- testSoftButtons.add(new SoftButton());
- ScrollableMessage testSM;
-
- // Test -- BuildScrollableMessage(String scrollableMessageBody, Integer timeout, Vector<SoftButton> softButtons, Integer correlationID)
- testSM = RPCRequestFactory.BuildScrollableMessage(testSMB, testTimeout, testSoftButtons, testCorrelationID);
- assertEquals(TestValues.MATCH, testSMB, testSM.getScrollableMessageBody());
- assertEquals(TestValues.MATCH, testTimeout, testSM.getTimeout());
- assertTrue(TestValues.TRUE, Validator.validateSoftButtons(testSoftButtons, testSM.getSoftButtons()));
- assertEquals(TestValues.MATCH, testCorrelationID, testSM.getCorrelationID());
-
- testSM = RPCRequestFactory.BuildScrollableMessage(null, null, null, null);
- assertNull(TestValues.NULL, testSM.getScrollableMessageBody());
- assertNull(TestValues.NULL, testSM.getTimeout());
- assertNull(TestValues.NULL, testSM.getSoftButtons());
- assertNotNull(TestValues.NOT_NULL, testSM.getCorrelationID());
- }
-
- public void testBuildSlider () {
-
- Integer testTicks = 1, testPosition = 2, testTimeout = 3, testCorrelationID = 0;
- String testHeader = "header";
- Vector<String> testFooter = new Vector<String>();
- testFooter.add("footer");
- Slider testSlider;
-
- // Test -- BuildSlider(Integer numTicks, Integer position, String sliderHeader, Vector<String> sliderFooter, Integer timeout, Integer correlationID)
- testSlider = RPCRequestFactory.BuildSlider(testTicks, testPosition, testHeader, testFooter, testTimeout, testCorrelationID);
- assertEquals(TestValues.MATCH, testTicks, testSlider.getNumTicks());
- assertEquals(TestValues.MATCH, testPosition, testSlider.getPosition());
- assertEquals(TestValues.MATCH, testHeader, testSlider.getSliderHeader());
- assertTrue(TestValues.TRUE, Validator.validateStringList(testFooter, testSlider.getSliderFooter()));
- assertEquals(TestValues.MATCH, testCorrelationID, testSlider.getCorrelationID());
-
- testSlider = RPCRequestFactory.BuildSlider(null, null, null, null, null, null);
- assertNull(TestValues.NULL, testSlider.getNumTicks());
- assertNull(TestValues.NULL, testSlider.getPosition());
- assertNull(TestValues.NULL, testSlider.getSliderHeader());
- assertNull(TestValues.NULL, testSlider.getSliderFooter());
- assertNull(TestValues.NULL, testSlider.getTimeout());
- assertNotNull(TestValues.NOT_NULL, testSlider.getCorrelationID());
- }
-
- public void testBuildChangeRegistration () {
-
- Language testLang = Language.EN_US, testHMILang = Language.EN_AU;
- Integer testCorrelationID = 0;
- ChangeRegistration testCR;
-
- // Test -- BuildChangeRegistration(Language language, Language hmiDisplayLanguage, Integer correlationID)
- testCR = RPCRequestFactory.BuildChangeRegistration(testLang, testHMILang, testCorrelationID);
- assertEquals(TestValues.MATCH, testLang, testCR.getLanguage());
- assertEquals(TestValues.MATCH, testHMILang, testCR.getHmiDisplayLanguage());
- assertEquals(TestValues.MATCH, testCorrelationID, testCR.getCorrelationID());
-
- testCR = RPCRequestFactory.BuildChangeRegistration(null, null, null);
- assertNull(TestValues.NULL, testCR.getLanguage());
- assertNull(TestValues.NULL, testCR.getHmiDisplayLanguage());
- assertNotNull(TestValues.NOT_NULL, testCR.getCorrelationID());
- }
-
- public void testBuildSetDisplayLayout () {
-
- String testDL = "layout";
- Integer testCorrelationID = 0;
- SetDisplayLayout testSDL;
-
- // Test -- BuildSetDisplayLayout(String displayLayout, Integer correlationID)
- testSDL = RPCRequestFactory.BuildSetDisplayLayout(testDL, testCorrelationID);
- assertEquals(TestValues.MATCH, testDL, testSDL.getDisplayLayout());
- assertEquals(TestValues.MATCH, testCorrelationID, testSDL.getCorrelationID());
-
- testSDL = RPCRequestFactory.BuildSetDisplayLayout(null, null);
- assertNull(TestValues.NULL, testSDL.getDisplayLayout());
- assertNotNull(TestValues.NOT_NULL, testSDL.getCorrelationID());
- }
-
- public void testBuildPerformAudioPassThru () {
-
- Vector<TTSChunk> testInitialPrompt = TTSChunkFactory.createSimpleTTSChunks("test");
- String testAPTDT1 = "audio", testAPTDT2 = "pass";
- SamplingRate testSR = SamplingRate._16KHZ;
- Integer testMaxDuration = 1, testCorrelationID = 0;
- BitsPerSample testBits = BitsPerSample._16_BIT;
- AudioType testAT = AudioType.PCM;
- Boolean testMute = false;
- PerformAudioPassThru testPAPT;
-
- // Test -- BuildPerformAudioPassThru(String ttsText, String audioPassThruDisplayText1, String audioPassThruDisplayText2, SamplingRate samplingRate, Integer maxDuration, BitsPerSample bitsPerSample, AudioType audioType, Boolean muteAudio, Integer correlationID)
- // ^ Calls another build method.
-
- // Test -- BuildPerformAudioPassThru(Vector<TTSChunk> initialPrompt, String audioPassThruDisplayText1, String audioPassThruDisplayText2, SamplingRate samplingRate, Integer maxDuration, BitsPerSample bitsPerSample, AudioType audioType, Boolean muteAudio, Integer correlationID)
- testPAPT = RPCRequestFactory.BuildPerformAudioPassThru(testInitialPrompt, testAPTDT1, testAPTDT2, testSR, testMaxDuration, testBits, testAT, testMute, testCorrelationID);
- assertTrue(TestValues.TRUE, Validator.validateTtsChunks(testInitialPrompt, testPAPT.getInitialPrompt()));
- assertEquals(TestValues.MATCH, testAPTDT1, testPAPT.getAudioPassThruDisplayText1());
- assertEquals(TestValues.MATCH, testAPTDT2, testPAPT.getAudioPassThruDisplayText2());
- assertEquals(TestValues.MATCH, testSR, testPAPT.getSamplingRate());
- assertEquals(TestValues.MATCH, testMaxDuration, testPAPT.getMaxDuration());
- assertEquals(TestValues.MATCH, testBits, testPAPT.getBitsPerSample());
- assertEquals(TestValues.MATCH, testAT, testPAPT.getAudioType());
- assertEquals(TestValues.MATCH, testMute, testPAPT.getMuteAudio());
- assertEquals(TestValues.MATCH, testCorrelationID, testPAPT.getCorrelationID());
-
- testPAPT = RPCRequestFactory.BuildPerformAudioPassThru((Vector<TTSChunk>) null, null, null, null, null, null, null, null, null);
- assertNull(TestValues.NULL, testPAPT.getInitialPrompt());
- assertNull(TestValues.NULL, testPAPT.getAudioPassThruDisplayText1());
- assertNull(TestValues.NULL, testPAPT.getAudioPassThruDisplayText2());
- assertNull(TestValues.NULL, testPAPT.getSamplingRate());
- assertNull(TestValues.NULL, testPAPT.getMaxDuration());
- assertNull(TestValues.NULL, testPAPT.getBitsPerSample());
- assertNull(TestValues.NULL, testPAPT.getAudioType());
- assertNull(TestValues.NULL, testPAPT.getMuteAudio());
- assertNotNull(TestValues.NOT_NULL, testPAPT.getCorrelationID());
- }
-
- public void testBuildEndAudioPassThru () {
-
- Integer testCorrelationID = 0;
- EndAudioPassThru testEAPT;
-
- // Test -- BuildEndAudioPassThru(Integer correlationID)
- testEAPT = RPCRequestFactory.BuildEndAudioPassThru(testCorrelationID);
- assertEquals(TestValues.MATCH, testCorrelationID, testEAPT.getCorrelationID());
-
- testEAPT = RPCRequestFactory.BuildEndAudioPassThru(null);
- assertNotNull(TestValues.NOT_NULL, testEAPT.getCorrelationID());
- }
-} \ No newline at end of file
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
deleted file mode 100644
index 92670c7d4..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java
+++ /dev/null
@@ -1,298 +0,0 @@
-package com.smartdevicelink.test.proxy;
-
-import android.content.Context;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import android.telephony.TelephonyManager;
-import android.util.Log;
-
-import com.smartdevicelink.exception.SdlException;
-import com.smartdevicelink.exception.SdlExceptionCause;
-import com.smartdevicelink.proxy.RPCMessage;
-import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.RPCResponse;
-import com.smartdevicelink.proxy.SdlProxyALM;
-import com.smartdevicelink.proxy.SdlProxyBase;
-import com.smartdevicelink.proxy.SdlProxyBuilder;
-import com.smartdevicelink.proxy.SdlProxyConfigurationResources;
-import com.smartdevicelink.proxy.interfaces.IProxyListenerALM;
-import com.smartdevicelink.proxy.rpc.GenericResponse;
-import com.smartdevicelink.proxy.rpc.Show;
-import com.smartdevicelink.proxy.rpc.ShowResponse;
-import com.smartdevicelink.proxy.rpc.Speak;
-import com.smartdevicelink.proxy.rpc.SpeakResponse;
-import com.smartdevicelink.proxy.rpc.enums.Result;
-import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
-import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
-import com.smartdevicelink.streaming.video.SdlRemoteDisplay;
-import com.smartdevicelink.streaming.video.VideoStreamingParameters;
-import com.smartdevicelink.test.streaming.video.SdlRemoteDisplayTest;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.assertNotNull;
-import static junit.framework.TestCase.assertTrue;
-import static junit.framework.TestCase.fail;
-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 androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
-
-@RunWith(AndroidJUnit4.class)
-public class SdlProxyBaseTests {
- public static final String TAG = "SdlProxyBaseTests";
-
- int onUpdateListenerCounter, onFinishedListenerCounter, onResponseListenerCounter, onErrorListenerCounter, remainingRequestsExpected;
-
- /**
- * Test SdlProxyBase for handling null SdlProxyConfigurationResources
- */
- @Test
- public void testNullSdlProxyConfigurationResources() {
- SdlProxyALM proxy = null;
- 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 {
- proxy = builder.build();
- } catch (Exception e) {
- Log.v(TAG, "Exception in testNullSdlProxyConfigurationResources, testing non null SdlProxyConfigurationResources");
- if (!(e instanceof SdlException) || !((SdlException) e).getSdlExceptionCause().equals(SdlExceptionCause.BLUETOOTH_ADAPTER_NULL)) {
- e.printStackTrace();
- Assert.fail("Exception in testNullSdlProxyConfigurationResources - \n" + e.toString());
- }
- }
-
- if (proxy != null) {
- try {
- proxy.dispose();
- proxy = null;
- }catch(SdlException e){
- e.printStackTrace();
- }
- }
-
- //Construct with a null SdlProxyConfigurationResources
- builder.setSdlProxyConfigurationResources(null);
- try {
- proxy = builder.build();
- } catch (Exception e) {
- Log.v(TAG, "Exception in testNullSdlProxyConfigurationResources, testing null SdlProxyConfigurationResources");
- if (!(e instanceof SdlException) || !((SdlException) e).getSdlExceptionCause().equals(SdlExceptionCause.BLUETOOTH_ADAPTER_NULL)) {
- e.printStackTrace();
- Assert.fail("Exception in testNullSdlProxyConfigurationResources, testing null SdlProxyConfigurationResources");
- }
- }
- if (proxy != null) {
- try {
- proxy.dispose();
- proxy = null;
- }catch(SdlException e){
- e.printStackTrace();
- }
- }
-
- //Construct with a non-null SdlProxyConfigurationResources and a null TelephonyManager
- config.setTelephonyManager(null);
- builder.setSdlProxyConfigurationResources(config);
- try {
- proxy = builder.build();
- } catch (Exception e) {
- Log.v(TAG, "Exception in testNullSdlProxyConfigurationResources, testing null TelephonyManager");
- if (!(e instanceof SdlException) || !((SdlException) e).getSdlExceptionCause().equals(SdlExceptionCause.BLUETOOTH_ADAPTER_NULL)) {
- Assert.fail("Exception in testNullSdlProxyConfigurationResources, testing null TelephonyManager");
- }
- }
- if (proxy != null) {
- try {
- proxy.dispose();
- proxy = null;
- }catch(SdlException e){
- e.printStackTrace();
- }
- }
- }
-
- @Test
- public void testRemoteDisplayStreaming(){
- SdlProxyALM proxy = null;
- 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,getInstrumentation().getTargetContext(), SdlRemoteDisplayTest.MockRemoteDisplay.class, (VideoStreamingParameters)null, false);
- assert true;
-
- }catch (Exception e){
- assert false;
- }
- }
-
- @Test
- public void testSendRPCsAllSucceed(){
- testSendMultipleRPCs(false, 1);
- }
-
- @Test
- public void testSendRPCsSomeFail(){
- testSendMultipleRPCs(false, 2);
- }
-
- @Test
- public void testSendSequentialRPCsAllSucceed(){
- testSendMultipleRPCs(true, 1);
- }
-
- @Test
- public void testSendSequentialRPCsSomeFail(){
- testSendMultipleRPCs(true, 2);
- }
-
- private void testSendMultipleRPCs(boolean sequentialSend, int caseNumber){
- final List<RPCRequest> rpcsList = new ArrayList<>();
- final List<RPCRequest> rpcsTempList = new ArrayList<>();
- final HashMap<RPCRequest, OnRPCResponseListener> requestsMap = new HashMap<>();
- onUpdateListenerCounter = 0;
- onFinishedListenerCounter = 0;
- onResponseListenerCounter = 0;
- onErrorListenerCounter = 0;
-
-
- // We extend the SdlProxyBase to be able to override getIsConnected() & sendRPCMessagePrivate() methods so they don't cause issues when trying to send RPCs
- // Because otherwise, they will throw exception cause there not actual connection to head unit
- SdlProxyBase proxy = new SdlProxyBase() {
-
- @Override
- public Boolean getIsConnected() {
- return true;
- }
-
- @Override
- protected void sendRPCMessagePrivate(RPCMessage message) {
- // Do nothing
- }
- };
-
-
- // We need to get list of all OnRPCResponseListeners so we can trigger onResponse/onError for each RPC to fake a response from Core
- final Answer<Void> answer = new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) {
- Object[] args = invocation.getArguments();
- RPCRequest request = (RPCRequest) invocation.getMock();
- OnRPCResponseListener listener = (OnRPCResponseListener) args[0];
- requestsMap.put(request, listener);
- rpcsTempList.add(request);
- return null;
- }
- };
-
-
- // Prepare RPCs to send
- Speak speak = mock(Speak.class);
- doReturn(RPCMessage.KEY_REQUEST).when(speak).getMessageType();
- doAnswer(answer).when(speak).setOnRPCResponseListener(any(OnRPCResponseListener.class));
- rpcsList.add(speak);
-
- Show show = mock(Show.class);
- doReturn(RPCMessage.KEY_REQUEST).when(show).getMessageType();
- doAnswer(answer).when(show).setOnRPCResponseListener(any(OnRPCResponseListener.class));
- rpcsList.add(show);
-
-
- // Send RPCs
- remainingRequestsExpected = rpcsList.size();
- OnMultipleRequestListener onMultipleRequestListener = new OnMultipleRequestListener() {
- @Override
- public void onUpdate(int remainingRequests) {
- onUpdateListenerCounter++;
- assertEquals(remainingRequestsExpected, remainingRequests);
- }
-
- @Override
- public void onFinished() {
- onFinishedListenerCounter++;
- }
-
- @Override
- public void onResponse(int correlationId, RPCResponse response) {
- if (response.getSuccess()) {
- onResponseListenerCounter++;
- remainingRequestsExpected--;
- } else {
- onErrorListenerCounter++;
- remainingRequestsExpected--;
- }
- }
- };
- try {
- if (sequentialSend) {
- proxy.sendSequentialRequests(rpcsList, onMultipleRequestListener);
- } else {
- proxy.sendRequests(rpcsList, onMultipleRequestListener);
- }
- assertTrue(true);
- } catch (SdlException e) {
- e.printStackTrace();
- fail();
- }
-
-
- // Trigger fake RPC responses
- int onUpdateListenerCounterExpected = 0, onFinishedListenerCounterExpected = 0, onResponseListenerCounterExpected = 0, onErrorListenerCounterExpected = 0;
- switch (caseNumber){
- case 1: // All RPCs succeed
- onUpdateListenerCounterExpected = 2;
- onFinishedListenerCounterExpected = 1;
- onResponseListenerCounterExpected = 2;
- onErrorListenerCounterExpected = 0;
-
- while (rpcsTempList.size() != 0){
- RPCRequest request = rpcsTempList.remove(0);
- if (request instanceof Speak) {
- requestsMap.get(request).onResponse(request.getCorrelationID(), new SpeakResponse(true, Result.SUCCESS));
- } else if (request instanceof Show) {
- requestsMap.get(request).onResponse(request.getCorrelationID(), new ShowResponse(true, Result.SUCCESS));
- }
- }
- break;
- case 2: // Some RPCs fail
- onUpdateListenerCounterExpected = 2;
- onFinishedListenerCounterExpected = 1;
- onResponseListenerCounterExpected = 1;
- onErrorListenerCounterExpected = 1;
-
- while (rpcsTempList.size() != 0){
- RPCRequest request = rpcsTempList.remove(0);
- if (request instanceof Speak) {
- requestsMap.get(request).onResponse(request.getCorrelationID(), new GenericResponse(false, Result.DISALLOWED));
- } else if (request instanceof Show) {
- requestsMap.get(request).onResponse(request.getCorrelationID(), new ShowResponse(true, Result.SUCCESS));
- }
- }
- break;
- }
-
-
- // Make sure the listener is called correctly
- assertEquals("onUpdate Listener was not called or called more/less frequently than expected", onUpdateListenerCounterExpected, onUpdateListenerCounter);
- assertEquals("onFinished Listener was not called or called more/less frequently than expected", onFinishedListenerCounterExpected, onFinishedListenerCounter);
- assertEquals("onResponse Listener was not called or called more/less frequently than expected", onResponseListenerCounterExpected, onResponseListenerCounter);
- assertEquals("onError Listener was not called or called more/less frequently than expected", onErrorListenerCounterExpected, onErrorListenerCounter);
- }
-}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/TTSChunkFactoryTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/TTSChunkFactoryTests.java
deleted file mode 100644
index ad1976cb1..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/TTSChunkFactoryTests.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package com.smartdevicelink.test.proxy;
-
-import com.smartdevicelink.proxy.TTSChunkFactory;
-import com.smartdevicelink.proxy.rpc.TTSChunk;
-import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
-import com.smartdevicelink.test.TestValues;
-
-import junit.framework.TestCase;
-
-import java.util.Vector;
-
-/**
- * This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.proxy.TTSChunkFactory}
- */
-public class TTSChunkFactoryTests extends TestCase {
-
- private TTSChunk testChunk;
-
- /**
- * This is a unit test for the following methods :
- * {@link com.smartdevicelink.proxy.TTSChunkFactory#createChunk(SpeechCapabilities, String)}
- */
- public void testCreateChunk () {
- // Valid Tests
- SpeechCapabilities testType = SpeechCapabilities.TEXT;
- testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
- assertNotNull(TestValues.NOT_NULL, testChunk);
- assertEquals(TestValues.MATCH, testType, testChunk.getType());
- assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
-
- testType = SpeechCapabilities.SILENCE;
- testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
- assertNotNull(TestValues.NOT_NULL, testChunk);
- assertEquals(TestValues.MATCH, testType, testChunk.getType());
- assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
-
- testType = SpeechCapabilities.SAPI_PHONEMES;
- testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
- assertNotNull(TestValues.NOT_NULL, testChunk);
- assertEquals(TestValues.MATCH, testType, testChunk.getType());
- assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
-
- testType = SpeechCapabilities.PRE_RECORDED;
- testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
- assertNotNull(TestValues.NOT_NULL, testChunk);
- assertEquals(TestValues.MATCH, testType, testChunk.getType());
- assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
-
- testType = SpeechCapabilities.LHPLUS_PHONEMES;
- testChunk = TTSChunkFactory.createChunk(testType, TestValues.GENERAL_STRING);
- assertNotNull(TestValues.NOT_NULL, testChunk);
- assertEquals(TestValues.MATCH, testType, testChunk.getType());
- assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunk.getText());
-
- // Invalid/Null Tests
- testChunk = TTSChunkFactory.createChunk(null, null);
- assertNotNull(TestValues.NOT_NULL, testChunk);
- assertNull(TestValues.NULL, testChunk.getType());
- assertNull(TestValues.NULL, testChunk.getText());
- }
-
- /**
- * This is a unit test for the following methods :
- * {@link com.smartdevicelink.proxy.TTSChunkFactory#createSimpleTTSChunks(String)}
- */
- public void testCreateSimpleTTSChunks () {
- // Test Values
- Vector<TTSChunk> testChunks;
- testChunks = TTSChunkFactory.createSimpleTTSChunks(TestValues.GENERAL_STRING);
-
- // Valid Tests
- assertNotNull(TestValues.NOT_NULL, testChunks);
- assertEquals(TestValues.MATCH, SpeechCapabilities.TEXT, testChunks.get(0).getType());
- assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunks.get(0).getText());
-
- // Invalid/Null Tests
- testChunks = TTSChunkFactory.createSimpleTTSChunks(null);
- assertNull(TestValues.NULL, testChunks);
- }
-
- /**
- * This is a unit test for the following methods :
- * {@link com.smartdevicelink.proxy.TTSChunkFactory#createPrerecordedTTSChunks(String)}
- */
- public void testCreatePrerecordedTTSChunks () {
- // Test Values
- Vector<TTSChunk> testChunks;
- testChunks = TTSChunkFactory.createPrerecordedTTSChunks(TestValues.GENERAL_STRING);
-
- // Valid Tests
- assertNotNull(TestValues.NOT_NULL, testChunks);
- assertEquals(TestValues.MATCH, SpeechCapabilities.PRE_RECORDED, testChunks.get(0).getType());
- assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testChunks.get(0).getText());
-
- // Invalid/Null Tests
- testChunks = TTSChunkFactory.createPrerecordedTTSChunks(null);
- assertNull(TestValues.NULL, testChunks);
- }
-} \ No newline at end of file
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
deleted file mode 100644
index 64f22a673..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCConstructorsTests.java
+++ /dev/null
@@ -1,339 +0,0 @@
-package com.smartdevicelink.test.rpc;
-
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
-import static junit.framework.TestCase.assertTrue;
-
-/**
- * This is a unit test class for the SmartDeviceLink library project
- * It makes sure that for each RPC, all mandatory parameters are set in a constructor
- */
-
-@RunWith(AndroidJUnit4.class)
-public class RPCConstructorsTests {
-
- private final String XML_FILE_NAME = "xml/MOBILE_API.xml";
- private final String RPC_PACKAGE_PREFIX = "com.smartdevicelink.proxy.rpc.";
- private Map<String, List<Parameter>> rpcMandatoryParamsMapFromXml;
-
- private class Parameter {
- private String name;
- private String type;
- private boolean isArray;
-
- public Parameter(String name, String type, boolean isArray) {
- this.name = name;
- this.type = type;
- this.isArray = isArray;
- }
- }
-
- @Before
- public void setUp(){
- // Map that has keys correspond to the RPC names and values correspond to the
- // mandatory params for that RPC. All info are loaded from the RPC spec xml file
- rpcMandatoryParamsMapFromXml = getRPCMandatoryParamsMap(XML_FILE_NAME);
-
- }
-
- // This method parses the RPC spec xml file and returns a map that has
- // keys correspond to the RPC names and values correspond to the mandatory params for that RPC
- private Map<String, List<Parameter>> getRPCMandatoryParamsMap(String fileName) {
- Map<String, List<Parameter>> rpcMandatoryParamsMap = new HashMap<>();
- try {
- InputStream stream = getInstrumentation().getTargetContext().getAssets().open(fileName);
- XmlPullParserFactory xmlFactoryObject = XmlPullParserFactory.newInstance();
- XmlPullParser myParser = xmlFactoryObject.newPullParser();
- myParser.setInput(stream, null);
- int event = myParser.getEventType();
- String rpcName = null;
- boolean ignoreRPC = false;
- while (event != XmlPullParser.END_DOCUMENT) {
- String name = myParser.getName();
- switch (event){
- case XmlPullParser.START_TAG:
- // Store the RPC name in the map
- if(name.equals("function") || name.equals("struct")){
- rpcName = myParser.getAttributeValue(null,"name");
- ignoreRPC = false;
- if (name.equals("function") && myParser.getAttributeValue(null, "messagetype").equals("response") && !rpcName.contains("Response")){
- rpcName += "Response";
- }
-
- // -------------- Exceptional cases because of mismatch between the RPC spec and the Android code --------------
- if(rpcName.equals("SyncMsgVersion")){
- rpcName = "SdlMsgVersion";
- } else if(rpcName.equals("ShowConstantTBTResponse")){
- rpcName = "ShowConstantTbtResponse";
- } else if(rpcName.equals("OASISAddress")) {
- rpcName = "OasisAddress";
- } else if(rpcName.equals("ShowConstantTBT")) {
- rpcName = "ShowConstantTbt";
- } else if (rpcName.equals("EncodedSyncPData") || rpcName.equals("OnEncodedSyncPData") || rpcName.equals("EncodedSyncPDataResponse")){
- ignoreRPC = true;
- }
- // -------------------------------------------------------------------------------------------------------------
-
- if (!ignoreRPC) {
- rpcMandatoryParamsMap.put(rpcName, new ArrayList<Parameter>());
- }
- }
- // Store the mandatory params for the current RPC in the map
- if(name.equals("param") && myParser.getAttributeValue(null, "until") == null && !ignoreRPC){
- boolean mandatory = Boolean.valueOf(myParser.getAttributeValue(null,"mandatory"));
- if (mandatory) {
- String paramName = myParser.getAttributeValue(null, "name");
- String paramType = myParser.getAttributeValue(null, "type");
- boolean paramIsArray = Boolean.valueOf(myParser.getAttributeValue(null, "array"));
-
- // -------------- Exceptional cases because of mismatch between the RPC spec and the Android code --------------
- if (paramType.equals("SyncMsgVersion")){
- paramType = "SdlMsgVersion";
- } else if (rpcName.equals("GPSData") && paramType.equals("Float")){
- paramType = "Double";
- } else if (rpcName.equals("TouchEvent") && paramType.equals("Integer") && paramIsArray){
- paramType = "Long";
- }
-
- if (paramName.equals("syncFileName")){
- paramName = "sdlFileName";
- } else if (paramName.equals("syncMsgVersion")){
- paramName = "sdlMsgVersion";
- } else if (paramName.equals("hmiPermissions")){
- paramName = "hMIPermissions";
- } else if (paramName.equals("resolution")){
- paramName = "imageResolution";
- } else if (paramName.equals("pressureTelltale")){
- paramName = "pressureTellTale";
- }
- // -------------------------------------------------------------------------------------------------------------
-
- Parameter param = new Parameter(paramName, paramType, paramIsArray);
- rpcMandatoryParamsMap.get(rpcName).add(param);
- }
- }
- break;
- }
- event = myParser.next();
- }
- stream.close();
- } catch (IOException | XmlPullParserException e) {
- e.printStackTrace();
- }
- return rpcMandatoryParamsMap;
- }
-
- // This method makes sure that for every RPC, there is a constructor that has all the mandatory params
- // It also checks if there are RPC in the XML file that don't exist in the code
- @Test
- public void testMandatoryParamsMatch() {
- // List of RPC names that don't have a constructor that has all mandatory params
- List<String> rpcsWithInvalidConstructor = new ArrayList<>();
-
- // List of the RPC names that couldn't be found in code
- // potentially because of a mismatch between name in the RPC spec xml file and name in code
- List<String> rpcsFromXmlNotFoundInCode = new ArrayList<>();
-
- // Loop through all RPCs that were loaded from RPC spec XML file
- // and make sure that every RPC has a constructor that has all mandatory params
- for (String rpcName : rpcMandatoryParamsMapFromXml.keySet()) {
- Class aClass;
- try {
- aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- rpcsFromXmlNotFoundInCode.add(rpcName);
- continue;
- }
- List<String> mandatoryParamsListFromXML = new ArrayList<>();
- for (Parameter param : rpcMandatoryParamsMapFromXml.get(rpcName)) {
- String type = param.type;
- // If the param is a list of objects, the type should be like "List<Object>"
- if (param.isArray){
- type = String.format("List<%s>", type);
- }
- mandatoryParamsListFromXML.add(type);
- }
- List<String> mandatoryParamsListFromCode = new ArrayList<>();
- boolean rpcHasValidConstructor = false;
- for (Constructor constructor : aClass.getConstructors()){
- mandatoryParamsListFromCode.clear();
- for (Type paramType : constructor.getGenericParameterTypes()){
- String paramFullType = paramType.toString();
- String paramSimpleType;
-
- // If the param is a list of objects, the type should be like "List<Object>"
- if (paramFullType.matches("java.util.List<.+>")) {
- paramSimpleType = String.format("List<%s>", paramFullType.substring(paramFullType.lastIndexOf('.') + 1, paramFullType.length() - 1));
- }
- // If the param is a simple object for example "java.lang.String", the type should be the last part "String"
- else if (!paramFullType.contains(">")){
- paramSimpleType = paramFullType.substring(paramFullType.lastIndexOf('.') + 1, paramFullType.length());
- }
- else {
- paramSimpleType = paramFullType;
- }
- mandatoryParamsListFromCode.add(paramSimpleType);
- }
- if (mandatoryParamsListFromCode.containsAll(mandatoryParamsListFromXML) && mandatoryParamsListFromXML.containsAll(mandatoryParamsListFromCode)){
- rpcHasValidConstructor = true;
- break;
- }
- }
- if (!rpcHasValidConstructor){
- rpcsWithInvalidConstructor.add(rpcName);
- }
- }
- assertTrue("The following RPCs were not found in the code: " + rpcsFromXmlNotFoundInCode, rpcsFromXmlNotFoundInCode.isEmpty());
- assertTrue("The following RPCs don't have a constructor that has all the mandatory params: " + rpcsWithInvalidConstructor, rpcsWithInvalidConstructor.isEmpty());
- }
-
- // This method makes sure that for every RPC, the constructor that has the mandatory params is setting the values correctly
- @Test
- public void testMandatoryParamsValues() {
- // List of RPC names that have a constructor which is not settings the values for the mandatory params correctly
- List<String> rpcsWithInvalidConstructor = new ArrayList<>();
-
- // List of types that exist in java.lang.*
- List<String> javaLangBuiltInTypes = Arrays.asList("String", "Integer", "Float", "Double", "Boolean");
-
- // Loop through all RPCs that were loaded from RPC spec XML file
- // and make sure that the constructor that has the mandatory params is setting the values correctly
- for (String rpcName : rpcMandatoryParamsMapFromXml.keySet()) {
- Class aClass;
- try {
- aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- continue;
- }
-
- List<Parameter> parameters = rpcMandatoryParamsMapFromXml.get(rpcName);
- List<Class<?>> mandatoryParamsTypes = new ArrayList<>();
- List<Object> mandatoryParamsValues = new ArrayList<>();
-
- // Loop through all mandatory params for the current RPC
- // and try to find the full Java type for each param
- // also assign a value for each param from com.smartdevicelink.test.Test class
- for (Parameter param : parameters) {
- String typeString = null;
- Class<?> type = null;
- String valueString = null;
- Object value = null;
-
- // Find the full Java type for the current param
- try {
- if (param.isArray) {
- type = List.class;
- } else {
- if (javaLangBuiltInTypes.contains(param.type)){
- typeString = "java.lang." + param.type;
- } else {
- typeString = RPC_PACKAGE_PREFIX + param.type;
- }
- type = Class.forName(typeString);
- }
-
- } catch (ClassNotFoundException e) {
- // If the class was not found in the com.smartdevicelink.proxy.rpc package
- // try to see if it can be found in com.smartdevicelink.proxy.rpc.enums package
- typeString = RPC_PACKAGE_PREFIX + "enums." + param.type;
- try {
- type = Class.forName(typeString);
- } catch (ClassNotFoundException e1) {
- e1.printStackTrace();
- assertTrue("Type: " + typeString + " cannot be found for RPC: " + rpcName , false);
- }
- }
-
-
- // Assign a value for the current param from com.smartdevicelink.test.Test based of the param type
- try {
- // --------------------------------------------- Exceptional cases ---------------------------------------------
- // This case is exceptional because the setter changes the input if it is not all digits
- if (rpcName.equals("DialNumber") && param.type.equals("String")){
- value = "5558675309";
- }
- // -------------------------------------------------------------------------------------------------------------
-
- if (value == null) {
- valueString = "GENERAL_" + param.type.toUpperCase();
- if (param.isArray){
- valueString += "_LIST";
- }
- value = Class.forName("com.smartdevicelink.test.TestValues").getDeclaredField(valueString).get(null);
- }
-
- } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
- e.printStackTrace();
- assertTrue("Value: " + valueString + " cannot be found for RPC: " + rpcName + ". Make sure that you declared that value in com.smartdevicelink.test.Test" , false);
- }
-
- mandatoryParamsTypes.add(type);
- mandatoryParamsValues.add(value);
- }
-
-
- // Create an instance of the RPC object using the constructor that has all the mandatory params
- Object instance = null;
- try {
- Constructor constructor = aClass.getConstructor(mandatoryParamsTypes.toArray(new Class<?>[mandatoryParamsTypes.size()]));
- instance = constructor.newInstance(mandatoryParamsValues.toArray(new Object[mandatoryParamsValues.size()]));
- } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
- e.printStackTrace();
- assertTrue("Constructor for RPC " + rpcName + " cannot be invoked. Make sure that the constructor parameters order and types are identical to the RPC specs", false);
- }
-
-
- // Loop through all getter methods for the instance and make sure that they are returning the expected values
- if (instance != null) {
- for (int i = 0; i < parameters.size(); i++) {
- // Find the getter method name by taking the param name, capitalize the first letter, then add thw word "get" to the beginning
- // for example if the param name is "buttonName" the method name will be "getButtonName"
- String getterMethodName = "get" + parameters.get(i).name.substring(0, 1).toUpperCase() + parameters.get(i).name.substring(1);
-
- // --------------------------------------------- Exceptional cases ---------------------------------------------
- if (rpcName.equals("CancelInteraction") && getterMethodName.equals("getFunctionID")){
- getterMethodName = "getInteractionFunctionID";
- }
- // -------------------------------------------------------------------------------------------------------------
-
- try {
- Method getterMethod = aClass.getMethod(getterMethodName);
- Object val = getterMethod.invoke(instance);
- if (val == null || !val.equals(mandatoryParamsValues.get(i))) {
- rpcsWithInvalidConstructor.add(rpcName);
- break;
- }
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
- e.printStackTrace();
- assertTrue("Method: " + getterMethodName + " cannot be found for RPC: " + rpcName + ". Make sure that the method exists and that the parameters order and types are identical to the RPC specs", false);
-
- }
- }
- }
- }
-
- assertTrue("The following RPCs have a constructor that is not setting the mandatory params correctly: " + rpcsWithInvalidConstructor, rpcsWithInvalidConstructor.isEmpty());
- }
-}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java
new file mode 100644
index 000000000..092f7031b
--- /dev/null
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCGenericTests.java
@@ -0,0 +1,662 @@
+package com.smartdevicelink.test.rpc;
+
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertTrue;
+import static junit.framework.TestCase.fail;
+
+@RunWith(AndroidJUnit4.class)
+public class RPCGenericTests {
+
+ private final String XML_FILE_NAME = "MOBILE_API.xml";
+ private final String RPC_PACKAGE_PREFIX = "com.smartdevicelink.proxy.rpc.";
+ private final String TEST_VALUES_CLASS = "com.smartdevicelink.test.TestValues";
+ private Map<String, List<Parameter>> rpcMandatoryParamsMapFromXml;
+ private Map<String, List<Parameter>> rpcAllParamsMapFromXml;
+
+ private class Parameter {
+ private String rpcName;
+ private String name;
+ private String type;
+ private Class<?> javaType;
+ private boolean isArray;
+ private boolean isMandatory;
+ private String setterName;
+ private String getterName1;
+ private String getterName2;
+ private Object value;
+ private boolean skip;
+
+
+ public Parameter setRPCName(String rpcName) {
+ this.rpcName = rpcName;
+ return this;
+ }
+
+ public Parameter setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Parameter setType(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public Parameter setJavaType(Class<?> javaType) {
+ this.javaType = javaType;
+ return this;
+ }
+
+ public Parameter setArray(boolean array) {
+ isArray = array;
+ return this;
+ }
+
+ public Parameter setMandatory(boolean mandatory) {
+ isMandatory = mandatory;
+ return this;
+ }
+
+ public Parameter setSetterName(String setterName) {
+ this.setterName = setterName;
+ return this;
+ }
+
+ public Parameter setGetterName1(String getterName1) {
+ this.getterName1 = getterName1;
+ return this;
+ }
+
+ public Parameter setGetterName2(String getterName2) {
+ this.getterName2 = getterName2;
+ return this;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public Parameter setSkip(boolean skip) {
+ this.skip = skip;
+ return this;
+ }
+ }
+
+ @Before
+ public void setUp(){
+ // Map that has keys correspond to the RPC names and values correspond to the params for that RPC.
+ rpcMandatoryParamsMapFromXml = getRPCParamsMap(XML_FILE_NAME, true);
+ rpcAllParamsMapFromXml = getRPCParamsMap(XML_FILE_NAME, false);
+ }
+
+ // This method parses the RPC spec xml file and returns a map that has
+ // keys correspond to the RPC names and values correspond to the params for that RPC
+ private Map<String, List<Parameter>> getRPCParamsMap(String fileName, boolean includeMandatoryOnly) {
+ Map<String, List<Parameter>> rpcParamsMap = new HashMap<>();
+ try {
+ InputStream stream = getInstrumentation().getTargetContext().getAssets().open(fileName);
+ XmlPullParserFactory xmlFactoryObject = XmlPullParserFactory.newInstance();
+ XmlPullParser myParser = xmlFactoryObject.newPullParser();
+ myParser.setInput(stream, null);
+ int event = myParser.getEventType();
+ String rpcName = null;
+ boolean ignoreRPC = false;
+ String setterMethodName;
+ String getterMethodName1;
+ String getterMethodName2;
+ Class<?> javaParamType;
+ boolean skipParam;
+ while (event != XmlPullParser.END_DOCUMENT) {
+ String name = myParser.getName();
+ switch (event){
+ case XmlPullParser.START_TAG:
+ // Store the RPC name in the map
+ if(name.equals("function") || name.equals("struct")){
+ rpcName = myParser.getAttributeValue(null,"name");
+ ignoreRPC = false;
+ if (name.equals("function") && myParser.getAttributeValue(null, "messagetype").equals("response") && !rpcName.contains("Response")){
+ rpcName += "Response";
+ }
+
+ // -------------- Exceptional cases because of mismatch between the RPC spec and the Android code --------------
+ if(rpcName.equals("SyncMsgVersion")){
+ rpcName = "SdlMsgVersion";
+ } else if(rpcName.equals("ShowConstantTBTResponse")){
+ rpcName = "ShowConstantTbtResponse";
+ } else if(rpcName.equals("OASISAddress")) {
+ rpcName = "OasisAddress";
+ } else if(rpcName.equals("ShowConstantTBT")) {
+ rpcName = "ShowConstantTbt";
+ } else if (rpcName.equals("EncodedSyncPData") || rpcName.equals("OnEncodedSyncPData") || rpcName.equals("EncodedSyncPDataResponse")){
+ ignoreRPC = true;
+ }
+ // -------------------------------------------------------------------------------------------------------------
+
+ if (!ignoreRPC) {
+ rpcParamsMap.put(rpcName, new ArrayList<Parameter>());
+ }
+ }
+ // Store the params for the current RPC in the map
+ if(name.equals("param") && myParser.getAttributeValue(null, "until") == null && !ignoreRPC){
+ setterMethodName = null;
+ getterMethodName1 = null;
+ getterMethodName2 = null;
+ javaParamType = null;
+ skipParam = false;
+ boolean isMandatory = Boolean.valueOf(myParser.getAttributeValue(null,"mandatory"));
+ if (isMandatory || !includeMandatoryOnly) {
+ String paramName = myParser.getAttributeValue(null, "name");
+ String paramType = myParser.getAttributeValue(null, "type");
+ boolean isArray = Boolean.valueOf(myParser.getAttributeValue(null, "array"));
+
+ // -------------- Exceptional cases because of mismatch between the RPC spec and the Android code --------------
+ if (paramName.equals("syncFileName")){
+ paramName = "sdlFileName";
+ } else if (paramName.equals("syncMsgVersion")){
+ paramName = "sdlMsgVersion";
+ } else if (paramName.equals("hmiPermissions")){
+ paramName = "hMIPermissions";
+ } else if (paramName.equals("resolution")){
+ paramName = "imageResolution";
+ } else if (paramName.equals("pressureTelltale")){
+ paramName = "pressureTellTale";
+ }
+
+ setterMethodName = "set" + paramName.substring(0, 1).toUpperCase() + paramName.substring(1);
+
+ if (paramType.equals("SyncMsgVersion")){
+ paramType = "SdlMsgVersion";
+ } else if (rpcName.equals("GPSData") && paramType.equals("Float")){
+ paramType = "Double";
+ } else if (rpcName.equals("TouchEvent") && paramType.equals("Integer") && isArray){
+ paramType = "Long";
+ } else if (paramType.equals("OASISAddress")) {
+ paramType = "OasisAddress";
+ } else if (rpcName.equals("VideoStreamingCapability") && paramType.equals("Float")) {
+ paramType = "Double";
+ } else if (rpcName.equals("UnsubscribeVehicleData") && setterMethodName.equals("setCloudAppVehicleID")) {
+ paramType = "boolean";
+ } else if (rpcName.equals("CancelInteraction") && setterMethodName.equals("setFunctionID")) {
+ setterMethodName = "setInteractionFunctionID";
+ } else if (rpcName.equals("NavigationCapability") && setterMethodName.equals("setGetWayPointsEnabled")) {
+ setterMethodName = "setWayPointsEnabled";
+ } else if (rpcName.equals("UnsubscribeWayPointsResponse") && setterMethodName.equals("setGetWayPointsEnabled")) {
+ setterMethodName = "setWayPointsEnabled";
+ } else if (rpcName.equals("HMICapabilities") && setterMethodName.equals("setNavigation")) {
+ setterMethodName = "setNavigationAvilable";
+ } else if (rpcName.equals("HMICapabilities") && setterMethodName.equals("setPhoneCall")) {
+ setterMethodName = "setPhoneCallAvilable";
+ } else if (rpcName.equals("HMICapabilities") && setterMethodName.equals("setDisplays")) {
+ setterMethodName = "setDisplaysCapabilityAvailable";
+ } else if (rpcName.equals("HMICapabilities")) {
+ setterMethodName += "Available";
+ } else if (rpcName.equals("VideoStreamingCapability") && setterMethodName.equals("setHapticSpatialDataSupported")) {
+ setterMethodName = "setIsHapticSpatialDataSupported";
+ } else if (rpcName.equals("OnDriverDistraction") && setterMethodName.equals("setLockScreenDismissalEnabled")) {
+ setterMethodName = "setLockscreenDismissibility";
+ paramType = "boolean";
+ } else if (rpcName.equals("OnDriverDistraction") && setterMethodName.equals("setLockScreenDismissalWarning")) {
+ setterMethodName = "setLockscreenWarningMessage";
+ } else if (rpcName.equals("PublishAppServiceResponse") && setterMethodName.equals("setAppServiceRecord")) {
+ setterMethodName = "setServiceRecord";
+ } else if (setterMethodName.equals("setFuelLevel_State")) {
+ setterMethodName = "setFuelLevelState";
+ } else if (rpcName.equals("LightCapabilities") && setterMethodName.equals("setRgbColorSpaceAvailable")) {
+ setterMethodName = "setRGBColorSpaceAvailable";
+ } else if (rpcName.equals("CloudAppProperties") && setterMethodName.equals("setEnabled")) {
+ paramType = "boolean";
+ } else if (rpcName.equals("DateTime") && setterMethodName.equals("setMillisecond")) {
+ setterMethodName = "setMilliSecond";
+ } else if (rpcName.equals("DateTime") && setterMethodName.equals("setTz_hour")) {
+ setterMethodName = "setTzHour";
+ } else if (rpcName.equals("DateTime") && setterMethodName.equals("setTz_minute")) {
+ setterMethodName = "setTzMinute";
+ } else if (rpcName.equals("PutFile") && setterMethodName.equals("setCrc")) {
+ setterMethodName = "setCRC";
+ paramType = "Long";
+ } else if (rpcName.equals("AppServiceManifest") && setterMethodName.equals("setHandledRPCs")) {
+ setterMethodName = "setHandledRpcs";
+ } else if (rpcName.equals("LocationDetails") && setterMethodName.equals("setHandledRPCs")) {
+ setterMethodName = "setHandledRpcs";
+ } else if (rpcName.equals("SendLocation") && setterMethodName.equals("setLongitudeDegrees")) {
+ paramType = "Double";
+ } else if (rpcName.equals("SendLocation") && setterMethodName.equals("setLatitudeDegrees")) {
+ paramType = "Double";
+ } else if (rpcName.equals("Grid") && setterMethodName.equals("setColspan")) {
+ setterMethodName = "setColSpan";
+ } else if (rpcName.equals("Grid") && setterMethodName.equals("setRowspan")) {
+ setterMethodName = "setRowSpan";
+ } else if (rpcName.equals("Grid") && setterMethodName.equals("setLevelspan")) {
+ setterMethodName = "setLevelSpan";
+ } else if (rpcName.equals("HeadLampStatus") && setterMethodName.equals("setAmbientLightSensorStatus")) {
+ setterMethodName = "setAmbientLightStatus";
+ } else if (rpcName.equals("GetVehicleData") && setterMethodName.equals("setCloudAppVehicleID")) {
+ paramType = "boolean";
+ } else if (rpcName.equals("GetVehicleDataResponse") && Arrays.asList("setInstantFuelConsumption", "setFuelLevel", "setSpeed", "setExternalTemperature", "setEngineTorque", "setAccPedalPosition", "setSteeringWheelAngle").contains(setterMethodName)) {
+ paramType = "Double";
+ } else if (rpcName.equals("RdsData") && setterMethodName.equals("setPS")) {
+ setterMethodName = "setProgramService";
+ } else if (rpcName.equals("RdsData") && setterMethodName.equals("setCT")) {
+ setterMethodName = "setClockText";
+ } else if (rpcName.equals("RdsData") && setterMethodName.equals("setRT")) {
+ setterMethodName = "setRadioText";
+ } else if (rpcName.equals("RdsData") && setterMethodName.equals("setPI")) {
+ setterMethodName = "setProgramIdentification";
+ } else if (rpcName.equals("RdsData") && setterMethodName.equals("setPTY")) {
+ setterMethodName = "setProgramType";
+ } else if (rpcName.equals("RdsData") && setterMethodName.equals("setTP")) {
+ setterMethodName = "setTrafficProgram";
+ } else if (rpcName.equals("RdsData") && setterMethodName.equals("setTA")) {
+ setterMethodName = "setTrafficAnnouncement";
+ } else if (rpcName.equals("RdsData") && setterMethodName.equals("setREG")) {
+ setterMethodName = "setRegion";
+ } else if (rpcName.equals("RadioControlCapabilities") && setterMethodName.equals("setSiriusxmRadioAvailable")) {
+ setterMethodName = "setSiriusXMRadioAvailable";
+ } else if (rpcName.equals("GetCloudAppPropertiesResponse") && setterMethodName.equals("setProperties")) {
+ setterMethodName = "setCloudAppProperties";
+ } else if (rpcName.equals("GetFileResponse") && setterMethodName.equals("setCrc")) {
+ setterMethodName = "setCRC";
+ } else if (rpcName.equals("RegisterAppInterfaceResponse") && setterMethodName.equals("setPcmStreamCapabilities")) {
+ setterMethodName = "setPcmStreamingCapabilities";
+ } else if (rpcName.equals("SubscribeVehicleData") && setterMethodName.equals("setElectronicParkBrakeStatus")) {
+ paramType = "boolean";
+ } else if (rpcName.equals("SubscribeVehicleData") && setterMethodName.equals("setCloudAppVehicleID")) {
+ paramType = "boolean";
+ } else if (rpcName.equals("ModuleInfo") && setterMethodName.equals("setLocation")) {
+ setterMethodName = "setModuleLocation";
+ } else if (rpcName.equals("ModuleInfo") && setterMethodName.equals("setServiceArea")) {
+ setterMethodName = "setModuleServiceArea";
+ } else if (rpcName.equals("ModuleInfo") && setterMethodName.equals("setAllowMultipleAccess")) {
+ setterMethodName = "setMultipleAccessAllowance";
+ } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setSpeed")) {
+ paramType = "Double";
+ } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setFuelLevel")) {
+ paramType = "Double";
+ } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setInstantFuelConsumption")) {
+ paramType = "Double";
+ } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setExternalTemperature")) {
+ paramType = "Double";
+ } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setEngineTorque")) {
+ paramType = "Double";
+ } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setAccPedalPosition")) {
+ paramType = "Double";
+ } else if (rpcName.equals("OnVehicleData") && setterMethodName.equals("setSteeringWheelAngle")) {
+ paramType = "Double";
+ } else if (rpcName.equals("GetInteriorVehicleDataConsentResponse") && setterMethodName.equals("setAllowed")) {
+ setterMethodName = "setAllowances";
+ } else if (rpcName.equals("SeatLocationCapability") && setterMethodName.equals("setColumns")) {
+ setterMethodName = "setCols";
+ } else if (rpcName.equals("ShowConstantTbt") && setterMethodName.equals("setDistanceToManeuver")) {
+ paramType = "Double";
+ } else if (rpcName.equals("ShowConstantTbt") && setterMethodName.equals("setDistanceToManeuverScale")) {
+ paramType = "Double";
+ } else if (rpcName.equals("SingleTireStatus") && setterMethodName.equals("setTpms")) {
+ setterMethodName = "setTPMS";
+ } else if (rpcName.equals("VehicleDataResult") && setterMethodName.equals("setOemCustomDataType")) {
+ setterMethodName = "setOEMCustomVehicleDataType";
+ } else if (rpcName.equals("SystemCapability") && !setterMethodName.equals("setSystemCapabilityType")) {
+ setterMethodName = "setCapabilityForType";
+ paramType = "SystemCapabilityType";
+ } else if (rpcName.equals("UnsubscribeWayPointsResponse") && paramName.equals("wayPoints")) {
+ skipParam = true;
+ } else if (rpcName.equals("UnsubscribeVehicleDataResponse") && paramName.equals("clusterModes")) {
+ skipParam = true;
+ } else if (rpcName.equals("ClimateControlCapabilities") && paramName.equals("currentTemperatureAvailable")) {
+ skipParam = true;
+ } else if (rpcName.equals("SubscribeVehicleDataResponse") && paramName.equals("clusterModes")) {
+ skipParam = true;
+ }
+
+ // -------------------------------------------------------------------------------------------------------------
+
+ javaParamType = findJavaTypeForParam(paramType, isArray);
+ getterMethodName1 = "get" + setterMethodName.substring(3);
+ if (paramType.equalsIgnoreCase("boolean")) {
+ getterMethodName2 = "is" + setterMethodName.substring(3);
+ }
+
+ Parameter param = new Parameter()
+ .setRPCName(rpcName)
+ .setName(paramName)
+ .setType(paramType)
+ .setJavaType(javaParamType)
+ .setArray(isArray)
+ .setMandatory(isMandatory)
+ .setSkip(skipParam)
+ .setSetterName(setterMethodName)
+ .setGetterName1(getterMethodName1)
+ .setGetterName2(getterMethodName2)
+ ;
+
+ rpcParamsMap.get(rpcName).add(param);
+ }
+ }
+ break;
+ }
+ event = myParser.next();
+ }
+ stream.close();
+ } catch (IOException | XmlPullParserException e) {
+ fail("Cannot parse mobile APIs XML file. Please make sure that the RPC Spec submodule is initialized: " + e.getMessage());
+ }
+ return rpcParamsMap;
+ }
+
+ // This method makes sure that for every RPC, there is a constructor that has all the mandatory params
+ // It also checks if there are RPC in the XML file that don't exist in the code
+ @Test
+ public void testMandatoryParamsMatch() {
+ // List of RPC names that don't have a constructor that has all mandatory params
+ List<String> rpcsWithInvalidConstructor = new ArrayList<>();
+
+ // List of the RPC names that couldn't be found in code
+ // potentially because of a mismatch between name in the RPC spec xml file and name in code
+ List<String> rpcsFromXmlNotFoundInCode = new ArrayList<>();
+
+ // Loop through all RPCs that were loaded from RPC spec XML file
+ // and make sure that every RPC has a constructor that has all mandatory params
+ for (String rpcName : rpcMandatoryParamsMapFromXml.keySet()) {
+ Class aClass;
+ try {
+ aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ rpcsFromXmlNotFoundInCode.add(rpcName);
+ continue;
+ }
+ List<String> mandatoryParamsListFromXML = new ArrayList<>();
+ for (Parameter param : rpcMandatoryParamsMapFromXml.get(rpcName)) {
+ String type = param.type;
+ // If the param is a list of objects, the type should be like "List<Object>"
+ if (param.isArray){
+ type = String.format("List<%s>", type);
+ }
+ mandatoryParamsListFromXML.add(type);
+ }
+ List<String> mandatoryParamsListFromCode = new ArrayList<>();
+ boolean rpcHasValidConstructor = false;
+ for (Constructor constructor : aClass.getConstructors()){
+ mandatoryParamsListFromCode.clear();
+ for (Type paramType : constructor.getGenericParameterTypes()){
+ String paramFullType = paramType.toString();
+ String paramSimpleType;
+
+ // If the param is a list of objects, the type should be like "List<Object>"
+ if (paramFullType.matches("java.util.List<.+>")) {
+ paramSimpleType = String.format("List<%s>", paramFullType.substring(paramFullType.lastIndexOf('.') + 1, paramFullType.length() - 1));
+ }
+ // If the param is a simple object for example "java.lang.String", the type should be the last part "String"
+ else if (!paramFullType.contains(">")){
+ paramSimpleType = paramFullType.substring(paramFullType.lastIndexOf('.') + 1, paramFullType.length());
+ }
+ else {
+ paramSimpleType = paramFullType;
+ }
+ mandatoryParamsListFromCode.add(paramSimpleType);
+ }
+ if (mandatoryParamsListFromCode.containsAll(mandatoryParamsListFromXML) && mandatoryParamsListFromXML.containsAll(mandatoryParamsListFromCode)){
+ rpcHasValidConstructor = true;
+ break;
+ }
+ }
+ if (!rpcHasValidConstructor){
+ rpcsWithInvalidConstructor.add(rpcName);
+ }
+ }
+ assertTrue("The following RPCs were not found in the code: " + rpcsFromXmlNotFoundInCode, rpcsFromXmlNotFoundInCode.isEmpty());
+ assertTrue("The following RPCs don't have a constructor that has all the mandatory params: " + rpcsWithInvalidConstructor, rpcsWithInvalidConstructor.isEmpty());
+ }
+
+ // This method returns the correct java reflection method in a specific class
+ private Method getMethod(Class aClass, Parameter parameter, String methodName, boolean isGetter) throws NoSuchMethodException {
+ Method method = null;
+ if (methodName == null) {
+ throw new NoSuchMethodException();
+ }
+ if (isGetter) {
+ if (parameter.rpcName.equals("SystemCapability") && !methodName.contains("SystemCapabilityType")) {
+ method = aClass.getMethod(methodName, SystemCapabilityType.class);
+ } else {
+ method = aClass.getMethod(methodName);
+ }
+ } else {
+ if (parameter.rpcName.equals("SystemCapability") && !methodName.contains("SystemCapabilityType")) {
+ method = aClass.getMethod(methodName, SystemCapabilityType.class, Object.class);
+ } else {
+ method = aClass.getMethod(methodName, parameter.javaType);
+ }
+ }
+ return method;
+ }
+
+ // This method returns the full Java type for a param
+ private Class<?> findJavaTypeForParam(String type, boolean isArray) {
+ String typeString = null;
+ Class<?> javaType = null;
+
+ // List of types that exist in java.lang.*
+ List<String> javaLangBuiltInTypes = Arrays.asList("String", "Integer", "Long", "Float", "Double", "Boolean");
+
+ // List of primitive types in java
+ List<String> javaLangPrimitiveTypes = Arrays.asList("int", "long", "float", "double", "boolean");
+
+ // Find the full Java type for the current param
+ try {
+ if (isArray) {
+ javaType = List.class;
+ } else if (javaLangPrimitiveTypes.contains(type)) {
+ if (type.equals("int")) {
+ javaType = int.class;
+ } else if (type.equals("long")) {
+ javaType = long.class;
+ } else if (type.equals("float")) {
+ javaType = float.class;
+ } else if (type.equals("double")) {
+ javaType = double.class;
+ } else if (type.equals("boolean")) {
+ javaType = boolean.class;
+ }
+ } else {
+ if (javaLangBuiltInTypes.contains(type)) {
+ typeString = "java.lang." + type;
+ } else {
+ typeString = RPC_PACKAGE_PREFIX + type;
+ }
+ javaType = Class.forName(typeString);
+ }
+
+ } catch (ClassNotFoundException e) {
+ // If the class was not found in the rpc package
+ // try to see if it can be found in enums package
+ typeString = RPC_PACKAGE_PREFIX + "enums." + type;
+ try {
+ javaType = Class.forName(typeString);
+ } catch (ClassNotFoundException e1) {
+ e1.printStackTrace();
+ }
+ }
+ assertNotNull("Java type cannot be found for: " + type, javaType);
+ return javaType;
+ }
+
+ // This method makes sure that for every RPC, the constructor that has the mandatory params is setting the values correctly
+ @Test
+ public void testMandatoryParamsValues() {
+ // List of RPC names that have a constructor which is not settings the values for the mandatory params correctly
+ List<String> rpcsWithInvalidConstructor = new ArrayList<>();
+
+ // Loop through all RPCs that were loaded from RPC spec XML file
+ // and make sure that the constructor that has the mandatory params is setting the values correctly
+ for (String rpcName : rpcMandatoryParamsMapFromXml.keySet()) {
+ Class aClass;
+ try {
+ aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName);
+ } catch (ClassNotFoundException e) {
+ fail(e.getMessage());
+ continue;
+ }
+
+ List<Parameter> parameters = rpcMandatoryParamsMapFromXml.get(rpcName);
+ List<Class<?>> mandatoryParamsTypes = new ArrayList<>();
+ List<Object> mandatoryParamsValues = new ArrayList<>();
+
+ // Loop through all mandatory params for the current RPC
+ // and try to find the full Java type for each param
+ // also assign a value for each param from TestValues class
+ for (Parameter param : parameters) {
+ String valueString = null;
+ Object value = null;
+
+ // Assign a value for the current param from TestValues based of the param type
+ try {
+ // --------------------------------------------- Exceptional cases ---------------------------------------------
+ // This case is exceptional because the setter changes the input if it is not all digits
+ if (rpcName.equals("DialNumber") && param.type.equals("String")){
+ value = "5558675309";
+ }
+ // -------------------------------------------------------------------------------------------------------------
+
+ if (value == null) {
+ valueString = "GENERAL_" + param.type.toUpperCase();
+ if (param.isArray){
+ valueString += "_LIST";
+ }
+ value = Class.forName(TEST_VALUES_CLASS).getDeclaredField(valueString).get(null);
+ }
+
+ } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
+ e.printStackTrace();
+ fail("Value: " + valueString + " cannot be found for RPC: " + rpcName + ". Make sure that you declared that value in " + TEST_VALUES_CLASS);
+ }
+
+ mandatoryParamsTypes.add(param.javaType);
+ mandatoryParamsValues.add(value);
+ }
+
+
+ // Create an instance of the RPC object using the constructor that has all the mandatory params
+ Object instance = null;
+ try {
+ Constructor constructor = aClass.getConstructor(mandatoryParamsTypes.toArray(new Class<?>[mandatoryParamsTypes.size()]));
+ instance = constructor.newInstance(mandatoryParamsValues.toArray(new Object[mandatoryParamsValues.size()]));
+ } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
+ e.printStackTrace();
+ fail("Constructor for RPC " + rpcName + " cannot be invoked. Make sure that the constructor parameters order and types are identical to the RPC specs");
+ }
+
+
+ // Loop through all getter methods for the instance and make sure that they are returning the expected values
+ if (instance != null) {
+ for (int i = 0; i < parameters.size(); i++) {
+ try {
+ Method getterMethod = getMethod(aClass, parameters.get(i), parameters.get(i).getterName1, true);
+ Object val = getterMethod.invoke(instance);
+ if (val == null || !val.equals(mandatoryParamsValues.get(i))) {
+ rpcsWithInvalidConstructor.add(rpcName);
+ break;
+ }
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
+ e.printStackTrace();
+ fail("Method: " + parameters.get(i).getterName1 + " cannot be found for RPC: " + rpcName + ". Make sure that the method exists and that the parameters order and types are identical to the RPC specs");
+ }
+ }
+ }
+ }
+
+ assertTrue("The following RPCs have a constructor that is not setting the mandatory params correctly: " + rpcsWithInvalidConstructor, rpcsWithInvalidConstructor.isEmpty());
+ }
+
+ /**
+ * This method makes sure that for every param in every RPC:
+ * - A setter exists and its name matches the RPC spec
+ * - The setter return type matches the RPC type (to make RPCs chainable)
+ * - A getter exists and its name matches the RPC spec
+ */
+ @Test
+ public void testParamsSettersAndGetters() {
+ List<String> errors = new ArrayList<>();
+
+ // Loop through all RPCs that were loaded from RPC spec XML file
+ for (String rpcName : rpcAllParamsMapFromXml.keySet()) {
+ Class aClass;
+ try {
+ aClass = Class.forName(RPC_PACKAGE_PREFIX + rpcName);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ errors.add("Class not found for rpc: "+ rpcName + ". \n");
+ continue;
+ }
+
+ // Loop through all params for the current RPC and make sure everyone has a a setter and a getter
+ List<Parameter> parameters = rpcAllParamsMapFromXml.get(rpcName);
+ for (int i = 0; i < parameters.size(); i++) {
+ Parameter parameter = parameters.get(i);
+ if (parameter.skip) {
+ continue;
+ }
+
+ // Confirm that the setter is correct
+ try {
+ Method setterMethod = getMethod(aClass, parameter, parameter.setterName, false);
+ List<String> expectedReturnTypes = Arrays.asList(aClass.getName(), aClass.getSuperclass().getName());
+ String actualReturnType = setterMethod.getReturnType().getName();
+ if (!expectedReturnTypes.contains(actualReturnType)) {
+ String errMsg = rpcName + "." + parameter.setterName + "() is expected to return one of these types: " + expectedReturnTypes + " but it returns: " + actualReturnType + ". \n";
+ errors.add(errMsg);
+ }
+ } catch (NoSuchMethodException e) {
+ String errMsg = rpcName + "." + parameter.setterName + "(" + parameter.type + ")" + " cannot be found. Make sure that the method exists. \n";
+ errors.add(errMsg);
+ }
+
+ // Confirm that the getter is correct
+ Method getterMethod = null;
+ try {
+ // --------------------------------------------- Exceptional cases ---------------------------------------------
+ if (parameter.getterName1.contains("Avilable")) {
+ continue;
+ } else if (parameter.getterName1.equals("getSeats")) {
+ parameter.getterName1 = "getSeatLocations";
+ }
+ // -------------------------------------------------------------------------------------------------------------
+ getterMethod = getMethod(aClass, parameter, parameter.getterName1, true);
+ } catch (NoSuchMethodException e) {
+ try {
+ getterMethod = getMethod(aClass, parameter, parameter.getterName2, true);
+ } catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ String errMsg = String.format(rpcName + "." + parameter.getterName1 + "()" + "%s" + " cannot be found. Make sure that the method exists. \n", parameter.type.equalsIgnoreCase("boolean")? "/" + parameter.getterName2 + "()" : "");
+ errors.add(errMsg);
+ }
+ }
+ }
+ }
+
+ assertTrue("There are " + errors.size() + " errors: \n" + errors, errors.isEmpty());
+ }
+}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCStructTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCStructTests.java
new file mode 100644
index 000000000..970c3c8ba
--- /dev/null
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/RPCStructTests.java
@@ -0,0 +1,48 @@
+package com.smartdevicelink.test.rpc;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.smartdevicelink.proxy.RPCStruct;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.TestCase.assertNotNull;
+
+@RunWith(AndroidJUnit4.class)
+public class RPCStructTests {
+
+ @Test
+ public void testFormatObject() {
+ final String KEY = "LIST";
+ RPCStruct struct = new RPCStruct();
+ List<RPCStruct> structs = new ArrayList<>();
+ struct.setValue(KEY, structs);
+ assertNotNull(struct.getObject(RPCStruct.class, KEY));
+
+ structs.add(new RPCStruct());
+ struct.setValue(KEY, structs);
+ assertNotNull(struct.getObject(RPCStruct.class, KEY));
+
+ structs.clear();
+ structs.add(null);
+ struct.setValue(KEY, structs);
+ assertNotNull(struct.getObject(RPCStruct.class, KEY));
+
+ structs.clear();
+ structs.add(null);
+ structs.add(new RPCStruct());
+ struct.setValue(KEY, structs);
+ assertNotNull(struct.getObject(RPCStruct.class, KEY));
+
+ structs.clear();
+ structs.add(new RPCStruct());
+ structs.add(null);
+ structs.add(new RPCStruct());
+ struct.setValue(KEY, structs);
+ assertNotNull(struct.getObject(RPCStruct.class, KEY));
+ }
+}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/FuelRangeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/FuelRangeTests.java
index f8bb07caf..6e23edc7a 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/FuelRangeTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/FuelRangeTests.java
@@ -1,6 +1,8 @@
package com.smartdevicelink.test.rpc.datatypes;
import com.smartdevicelink.proxy.rpc.FuelRange;
+import com.smartdevicelink.proxy.rpc.enums.CapacityUnit;
+import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
import com.smartdevicelink.proxy.rpc.enums.FuelType;
import com.smartdevicelink.test.JsonUtils;
import com.smartdevicelink.test.TestValues;
@@ -26,6 +28,10 @@ public class FuelRangeTests extends TestCase{
msg.setType(TestValues.GENERAL_FUELTYPE);
msg.setRange(TestValues.GENERAL_FLOAT);
+ msg.setLevel(TestValues.GENERAL_FLOAT);
+ msg.setLevelState(TestValues.GENERAL_COMPONENTVOLUMESTATUS);
+ msg.setCapacity(TestValues.GENERAL_FLOAT);
+ msg.setCapacityUnit(TestValues.GENERAL_CAPACITYUNIT);
}
/**
@@ -35,10 +41,18 @@ public class FuelRangeTests extends TestCase{
// Test Values
FuelType fuelType = msg.getType();
float range = msg.getRange();
-
+ float level = msg.getLevel();
+ ComponentVolumeStatus levelState = msg.getLevelState();
+ CapacityUnit capacityUnit = msg.getCapacityUnit();
+ float capacity = msg.getCapacity();
+
// Valid Tests
assertEquals(TestValues.MATCH, TestValues.GENERAL_FLOAT, range);
assertEquals(TestValues.MATCH, TestValues.GENERAL_FUELTYPE, fuelType);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_FLOAT, level);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_COMPONENTVOLUMESTATUS, levelState);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_CAPACITYUNIT, capacityUnit);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_FLOAT, capacity);
// Invalid/Null Tests
FuelRange msg = new FuelRange();
@@ -46,6 +60,10 @@ public class FuelRangeTests extends TestCase{
assertNull(TestValues.NULL, msg.getType());
assertNull(TestValues.NULL, msg.getRange());
+ assertNull(TestValues.NULL, msg.getLevel());
+ assertNull(TestValues.NULL, msg.getLevelState());
+ assertNull(TestValues.NULL, msg.getCapacityUnit());
+ assertNull(TestValues.NULL, msg.getCapacity());
}
public void testJson(){
@@ -54,6 +72,10 @@ public class FuelRangeTests extends TestCase{
try{
reference.put(FuelRange.KEY_TYPE, TestValues.GENERAL_FUELTYPE);
reference.put(FuelRange.KEY_RANGE, (Float) TestValues.GENERAL_FLOAT);
+ reference.put(FuelRange.KEY_LEVEL, TestValues.GENERAL_FLOAT);
+ reference.put(FuelRange.KEY_LEVEL_STATE, TestValues.GENERAL_COMPONENTVOLUMESTATUS);
+ reference.put(FuelRange.KEY_CAPACITY, TestValues.GENERAL_FLOAT);
+ reference.put(FuelRange.KEY_CAPACITY_UNIT, TestValues.GENERAL_CAPACITYUNIT);
JSONObject underTest = msg.serializeJSON();
assertEquals(TestValues.MATCH, reference.length(), underTest.length());
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/StabilityControlsStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/StabilityControlsStatusTests.java
new file mode 100644
index 000000000..1de8abfdf
--- /dev/null
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/StabilityControlsStatusTests.java
@@ -0,0 +1,58 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.StabilityControlsStatus;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataStatus;
+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;
+
+public class StabilityControlsStatusTests extends TestCase {
+ private StabilityControlsStatus msg;
+
+ @Override
+ public void setUp() {
+ msg = new StabilityControlsStatus();
+
+ msg.setEscSystem(TestValues.GENERAL_ESC_SYSTEM);
+ msg.setTrailerSwayControl(TestValues.GENERAL_S_WAY_CONTROL);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ VehicleDataStatus esc = msg.getEscSystem();
+ VehicleDataStatus sTrailer = msg.getTrailerSwayControl();
+
+ // Valid Tests
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_ESC_SYSTEM, esc);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_S_WAY_CONTROL, sTrailer);
+ }
+
+ public void testJson() {
+ JSONObject reference = new JSONObject();
+
+ try {
+ reference.put(StabilityControlsStatus.KEY_TRAILER_SWAY_CONTROL, TestValues.GENERAL_S_WAY_CONTROL);
+ reference.put(StabilityControlsStatus.KEY_ESC_SYSTEM, TestValues.GENERAL_ESC_SYSTEM);
+
+ 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);
+ }
+ }
+} \ No newline at end of file
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CapacityUnitTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CapacityUnitTests.java
new file mode 100644
index 000000000..4da32bebf
--- /dev/null
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/CapacityUnitTests.java
@@ -0,0 +1,71 @@
+package com.smartdevicelink.test.rpc.enums;
+
+import com.smartdevicelink.proxy.rpc.enums.CapacityUnit;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class CapacityUnitTests extends TestCase {
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "LITERS";
+ CapacityUnit enumLiters = CapacityUnit.valueForString(example);
+ example = "KILOWATTHOURS";
+ CapacityUnit enumKWH = CapacityUnit.valueForString(example);
+ example = "KILOGRAMS";
+ CapacityUnit enumKilograms = CapacityUnit.valueForString(example);
+
+ assertNotNull("LITERS returned null", enumLiters);
+ assertNotNull("KILOWATTHOURS returned null", enumKWH);
+ assertNotNull("KILOGRAMS returned null", enumKilograms);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "lONg";
+ try {
+ CapacityUnit temp = CapacityUnit.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ CapacityUnit temp = CapacityUnit.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+ /**
+ * Verifies the possible enum values of ButtonPressMode.
+ */
+ public void testListEnum() {
+ List<CapacityUnit> enumValueList = Arrays.asList(CapacityUnit.values());
+
+ List<CapacityUnit> enumTestList = new ArrayList<CapacityUnit>();
+ enumTestList.add(CapacityUnit.KILOGRAMS);
+ enumTestList.add(CapacityUnit.KILOWATTHOURS);
+ enumTestList.add(CapacityUnit.LITERS);
+
+ 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 37793b489..a337058f9 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
@@ -88,6 +88,8 @@ public class VehicleDataTypeTests extends TestCase {
VehicleDataType enumVehicleDataGearStatus= VehicleDataType.valueForString(example);
example = "VEHICLEDATA_WINDOWSTATUS";
VehicleDataType enumVehicleDataTypeWindowStatus= VehicleDataType.valueForString(example);
+ example = "VEHICLEDATA_STABILITYCONTROLSSTATUS";
+ VehicleDataType enumVehicleDataStabilityControlsStatus = VehicleDataType.valueForString(example);
assertNotNull("VEHICLEDATA_GPS returned null", enumVehicleDataGps);
assertNotNull("VEHICLEDATA_SPEED returned null", enumVehicleDataSpeed);
@@ -124,6 +126,7 @@ public class VehicleDataTypeTests extends TestCase {
assertNotNull("VEHICLEDATA_HANDSOFFSTEERING returned null", enumVehicleDataHandsOffSteeringType);
assertNotNull("VEHICLEDATA_WINDOWSTATUS returned null", enumVehicleDataTypeWindowStatus);
assertNotNull("VEHICLEDATA_GEARSTATUS returned null", enumVehicleDataGearStatus);
+ assertNotNull("VEHICLEDATA_STABILITYCONTROLSSTATUS returned null", enumVehicleDataStabilityControlsStatus);
}
/**
@@ -196,6 +199,7 @@ public class VehicleDataTypeTests extends TestCase {
enumTestList.add(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING);
enumTestList.add(VehicleDataType.VEHICLEDATA_WINDOWSTATUS);
enumTestList.add(VehicleDataType.VEHICLEDATA_GEARSTATUS);
+ enumTestList.add(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS);
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/OnErrorTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnErrorTests.java
deleted file mode 100644
index f0c542894..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnErrorTests.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.smartdevicelink.test.rpc.notifications;
-
-import com.smartdevicelink.proxy.callbacks.InternalProxyMessage;
-import com.smartdevicelink.proxy.callbacks.OnError;
-import com.smartdevicelink.test.TestValues;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-/**
- * This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.proxy.callbacks.OnError}
- */
-public class OnErrorTests extends TestCase {
-
- /**
- * This is a unit test for the following methods :
- * {@link com.smartdevicelink.proxy.callbacks.OnError#OnError()}
- * {@link com.smartdevicelink.proxy.callbacks.OnError#OnError(String, Exception)}
- */
- @Test
- public void testValues () {
- // Valid Tests
- OnError testOnError = new OnError();
- assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyError, testOnError.getFunctionName());
-
- Exception testE = new Exception();
- testOnError = new OnError(TestValues.GENERAL_STRING, testE);
- assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyError, testOnError.getFunctionName());
- assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testOnError.getInfo());
- assertEquals(TestValues.MATCH, testE, testOnError.getException());
-
- // Invalid/Null Tests
- testOnError = new OnError(null, null);
- assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyError, testOnError.getFunctionName());
- assertNull(TestValues.NULL, testOnError.getInfo());
- assertNull(TestValues.NULL, testOnError.getException());
- }
-} \ No newline at end of file
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyClosedTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyClosedTests.java
deleted file mode 100644
index 1ef639029..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyClosedTests.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.smartdevicelink.test.rpc.notifications;
-
-import com.smartdevicelink.proxy.callbacks.InternalProxyMessage;
-import com.smartdevicelink.proxy.callbacks.OnProxyClosed;
-import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
-import com.smartdevicelink.test.TestValues;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-/**
- * This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.proxy.callbacks.OnProxyClosed}
- */
-public class OnProxyClosedTests extends TestCase {
-
- /**
- * This is a unit test for the following methods :
- * {@link com.smartdevicelink.proxy.callbacks.OnProxyClosed#OnProxyClosed()}
- * {@link com.smartdevicelink.proxy.callbacks.OnProxyClosed#OnProxyClosed(String, Exception, SdlDisconnectedReason)}
- */
- @Test
- public void testValues () {
- // Valid Tests
- OnProxyClosed testOnProxyClosed = new OnProxyClosed();
- assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyClosed, testOnProxyClosed.getFunctionName());
-
- Exception testE = new Exception();
- SdlDisconnectedReason testReason = SdlDisconnectedReason.DEFAULT;
- testOnProxyClosed = new OnProxyClosed(TestValues.GENERAL_STRING, testE, testReason);
- assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyClosed, testOnProxyClosed.getFunctionName());
- assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testOnProxyClosed.getInfo());
- assertEquals(TestValues.MATCH, testE, testOnProxyClosed.getException());
- assertEquals(TestValues.MATCH, testReason, testOnProxyClosed.getReason());
-
- // Invalid/Null Tests
- testOnProxyClosed = new OnProxyClosed(null, null, null);
- assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyClosed, testOnProxyClosed.getFunctionName());
- assertNull(TestValues.NULL, testOnProxyClosed.getInfo());
- assertNull(TestValues.NULL, testOnProxyClosed.getException());
- assertNull(TestValues.NULL, testOnProxyClosed.getReason());
- }
-} \ No newline at end of file
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyOpenedTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyOpenedTests.java
deleted file mode 100644
index 3f76fd4cb..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnProxyOpenedTests.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.smartdevicelink.test.rpc.notifications;
-
-import com.smartdevicelink.proxy.callbacks.InternalProxyMessage;
-import com.smartdevicelink.proxy.callbacks.OnProxyOpened;
-import com.smartdevicelink.test.TestValues;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-/**
- * This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.proxy.callbacks.OnProxyOpened}
- */
-public class OnProxyOpenedTests extends TestCase {
-
-
- /**
- * This is a unit test for the following methods :
- * {@link com.smartdevicelink.proxy.callbacks.OnProxyOpened#OnProxyOpened()}
- * {@link com.smartdevicelink.proxy.callbacks.OnProxyOpened#getFunctionName()}
- */
- @Test
- public void testMethods () {
- OnProxyOpened testOnProxyOpened = new OnProxyOpened();
- assertNotNull(TestValues.NOT_NULL, testOnProxyOpened);
- assertEquals(TestValues.MATCH, InternalProxyMessage.OnProxyOpened, testOnProxyOpened.getFunctionName());
- }
-} \ 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 d333d3b5a..409ad1dd1 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
@@ -13,10 +13,12 @@ import com.smartdevicelink.proxy.rpc.EmergencyEvent;
import com.smartdevicelink.proxy.rpc.FuelRange;
import com.smartdevicelink.proxy.rpc.GPSData;
import com.smartdevicelink.proxy.rpc.GearStatus;
+import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse;
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.StabilityControlsStatus;
import com.smartdevicelink.proxy.rpc.TireStatus;
import com.smartdevicelink.proxy.rpc.WindowStatus;
import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
@@ -104,6 +106,7 @@ public class OnVehicleDataTests extends BaseRpcTests{
result.put(OnVehicleData.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING);
result.put(OnVehicleData.KEY_GEAR_STATUS, VehicleDataHelper.GEAR_STATUS);
result.put(OnVehicleData.KEY_WINDOW_STATUS, VehicleDataHelper.WINDOW_STATUS_LIST);
+ result.put(OnVehicleData.KEY_STABILITY_CONTROLS_STATUS, VehicleDataHelper.STABILITY_CONTROLS_STATUS);
result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE);
} catch(JSONException e) {
fail(TestValues.JSON_FAIL);
@@ -149,6 +152,7 @@ public class OnVehicleDataTests extends BaseRpcTests{
TurnSignal turnSignal = ( (OnVehicleData) msg).getTurnSignal();
ElectronicParkBrakeStatus electronicParkBrakeStatus = ( (OnVehicleData) msg).getElectronicParkBrakeStatus();
GearStatus gearStatus = ( (OnVehicleData) msg).getGearStatus();
+ StabilityControlsStatus stabilityControlsStatus = ( (OnVehicleData) msg).getStabilityControlsStatus();
Object oemCustomVehicleData = ( (OnVehicleData) msg).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME);
Boolean handsOffSteering = ( (OnVehicleData) msg).getHandsOffSteering();
// Valid Tests
@@ -183,6 +187,7 @@ public class OnVehicleDataTests extends BaseRpcTests{
assertEquals(TestValues.MATCH, VehicleDataHelper.TURN_SIGNAL, turnSignal);
assertEquals(TestValues.MATCH, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus);
assertEquals(TestValues.MATCH, VehicleDataHelper.GEAR_STATUS, gearStatus);
+ assertEquals(TestValues.MATCH, VehicleDataHelper.STABILITY_CONTROLS_STATUS, stabilityControlsStatus);
assertEquals(TestValues.MATCH, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE, oemCustomVehicleData);
assertEquals(TestValues.MATCH, VehicleDataHelper.HANDS_OFF_STEERING, handsOffSteering);
// Invalid/Null Tests
@@ -222,6 +227,7 @@ public class OnVehicleDataTests extends BaseRpcTests{
assertNull(TestValues.NULL, msg.getHandsOffSteering());
assertNull(TestValues.NULL, msg.getWindowStatus());
assertNull(TestValues.NULL, msg.getGearStatus());
+ assertNull(TestValues.NULL, msg.getStabilityControlsStatus());
assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
}
@@ -244,8 +250,9 @@ public class OnVehicleDataTests extends BaseRpcTests{
JSONObject fuelRangeObj = new JSONObject();
JSONObject windowStatusObj = new JSONObject();
JSONObject gearStatusObj = new JSONObject();
+ JSONObject stabilityControlStatusObj = new JSONObject();
JSONArray fuelRangeArrayObj = new JSONArray();
- JSONArray windowStatusArrayObj = new JSONArray();
+ JSONArray windowStatusArrayObj = new JSONArray();
try {
//Set up the JSONObject to represent OnVehicleData:
@@ -370,8 +377,16 @@ public class OnVehicleDataTests extends BaseRpcTests{
// FUEL_RANGE
fuelRangeObj.put(FuelRange.KEY_TYPE, VehicleDataHelper.FUEL_RANGE_TYPE);
fuelRangeObj.put(FuelRange.KEY_RANGE, VehicleDataHelper.FUEL_RANGE_RANGE);
+ fuelRangeObj.put(FuelRange.KEY_CAPACITY, VehicleDataHelper.FUEL_RANGE_CAPACITY);
+ fuelRangeObj.put(FuelRange.KEY_CAPACITY_UNIT, VehicleDataHelper.FUEL_RANGE_CAPACITY_UNIT);
+ fuelRangeObj.put(FuelRange.KEY_LEVEL, VehicleDataHelper.FUEL_RANGE_LEVEL);
+ fuelRangeObj.put(FuelRange.KEY_LEVEL_STATE, VehicleDataHelper.FUEL_RANGE_LEVEL_STATE);
fuelRangeArrayObj.put(fuelRangeObj);
+ // STABILITY_CONTROLS_STATU
+ stabilityControlStatusObj.put(StabilityControlsStatus.KEY_ESC_SYSTEM, VehicleDataHelper.ESC_SYSTEM);
+ stabilityControlStatusObj.put(StabilityControlsStatus.KEY_TRAILER_SWAY_CONTROL, VehicleDataHelper.S_WAY_TRAILER);
+
// WINDOW_STATUS
windowStatusObj.put(WindowStatus.KEY_LOCATION, VehicleDataHelper.LOCATION_GRID);
windowStatusObj.put(WindowStatus.KEY_STATE, VehicleDataHelper.WINDOW_STATE);
@@ -414,6 +429,7 @@ public class OnVehicleDataTests extends BaseRpcTests{
reference.put(OnVehicleData.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING);
reference.put(OnVehicleData.KEY_WINDOW_STATUS, windowStatusArrayObj);
reference.put(OnVehicleData.KEY_GEAR_STATUS, gearStatusObj);
+ reference.put(OnVehicleData.KEY_STABILITY_CONTROLS_STATUS, stabilityControlStatusObj);
reference.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE);
JSONObject underTest = msg.serializeJSON();
@@ -561,6 +577,20 @@ public class OnVehicleDataTests extends BaseRpcTests{
windowStatusReferenceList,
windowStatusUnderTestList));
}
+ else if (key.equals(GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS)) {
+ JSONObject myKeyObjReference = JsonUtils.readJsonObjectFromJsonObject(reference, key);
+ JSONObject myKeyObjTest = JsonUtils.readJsonObjectFromJsonObject(underTest, key);
+
+ StabilityControlsStatus status1 = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjReference));
+ StabilityControlsStatus status2 = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjTest));
+
+ assertTrue("JSON value didn't match expected value for key \"" + key + "\".",
+ Validator.validateStabilityControlStatus(
+ status1,
+ status2
+ )
+ );
+ }
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/GetVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java
index f3b4b564e..467c37b2e 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
@@ -64,6 +64,7 @@ public class GetVehicleDataTests extends BaseRpcTests {
msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN);
msg.setWindowStatus(TestValues.GENERAL_BOOLEAN);
msg.setGearStatus(TestValues.GENERAL_BOOLEAN);
+ msg.setStabilityControlsStatus(TestValues.GENERAL_BOOLEAN);
msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN);
return msg;
@@ -116,6 +117,7 @@ public class GetVehicleDataTests extends BaseRpcTests {
result.put(GetVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN);
result.put(GetVehicleData.KEY_GEAR_STATUS, TestValues.GENERAL_BOOLEAN);
result.put(GetVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN);
+ result.put(GetVehicleData.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_BOOLEAN);
result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN);
}catch(JSONException e){
fail(TestValues.JSON_FAIL);
@@ -163,6 +165,7 @@ public class GetVehicleDataTests extends BaseRpcTests {
assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getHandsOffSteering());
assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getWindowStatus());
assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getGearStatus());
+ assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getStabilityControlsStatus());
assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
// Invalid/Null Tests
@@ -202,6 +205,7 @@ public class GetVehicleDataTests extends BaseRpcTests {
assertNull(TestValues.NULL, msg.getHandsOffSteering());
assertNull(TestValues.NULL, msg.getWindowStatus());
assertNull(TestValues.NULL, msg.getGearStatus());
+ assertNull(TestValues.NULL, msg.getStabilityControlsStatus());
assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
}
@@ -257,6 +261,7 @@ public class GetVehicleDataTests extends BaseRpcTests {
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, GetVehicleData.KEY_GEAR_STATUS), cmd.getGearStatus());
+ assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_STABILITY_CONTROLS_STATUS), cmd.getStabilityControlsStatus());
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/SubscribeVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java
index fee5ddd25..7f5113fc7 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
@@ -63,6 +63,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests {
msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN);
msg.setWindowStatus(TestValues.GENERAL_BOOLEAN);
msg.setGearStatus(TestValues.GENERAL_BOOLEAN);
+ msg.setStabilityControlsStatus(TestValues.GENERAL_BOOLEAN);
msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN);
return msg;
@@ -114,6 +115,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests {
result.put(SubscribeVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN);
result.put(SubscribeVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN);
result.put(SubscribeVehicleData.KEY_GEAR_STATUS, TestValues.GENERAL_BOOLEAN);
+ result.put(SubscribeVehicleData.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_BOOLEAN);
result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN);
} catch (JSONException e) {
fail(TestValues.JSON_FAIL);
@@ -160,6 +162,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests {
assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getHandsOffSteering());
assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getWindowStatus());
assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getGearStatus());
+ assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getStabilityControlsStatus());
assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
// Invalid/Null Tests
@@ -198,6 +201,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests {
assertNull(TestValues.NULL, msg.getHandsOffSteering());
assertNull(TestValues.NULL, msg.getWindowStatus());
assertNull(TestValues.NULL, msg.getGearStatus());
+ assertNull(TestValues.NULL, msg.getStabilityControlsStatus());
assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
}
@@ -251,6 +255,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests {
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, SubscribeVehicleData.KEY_STABILITY_CONTROLS_STATUS), cmd.getStabilityControlsStatus());
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/UnsubscribeVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java
index 747b61563..9ca309030 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
@@ -66,6 +66,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests {
msg.setGearStatus(TestValues.GENERAL_BOOLEAN);
msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN);
msg.setWindowStatus(TestValues.GENERAL_BOOLEAN);
+ msg.setStabilityControlsStatus(TestValues.GENERAL_BOOLEAN);
msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN);
return msg;
@@ -118,6 +119,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests {
result.put(UnsubscribeVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN);
result.put(UnsubscribeVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN);
result.put(UnsubscribeVehicleData.KEY_GEAR_STATUS, TestValues.GENERAL_BOOLEAN);
+ result.put(UnsubscribeVehicleData.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_BOOLEAN);
result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN);
} catch (JSONException e) {
fail(TestValues.JSON_FAIL);
@@ -164,6 +166,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests {
assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getHandsOffSteering());
assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getWindowStatus());
assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getGearStatus());
+ assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getStabilityControlsStatus());
assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
// Invalid/Null Tests
UnsubscribeVehicleData msg = new UnsubscribeVehicleData();
@@ -202,6 +205,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests {
assertNull(TestValues.NULL, msg.getHandsOffSteering());
assertNull(TestValues.NULL, msg.getWindowStatus());
assertNull(TestValues.NULL, msg.getGearStatus());
+ assertNull(TestValues.NULL, msg.getStabilityControlsStatus());
assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
}
@@ -257,6 +261,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests {
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, UnsubscribeVehicleData.KEY_GEAR_STATUS), cmd.getGearStatus());
+ assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_STABILITY_CONTROLS_STATUS), cmd.getStabilityControlsStatus());
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/responses/GetVehicleDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java
index 6ebc03f80..818c9b4ce 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.GetVehicleDataResponse;
import com.smartdevicelink.proxy.rpc.HeadLampStatus;
import com.smartdevicelink.proxy.rpc.MyKey;
import com.smartdevicelink.proxy.rpc.SingleTireStatus;
+import com.smartdevicelink.proxy.rpc.StabilityControlsStatus;
import com.smartdevicelink.proxy.rpc.TireStatus;
import com.smartdevicelink.proxy.rpc.WindowStatus;
import com.smartdevicelink.proxy.rpc.enums.TurnSignal;
@@ -100,10 +101,11 @@ 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_WINDOW_STATUS, VehicleDataHelper.WINDOW_STATUS_LIST);
result.put(GetVehicleDataResponse.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING);
result.put(GetVehicleDataResponse.KEY_GEAR_STATUS, VehicleDataHelper.GEAR_STATUS);
- result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE);
+ result.put(GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS, VehicleDataHelper.STABILITY_CONTROLS_STATUS);
+ result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE);
} catch(JSONException e){
fail(TestValues.JSON_FAIL);
}
@@ -127,6 +129,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{
JSONObject emergencyEventObj = new JSONObject();
JSONObject clusterModeStatusObj = new JSONObject();
JSONObject myKeyObj = new JSONObject();
+ JSONObject stabilityControlsStatusObj = new JSONObject();
JSONObject fuelRangeObj = new JSONObject();
JSONObject windowStatusObj = new JSONObject();
JSONObject gearStatusObj = new JSONObject();
@@ -248,13 +251,21 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{
clusterModeStatusObj.put(ClusterModeStatus.KEY_POWER_MODE_QUALIFICATION_STATUS, VehicleDataHelper.CLUSTER_MODE_STATUS_POWER_MODE_QUALIFICATION_STATUS);
clusterModeStatusObj.put(ClusterModeStatus.KEY_CAR_MODE_STATUS, VehicleDataHelper.CLUSTER_MODE_STATUS_CAR_MODE_STATUS);
clusterModeStatusObj.put(ClusterModeStatus.KEY_POWER_MODE_STATUS, VehicleDataHelper.CLUSTER_MODE_STATUS_POWER_MODE_STATUS);
-
+
+ // STABILITY_CONTROL_STATUS
+ stabilityControlsStatusObj.put(StabilityControlsStatus.KEY_ESC_SYSTEM, VehicleDataHelper.ESC_SYSTEM);
+ stabilityControlsStatusObj.put(StabilityControlsStatus.KEY_TRAILER_SWAY_CONTROL, VehicleDataHelper.S_WAY_TRAILER);
+
//MY_KEY
myKeyObj.put(MyKey.KEY_E_911_OVERRIDE, VehicleDataHelper.MY_KEY_E_911_OVERRIDE);
// FUEL_RANGE
fuelRangeObj.put(FuelRange.KEY_TYPE, VehicleDataHelper.FUEL_RANGE_TYPE);
fuelRangeObj.put(FuelRange.KEY_RANGE, VehicleDataHelper.FUEL_RANGE_RANGE);
+ fuelRangeObj.put(FuelRange.KEY_CAPACITY, VehicleDataHelper.FUEL_RANGE_CAPACITY);
+ fuelRangeObj.put(FuelRange.KEY_CAPACITY_UNIT, VehicleDataHelper.FUEL_RANGE_CAPACITY_UNIT);
+ fuelRangeObj.put(FuelRange.KEY_LEVEL, VehicleDataHelper.FUEL_RANGE_LEVEL);
+ fuelRangeObj.put(FuelRange.KEY_LEVEL_STATE, VehicleDataHelper.FUEL_RANGE_LEVEL_STATE);
fuelRangeArrayObj.put(fuelRangeObj);
//GEAR_STATUS
@@ -299,6 +310,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{
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(GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS, stabilityControlsStatusObj);
reference.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE);
JSONObject underTest = msg.serializeJSON();
@@ -425,6 +437,20 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{
new GearStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjReference)),
new GearStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjTest))));
}
+ else if (key.equals(GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS)) {
+ JSONObject myKeyObjReference = JsonUtils.readJsonObjectFromJsonObject(reference, key);
+ JSONObject myKeyObjTest = JsonUtils.readJsonObjectFromJsonObject(underTest, key);
+
+ StabilityControlsStatus status1 = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjReference));
+ StabilityControlsStatus status2 = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(myKeyObjTest));
+
+ assertTrue("JSON value didn't match expected value for key \"" + key + "\".",
+ Validator.validateStabilityControlStatus(
+ status1,
+ status2
+ )
+ );
+ }
else if (key.equals(GetVehicleDataResponse.KEY_FUEL_RANGE)) {
JSONArray fuelRangeArrayObjReference = JsonUtils.readJsonArrayFromJsonObject(reference, key);
List<FuelRange> fuelRangeRefereceList = new ArrayList<FuelRange>();
@@ -514,6 +540,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{
assertEquals(TestValues.MATCH, VehicleDataHelper.WINDOW_STATUS_LIST, ( (GetVehicleDataResponse) msg ).getWindowStatus());
assertEquals(TestValues.MATCH, VehicleDataHelper.GEAR_STATUS, ( (GetVehicleDataResponse) msg ).getGearStatus());
assertEquals(TestValues.MATCH, VehicleDataHelper.HANDS_OFF_STEERING, ( (GetVehicleDataResponse) msg ).getHandsOffSteering());
+ assertEquals(TestValues.MATCH, VehicleDataHelper.STABILITY_CONTROLS_STATUS, ( (GetVehicleDataResponse) msg ).getStabilityControlsStatus());
assertEquals(TestValues.MATCH, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE, ( (GetVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
// Invalid/Null Tests
@@ -550,6 +577,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{
assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus());
assertNull(TestValues.NULL, msg.getGearStatus());
assertNull(TestValues.NULL, msg.getHandsOffSteering());
+ assertNull(TestValues.NULL, msg.getStabilityControlsStatus());
assertNull(TestValues.NULL, msg.getWindowStatus());
assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
}
@@ -656,6 +684,10 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{
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));
+
+ JSONObject stabilityControlStatusObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS);
+ StabilityControlsStatus stabilityControlsStatus = new StabilityControlsStatus(JsonRPCMarshaller.deserializeJSONObject(stabilityControlStatusObj));
+ assertTrue(TestValues.TRUE, Validator.validateStabilityControlStatus(stabilityControlsStatus, cmd.getStabilityControlsStatus()));
} catch (JSONException e) {
e.printStackTrace();
}
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 643935a02..79af1baa8 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
@@ -68,6 +68,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests {
msg.setGearStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GEARSTATUS.ordinal()));
msg.setHandsOffSteering(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal()));
msg.setWindowStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal()));
+ msg.setStabilityControlsStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS.ordinal()));
msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA);
return msg;
@@ -122,6 +123,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests {
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_GEAR_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GEARSTATUS.ordinal()).serializeJSON());
+ result.put(SubscribeVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS.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());
@@ -169,6 +171,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests {
VehicleDataResult testHOffSteering = ( (SubscribeVehicleDataResponse) msg ).getHandsOffSteering();
VehicleDataResult testWindowStatus = ( (SubscribeVehicleDataResponse) msg ).getWindowStatus();
VehicleDataResult testGearStatus = ( (SubscribeVehicleDataResponse) msg ).getGearStatus();
+ VehicleDataResult testStabilityControlStatus = ( (SubscribeVehicleDataResponse) msg ).getStabilityControlsStatus();
VehicleDataResult testOEMCustomVehicleData = ( (SubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME);
// Valid Tests
@@ -203,6 +206,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests {
assertTrue(TestValues.TRUE, testHOffSteering.getDataType().equals(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING));
assertTrue(TestValues.TRUE, testGearStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_GEARSTATUS));
assertTrue(TestValues.TRUE, testWindowStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_WINDOWSTATUS));
+ assertTrue(TestValues.TRUE, testStabilityControlStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS));
assertTrue(TestValues.TRUE, testOEMCustomVehicleData.getOEMCustomVehicleDataType().equals(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
// Invalid/Null Tests
@@ -241,6 +245,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests {
assertNull(TestValues.NULL, msg.getHandsOffSteering());
assertNull(TestValues.NULL, msg.getWindowStatus());
assertNull(TestValues.NULL, msg.getGearStatus());
+ assertNull(TestValues.NULL, msg.getStabilityControlsStatus());
assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
}
@@ -389,6 +394,10 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests {
VehicleDataResult referenceGearStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(gearStatus));
assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceGearStatus, cmd.getGearStatus()));
+ JSONObject stabilityControlStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS);
+ VehicleDataResult referenceStabilityControlStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(stabilityControlStatus));
+ assertTrue(TestValues.TRUE, Validator.validateStabilityControlStatus(referenceStabilityControlStatus, cmd.getStabilityControlsStatus()));
+
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/UnsubscribeVehicleDataResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java
index dc69b66ae..284090cd5 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
@@ -70,6 +70,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests {
msg.setWindowStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal()));
msg.setHandsOffSteering(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal()));
msg.setGearStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GEARSTATUS.ordinal()));
+ msg.setStabilityControlsStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS.ordinal()));
msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA);
return msg;
@@ -124,6 +125,8 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests {
result.put(SubscribeVehicleDataResponse.KEY_TURN_SIGNAL, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal()).serializeJSON());
result.put(SubscribeVehicleDataResponse.KEY_GEAR_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GEARSTATUS.ordinal()).serializeJSON());
result.put(SubscribeVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal()).serializeJSON());
+ result.put(SubscribeVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS.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());
@@ -171,6 +174,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests {
VehicleDataResult testHOffSteering = ( (UnsubscribeVehicleDataResponse) msg ).getHandsOffSteering();
VehicleDataResult testGearStatus = ( (UnsubscribeVehicleDataResponse) msg ).getGearStatus();
VehicleDataResult testWindowStatus = ( (UnsubscribeVehicleDataResponse) msg ).getWindowStatus();
+ VehicleDataResult testStabilityControlStatus = ( (UnsubscribeVehicleDataResponse) msg ).getStabilityControlsStatus();
VehicleDataResult testOemCustomData = ( (UnsubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME);
// Valid Tests
@@ -204,6 +208,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests {
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, testStabilityControlStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_STABILITYCONTROLSSTATUS));
assertTrue(TestValues.TRUE, testOemCustomData.getOEMCustomVehicleDataType().equals(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
assertTrue(TestValues.TRUE, testGearStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_GEARSTATUS));
@@ -243,6 +248,8 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests {
assertNull(TestValues.NULL, msg.getGearStatus());
assertNull(TestValues.NULL, msg.getHandsOffSteering());
assertNull(TestValues.NULL, msg.getWindowStatus());
+ assertNull(TestValues.NULL, msg.getHandsOffSteering());
+ assertNull(TestValues.NULL, msg.getStabilityControlsStatus());
assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME));
}
@@ -394,6 +401,10 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests {
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)));
+
+ JSONObject stabilityControlsStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_STABILITY_CONTROLS_STATUS);
+ VehicleDataResult referenceStabilityControlStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(stabilityControlsStatus));
+ assertTrue(TestValues.TRUE, Validator.validateStabilityControlStatus(referenceStabilityControlStatus, cmd.getStabilityControlsStatus()));
} catch (JSONException e) {
e.printStackTrace();
}
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 e5e47f3a5..0cccc48e8 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
@@ -5,8 +5,6 @@ import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.streaming.IStreamListener;
import com.smartdevicelink.test.TestValues;
-import com.smartdevicelink.transport.BTTransportConfig;
-import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.MultiplexTransportConfig;
import com.smartdevicelink.util.Version;
@@ -34,14 +32,11 @@ public class AbstractPacketizerTests extends TestCase {
// Test Values
byte testSessionId = (byte) 0x0A;
- byte testWiproVersion = (byte) 0x0B;
- RPCRequest testRpcRequest = new RPCRequest("test");
SessionType testSessionType = SessionType.RPC;
SdlSession testSdlSession = null;
InputStream testInputStream = null;
MockPacketizer testPacketizer1 = null;
MockPacketizer testPacketizer2 = null;
- MockPacketizer testPacketizer3 = null;
IStreamListener testListener = new MockStreamListener();
try {
testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes()));
@@ -50,31 +45,15 @@ public class AbstractPacketizerTests extends TestCase {
testSdlSession = new SdlSession(interfaceBroker, transportConfig);
testPacketizer1 = new MockPacketizer(testListener, testInputStream, testSessionType, testSessionId, testSdlSession);
testPacketizer2 = new MockPacketizer(null, null, null, testSessionId, testSdlSession);
- testPacketizer3 = new MockPacketizer(testListener, testInputStream, testRpcRequest, testSessionType, testSessionId, testWiproVersion, testSdlSession);
- try {
- new MockPacketizer(null, null, null, null, testSessionId, testWiproVersion, null);
- fail("Exception should be thrown");
- }catch(Exception e) {
- assertTrue(e instanceof IllegalArgumentException);
- }
-
// Valid Tests
assertNotNull(TestValues.NOT_NULL, testPacketizer1);
assertNotNull(TestValues.NOT_NULL, testPacketizer2);
- assertNotNull(TestValues.NOT_NULL, testPacketizer3);
-
+
assertEquals(TestValues.MATCH, testListener, testPacketizer1.getListener());
assertEquals(TestValues.MATCH, testInputStream, testPacketizer1.getInputStream());
assertEquals(TestValues.MATCH, testSessionType, testPacketizer1.getSessionType());
assertEquals(TestValues.MATCH, testSessionId, testPacketizer1.getSessionId());
- assertEquals(TestValues.MATCH, testListener, testPacketizer3.getListener());
- assertEquals(TestValues.MATCH, testInputStream, testPacketizer3.getInputStream());
- assertEquals(TestValues.MATCH, testSessionType, testPacketizer3.getSessionType());
- assertEquals(TestValues.MATCH, testSessionId, testPacketizer3.getSessionId());
- assertEquals(TestValues.MATCH, testWiproVersion, testPacketizer3.getWiproVersion());
- assertEquals(TestValues.MATCH, testRpcRequest.getFunctionName(), testPacketizer3.getRPCRequest().getFunctionName());
- assertEquals(TestValues.MATCH, testSdlSession, testPacketizer3.getSdlSession());
// Invalid/Null Tests
assertNull(TestValues.NULL, testPacketizer2.getListener());
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java
index 2c6618f62..ca6a77820 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java
@@ -2,10 +2,8 @@ package com.smartdevicelink.test.streaming;
import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.protocol.enums.SessionType;
-import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.streaming.AbstractPacketizer;
import com.smartdevicelink.streaming.IStreamListener;
-import com.smartdevicelink.util.Version;
import java.io.IOException;
import java.io.InputStream;
@@ -16,8 +14,6 @@ import java.io.InputStream;
*/
public class MockPacketizer extends AbstractPacketizer {
public MockPacketizer (IStreamListener l, InputStream i, SessionType s, byte sid, SdlSession sdlsession) throws IOException { super (l, i, s, sid, sdlsession); }
- public MockPacketizer (IStreamListener l, InputStream i, RPCRequest r, SessionType s, byte sid, Version protocolVersion,SdlSession sdlsession) throws IOException { super (l, i, r, s, sid, protocolVersion, sdlsession); }
- public MockPacketizer (IStreamListener l, InputStream i, RPCRequest r, SessionType s, byte sid, byte w, SdlSession sdlsession) throws IOException { super (l, i, r, s, sid, w, sdlsession); }
@Override public void start() throws IOException { }
@Override public void stop() { }
@@ -25,12 +21,7 @@ public class MockPacketizer extends AbstractPacketizer {
public IStreamListener getListener () { return _streamListener; }
public InputStream getInputStream () { return is; }
public SessionType getSessionType () { return _serviceType; }
- public SdlSession getSdlSession () { return _session; }
public byte getSessionId () { return _rpcSessionID; }
- public RPCRequest getRPCRequest () { return _request; }
- @Deprecated
- public byte getWiproVersion () { if(_wiproVersion != null){return (byte)_wiproVersion.getMajor(); }else{return 5;}}
- public Version getProtocolVersion () { return _wiproVersion; }
@Override public void pause() { }
@Override public void resume() { }
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 736798d67..bf6f6a850 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
@@ -7,8 +7,6 @@ import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
import com.smartdevicelink.streaming.IStreamListener;
import com.smartdevicelink.streaming.StreamPacketizer;
import com.smartdevicelink.test.TestValues;
-import com.smartdevicelink.transport.BTTransportConfig;
-import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.MultiplexTransportConfig;
import junit.framework.TestCase;
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
deleted file mode 100644
index 561cc1ef7..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.smartdevicelink.test.streaming;
-
-import com.smartdevicelink.SdlConnection.SdlSession;
-import com.smartdevicelink.protocol.enums.SessionType;
-import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.SdlProxyBase;
-import com.smartdevicelink.streaming.IStreamListener;
-import com.smartdevicelink.streaming.StreamRPCPacketizer;
-import com.smartdevicelink.test.TestValues;
-import com.smartdevicelink.transport.BTTransportConfig;
-import com.smartdevicelink.transport.BaseTransportConfig;
-import com.smartdevicelink.transport.MultiplexTransportConfig;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
-
-/**
- * This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.streaming.StreamRPCPacketizer}
- */
-public class StreamRPCPacketizerTests extends TestCase {
-
- /**
- * This is a unit test for the following methods :
- * {@link com.smartdevicelink.streaming.StreamRPCPacketizer#StreamRPCPacketizer(SdlProxyBase, IStreamListener, InputStream, RPCRequest, SessionType, byte, byte, long, SdlSession)}
- */
- public void testConstructor () {
-
- // Test Values
- byte testSessionId = (byte) 0x0A;
- byte testWV = (byte) 0x0B;
- RPCRequest testRequest = new RPCRequest("test");
- SessionType testSessionType = SessionType.RPC;
- InputStream testInputStream = null;
- IStreamListener testListener = new MockStreamListener();
-
- MockInterfaceBroker interfaceBroker = new MockInterfaceBroker();
- MultiplexTransportConfig transportConfig = new MultiplexTransportConfig(getInstrumentation().getTargetContext(),"19216801");
- SdlSession testSdlSession = new SdlSession(interfaceBroker, transportConfig);
- try {
- testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes()));
- StreamRPCPacketizer testStreamRpcPacketizer = new StreamRPCPacketizer(null, testListener, testInputStream, testRequest, testSessionType, testSessionId, testWV, testWV, testSdlSession);
- assertNotNull(TestValues.NOT_NULL, testStreamRpcPacketizer);
-
- // NOTE: Cannot test thread handling methods currently.
-
- } catch (IOException e) {
- fail("IOException was thrown.");
- }
- }
-} \ No newline at end of file
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 5867fee7f..a297a9626 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
@@ -25,6 +25,7 @@ public class VideoStreamingParametersTest {
private VideoStreamingParameters params;
private VideoStreamingCapability capability;
private ImageResolution preferredResolution;
+ private final String vehicleMake = "SDL";
@Before
public void setUp() {
@@ -39,7 +40,7 @@ public class VideoStreamingParametersTest {
capability.setScale(null);
capability.setPreferredResolution(preferredResolution);
- params.update(capability);
+ params.update(capability, vehicleMake);
int width = params.getResolution().getResolutionWidth();
int height = params.getResolution().getResolutionHeight();
@@ -55,7 +56,7 @@ public class VideoStreamingParametersTest {
capability.setScale(1.0);
capability.setPreferredResolution(preferredResolution);
- params.update(capability);
+ params.update(capability, vehicleMake);
int width = params.getResolution().getResolutionWidth();
int height = params.getResolution().getResolutionHeight();
@@ -71,7 +72,7 @@ public class VideoStreamingParametersTest {
capability.setScale(1.25);
capability.setPreferredResolution(preferredResolution);
- params.update(capability);
+ params.update(capability, vehicleMake);
int width = params.getResolution().getResolutionWidth();
int height = params.getResolution().getResolutionHeight();
@@ -87,7 +88,7 @@ public class VideoStreamingParametersTest {
capability.setScale(1.5);
capability.setPreferredResolution(preferredResolution);
- params.update(capability);
+ params.update(capability, vehicleMake);
int width = params.getResolution().getResolutionWidth();
int height = params.getResolution().getResolutionHeight();
@@ -175,23 +176,23 @@ public class VideoStreamingParametersTest {
assertNull(params.getFormat());
- params.update(capability);
+ params.update(capability, vehicleMake);
assertEquals(params.getFormat(), format);
format = new VideoStreamingFormat(VideoStreamingProtocol.RTP, VideoStreamingCodec.H264);
capability.setSupportedFormats(Collections.singletonList(format));
- params.update(capability);
+ params.update(capability, vehicleMake);
assertEquals(params.getFormat(), format);
format = new VideoStreamingFormat(VideoStreamingProtocol.RTP, VideoStreamingCodec.H265);
capability.setSupportedFormats(Collections.singletonList(format));
- params.update(capability);
+ params.update(capability, vehicleMake);
assertFalse(params.getFormat().equals(format));
format = new VideoStreamingFormat(VideoStreamingProtocol.RAW, VideoStreamingCodec.VP8);
capability.setSupportedFormats(Collections.singletonList(format));
- params.update(capability);
+ params.update(capability, vehicleMake);
assertFalse(params.getFormat().equals(format));
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BTTransportConfigTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BTTransportConfigTests.java
deleted file mode 100644
index edb932f62..000000000
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BTTransportConfigTests.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.smartdevicelink.test.transport;
-
-import com.smartdevicelink.test.TestValues;
-import com.smartdevicelink.transport.BTTransportConfig;
-import com.smartdevicelink.transport.enums.TransportType;
-
-import junit.framework.TestCase;
-
-/**
- * This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.transport.BtTransportConfig}
- */
-public class BTTransportConfigTests extends TestCase {
-
- /**
- * This is a unit test for the following methods :
- * {@link com.smartdevicelink.transport.BtTransportConfig#getTransportType()}
- * {@link com.smartdevicelink.transport.BtTransportConfig#setKeepSocketActive(boolean)}
- * {@link com.smartdevicelink.transport.BtTransportConfig#getKeepSocketActive}
- */
- public void testConfigs () {
-
- // Test Values
- boolean testBoolean = true;
- BTTransportConfig testConfig1 = new BTTransportConfig();
- BTTransportConfig testConfig2 = new BTTransportConfig(testBoolean);
-
- // Comparison Values
- TransportType expectedTransportType = TransportType.BLUETOOTH;
- boolean actualShareConnection = testConfig2.shareConnection();
- TransportType actualTransportType = testConfig1.getTransportType();
-
- // Valid Tests
- assertEquals(TestValues.MATCH, expectedTransportType, actualTransportType);
- assertTrue(TestValues.TRUE, actualShareConnection);
-
-
- testConfig1.setKeepSocketActive(true);
- assertTrue(TestValues.TRUE, testConfig1.getKeepSocketActive());
- testConfig1.setKeepSocketActive(false);
- assertFalse(TestValues.FALSE, testConfig1.getKeepSocketActive());
- }
-} \ No newline at end of file
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BaseTransportConfigTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BaseTransportConfigTests.java
index d5f6629bd..8fcde0456 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BaseTransportConfigTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/BaseTransportConfigTests.java
@@ -15,7 +15,6 @@ public class BaseTransportConfigTests extends TestCase {
/**
* This is a unit test for the following methods :
* {@link com.smartdevicelink.transport.BaseTransportConfig#getTransportType()}
- * {@link com.smartdevicelink.transport.BaseTransportConfig#shareConnection()}
* {@link com.smartdevicelink.transport.BaseTransportConfig#getHeartBeatTimeout()}
* {@link com.smartdevicelink.transport.BaseTransportConfig#setHeartBeatTimeout(int)}
*/
@@ -27,14 +26,12 @@ public class BaseTransportConfigTests extends TestCase {
// Comparison Values
int expectedMaxValue = Integer.MAX_VALUE;
- boolean actualShareConnection = testBaseTransportConfig.shareConnection();
int actualMaxValue = testBaseTransportConfig.getHeartBeatTimeout();
// Valid Tests
assertNotNull(TestValues.NOT_NULL, testBaseTransportConfig);
assertEquals(TestValues.MATCH, expectedMaxValue, actualMaxValue);
- assertTrue(TestValues.TRUE, actualShareConnection);
-
+
testBaseTransportConfig.setHeartBeatTimeout(testInt);
assertEquals(TestValues.MATCH, testInt, testBaseTransportConfig.getHeartBeatTimeout());
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java
index cdf83079c..51916ea16 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java
@@ -47,11 +47,7 @@ public class MultiplexBluetoothTransportTest extends TestCase {
};
- //TODO test for more than the two states
- bluetooth = MultiplexBluetoothTransport.getBluetoothSerialServerInstance();
- assertNull(bluetooth);
-
- bluetooth = MultiplexBluetoothTransport.getBluetoothSerialServerInstance(stateChangeHandler);
+ bluetooth = new MultiplexBluetoothTransport(stateChangeHandler);
assertEquals(bluetooth.getState(), MultiplexBluetoothTransport.STATE_NONE);
bluetooth.start();
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java
index 6f4f0231b..d1a359e24 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java
@@ -1,12 +1,12 @@
package com.smartdevicelink.transport;
+import android.content.ComponentName;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import com.smartdevicelink.protocol.SdlPacket;
import org.junit.Before;
import org.junit.Test;
@@ -15,40 +15,24 @@ import org.junit.runner.RunWith;
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;
@RunWith(AndroidJUnit4.class)
public class MultiplexTransportTest {
RouterServiceValidator rsvp;
- ITransportListener transportListener;
@Before
public void setUp() throws Exception {
rsvp = new RouterServiceValidator(getInstrumentation().getTargetContext());
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_NONE);
- rsvp.validate();
-
- transportListener = new ITransportListener(){
-
- @Override
- public void onTransportPacketReceived(SdlPacket packet) {
- }
-
+ rsvp.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
@Override
- public void onTransportConnected() {
- }
+ public void onFinishedValidation(boolean valid, ComponentName name) {
- @Override
- public void onTransportDisconnected(String info) {
}
+ });
- @Override
- public void onTransportError(String info, Exception e) {
- }
-
- };
}
// test for setting error state.
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java
index 91aea6432..69a8caeea 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java
@@ -86,7 +86,12 @@ public class RSVTestCase {
public void testInstalledFrom(){
if(liveTest){
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_INSTALLED_FROM_CHECK);
- assertTrue(rsvp.validate());
+ rsvp.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
+ @Override
+ public void onFinishedValidation(boolean valid, ComponentName name) {
+ assertTrue(valid);
+ }
+ });
}
}
@@ -94,7 +99,12 @@ public class RSVTestCase {
public void testPackageCheck(){
if(liveTest){
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_PACKAGE_CHECK);
- assertTrue(rsvp.validate());
+ rsvp.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
+ @Override
+ public void onFinishedValidation(boolean valid, ComponentName name) {
+ assertTrue(valid);
+ }
+ });
}
}
@@ -102,7 +112,12 @@ public class RSVTestCase {
public void testVersionCheck(){
if(liveTest){
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_VERSION_CHECK);
- assertTrue(rsvp.validate());
+ rsvp.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
+ @Override
+ public void onFinishedValidation(boolean valid, ComponentName name) {
+ assertTrue(valid);
+ }
+ });
}
}
@@ -110,7 +125,12 @@ public class RSVTestCase {
public void testNoFlags(){
if(liveTest){
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_NONE);
- assertTrue(rsvp.validate());
+ rsvp.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
+ @Override
+ public void onFinishedValidation(boolean valid, ComponentName name) {
+ assertTrue(valid);
+ }
+ });
}
}
@@ -118,7 +138,12 @@ public class RSVTestCase {
public void testAllFlags(){
if(liveTest){
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_PERFORM_ALL_CHECKS);
- assertTrue(rsvp.validate());
+ rsvp.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
+ @Override
+ public void onFinishedValidation(boolean valid, ComponentName name) {
+ assertTrue(valid);
+ }
+ });
}
}
@@ -192,7 +217,12 @@ public class RSVTestCase {
public void testNoSecurity(){
requestTListLock();
- RouterServiceValidator rsvp = new RouterServiceValidator(getInstrumentation().getTargetContext()); //Use a locally scoped instance
+ RouterServiceValidator rsvp = new RouterServiceValidator(getInstrumentation().getTargetContext(), new ComponentName("anything", getInstrumentation().getTargetContext().getClass().getSimpleName())) {
+ @Override
+ protected boolean isServiceRunning(Context context, ComponentName service) {
+ return true;
+ }
+ };
rsvp.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_OFF);
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_INSTALLED_FROM_CHECK);
@@ -203,7 +233,12 @@ public class RSVTestCase {
assertFalse(RouterServiceValidator.createTrustedListRequest(getInstrumentation().getTargetContext(), true, null, trustedListCallback));
//This should always return true
- assertTrue(rsvp.validate());
+ rsvp.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
+ @Override
+ public void onFinishedValidation(boolean valid, ComponentName name) {
+ assertTrue(valid);
+ }
+ });
}
@@ -371,7 +406,7 @@ public class RSVTestCase {
}
};
- assertTrue(RouterServiceValidator.createTrustedListRequest(getInstrumentation().getTargetContext(),true, cb));
+ assertTrue(RouterServiceValidator.createTrustedListRequest(getInstrumentation().getTargetContext(),true, cb, null));
//Now wait for call to finish
synchronized(REQUEST_LOCK){
try {
@@ -451,12 +486,22 @@ public class RSVTestCase {
// Fail, different package name for context and service and app security setting is not OFF and app is not on trusted list
RouterServiceValidatorTest rsvpFail = new RouterServiceValidatorTest(getInstrumentation().getTargetContext(), new ComponentName("anything", getInstrumentation().getTargetContext().getClass().getSimpleName()));
rsvpFail.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH);
- assertFalse(rsvpFail.validate());
+ rsvpFail.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
+ @Override
+ public void onFinishedValidation(boolean valid, ComponentName name) {
+ assertFalse(valid);
+ }
+ });
// Success, same package name for context and service
RouterServiceValidatorTest rsvpPass = new RouterServiceValidatorTest(getInstrumentation().getTargetContext(), new ComponentName(getInstrumentation().getTargetContext().getPackageName(), getInstrumentation().getTargetContext().getClass().getSimpleName()));
rsvpPass.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH);
- assertTrue(rsvpPass.validate());
+ rsvpPass.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
+ @Override
+ public void onFinishedValidation(boolean valid, ComponentName name) {
+ assertTrue(valid);
+ }
+ });
}
/**
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java
index 22837f77d..aa0507a36 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java
@@ -1,6 +1,7 @@
package com.smartdevicelink.transport;
import android.bluetooth.BluetoothAdapter;
+import android.content.ComponentName;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -27,7 +28,12 @@ public class TransportBrokerTest { //FIXME this test class needs to be fixed. At
@Before
public void setUp() throws Exception {
rsvp = new RouterServiceValidator(getInstrumentation().getTargetContext());
- rsvp.validate();
+ rsvp.validateAsync(new RouterServiceValidator.ValidationStatusCallback() {
+ @Override
+ public void onFinishedValidation(boolean valid, ComponentName name) {
+
+ }
+ });
}