--- old/functional/ControlsTests/test/javafx/scene/control/test/textinput/TextInputBase.java 2016-12-22 11:26:33.589119279 +0300 +++ new/functional/ControlsTests/test/javafx/scene/control/test/textinput/TextInputBase.java 2016-12-22 11:26:33.537118777 +0300 @@ -1,1013 +1,1028 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * 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; -import java.util.logging.Level; -import java.util.logging.Logger; -import javafx.beans.property.BooleanProperty; -import javafx.scene.Node; -import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.scene.control.Control; -import javafx.scene.control.MenuItem; -import javafx.scene.control.PasswordField; -import javafx.scene.control.TextInputControl; -import javafx.scene.control.test.Change; -import javafx.scene.control.test.mix.PopupMenuTest; -import javafx.scene.control.test.textinput.TextInputBaseApp.Pages; -import javafx.scene.control.test.textinput.TextInputChanger.TextInputControlWrapInterface; -import javafx.scene.control.test.textinput.TextInputChanger.TextInputPages; -import javafx.scene.input.Clipboard; -import javafx.scene.input.DataFormat; -import javafx.scene.layout.Pane; -import org.jemmy.Point; -import org.jemmy.action.GetAction; -import org.jemmy.control.Wrap; -import org.jemmy.fx.ByID; -import org.jemmy.fx.Root; -import org.jemmy.interfaces.Keyboard; -import org.jemmy.interfaces.Keyboard.KeyboardButtons; -import org.jemmy.interfaces.Keyboard.KeyboardModifiers; -import org.jemmy.interfaces.Mouse.MouseButtons; -import org.jemmy.interfaces.Parent; -import org.jemmy.interfaces.Text; -import org.jemmy.lookup.LookupCriteria; -import org.jemmy.timing.State; -import org.junit.Assert; -import static org.junit.Assert.*; -import org.junit.Test; -import org.junit.runner.RunWith; -import test.javaclient.shared.FilteredTestRunner; -import test.javaclient.shared.TestBase; -import test.javaclient.shared.Utils; -import test.javaclient.shared.screenshots.ScreenshotUtils; - -/** - * @author Oleg Barbashov - */ -@RunWith(FilteredTestRunner.class) -public class TextInputBase extends TestBase { - - { - ScreenshotUtils.setComparatorDistance(0.003f); - } - private Wrap 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) -// public void maximumLengthTest() throws InterruptedException, Throwable { -// openPage(Pages.MaximumLength.name()); -// -// verifyFailures(); -// -// Parent parent = scene.as(Parent.class, Node.class); -// Lookup lookup = parent.lookup(TextInput.class); -// for (int i = 0; i < lookup.size(); i++) { -// final Wrap wrap = lookup.wrap(i); -// final Integer maximumLength = new GetAction() { -// @Override -// public void run(Object... parameters) { -// setResult(wrap.getControl().getMaximumLength()); -// } -// }.dispatch(Root.ROOT.getEnvironment()); -// Text text = wrap.as(Text.class); -// long timeout = Wrap.WAIT_STATE_TIMEOUT.getValue(); -// String str = createLongString(maximumLength + 2); -// try { -// text.type(str); -// } catch (Exception ex) { -// // expected as text length is limited but Jemmy does not expect limitation and wait for all sequence -// } -// Wrap.WAIT_STATE_TIMEOUT.setValue(timeout); -// wrap.waitProperty(Wrap.TEXT_PROP_NAME, str.subSequence(0, maximumLength)); -// } -// checkScreenshot(getClass().getSimpleName() + "-" + Pages.MaximumLength.name()); -// throwScreenshotError(); -// } - /** - * Test for backward API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void backwardInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.backward.name(), true); - } - - /** - * Test for copy API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void copyInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.copy.name(), true); - } - - /** - * Test for cut API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void cutInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.cut.name(), true); - } - - /** - * Test for deleteNextChar API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void deleteNextCharInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.deleteNextChar.name(), true); - } - - /** - * Test for deletePreviousChar API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void deletePreviousCharInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.deletePreviousChar.name(), true); - } - - /** - * Test for end API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void endInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.end.name(), true); - } - - /** - * Test for forward API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void forwardInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.forward.name(), true); - } - - /** - * Test for home API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void homeInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.home.name(), true); - } - - /** - * Test for isEditableTextBoxWrap API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void isEditableTextBoxWrapInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.isEditable.name(), true); - } - - /** - * Test for nextWord API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void nextWordInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.nextWord.name(), true); - } - - /** - * Test for paste API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void pasteInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.paste.name(), true); - } - - /** - * Test for positionCaret API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void positionCaretInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.positionCaret.name(), true); - } - - /** - * Test for previousWord API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void previousWordInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.previousWord.name(), true); - } - - /** - * Test for selectAll API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectAllInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectAll.name(), true); - } - - /** - * Test for selectBackward API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectBackwardInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectBackward.name(), true); - } - - /** - * Test for selectEnd API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectEndInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectEnd.name(), true); - } - - /** - * Test for selectForward API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectForwardInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectForward.name(), true); - } - - /** - * Test for selectHome API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectHomeInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectHome.name(), true); - } - - /** - * Test for selectNext API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectNextWordInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectNextWord.name(), true); - } - - /** - * Test for selectPreviousWord API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectPreviousWordInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectPreviousWord.name(), true); - } - - /** - * Test for setText API - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void setTextInternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.setText.name(), true); - } - - /** - * Test for backward API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void backwardExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.backward.name(), false); - } - - /** - * Test for copy API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void copyExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.copy.name(), false); - } - - /** - * Test for cut API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void cutExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.cut.name(), false); - } - - /** - * Test for deleteNextChar API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void deleteNextCharExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.deleteNextChar.name(), false); - } - - /** - * Test for deletePreviousChar API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void deletePreviousCharExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.deletePreviousChar.name(), false); - } - - /** - * Test for end API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void endExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.end.name(), false); - } - - /** - * Test for forward API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void forwardExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.forward.name(), false); - } - - /** - * Test for home API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void homeExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.home.name(), false); - } - - /** - * Test for isEditableTextBoxWrap API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void isEditableTextBoxWrapExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.isEditable.name(), false); - } - - /** - * Test for nextWord API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void nextWordExternalTest() throws InterruptedException { - if (Utils.isMacOS()) { - textInputControlInput(TextInputPages.macNextWordExternal.name(), false); - } else { - textInputControlInput(TextInputPages.nextWord.name(), false); - } - } - - /** - * Test for paste API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void pasteExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.paste.name(), false); - } - - /** - * Test for positionCaret API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void positionCaretExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.positionCaret.name(), false); - } - - /** - * Test for previousWord API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void previousWordExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.previousWord.name(), false); - } - - /** - * Test for selectAll API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectAllExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectAll.name(), false); - } - - /** - * Test for selectBackward API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectBackwardExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectBackward.name(), false); - } - - /** - * Test for selectEnd API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectEndExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectEnd.name(), false); - } - - /** - * Test for selectForward API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectForwardExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectForward.name(), false); - } - - /** - * Test for selectHome API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectHomeExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectHome.name(), false); - } - - /** - * Test for selectNext API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectNextWordExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectNextWord.name(), false); - } - - /** - * Test for selectPreviousWord API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void selectPreviousWordExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.selectPreviousWord.name(), false); - } - - /** - * Test for setText API by simulating user input - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void setTextExternalTest() throws InterruptedException { - textInputControlInput(TextInputPages.setText.name(), false); - } - - /** - * Test for Context Menu - */ - @ScreenshotCheck - @Test(timeout = 300000) - public void contextMenuTest() throws InterruptedException { - openPage(Pages.InputTest.name()); - - final Wrap wrap = getScene().as(Parent.class, Node.class).lookup(TextInputControl.class).wrap(); - final Text text = wrap.as(Text.class); - - initContext(); - boolean password = PasswordField.class.isAssignableFrom(wrap.getControl().getClass()); - if (!password) { - getMenuItem("Select All").mouse().move(); - getMenuItem("Copy").mouse().click(); - checkClipboard(SAMPLE_STRING); - - getMenuItem("Cut").mouse().click(); - checkClipboard(SAMPLE_STRING); - checkText(text, ""); - } else { - checkState("Copy", true); - checkState("Cut", true); - } - - initContext(); - getMenuItem("Delete").mouse().click(); - checkText(text, ""); - - initContext(); - getMenuItem("Select All").mouse().click(); - getScene().waitState(new State() { - public Object reached() { - return wrap.getControl().getSelection().getLength() == SAMPLE_STRING.length() ? true : null; - } - }); - - initContext(); - final Map data_map = new HashMap(); - data_map.put(DataFormat.PLAIN_TEXT, SAMPLE_STRING); - - new GetAction() { - @Override - public void run(Object... os) throws Exception { - Clipboard.getSystemClipboard().setContent(data_map); - } - }.dispatch(Root.ROOT.getEnvironment()); - - getMenuItem("Paste").mouse().click(); - checkText(text, SAMPLE_STRING); - - wrap.keyboard().pushKey(KeyboardButtons.HOME); - checkState("Copy", true); - checkState("Cut", true); - checkState("Paste", false); - - new GetAction() { - @Override - public void run(Object... os) throws Exception { - Clipboard.getSystemClipboard().clear(); - } - }.dispatch(Root.ROOT.getEnvironment()); - - checkState("Paste", true); - checkState("Delete", true); - checkState("Select All", false); - } - - @ScreenshotCheck - @Test - public void ctrlBackspaceMultilineTest() { - openPage(Pages.CtrlBackspaceTest.name()); - Wrap btn = getScene().as(org.jemmy.interfaces.Parent.class, Node.class).lookup(new ByID