functional/ControlsTests/test/javafx/scene/control/test/textinput/TextInputBase.java

Print this page

        

*** 23,33 **** * questions. */ package javafx.scene.control.test.textinput; import client.test.ScreenshotCheck; ! import com.sun.javafx.scene.control.skin.TextInputControlSkin; import java.lang.reflect.Field; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; --- 23,33 ---- * questions. */ package javafx.scene.control.test.textinput; import client.test.ScreenshotCheck; ! import javafx.scene.control.skin.TextInputControlSkin; import java.lang.reflect.Field; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map;
*** 80,90 **** { ScreenshotUtils.setComparatorDistance(0.003f); } private Wrap<? extends TextInputControl> taTesting = null; ! static final KeyboardModifiers CTRL = Utils.isMacOS() ? KeyboardModifiers.META_DOWN_MASK : KeyboardModifiers.CTRL_DOWN_MASK; // /** // * Test for TextInput setMaximumLength API // */ // @ScreenshotCheck // @Test(timeout=300000) --- 80,90 ---- { ScreenshotUtils.setComparatorDistance(0.003f); } private Wrap<? extends TextInputControl> taTesting = null; ! static final KeyboardModifiers CTRL = Utils.isMacOS() ? KeyboardModifiers.ALT_DOWN_MASK : KeyboardModifiers.CTRL_DOWN_MASK; // /** // * Test for TextInput setMaximumLength API // */ // @ScreenshotCheck // @Test(timeout=300000)
*** 521,530 **** --- 521,531 ---- checkClipboard(SAMPLE_STRING); checkText(text, ""); } else { checkState("Copy", true); checkState("Cut", true); + getScene().keyboard().pushKey(KeyboardButtons.ESCAPE); } initContext(); getMenuItem("Delete").mouse().click(); checkText(text, "");
*** 609,624 **** click(taTesting); end(); String text = getTextFromControl(); final String initialText = text; - while (!"".equals(text)) { - text = deleteLastWord(text); - taTesting.keyboard().pushKey(Keyboard.KeyboardButtons.BACK_SPACE, CTRL); if (isPasswordField()) { Assert.assertEquals(initialText, getTextFromControl()); } else { if (!text.equals(getTextFromControl())) { out(initialText, text); } Assert.assertEquals(text, getTextFromControl()); } --- 610,630 ---- click(taTesting); end(); String text = getTextFromControl(); final String initialText = text; if (isPasswordField()) { + taTesting.keyboard().pushKey(Keyboard.KeyboardButtons.BACK_SPACE, CTRL); + if (Utils.isMacOS()) { + Assert.assertEquals("", getTextFromControl()); + } else { Assert.assertEquals(initialText, getTextFromControl()); + } } else { + while (!text.isEmpty()) { + text = deleteLastWord(text); + taTesting.keyboard().pushKey(Keyboard.KeyboardButtons.BACK_SPACE, CTRL); if (!text.equals(getTextFromControl())) { out(initialText, text); } Assert.assertEquals(text, getTextFromControl()); }
*** 631,641 **** click(taTesting); home(); String text = getTextFromControl(); final String initialText = text; while (!"".equals(text)) { ! text = deleteFirstWord(text, true); taTesting.keyboard().pushKey(Keyboard.KeyboardButtons.DELETE, CTRL); if (isPasswordField()) { Assert.assertEquals(initialText, getTextFromControl()); } else { if (!text.equals(getTextFromControl())) { --- 637,647 ---- click(taTesting); home(); String text = getTextFromControl(); final String initialText = text; while (!"".equals(text)) { ! text = deleteFirstWord(text, Utils.isMacOS() ? false : true); taTesting.keyboard().pushKey(Keyboard.KeyboardButtons.DELETE, CTRL); if (isPasswordField()) { Assert.assertEquals(initialText, getTextFromControl()); } else { if (!text.equals(getTextFromControl())) {
*** 672,704 **** * @param text initial string * @param deleteFromBeginning flag which shows how deletion is performed. * @return string without first word. */ private String deleteFirstWord(String text, boolean deleteFromBeginning) { ! final String[] punctuation = new String[]{" ", "\n", "\t", "/", ",", ";", "!", "@", "#", "$", "%", "^", "*", "(", ")", "&", "."}; if (!deleteFromBeginning) { while (startsWithAnyOf(text, punctuation)) { text = text.substring(1); } text = removeLeadingChars(text, punctuation); } else { ! if (!Utils.isWindows()) { if (' ' == text.charAt(0)) { int pos = 0; while(' ' == text.charAt(pos)) ++pos; text = text.substring(pos); } else if (startsWithAnyOf(text, punctuation)) { text = text.substring(1); } } text = removeLeadingChars(text, punctuation); ! while (startsWithAnyOf(text, punctuation)) { ! if (!Utils.isWindows()) { ! break; } text = text.substring(1); } } return text; } --- 678,719 ---- * @param text initial string * @param deleteFromBeginning flag which shows how deletion is performed. * @return string without first word. */ private String deleteFirstWord(String text, boolean deleteFromBeginning) { ! final String[] punctuation = new String[] {" ", "\n", "\t", "/", ",", ";", "!", "@", "#", "$", "%", "^", "*", "(", ")", "&", "."}; ! if (!deleteFromBeginning) { while (startsWithAnyOf(text, punctuation)) { text = text.substring(1); } text = removeLeadingChars(text, punctuation); } else { ! if (Utils.isLinux()) { if (' ' == text.charAt(0)) { int pos = 0; while(' ' == text.charAt(pos)) ++pos; text = text.substring(pos); } else if (startsWithAnyOf(text, punctuation)) { text = text.substring(1); } } + if ('\n' == text.charAt(0)) { + text = text.substring(1); + return text; + } + text = removeLeadingChars(text, punctuation); ! if ('\n' == text.charAt(0)) { ! return text; ! } ! if (Utils.isLinux()) { ! return text; } + while (startsWithAnyOf(text, punctuation)) { text = text.substring(1); } } return text; }
*** 735,745 **** protected void initContext() { final Wrap<? extends TextInputControl> wrap = getScene().as(Parent.class, Node.class).lookup(TextInputControl.class).wrap(); wrap.as(Text.class).clear(); wrap.as(Text.class).type(SAMPLE_STRING); ! wrap.keyboard().pushKey(KeyboardButtons.A, Utils.isMacOS() ? KeyboardModifiers.META_DOWN_MASK : CTRL); new GetAction() { @Override public void run(Object... os) throws Exception { Clipboard.getSystemClipboard().clear(); } --- 750,760 ---- protected void initContext() { final Wrap<? extends TextInputControl> wrap = getScene().as(Parent.class, Node.class).lookup(TextInputControl.class).wrap(); wrap.as(Text.class).clear(); wrap.as(Text.class).type(SAMPLE_STRING); ! wrap.keyboard().pushKey(KeyboardButtons.A, Utils.isMacOS() ? KeyboardModifiers.META_DOWN_MASK : KeyboardModifiers.CTRL_DOWN_MASK); new GetAction() { @Override public void run(Object... os) throws Exception { Clipboard.getSystemClipboard().clear(); }