diff options
author | Julian Kast <julian@livio.com> | 2021-05-25 14:07:58 -0400 |
---|---|---|
committer | Julian Kast <julian@livio.com> | 2021-05-25 14:07:58 -0400 |
commit | 74b62a9aa74da988c8129ad233d96a3ff0ecbac4 (patch) | |
tree | 5971f5dd3ac20db80798ef0b2774d5fc5cf94462 | |
parent | a7c391d1c107e4c89a3988e67d34e12838b2c3a7 (diff) | |
download | sdl_android-74b62a9aa74da988c8129ad233d96a3ff0ecbac4.tar.gz |
Fix errors found in unit test dealing with null check and fix unit test to test new logic correctly
2 files changed, 8 insertions, 1 deletions
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 9aeb0504b..4d5786899 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 @@ -182,7 +182,7 @@ public class VoiceCommandManagerTests { // Fake onCommand - we want to make sure that we can pass back onCommand events to our VoiceCommand Objects OnCommand onCommand = new OnCommand(); - onCommand.setCmdID(command3.getCommandId()); + onCommand.setCmdID(voiceCommandManager.getVoiceCommands().get(voiceCommandManager.getVoiceCommands().indexOf(command3)).getCommandId()); onCommand.setTriggerSource(TriggerSource.TS_VR); // these are voice commands commandListener.onNotified(onCommand); // send off the notification diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java index 4ef146fb1..9c5c39c21 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java @@ -140,6 +140,9 @@ abstract class BaseVoiceCommandManager extends BaseSubManager { // Clone voice commands this.voiceCommands = new ArrayList<>(); for (VoiceCommand voiceCommand : voiceCommands) { + if (voiceCommand == null) { + continue; + } this.voiceCommands.add(voiceCommand.clone()); } @@ -147,14 +150,18 @@ abstract class BaseVoiceCommandManager extends BaseSubManager { if (validatedVoiceCommands.size() == 0 && voiceCommands.size() > 0) { DebugTool.logError(TAG, "New voice commands are invalid, skipping..."); + this.voiceCommands = null; return; } if (!isVoiceCommandsUnique(validatedVoiceCommands)) { DebugTool.logError(TAG, "Not all voice command strings are unique across all voice commands. Voice commands will not be set."); + this.voiceCommands = null; return; } + this.voiceCommands = validatedVoiceCommands; + updateIdsOnVoiceCommands(this.voiceCommands); cleanTransactionQueue(); |