< prev index next >
functional/ControlsTests/test/javafx/scene/control/test/textinput/TextInputBase.java
Print this page
@@ -23,11 +23,11 @@
* questions.
*/
package javafx.scene.control.test.textinput;
import client.test.ScreenshotCheck;
-import com.sun.javafx.scene.control.skin.TextInputControlSkin;
+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,11 +80,11 @@
{
ScreenshotUtils.setComparatorDistance(0.003f);
}
private Wrap<? extends TextInputControl> taTesting = null;
- static final KeyboardModifiers CTRL = Utils.isMacOS() ? KeyboardModifiers.META_DOWN_MASK : KeyboardModifiers.CTRL_DOWN_MASK;
+ static final KeyboardModifiers CTRL = Utils.isMacOS() ? KeyboardModifiers.ALT_DOWN_MASK : KeyboardModifiers.CTRL_DOWN_MASK;
// /**
// * Test for TextInput setMaximumLength API
// */
// @ScreenshotCheck
// @Test(timeout=300000)
@@ -521,10 +521,11 @@
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,16 +610,21 @@
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()) {
+ 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,11 +637,11 @@
click(taTesting);
home();
String text = getTextFromControl();
final String initialText = text;
while (!"".equals(text)) {
- text = deleteFirstWord(text, true);
+ 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,33 +678,42 @@
* @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", "/", ",", ";", "!", "@", "#", "$", "%", "^", "*", "(", ")", "&", "."};
+ 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 (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);
- while (startsWithAnyOf(text, punctuation)) {
- if (!Utils.isWindows()) {
- break;
+ if ('\n' == text.charAt(0)) {
+ return text;
+ }
+ if (Utils.isLinux()) {
+ return text;
}
+ while (startsWithAnyOf(text, punctuation)) {
text = text.substring(1);
}
}
return text;
}
@@ -735,11 +750,11 @@
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);
+ 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();
}
< prev index next >