|
40 | 40 | import com.smartdevicelink.managers.BaseSubManager; |
41 | 41 | import com.smartdevicelink.managers.ISdl; |
42 | 42 | import com.smartdevicelink.managers.file.FileManager; |
| 43 | +import com.smartdevicelink.proxy.rpc.ImageField; |
43 | 44 | import com.smartdevicelink.proxy.rpc.KeyboardCapabilities; |
44 | 45 | import com.smartdevicelink.proxy.rpc.KeyboardLayoutCapability; |
45 | 46 | import com.smartdevicelink.proxy.rpc.KeyboardProperties; |
46 | 47 | import com.smartdevicelink.proxy.rpc.SdlMsgVersion; |
| 48 | +import com.smartdevicelink.proxy.rpc.TextField; |
47 | 49 | import com.smartdevicelink.proxy.rpc.WindowCapability; |
48 | 50 | import com.smartdevicelink.proxy.rpc.enums.HMILevel; |
| 51 | +import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; |
49 | 52 | import com.smartdevicelink.proxy.rpc.enums.KeyboardInputMask; |
50 | 53 | import com.smartdevicelink.proxy.rpc.enums.KeyboardLayout; |
51 | 54 | import com.smartdevicelink.proxy.rpc.enums.KeypressMode; |
52 | 55 | import com.smartdevicelink.proxy.rpc.enums.Language; |
53 | 56 | import com.smartdevicelink.proxy.rpc.enums.SystemContext; |
| 57 | +import com.smartdevicelink.proxy.rpc.enums.TextFieldName; |
54 | 58 | import com.smartdevicelink.proxy.rpc.enums.TriggerSource; |
| 59 | +import com.smartdevicelink.test.TestValues; |
55 | 60 |
|
56 | 61 | import org.junit.After; |
57 | 62 | import org.junit.Before; |
@@ -231,7 +236,8 @@ public void testAddUniqueNamesToCells() { |
231 | 236 | ChoiceCell cell4 = new ChoiceCell("McDonalds", "4 mile away", null, null, null, null); |
232 | 237 | ChoiceCell cell5 = new ChoiceCell("Starbucks", "5 mile away", null, null, null, null); |
233 | 238 | ChoiceCell cell6 = new ChoiceCell("Meijer", "6 mile away", null, null, null, null); |
234 | | - LinkedHashSet<ChoiceCell> cellList = new LinkedHashSet<>(); |
| 239 | + List<ChoiceCell> cellList = new ArrayList<>(); |
| 240 | + |
235 | 241 | cellList.add(cell1); |
236 | 242 | cellList.add(cell2); |
237 | 243 | cellList.add(cell3); |
@@ -468,4 +474,51 @@ public void testDismissingQueuedKeyboard() { |
468 | 474 | verify(testKeyboardOp, times(0)).dismissKeyboard(); |
469 | 475 | verify(testKeyboardOp2, times(1)).dismissKeyboard(); |
470 | 476 | } |
| 477 | + |
| 478 | + @Test |
| 479 | + public void testUniquenessForAvailableFields() { |
| 480 | + WindowCapability windowCapability = new WindowCapability(); |
| 481 | + TextField secondaryText = new TextField(); |
| 482 | + secondaryText.setName(TextFieldName.secondaryText); |
| 483 | + TextField tertiaryText = new TextField(); |
| 484 | + tertiaryText.setName(TextFieldName.tertiaryText); |
| 485 | + |
| 486 | + List<TextField> textFields = new ArrayList<>(); |
| 487 | + textFields.add(secondaryText); |
| 488 | + textFields.add(tertiaryText); |
| 489 | + windowCapability.setTextFields(textFields); |
| 490 | + |
| 491 | + ImageField choiceImage = new ImageField(); |
| 492 | + choiceImage.setName(ImageFieldName.choiceImage); |
| 493 | + ImageField choiceSecondaryImage = new ImageField(); |
| 494 | + choiceSecondaryImage.setName(ImageFieldName.choiceSecondaryImage); |
| 495 | + List<ImageField> imageFieldList = new ArrayList<>(); |
| 496 | + imageFieldList.add(choiceImage); |
| 497 | + imageFieldList.add(choiceSecondaryImage); |
| 498 | + windowCapability.setImageFields(imageFieldList); |
| 499 | + |
| 500 | + csm.defaultMainWindowCapability = windowCapability; |
| 501 | + |
| 502 | + ChoiceCell cell1 = new ChoiceCell("Item 1", "null", "tertiaryText", null, TestValues.GENERAL_ARTWORK, TestValues.GENERAL_ARTWORK); |
| 503 | + ChoiceCell cell2 = new ChoiceCell("Item 1", "null2", "tertiaryText2", null, null, null); |
| 504 | + List<ChoiceCell> choiceCellList = new ArrayList<>(); |
| 505 | + choiceCellList.add(cell1); |
| 506 | + choiceCellList.add(cell2); |
| 507 | + |
| 508 | + List<ChoiceCell> removedProperties = csm.removeUnusedProperties(choiceCellList); |
| 509 | + assertNotNull(removedProperties.get(0).getSecondaryText()); |
| 510 | + |
| 511 | + textFields.remove(secondaryText); |
| 512 | + textFields.remove(tertiaryText); |
| 513 | + imageFieldList.remove(choiceImage); |
| 514 | + imageFieldList.remove(choiceSecondaryImage); |
| 515 | + |
| 516 | + removedProperties = csm.removeUnusedProperties(choiceCellList); |
| 517 | + csm.addUniqueNamesBasedOnStrippedCells(removedProperties, choiceCellList); |
| 518 | + assertEquals(choiceCellList.get(1).getUniqueText(), "Item 1 (2)"); |
| 519 | + |
| 520 | + |
| 521 | + } |
| 522 | + |
| 523 | + |
471 | 524 | } |
0 commit comments