diff options
Diffstat (limited to 'android/sdl_android/src')
-rw-r--r-- | android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperationTests.java | 86 |
1 files changed, 84 insertions, 2 deletions
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 b29863110..b4a37e94c 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 @@ -59,6 +59,9 @@ import static org.mockito.Mockito.mock; public class PreloadChoicesOperationTests extends AndroidTestCase2 { private PreloadChoicesOperation preloadChoicesOperation; + private PreloadChoicesOperation preloadChoicesOperationNullCapability; + private PreloadChoicesOperation preloadChoicesOperationEmptyCapability; + @Override public void setUp() throws Exception{ @@ -72,18 +75,71 @@ public class PreloadChoicesOperationTests extends AndroidTestCase2 { cellsToPreload.add(cell2); ImageField imageField = new ImageField(ImageFieldName.choiceImage, Arrays.asList(FileType.GRAPHIC_PNG, FileType.GRAPHIC_JPEG)); + ImageField imageField2 = new ImageField(); + imageField2.setName(ImageFieldName.choiceSecondaryImage); TextField textField = new TextField(TextFieldName.menuName, CharacterSet.CID1SET, 2, 2); + TextField textField2 = new TextField(); + TextField textField3 = new TextField(); + + textField2.setName(TextFieldName.secondaryText); + textField3.setName(TextFieldName.tertiaryText); + + WindowCapability windowCapability = new WindowCapability(); - windowCapability.setImageFields(Collections.singletonList(imageField)); + windowCapability.setImageFields(Arrays.asList(imageField, imageField2)); windowCapability.setImageTypeSupported(Arrays.asList(ImageType.STATIC, ImageType.DYNAMIC)); - windowCapability.setTextFields(Collections.singletonList(textField)); + windowCapability.setTextFields(Arrays.asList(textField, textField2, textField3)); ISdl internalInterface = mock(ISdl.class); FileManager fileManager = mock(FileManager.class); preloadChoicesOperation = new PreloadChoicesOperation(internalInterface, fileManager, windowCapability, true, cellsToPreload, null); } + /** + * Sets up PreloadChoicesOperation with WindowCapability being null + */ + public void setUpNullWindowCapability() { + + ChoiceCell cell1 = new ChoiceCell("cell 1"); + ChoiceCell cell2 = new ChoiceCell("cell 2", null, Test.GENERAL_ARTWORK); + HashSet<ChoiceCell> cellsToPreload = new HashSet<>(); + cellsToPreload.add(cell1); + cellsToPreload.add(cell2); + + ISdl internalInterface = mock(ISdl.class); + FileManager fileManager = mock(FileManager.class); + preloadChoicesOperationNullCapability = new PreloadChoicesOperation(internalInterface, fileManager, null, true, cellsToPreload, null); + } + + /** + * Sets up PreloadChoicesOperation with an Capability not being set + * certain imageFields and TextFields + */ + public void setUpEmptyWindowCapability() { + + ChoiceCell cell1 = new ChoiceCell("cell 1"); + ChoiceCell cell2 = new ChoiceCell("cell 2", null, Test.GENERAL_ARTWORK); + HashSet<ChoiceCell> cellsToPreload = new HashSet<>(); + cellsToPreload.add(cell1); + cellsToPreload.add(cell2); + + ImageField imageField = new ImageField(); + imageField.setName(ImageFieldName.alertIcon); + + TextField textField = new TextField(); + textField.setName(TextFieldName.mainField1); + + WindowCapability windowCapability = new WindowCapability(); + windowCapability.setImageFields(Collections.singletonList(imageField)); + windowCapability.setTextFields(Collections.singletonList(textField)); + + ISdl internalInterface = mock(ISdl.class); + FileManager fileManager = mock(FileManager.class); + preloadChoicesOperationEmptyCapability = new PreloadChoicesOperation(internalInterface, fileManager, windowCapability, true, cellsToPreload, null); + } + + @Override public void tearDown() throws Exception { super.tearDown(); @@ -116,4 +172,30 @@ public class PreloadChoicesOperationTests extends AndroidTestCase2 { assertEquals(artworksToUpload.size(), 1); } + /** + * Testing shouldSend method's with varying WindowCapability set. + */ + public void testsShouldSendText() { + setUpNullWindowCapability(); + assertTrue(preloadChoicesOperationNullCapability.shouldSendChoicePrimaryImage()); + assertTrue(preloadChoicesOperationNullCapability.shouldSendChoiceSecondaryImage()); + assertTrue(preloadChoicesOperationNullCapability.shouldSendChoiceSecondaryText()); + assertTrue(preloadChoicesOperationNullCapability.shouldSendChoiceTertiaryText()); + assertTrue(preloadChoicesOperationNullCapability.shouldSendChoiceText()); + + + assertTrue(preloadChoicesOperation.shouldSendChoicePrimaryImage()); + assertTrue(preloadChoicesOperation.shouldSendChoiceSecondaryImage()); + assertTrue(preloadChoicesOperation.shouldSendChoiceSecondaryText()); + assertTrue(preloadChoicesOperation.shouldSendChoiceTertiaryText()); + assertTrue(preloadChoicesOperation.shouldSendChoiceText()); + + setUpEmptyWindowCapability(); + assertFalse(preloadChoicesOperationEmptyCapability.shouldSendChoicePrimaryImage()); + assertFalse(preloadChoicesOperationEmptyCapability.shouldSendChoiceSecondaryImage()); + assertFalse(preloadChoicesOperationEmptyCapability.shouldSendChoiceSecondaryText()); + assertFalse(preloadChoicesOperationEmptyCapability.shouldSendChoiceTertiaryText()); + assertFalse(preloadChoicesOperationEmptyCapability.shouldSendChoiceText()); + } + } |