diff options
author | Shinichi Watanabe <swatanabe@xevo.com> | 2020-09-16 15:18:18 +0900 |
---|---|---|
committer | Shinichi Watanabe <swatanabe@xevo.com> | 2020-09-16 15:18:18 +0900 |
commit | 0aeb8da0119132f4b316c9d1983bbcfa9baba79f (patch) | |
tree | 6233534867bb1888d56a052537772275d2bdb698 /android/sdl_android/src/androidTest/java | |
parent | a4f25398780ef4ef94e930baa54857534f2cbf0a (diff) | |
parent | de8e5c9a71ba2c4c793bcf6fcccbb964fe25853a (diff) | |
download | sdl_android-0aeb8da0119132f4b316c9d1983bbcfa9baba79f.tar.gz |
Merge remote-tracking branch 'upstream/develop' into feature/issue-1361
Diffstat (limited to 'android/sdl_android/src/androidTest/java')
182 files changed, 2633 insertions, 3175 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..0257be444 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/ManagerUtilityTests.java @@ -0,0 +1,204 @@ +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.assertFalse; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertTrue; + +/** + * 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 b33c4f494..760a8e40d 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 @@ -1,6 +1,7 @@ package com.smartdevicelink.managers; import android.content.Context; + import androidx.test.ext.junit.runners.AndroidJUnit4; import com.livio.taskmaster.Taskmaster; @@ -10,7 +11,6 @@ import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.proxy.RPCResponse; -import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.GetAppServiceDataResponse; import com.smartdevicelink.proxy.rpc.GetVehicleData; import com.smartdevicelink.proxy.rpc.OnAppServiceData; @@ -18,7 +18,6 @@ import com.smartdevicelink.proxy.rpc.Show; import com.smartdevicelink.proxy.rpc.TemplateColorScheme; import com.smartdevicelink.proxy.rpc.enums.AppHMIType; import com.smartdevicelink.proxy.rpc.enums.Language; -import com.smartdevicelink.proxy.rpc.enums.Result; import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; import com.smartdevicelink.test.TestValues; @@ -112,11 +111,6 @@ public class SdlManagerTests { } @Override - public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language) { - return null; - } - - @Override public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage) { return null; } @@ -222,7 +216,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 +226,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 +236,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 +246,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 +256,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 +266,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 +276,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 +286,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 +296,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 +306,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()); @@ -404,10 +398,6 @@ public class SdlManagerTests { } @Override - public void onError(int correlationId, Result resultCode, String info) { - } - - @Override public void onResponse(int correlationId, RPCResponse response) { } }; 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..cf6735ab6 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,16 +5,19 @@ 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 com.smartdevicelink.SdlConnection.SdlSession;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import com.smartdevicelink.session.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;
-import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
+import com.smartdevicelink.streaming.audio.IAudioStreamListener;
+import com.smartdevicelink.managers.ISdl;
+import com.smartdevicelink.protocol.ISdlServiceListener;
import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities;
import com.smartdevicelink.proxy.rpc.enums.AudioType;
import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
@@ -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 dccd7c10b..a99214774 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 @@ -2,6 +2,7 @@ package com.smartdevicelink.managers.file; import android.content.Context; import android.net.Uri; + import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.managers.BaseSubManager; @@ -10,7 +11,7 @@ import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.managers.file.filetypes.SdlFile; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.DeleteFile; import com.smartdevicelink.proxy.rpc.DeleteFileResponse; import com.smartdevicelink.proxy.rpc.ListFiles; @@ -72,10 +73,9 @@ public class FileManagerTests { RPCRequest message = (RPCRequest) args[0]; if (message instanceof PutFile) { int correlationId = message.getCorrelationID(); - Result resultCode = Result.REJECTED; - PutFileResponse putFileResponse = new PutFileResponse(); - putFileResponse.setSuccess(false); - message.getOnRPCResponseListener().onError(correlationId, resultCode, "Binary data empty"); + PutFileResponse putFileResponse = new PutFileResponse(false, Result.REJECTED); + putFileResponse.setInfo("Binary data empty"); + message.getOnRPCResponseListener().onResponse(correlationId, putFileResponse); } return null; } @@ -88,13 +88,12 @@ public class FileManagerTests { List<RPCRequest> rpcs = (List<RPCRequest>) args[0]; OnMultipleRequestListener listener = (OnMultipleRequestListener) args[1]; if (rpcs.get(0) instanceof PutFile) { - Result resultCode = Result.REJECTED; for (RPCRequest message : rpcs) { int correlationId = message.getCorrelationID(); listener.addCorrelationId(correlationId); - PutFileResponse putFileResponse = new PutFileResponse(); - putFileResponse.setSuccess(true); - listener.onError(correlationId, resultCode, "Binary data empty"); + PutFileResponse putFileResponse = new PutFileResponse(false, Result.REJECTED); + putFileResponse.setInfo("Binary data empty"); + listener.onResponse(correlationId, putFileResponse); } listener.onFinished(); } @@ -197,13 +196,12 @@ public class FileManagerTests { List<RPCRequest> rpcs = (List<RPCRequest>) args[0]; OnMultipleRequestListener listener = (OnMultipleRequestListener) args[1]; if (rpcs.get(0) instanceof DeleteFile) { - Result resultCode = Result.REJECTED; for (RPCRequest message : rpcs) { int correlationId = message.getCorrelationID(); listener.addCorrelationId(correlationId); - DeleteFileResponse deleteFileResponse = new DeleteFileResponse(); - deleteFileResponse.setSuccess(true); - listener.onError(correlationId, resultCode, "Binary data empty"); + DeleteFileResponse deleteFileResponse = new DeleteFileResponse(false, Result.REJECTED); + deleteFileResponse.setInfo("Binary data empty"); + listener.onResponse(correlationId, deleteFileResponse); } listener.onFinished(); } @@ -218,7 +216,6 @@ public class FileManagerTests { List<RPCRequest> rpcs = (List<RPCRequest>) args[0]; OnMultipleRequestListener listener = (OnMultipleRequestListener) args[1]; if (rpcs.get(0) instanceof PutFile) { - Result resultCode = Result.REJECTED; boolean flip = false; for (RPCRequest message : rpcs) { int correlationId = message.getCorrelationID(); @@ -231,7 +228,9 @@ public class FileManagerTests { } else { flip = true; putFileResponse.setSuccess(false); - listener.onError(correlationId, resultCode, "Binary data empty"); + putFileResponse.setResultCode(Result.REJECTED); + putFileResponse.setInfo("Binary data empty"); + listener.onResponse(correlationId, putFileResponse); } } listener.onFinished(); @@ -250,7 +249,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"); @@ -282,7 +281,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"); @@ -405,7 +404,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"); @@ -436,7 +435,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)); } /** @@ -554,7 +553,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); @@ -575,7 +574,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)); } /** @@ -586,7 +585,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); @@ -608,7 +607,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)); } /** @@ -704,7 +703,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(); @@ -741,7 +740,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"); @@ -790,7 +789,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); @@ -910,7 +909,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"); @@ -946,7 +945,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/file/filetypes/SdlArtworkTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlArtworkTests.java index 5c59f20d7..3f6f6cff5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlArtworkTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlArtworkTests.java @@ -1,8 +1,7 @@ -package com.smartdevicelink.managers.file; +package com.smartdevicelink.managers.file.filetypes; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.proxy.rpc.enums.StaticIconName; import com.smartdevicelink.test.TestValues; 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 f96ac72a8..c50e8b1ae 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 @@ -10,11 +10,8 @@ import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.proxy.interfaces.IAudioStreamListener; -import com.smartdevicelink.proxy.interfaces.ISdl; -import com.smartdevicelink.proxy.interfaces.ISdlServiceListener; -import com.smartdevicelink.proxy.interfaces.IVideoStreamListener; -import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener; +import com.smartdevicelink.managers.ISdl; +import com.smartdevicelink.protocol.ISdlServiceListener; import com.smartdevicelink.proxy.rpc.AppServiceCapability; import com.smartdevicelink.proxy.rpc.AppServicesCapabilities; import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities; @@ -55,8 +52,6 @@ import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener; -import com.smartdevicelink.streaming.audio.AudioStreamingCodec; -import com.smartdevicelink.streaming.audio.AudioStreamingParams; import com.smartdevicelink.streaming.video.VideoStreamingParameters; import com.smartdevicelink.test.TestValues; import com.smartdevicelink.test.Validator; @@ -185,25 +180,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))); } @@ -259,7 +254,7 @@ public class SystemCapabilityManagerTests { public void onError(String info) { assertTrue(false); } - }); + }, false); } private Answer<Void> createOnHMIStatusAnswer(final HMILevel hmiLevel){ @@ -690,7 +685,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); @@ -710,7 +705,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); @@ -726,7 +721,7 @@ public class SystemCapabilityManagerTests { scmRpcListener.onReceived(onSystemCapabilityUpdated); - assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES)); + assertNotNull(systemCapabilityManager.getCapability(SystemCapabilityType.APP_SERVICES, null, false)); } @Test @@ -736,8 +731,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);; @@ -750,11 +745,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)); @@ -775,13 +770,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); @@ -801,7 +796,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)); @@ -826,7 +821,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); @@ -845,7 +840,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); @@ -864,7 +859,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); @@ -879,7 +874,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); @@ -892,7 +887,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); @@ -916,11 +911,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)); @@ -963,23 +958,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) { } @@ -1030,12 +1011,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() { @@ -1043,11 +1018,6 @@ public class SystemCapabilityManagerTests { } @Override - public Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate) { - return null; - } - - @Override public SdlMsgVersion getSdlMsgVersion() { return null; } @@ -1057,46 +1027,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/LockScreenDeviceIconManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenDeviceIconManagerTests.java index 38701bd64..727c043cc 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenDeviceIconManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lockscreen/LockScreenDeviceIconManagerTests.java @@ -3,6 +3,7 @@ package com.smartdevicelink.managers.lockscreen; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Bitmap; + import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; 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..dd606a2c0 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 @@ -1,10 +1,11 @@ package com.smartdevicelink.managers.lockscreen; import android.content.Context; + import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.OnDriverDistraction; import com.smartdevicelink.proxy.rpc.enums.DriverDistractionState; import com.smartdevicelink.proxy.rpc.enums.HMILevel; @@ -60,7 +61,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/permission/PermissionManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/permission/PermissionManagerTests.java index d53287b61..973625106 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/permission/PermissionManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/permission/PermissionManagerTests.java @@ -4,7 +4,7 @@ import androidx.annotation.NonNull; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.HMIPermissions; import com.smartdevicelink.proxy.rpc.OnHMIStatus; import com.smartdevicelink.proxy.rpc.OnPermissionsChange; 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..5e9203e99 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 @@ -1,13 +1,13 @@ package com.smartdevicelink.managers.screen; -import com.livio.taskmaster.Taskmaster; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.livio.taskmaster.Taskmaster; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.managers.screen.menu.DynamicMenuUpdatesMode; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.enums.FileType; import com.smartdevicelink.proxy.rpc.enums.MetadataType; import com.smartdevicelink.proxy.rpc.enums.TextAlignment; @@ -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 3a680221e..713aae4fd 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,14 +3,14 @@ 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.interfaces.OnSystemCapabilityListener; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.DisplayCapability; import com.smartdevicelink.proxy.rpc.Image; import com.smartdevicelink.proxy.rpc.OnButtonEvent; @@ -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/SubscribeButtonManagerTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/SubscribeButtonManagerTest.java index 8e16c3ed0..e0fcc5d0a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/SubscribeButtonManagerTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/SubscribeButtonManagerTest.java @@ -5,7 +5,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.RPCRequest; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.OnButtonEvent; import com.smartdevicelink.proxy.rpc.OnButtonPress; import com.smartdevicelink.proxy.rpc.SubscribeButton; @@ -61,9 +61,9 @@ public class SubscribeButtonManagerTest { Object[] args = invocation.getArguments(); RPCRequest message = (RPCRequest) args[0]; if(message instanceof SubscribeButton){ - SubscribeButtonResponse subscribeButtonResponse = new SubscribeButtonResponse(); - subscribeButtonResponse.setSuccess(false); - message.getOnRPCResponseListener().onError(message.getCorrelationID(), Result.GENERIC_ERROR, "Fail"); + SubscribeButtonResponse subscribeButtonResponse = new SubscribeButtonResponse(false, Result.GENERIC_ERROR); + subscribeButtonResponse.setInfo("Fail"); + message.getOnRPCResponseListener().onResponse(message.getCorrelationID(), subscribeButtonResponse); } return null; } 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..e65911ccb 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 @@ -2,30 +2,38 @@ package com.smartdevicelink.managers.screen; 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.proxy.interfaces.ISdl; -import com.smartdevicelink.proxy.rpc.MetadataTags; -import com.smartdevicelink.proxy.rpc.Show; +import com.smartdevicelink.managers.lifecycle.OnSystemCapabilityListener; +import com.smartdevicelink.managers.lifecycle.SystemCapabilityManager; +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.managers.ISdl; +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 +41,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 +63,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 +75,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 +171,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 +198,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 +220,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 +255,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..94f75d764 --- /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.managers.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/screen/choiceset/CheckChoiceVROptionalOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperationTests.java index abf868876..fb8308e5f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperationTests.java @@ -37,7 +37,7 @@ package com.smartdevicelink.managers.screen.choiceset; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.Choice; import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSet; import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSet; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java index 4e9ba2e6b..482d29b90 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSetManagerTests.java @@ -40,7 +40,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.livio.taskmaster.Taskmaster; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.file.FileManager; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.KeyboardProperties; import com.smartdevicelink.proxy.rpc.enums.HMILevel; import com.smartdevicelink.proxy.rpc.enums.KeyboardLayout; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperationTests.java index e8a9eeb23..ca5c7df56 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperationTests.java @@ -37,7 +37,7 @@ package com.smartdevicelink.managers.screen.choiceset; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSet; import org.junit.Before; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperationTests.java index 14144758f..f5094917f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperationTests.java @@ -39,7 +39,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.filetypes.SdlArtwork; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.ImageField; import com.smartdevicelink.proxy.rpc.TextField; import com.smartdevicelink.proxy.rpc.WindowCapability; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java index 8e91c3a04..6da649165 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperationTests.java @@ -42,7 +42,7 @@ import com.livio.taskmaster.Task; import com.livio.taskmaster.Taskmaster; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCResponse; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.CancelInteraction; import com.smartdevicelink.proxy.rpc.KeyboardProperties; import com.smartdevicelink.proxy.rpc.PerformInteraction; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java index 37264b865..6eb3a1912 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperationTests.java @@ -42,7 +42,7 @@ import com.livio.taskmaster.Task; import com.livio.taskmaster.Taskmaster; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCResponse; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.CancelInteraction; import com.smartdevicelink.proxy.rpc.KeyboardProperties; import com.smartdevicelink.proxy.rpc.PerformInteraction; @@ -60,14 +60,8 @@ import org.junit.runner.RunWith; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertNull; -import static junit.framework.TestCase.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java index 518fa451c..eae5b530a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuCellTests.java @@ -34,7 +34,7 @@ package com.smartdevicelink.managers.screen.menu; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.smartdevicelink.managers.file.SdlArtworkTests; +import com.smartdevicelink.managers.file.filetypes.SdlArtworkTests; import com.smartdevicelink.proxy.rpc.enums.MenuLayout; import com.smartdevicelink.proxy.rpc.enums.TriggerSource; import com.smartdevicelink.test.TestValues; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java index b740d303a..08b0deb86 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/MenuManagerTests.java @@ -42,7 +42,7 @@ import com.smartdevicelink.managers.file.filetypes.SdlArtwork; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.proxy.RPCResponse; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.OnCommand; import com.smartdevicelink.proxy.rpc.OnHMIStatus; import com.smartdevicelink.proxy.rpc.SdlMsgVersion; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManagerTests.java index a73c28ef2..a3d07438e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/menu/VoiceCommandManagerTests.java @@ -37,7 +37,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.protocol.enums.FunctionID; -import com.smartdevicelink.proxy.interfaces.ISdl; +import com.smartdevicelink.managers.ISdl; import com.smartdevicelink.proxy.rpc.OnCommand; import com.smartdevicelink.proxy.rpc.OnHMIStatus; import com.smartdevicelink.proxy.rpc.enums.HMILevel; 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 1701dcc99..c02ba30c4 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.interfaces.OnSystemCapabilityListener; +import com.smartdevicelink.managers.ISdl; +import com.smartdevicelink.protocol.ISdlServiceListener; 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/protocol/SdlProtocolTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/protocol/SdlProtocolTests.java index e05767aac..ba6249e40 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/protocol/SdlProtocolTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/protocol/SdlProtocolTests.java @@ -1,8 +1,9 @@ package com.smartdevicelink.protocol; -import androidx.test.ext.junit.runners.AndroidJUnit4; import android.util.Log; +import androidx.test.ext.junit.runners.AndroidJUnit4; + import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.security.SdlSecurityBase; import com.smartdevicelink.streaming.video.VideoStreamingParameters; @@ -21,12 +22,12 @@ import org.junit.runner.RunWith; import java.io.ByteArrayOutputStream; import java.lang.reflect.Method; +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; import static junit.framework.TestCase.assertNull; import static org.mockito.Mockito.mock; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; @RunWith(AndroidJUnit4.class) public class SdlProtocolTests { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java index cc5b2f7ab..ac575dfbc 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java @@ -1,20 +1,18 @@ package com.smartdevicelink.test.SdlConnection; -import com.smartdevicelink.SdlConnection.SdlSession; +import com.smartdevicelink.session.SdlSession; +import com.smartdevicelink.protocol.ISdlServiceListener; import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.interfaces.ISdlServiceListener; import com.smartdevicelink.test.streaming.MockInterfaceBroker; import com.smartdevicelink.transport.MultiplexTransportConfig; -import com.smartdevicelink.transport.TCPTransportConfig; import junit.framework.TestCase; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; -import static org.mockito.Mockito.mock; /** * This is a unit test class for the SmartDeviceLink library project class : - * {@link com.smartdevicelink.SdlConnection.SdlSession} + * {@link com.smartdevicelink.session.SdlSession} */ public class SdlSessionTests extends TestCase { 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 da8b48d8c..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.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 onError(int correlationId, Result resultCode, String info) { - onErrorListenerCounter++; - remainingRequestsExpected--; - } - - @Override - public void onResponse(int correlationId, RPCResponse response) { - onResponseListenerCounter++; - 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).onError(request.getCorrelationID(), Result.DISALLOWED, "ERROR"); - } 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/DriverDistractionCapabilityTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DriverDistractionCapabilityTest.java index 2e98296a1..767c264fa 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DriverDistractionCapabilityTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DriverDistractionCapabilityTest.java @@ -3,9 +3,12 @@ package com.smartdevicelink.test.rpc.datatypes; import com.smartdevicelink.proxy.rpc.DriverDistractionCapability; import com.smartdevicelink.test.JsonUtils; import com.smartdevicelink.test.TestValues; + import junit.framework.TestCase; + import org.json.JSONException; import org.json.JSONObject; + import java.util.Iterator; /** 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/AddCommandTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddCommandTests.java index 88d22cd8d..04a77613e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddCommandTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddCommandTests.java @@ -18,6 +18,7 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java index 74efd59e9..01ebf5f8c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AddSubmenuTests.java @@ -18,12 +18,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertManeuverTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertManeuverTests.java index 2fef7e829..5fce62fe4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertManeuverTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertManeuverTests.java @@ -21,12 +21,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertTests.java index 2224191dd..525fae442 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/AlertTests.java @@ -22,12 +22,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CancelInteractionTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CancelInteractionTests.java index d2e41f85e..26ddbf7b5 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CancelInteractionTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CancelInteractionTests.java @@ -49,11 +49,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CloseApplicationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CloseApplicationTests.java index 62a92acfc..02cc2d718 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CloseApplicationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CloseApplicationTests.java @@ -49,10 +49,10 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateInteractionChoiceSetTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateInteractionChoiceSetTests.java index 3e8e533e2..799936921 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateInteractionChoiceSetTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateInteractionChoiceSetTests.java @@ -19,12 +19,12 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateWindowTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateWindowTests.java index 733932efb..8f905ac73 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateWindowTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/CreateWindowTests.java @@ -16,11 +16,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java index 20d5fe591..a6defa4b7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java @@ -15,11 +15,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java index 5174f9789..e6cba8157 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java @@ -15,11 +15,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteInteractionChoiceSetTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteInteractionChoiceSetTests.java index 0fb31ba25..32104b281 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteInteractionChoiceSetTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteInteractionChoiceSetTests.java @@ -15,11 +15,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteSubMenuTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteSubMenuTests.java index 68adc14fa..4d0358cc6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteSubMenuTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteSubMenuTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteWindowTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteWindowTests.java index c442395bd..e05748b29 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteWindowTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteWindowTests.java @@ -14,11 +14,12 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DiagnosticMessageTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DiagnosticMessageTests.java index 7b0ecacf9..44c4de760 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DiagnosticMessageTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DiagnosticMessageTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java index 88e9fbffd..7e6cd3991 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java @@ -14,11 +14,12 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * Created by austinkirk on 6/6/17. diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/EndAudioPassThruTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/EndAudioPassThruTests.java index d97bc0f32..b4cd32af7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/EndAudioPassThruTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/EndAudioPassThruTests.java @@ -15,10 +15,10 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetAppServiceDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetAppServiceDataTests.java index f5e7bba89..02e7fb5ff 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetAppServiceDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetAppServiceDataTests.java @@ -15,11 +15,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class GetAppServiceDataTests extends BaseRpcTests { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetDTCsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetDTCsTests.java index 73d15ad6d..f9b8e528f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetDTCsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetDTCsTests.java @@ -15,11 +15,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetFileTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetFileTests.java index 450dcba1e..9d358cc8a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetFileTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetFileTests.java @@ -16,11 +16,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class GetFileTests extends BaseRpcTests { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java index 2aa7dc593..6d9bc2283 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java @@ -16,6 +16,7 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java index 4c7f5f461..17d500b6f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java @@ -16,11 +16,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java index 533ff8c50..6eb55d90f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java @@ -16,11 +16,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class GetSystemCapabilityTests extends BaseRpcTests { 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..637445ac7 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 @@ -15,12 +15,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -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/GetWayPointsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java index a52d1a644..8a9586a93 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java @@ -16,11 +16,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * Created by austinkirk on 6/6/17. diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ListFilesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ListFilesTests.java index 92e7286e4..cc5b542a0 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ListFilesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ListFilesTests.java @@ -15,10 +15,10 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAppServiceInteractionTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAppServiceInteractionTests.java index 9a9b7b375..bdc8bb9ac 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAppServiceInteractionTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAppServiceInteractionTests.java @@ -15,11 +15,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class PerformAppServiceInteractionTests extends BaseRpcTests { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAudioPassThruTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAudioPassThruTests.java index abbe3d644..a1525c773 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAudioPassThruTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformAudioPassThruTests.java @@ -23,12 +23,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformInteractionTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformInteractionTests.java index 176cc3ec5..89afaa843 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformInteractionTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PerformInteractionTests.java @@ -23,12 +23,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PublishAppServiceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PublishAppServiceTests.java index 9d0c3ed94..e999cb6d1 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PublishAppServiceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PublishAppServiceTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class PublishAppServiceTests extends BaseRpcTests { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PutFileTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PutFileTests.java index b70c83794..0e3b39aab 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PutFileTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/PutFileTests.java @@ -17,11 +17,11 @@ import org.junit.Test; import java.util.Hashtable; import java.util.zip.CRC32; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReadDidTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReadDidTests.java index 151f5cc3e..0f9319f24 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReadDidTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReadDidTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/RegisterAppInterfaceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/RegisterAppInterfaceTests.java index 665a3dc80..b61687bd7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/RegisterAppInterfaceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/RegisterAppInterfaceTests.java @@ -26,12 +26,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReleaseInteriorVehicleDataModuleTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReleaseInteriorVehicleDataModuleTests.java index e786d1786..840eb246d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReleaseInteriorVehicleDataModuleTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ReleaseInteriorVehicleDataModuleTests.java @@ -16,11 +16,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class ReleaseInteriorVehicleDataModuleTests extends BaseRpcTests { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ResetGlobalPropertiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ResetGlobalPropertiesTests.java index 68448c5a6..bbb4f8012 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ResetGlobalPropertiesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ResetGlobalPropertiesTests.java @@ -18,11 +18,11 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ScrollableMessageTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ScrollableMessageTests.java index e6d8b146d..40d4eb33e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ScrollableMessageTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ScrollableMessageTests.java @@ -20,12 +20,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendLocationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendLocationTests.java index 99a74dfae..ad1ad8a2c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendLocationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendLocationTests.java @@ -18,12 +18,12 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetAppIconTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetAppIconTests.java index 5878aad7c..01a391518 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetAppIconTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetAppIconTests.java @@ -15,11 +15,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetDisplayLayoutTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetDisplayLayoutTests.java index 22118bdb1..f5a080295 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetDisplayLayoutTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetDisplayLayoutTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java index 379b1c1ee..abf889104 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetGlobalPropertiesTests.java @@ -24,12 +24,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java index 1285acafd..ad4bb2780 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java index a60709dba..c4937aa95 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetMediaClockTimerTests.java @@ -19,12 +19,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowAppMenuTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowAppMenuTests.java index 3e486bc6a..27d876f14 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowAppMenuTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowAppMenuTests.java @@ -50,11 +50,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowConstantTbtTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowConstantTbtTests.java index 85c830214..482c73783 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowConstantTbtTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowConstantTbtTests.java @@ -21,12 +21,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java index 742d23ff4..14585c439 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java @@ -24,12 +24,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SliderTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SliderTests.java index 32f60d4e5..def35eae2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SliderTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SliderTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SpeakTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SpeakTests.java index f0214c78c..b9c89493f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SpeakTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SpeakTests.java @@ -20,12 +20,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class SpeakTests extends BaseRpcTests { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeButtonTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeButtonTests.java index 19b192b31..7cc1ca35c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeButtonTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeButtonTests.java @@ -15,6 +15,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; 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..341eb73d4 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 @@ -15,12 +15,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -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/SubscribeWayPointsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java index 2ce400e55..a28d31bbf 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java @@ -15,10 +15,10 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * Created by austinkirk on 6/7/17. diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SystemRequestTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SystemRequestTests.java index aeb061dc6..dae825cc2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SystemRequestTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SystemRequestTests.java @@ -18,12 +18,12 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnpublishAppServiceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnpublishAppServiceTests.java index 796fe2a25..7b57be8ac 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnpublishAppServiceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnpublishAppServiceTests.java @@ -50,11 +50,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnregisterAppInterfaceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnregisterAppInterfaceTests.java index dec7b0376..66bd76bdb 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnregisterAppInterfaceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnregisterAppInterfaceTests.java @@ -15,10 +15,10 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeButtonTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeButtonTests.java index 97833ce02..74160bf4c 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeButtonTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeButtonTests.java @@ -16,11 +16,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : 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..2ea0dae9b 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 @@ -16,12 +16,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -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/requests/UnsubscribeWayPointsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java index 5d20c8454..fe3aa9ffc 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UpdateTurnListTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UpdateTurnListTests.java index 53dc91fc6..905bed6d8 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UpdateTurnListTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UpdateTurnListTests.java @@ -21,12 +21,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java index e4d69e79f..618cb9c45 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java @@ -15,6 +15,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java index 861de0d37..163fec190 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java index 01805fce6..7ff5cfaef 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java index d8f554c53..9a89d8d27 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java @@ -15,11 +15,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java index 2c4bfc651..1dcfd95d6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CancelInteractionResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CancelInteractionResponseTests.java index a981719e9..fb9374247 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CancelInteractionResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CancelInteractionResponseTests.java @@ -48,6 +48,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java index 6888c589d..1c96e774d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java @@ -15,9 +15,9 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CloseApplicationResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CloseApplicationResponseTests.java index 6eb9a09a5..135155e6e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CloseApplicationResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CloseApplicationResponseTests.java @@ -48,6 +48,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CreateWindowResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CreateWindowResponseTest.java index a06af985b..b50b34221 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CreateWindowResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/CreateWindowResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java index b2e6e27a9..74cd75664 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java index 0e529dc69..42b26d1bd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java index 24ce266d1..bb0e428e0 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java index 8392f915b..0084305ad 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteWindowResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteWindowResponseTest.java index 347db5ea6..2d4486f21 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteWindowResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DeleteWindowResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java index 7bfefbeea..302c01c8e 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java @@ -16,6 +16,7 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java index ff23c5ad7..006e6d050 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java index f68a6837b..c9da248f8 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetAppServiceDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetAppServiceDataResponseTests.java index 3e1d1f136..49de496e4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetAppServiceDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetAppServiceDataResponseTests.java @@ -15,6 +15,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java index ea4d48790..3ff630c93 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetFileResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetFileResponseTests.java index a4abf011d..867e91cb2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetFileResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetFileResponseTests.java @@ -16,11 +16,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataConsentResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataConsentResponseTests.java index 411691bd0..512d324e3 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataConsentResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataConsentResponseTests.java @@ -16,6 +16,7 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java index 80185c05c..af6f2cb4b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java @@ -16,6 +16,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java index ee2b24d1f..827b340e7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java @@ -16,11 +16,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; public class GetSystemCapabilityResponseTests extends BaseRpcTests { 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..91e13586a 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; @@ -37,12 +38,12 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** @@ -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/GetWayPointsResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java index fb123bef4..131aba5fa 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java @@ -18,6 +18,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java index 7b7bd20ec..67b23ef2b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAppServiceInteractionResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAppServiceInteractionResponseTests.java index 4280902e2..2278a61a1 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAppServiceInteractionResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAppServiceInteractionResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java index 7cff8e766..78f9d258b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java index 32c42c16c..83f4bd734 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java @@ -15,6 +15,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PublishAppServiceResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PublishAppServiceResponseTests.java index 5bb6f923a..197aa13d4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PublishAppServiceResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PublishAppServiceResponseTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java index e95285db8..6c34c9df4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java index aec63227d..b18bea1c7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java @@ -19,6 +19,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java index 862ed5342..4e790a758 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java @@ -31,12 +31,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReleaseInteriorVehicleDataModuleResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReleaseInteriorVehicleDataModuleResponseTests.java index 965980a0d..b2ba952b8 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReleaseInteriorVehicleDataModuleResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ReleaseInteriorVehicleDataModuleResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java index e8d3576e6..b6394fa0a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java index 4e12cb78c..286cb9ad2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java index 7208eeff4..938d8dbc6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java index e6f0bf140..5203bb1e8 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java index 63d63dab9..6985ad238 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java @@ -23,12 +23,12 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java index 9765dcfba..825c358cf 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java index 7abcdcecc..9e7fd8129 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java @@ -17,12 +17,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java index d8f699b5a..4c4ae89ce 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java @@ -15,9 +15,9 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowAppMenuResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowAppMenuResponseTests.java index 1cfafd319..28cf0b436 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowAppMenuResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowAppMenuResponseTests.java @@ -49,6 +49,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java index aa44a190b..a11e31881 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java index ebd5f41b6..2062c5fe1 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java @@ -15,9 +15,9 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java index f454af9eb..4ea612e2b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java index f2880d3eb..b8f8573cb 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java index 1c58b13bc..ed607231f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java @@ -15,9 +15,9 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** 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..408a0af28 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 @@ -18,11 +18,11 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.fail; /** @@ -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/SubscribeWaypointsResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java index 239702805..8a156d12f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java index 9f4e464f4..a52ff7c21 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnpublishAppServiceResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnpublishAppServiceResponseTests.java index 7536dd2a7..474c05cd6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnpublishAppServiceResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnpublishAppServiceResponseTests.java @@ -49,6 +49,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java index 01aad979c..14c276504 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java index 3cf7d6491..de29a5288 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java @@ -15,9 +15,9 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** 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..80c61c284 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 @@ -20,12 +20,12 @@ import org.junit.Test; import java.util.Hashtable; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; /** * This is a unit test class for the SmartDeviceLink library project class : @@ -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/rpc/responses/UnsubscribeWayPointsResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java index 5360c023c..bd962f474 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java index 47951d34c..eaaebf1bd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java @@ -14,6 +14,7 @@ import org.json.JSONObject; import org.junit.Test; import java.util.Hashtable; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertNotNull; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java index aeb73e3de..f2648c7e2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java @@ -2,7 +2,7 @@ package com.smartdevicelink.test.security; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.smartdevicelink.SdlConnection.SdlSession; +import com.smartdevicelink.session.SdlSession; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.security.SdlSecurityBase; import com.smartdevicelink.test.TestValues; 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..dbec1301e 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 @@ -1,12 +1,10 @@ package com.smartdevicelink.test.streaming; -import com.smartdevicelink.SdlConnection.SdlSession; +import com.smartdevicelink.session.SdlSession; 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/MockInterfaceBroker.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java index 1c7005012..14905fa7d 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java @@ -1,6 +1,6 @@ package com.smartdevicelink.test.streaming; -import com.smartdevicelink.SdlConnection.ISdlSessionListener; +import com.smartdevicelink.session.ISdlSessionListener; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.util.Version; 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..77eae6cba 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 @@ -1,11 +1,9 @@ package com.smartdevicelink.test.streaming; -import com.smartdevicelink.SdlConnection.SdlSession; +import com.smartdevicelink.session.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..7791a1c79 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 @@ -1,14 +1,12 @@ package com.smartdevicelink.test.streaming; -import com.smartdevicelink.SdlConnection.SdlSession; +import com.smartdevicelink.session.SdlSession; import com.smartdevicelink.protocol.ProtocolMessage; import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.interfaces.IVideoStreamListener; +import com.smartdevicelink.streaming.video.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/RTPH264PacketizerTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java index 60fa6fb80..5dfe36e19 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java @@ -33,10 +33,10 @@ package com.smartdevicelink.test.streaming.video; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.smartdevicelink.SdlConnection.SdlSession; +import com.smartdevicelink.session.SdlSession; import com.smartdevicelink.protocol.ProtocolMessage; import com.smartdevicelink.protocol.enums.SessionType; -import com.smartdevicelink.proxy.interfaces.IVideoStreamListener; +import com.smartdevicelink.streaming.video.IVideoStreamListener; import com.smartdevicelink.streaming.IStreamListener; import com.smartdevicelink.streaming.video.RTPH264Packetizer; import com.smartdevicelink.test.streaming.MockInterfaceBroker; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java index e5b07930e..4a0d7b87f 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java @@ -4,13 +4,14 @@ import android.annotation.TargetApi; import android.content.Context; import android.os.Bundle; import android.os.Looper; -import androidx.test.platform.app.InstrumentationRegistry; import android.view.Display; import android.view.MotionEvent; import android.widget.RelativeLayout; +import androidx.test.platform.app.InstrumentationRegistry; + import com.smartdevicelink.encoder.VirtualDisplayEncoder; -import com.smartdevicelink.proxy.interfaces.IVideoStreamListener; +import com.smartdevicelink.streaming.video.IVideoStreamListener; import com.smartdevicelink.streaming.video.SdlRemoteDisplay; import com.smartdevicelink.streaming.video.VideoStreamingParameters; 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/test/util/SdlAppInfoTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlAppInfoTests.java index 35ad87cce..64c2d7b7b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlAppInfoTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlAppInfoTests.java @@ -38,6 +38,7 @@ import android.content.pm.PackageInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.os.Bundle; + import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.R; @@ -50,6 +51,7 @@ import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.Collections; import java.util.List; + import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/utl/AndroidToolsTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/utl/AndroidToolsTests.java index 601895b1c..9deff1ec8 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/utl/AndroidToolsTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/utl/AndroidToolsTests.java @@ -1,6 +1,7 @@ package com.smartdevicelink.test.utl; import android.content.ComponentName; + import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.util.AndroidTools; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/LocalRouterServiceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/LocalRouterServiceTests.java index e3070cd70..a816d6d87 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/LocalRouterServiceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/LocalRouterServiceTests.java @@ -3,6 +3,7 @@ package com.smartdevicelink.transport; import android.content.ComponentName; import android.content.Intent; import android.os.Parcel; + import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; 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..03c71264a 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 androidx.test.ext.junit.runners.AndroidJUnit4; 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..812556f2c 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 @@ -5,9 +5,10 @@ import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.ConditionVariable; -import androidx.test.ext.junit.runners.AndroidJUnit4; import android.util.Log; +import androidx.test.ext.junit.runners.AndroidJUnit4; + import com.smartdevicelink.transport.RouterServiceValidator.TrustedAppStore; import com.smartdevicelink.util.HttpRequestTask.HttpRequestTaskCallback; @@ -86,7 +87,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 +100,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 +113,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 +126,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 +139,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 +218,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 +234,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 +407,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 +487,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/RegisteredAppTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java index f2164e498..d9af0faed 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java @@ -2,8 +2,11 @@ package com.smartdevicelink.transport; import android.os.Looper; import android.os.Messenger; + import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.smartdevicelink.transport.enums.TransportType; + import org.junit.Test; import org.junit.runner.RunWith; @@ -30,10 +33,10 @@ public class RegisteredAppTests { // Instantiate SdlRouterService and Registered App class SdlRouterService router = new SdlRouterService(); - SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); + SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, 1, messenger); // Call Handle Message - app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_LARGE_PACKET_START,bytes); + app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_LARGE_PACKET_START,bytes, TransportType.BLUETOOTH); // Insure that the buffer is not null, if it is the test will fail assertNotNull(app.buffer); @@ -50,13 +53,13 @@ public class RegisteredAppTests { // Instantiate SdlRouterService and Registered App class SdlRouterService router = new SdlRouterService(); - SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); + SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, 1, messenger); // Force Null Buffer app.buffer = null; // Call Handle Message - Making sure it doesn't init buffer - app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_NONE,bytes); + app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_NONE, bytes, TransportType.BLUETOOTH); // Insure that the buffer is null. and no NPE assertNull(app.buffer); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/SdlRouterServiceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/SdlRouterServiceTests.java index 5815911e7..2ab12e51a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/SdlRouterServiceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/SdlRouterServiceTests.java @@ -5,11 +5,12 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; -import androidx.test.ext.junit.runners.AndroidJUnit4; import android.util.Log; import android.util.SparseArray; import android.util.SparseIntArray; +import androidx.test.ext.junit.runners.AndroidJUnit4; + import com.smartdevicelink.marshal.JsonRPCMarshaller; import com.smartdevicelink.protocol.BinaryFrameHeader; import com.smartdevicelink.protocol.ProtocolMessage; @@ -187,8 +188,8 @@ public class SdlRouterServiceTests { // We need a registered app for this to work Message message = Message.obtain(); - SdlRouterService.RegisteredApp app1 = sdlRouterService.new RegisteredApp("12345",message.replyTo); - SdlRouterService.RegisteredApp app2 = sdlRouterService.new RegisteredApp("12344",message.replyTo); + SdlRouterService.RegisteredApp app1 = sdlRouterService.new RegisteredApp("12345", 1, message.replyTo); + SdlRouterService.RegisteredApp app2 = sdlRouterService.new RegisteredApp("12344", 1, message.replyTo); HashMap<String,SdlRouterService.RegisteredApp> registeredApps = new HashMap<>(); registeredApps.put(app1.getAppId(),app1); registeredApps.put(app2.getAppId(),app2); @@ -280,8 +281,8 @@ public class SdlRouterServiceTests { // We need a registered app for this to work Message message = Message.obtain(); - SdlRouterService.RegisteredApp app1 = sdlRouterService.new RegisteredApp("12345",message.replyTo); - SdlRouterService.RegisteredApp app2 = sdlRouterService.new RegisteredApp("12344",message.replyTo); + SdlRouterService.RegisteredApp app1 = sdlRouterService.new RegisteredApp("12345", 1, message.replyTo); + SdlRouterService.RegisteredApp app2 = sdlRouterService.new RegisteredApp("12344", 1, message.replyTo); HashMap<String,SdlRouterService.RegisteredApp> registeredApps = new HashMap<>(); registeredApps.put(app1.getAppId(),app1); registeredApps.put(app2.getAppId(),app2); @@ -688,7 +689,7 @@ public class SdlRouterServiceTests { private void addDummyRegisteredApp(SdlRouterService routerService, String appId, int sessionId) throws IllegalAccessException, NoSuchFieldException { Message message = Message.obtain(); - SdlRouterService.RegisteredApp app = routerService.new RegisteredApp(appId, message.replyTo); + SdlRouterService.RegisteredApp app = routerService.new RegisteredApp(appId, 1, message.replyTo); Field raf = routerService.getClass().getDeclaredField("registeredApps"); raf.setAccessible(true); 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..811fd8307 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,10 +1,12 @@ package com.smartdevicelink.transport; import android.bluetooth.BluetoothAdapter; +import android.content.ComponentName; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Messenger; + import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.test.SdlUnitTestContants; @@ -27,7 +29,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) { + + } + }); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java index b1d3263b2..a808ba936 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportManagerTests.java @@ -2,6 +2,7 @@ package com.smartdevicelink.transport; import android.content.ComponentName; import android.os.Looper; + import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.protocol.SdlPacket; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java index 5f7f06f59..4a80343ad 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/util/MediaStreamingStatusTests.java @@ -4,6 +4,7 @@ import android.content.Context; import android.media.AudioDeviceInfo; import android.media.AudioManager; import android.os.Build; + import androidx.test.ext.junit.runners.AndroidJUnit4; import com.smartdevicelink.managers.SdlManager; |