/** * Tests format string converter and checks that transformation is performed * properly */ @Smoke @Test(timeout = 300000) public void testFormatStringConverter() throws InterruptedException { setPropertyBySlider(SettingType.SETTER, Properties.prefWidth, 150); int itemsCount = 3; String prefix = "value #"; final List<String> testedValues = new ArrayList<String>(itemsCount); for (int i = 0; i < itemsCount; i++) { testedValues.add(prefix + i); } final String pattern = "Before text. {0} After text."; MessageFormat m = new MessageFormat(pattern); final Format fmt = new ComboBoxApp.MyMessageFormat(m); //Set format string converter new GetAction<Object>() { @Override public void run(Object... parameters) throws Exception { testedControl.getControl().setConverter(new FormatStringConverter<String>(fmt)); //populate control testedControl.getControl().getItems().addAll(testedValues); } }.dispatch(Root.ROOT.getEnvironment()); setPropertyByToggleClick(SettingType.SETTER, Properties.editable, true); //#toString for (int i = 0; i < testedValues.size(); i++) { testedControl.as(Selectable.class).selector().select(testedValues.get(i)); assertEquals(getTextFieldText(), fmt.format(testedValues.get(i))); } //#fromString for (int i = 0; i < testedValues.size(); i++) { testedControl.as(Text.class).clear(); testedControl.as(Text.class).type(fmt.format(testedValues.get(i))); testedControl.keyboard().pushKey(KeyboardButtons.ENTER); checkTextFieldText(Properties.value, testedValues.get(i)); } doNextResetHard(); }