diff --git a/.travis.yml b/.travis.yml index 9ecca7d3c..4760cc98d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,8 +35,8 @@ before_script: - if [[ "${TRAVIS_OS_NAME}" == linux ]]; then export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start; fi script: - - gradle assemble - - gradle check --info --stacktrace + - ./gradlew assemble + - ./gradlew check --info --stacktrace # See https://docs.travis-ci.com/user/languages/java/#Caching before_cache: diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..42bde5ae5 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,23 @@ +# Adapted from TestFX +version: "{branch} {build}" + +environment: + JAVA_HOME: C:\Program Files\Java\jdk1.8.0 + matrix: + - JAVA_OPTS: "" + - JAVA_OPTS: "-Djava.awt.headless=true -Dtestfx.robot=glass -Dtestfx.headless=true -Dprism.order=sw -Dprism.text=t2k -Dtestfx.setup.timeout=2500" + +shallow_clone: true + +build: + verbosity: detailed + +build_script: + - cmd: java -version + - cmd: gradlew.bat --version --no-daemon + +test_script: + - gradlew.bat check --info --stacktrace --no-daemon + +cache: +- C:\Users\appveyor\.gradle \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..736fb7d3f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..4c1b12730 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip +distributionSha256Sum=515dd63d32e55a9c05667809c5e40a947529de3054444ad274b3b75af5582eae diff --git a/gradlew b/gradlew new file mode 100755 index 000000000..cccdd3d51 --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 000000000..f9553162f --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/richtextfx/build.gradle b/richtextfx/build.gradle index d53d1a313..6ffaf80d5 100644 --- a/richtextfx/build.gradle +++ b/richtextfx/build.gradle @@ -30,9 +30,9 @@ dependencies { compile (group: 'org.fxmisc.flowless', name: 'flowless', version: '0.6-SNAPSHOT') compile group: 'org.fxmisc.wellbehaved', name: 'wellbehavedfx', version: '0.3' - testCompile group: 'junit', name: 'junit', version: '[4.0,5)' + testCompile group: 'junit', name: 'junit', version: '4.12' - integrationTestCompile group: 'junit', name: 'junit', version: '[4.0,)' + integrationTestCompile group: 'junit', name: 'junit', version: '4.12' integrationTestCompile group: 'com.nitorcreations', name: 'junit-runners', version: '1.2' integrationTestCompile "org.testfx:testfx-core:4.0.6-alpha" integrationTestCompile ("org.testfx:testfx-junit:4.0.6-alpha") { diff --git a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/RichTextFXTestBase.java b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/RichTextFXTestBase.java index 67a20f8bf..6e2e2dee4 100644 --- a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/RichTextFXTestBase.java +++ b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/RichTextFXTestBase.java @@ -24,6 +24,12 @@ public abstract class RichTextFXTestBase extends ApplicationTest { static { + String robotProperty = System.getProperty("testfx.robot"); + boolean usingGlass = robotProperty != null && robotProperty.equals("glass"); + + USING_GLASS_ADAPTER = usingGlass; + USING_AWT_ADAPTER = !usingGlass; + String osName = System.getProperty("os.name").toLowerCase(); IS_WINDOWS = osName.startsWith("win"); @@ -31,6 +37,21 @@ public abstract class RichTextFXTestBase extends ApplicationTest { IS_LINUX = osName.startsWith("linux"); } + /* *********************************************** * + * TestFX--Related + * *********************************************** */ + + public static final boolean USING_AWT_ADAPTER; + public static final boolean USING_GLASS_ADAPTER; + + public final void skip_if_using_glass_robot() { + assumeTrue(USING_AWT_ADAPTER); + } + + public final void skip_if_using_awt_robot() { + assumeTrue(USING_GLASS_ADAPTER); + } + /* *********************************************** * * OS-RELATED * *********************************************** */ diff --git a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/api/UndoManagerTests.java b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/api/UndoManagerTests.java index 3187e314c..441ab0ddc 100644 --- a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/api/UndoManagerTests.java +++ b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/api/UndoManagerTests.java @@ -1,28 +1,94 @@ package org.fxmisc.richtext.api; +import com.nitorcreations.junit.runners.NestedRunner; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.stage.Stage; import org.fxmisc.richtext.InlineCssTextAreaAppTest; +import org.fxmisc.richtext.RichTextFXTestBase; +import org.fxmisc.richtext.StyledTextArea; +import org.fxmisc.richtext.model.SimpleEditableStyledDocument; import org.fxmisc.richtext.util.UndoUtils; import org.junit.Test; +import org.junit.runner.RunWith; +import org.testfx.framework.junit.ApplicationTest; import static org.junit.Assert.assertEquals; -public class UndoManagerTests extends InlineCssTextAreaAppTest { +@RunWith(NestedRunner.class) +public class UndoManagerTests { - @Test - public void incoming_change_is_not_merged_after_period_of_user_inactivity() { - String text1 = "text1"; - String text2 = "text2"; + public class UsingInlineCssTextArea extends InlineCssTextAreaAppTest { - long periodOfUserInactivity = UndoUtils.DEFAULT_PREVENT_MERGE_DELAY.toMillis() + 300L; + @Test + public void incoming_change_is_not_merged_after_period_of_user_inactivity() { + String text1 = "text1"; + String text2 = "text2"; - write(text1); - sleep(periodOfUserInactivity); - write(text2); + long periodOfUserInactivity = UndoUtils.DEFAULT_PREVENT_MERGE_DELAY.toMillis() + 300L; - interact(area::undo); - assertEquals(text1, area.getText()); + write(text1); + sleep(periodOfUserInactivity); + write(text2); + + interact(area::undo); + assertEquals(text1, area.getText()); + + interact(area::undo); + assertEquals("", area.getText()); + } + + @Test + public void testUndoWithWinNewlines() { + String text1 = "abc\r\ndef"; + String text2 = "A\r\nB\r\nC"; + + interact(() -> { + area.replaceText(text1); + area.getUndoManager().forgetHistory(); + area.insertText(0, text2); + assertEquals("A\nB\nCabc\ndef", area.getText()); + + area.undo(); + assertEquals("abc\ndef", area.getText()); + }); + } + + } + + public class UsingStyledTextArea extends RichTextFXTestBase { + + @Override + public void start(Stage stage) throws Exception { + stage.setScene(new Scene(new Label("Ignore me..."), 400, 400)); + stage.show(); + } + + @Test + public void testForBug216() { + interact(() -> { + // set up area with some styled text content + boolean initialStyle = false; + StyledTextArea area = new StyledTextArea<>( + "", (t, s) -> {}, + initialStyle, (t, s) -> {}, + new SimpleEditableStyledDocument<>("", initialStyle), true + ); + area.replaceText("testtest"); + area.setStyle(0, 8, true); + + // add a space styled by initialStyle + area.setUseInitialStyleForInsertion(true); + area.insertText(4, " "); + + // add another space + area.insertText(5, " "); + + // testing that undo/redo don't throw an exception + area.undo(); + area.redo(); + }); + } - interact(area::undo); - assertEquals("", area.getText()); } } diff --git a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/CutCopyPasteTests.java b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/CutCopyPasteTests.java index 3909db2f4..242d91114 100644 --- a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/CutCopyPasteTests.java +++ b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/CutCopyPasteTests.java @@ -17,6 +17,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertTrue; +import static org.junit.Assume.assumeFalse; @RunWith(NestedRunner.class) public class CutCopyPasteTests extends InlineCssTextAreaAppTest { @@ -56,6 +57,8 @@ public void insureClipboardHasNoContent() { @Test public void copy() { + assumeFalse(USING_AWT_ADAPTER && IS_WINDOWS); + press(COPY); runAssert(); @@ -85,6 +88,8 @@ private void runAssert() { @Test public void cut() { + assumeFalse(USING_AWT_ADAPTER && IS_WINDOWS); + press(CUT); runAssert(); diff --git a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/navigation/MultiLineGridlikeTextTests.java b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/navigation/MultiLineGridlikeTextTests.java index 6afc0ba0e..b1b4b35da 100644 --- a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/navigation/MultiLineGridlikeTextTests.java +++ b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/navigation/MultiLineGridlikeTextTests.java @@ -6,11 +6,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.testfx.util.WaitForAsyncUtils; - -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import static javafx.scene.input.KeyCode.DOWN; import static javafx.scene.input.KeyCode.END; @@ -48,18 +43,6 @@ private void moveCaretTo(int position) { area.moveTo(position); } - private void waitForMultiLineRegistration() throws TimeoutException { - // When the stage's width changes, TextFlow does not properly handle API calls to a - // multi-line paragraph immediately. So, wait until it correctly responds - // to the stage width change - Future textFlowIsReady = WaitForAsyncUtils.asyncFx(() -> { - while (area.getParagraphLinesCount(0) != lines.length) { - sleep(10); - } - }); - WaitForAsyncUtils.waitFor(5, TimeUnit.SECONDS, textFlowIsReady); - } - @Override public void start(Stage stage) throws Exception { super.start(stage); @@ -76,11 +59,6 @@ public void start(Stage stage) throws Exception { public class When_No_Modifiers_Pressed { - @Before - public void setup() throws TimeoutException { - waitForMultiLineRegistration(); - } - @Test public void up_moves_caret_to_previous_line() { moveCaretTo(lineStart(2)); @@ -130,9 +108,7 @@ public void end_moves_caret_to_end_of_current_line() { public class When_Shortcut_Is_Pressed { @Before - public void setup() throws TimeoutException { - waitForMultiLineRegistration(); - + public void setup() { press(SHORTCUT); } @@ -185,9 +161,7 @@ public void end_moves_caret_to_end_of_current_paragraph() { public class When_Shift_Is_Pressed { @Before - public void setup() throws TimeoutException { - waitForMultiLineRegistration(); - + public void setup() { press(SHIFT); } @@ -240,9 +214,7 @@ public void end_selects_up_to_the_end_of_current_line() { public class When_Shortcut_And_Shift_Pressed { @Before - public void setup() throws TimeoutException { - waitForMultiLineRegistration(); - + public void setup() { press(SHORTCUT, SHIFT); } diff --git a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/navigation/MultiLineJaggedTextTests.java b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/navigation/MultiLineJaggedTextTests.java index 9a76fc5af..4394bd061 100644 --- a/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/navigation/MultiLineJaggedTextTests.java +++ b/richtextfx/src/integrationTest/java/org/fxmisc/richtext/keyboard/navigation/MultiLineJaggedTextTests.java @@ -2,12 +2,9 @@ import javafx.stage.Stage; import org.fxmisc.richtext.InlineCssTextAreaAppTest; +import org.junit.Rule; import org.junit.Test; -import org.testfx.util.WaitForAsyncUtils; - -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; +import org.junit.rules.Timeout; import static javafx.scene.input.KeyCode.DOWN; import static javafx.scene.input.KeyCode.UP; @@ -15,6 +12,9 @@ public class MultiLineJaggedTextTests extends InlineCssTextAreaAppTest { + @Rule + public Timeout globalTimeout = Timeout.seconds(10); + String threeLinesOfText = "Some long amount of text to take up a lot of space in the given area."; @Override @@ -25,37 +25,24 @@ public void start(Stage stage) throws Exception { area.setWrapText(true); } - private void waitForMultiLineRegistration() throws TimeoutException { - // When the stage's width changes, TextFlow does not properly handle API calls to a - // multi-line paragraph immediately. So, wait until it correctly responds - // to the stage width change - Future textFlowIsReady = WaitForAsyncUtils.asyncFx(() -> { - while (area.getParagraphLinesCount(0) != 3) { - sleep(10); - } - }); - WaitForAsyncUtils.waitFor(5, TimeUnit.SECONDS, textFlowIsReady); - } - @Test - public void pressing_down_moves_caret_to_next_line() throws TimeoutException { - waitForMultiLineRegistration(); - - area.moveTo(27); + public void pressing_down_moves_caret_to_next_line() { + area.moveTo(0); + assertEquals(0, area.getCaretSelectionBind().getLineIndex().getAsInt()); push(DOWN); - assertEquals(57, area.getCaretPosition()); + assertEquals(1, area.getCaretSelectionBind().getLineIndex().getAsInt()); } @Test - public void pressing_up_moves_caret_to_previous_line() throws TimeoutException { - waitForMultiLineRegistration(); - - area.moveTo(66); + public void pressing_up_moves_caret_to_previous_line() { + area.moveTo(area.getLength()); + int lastLineIndex = area.getParagraphLinesCount(0) - 1; + assertEquals(lastLineIndex, area.getCaretSelectionBind().getLineIndex().getAsInt()); push(UP); - assertEquals(36, area.getCaretPosition()); + assertEquals(lastLineIndex - 1, area.getCaretSelectionBind().getLineIndex().getAsInt()); } } diff --git a/richtextfx/src/test/java/org/fxmisc/richtext/model/UndoManagerTest.java b/richtextfx/src/test/java/org/fxmisc/richtext/model/UndoManagerTest.java deleted file mode 100644 index 065bd8db3..000000000 --- a/richtextfx/src/test/java/org/fxmisc/richtext/model/UndoManagerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.fxmisc.richtext.model; - -import org.fxmisc.richtext.InlineCssTextArea; -import org.fxmisc.richtext.StyledTextArea; -import org.junit.Test; - -import java.util.Collection; - -import static org.junit.Assert.assertEquals; - -public class UndoManagerTest { - - private InlineCssTextArea area = new InlineCssTextArea(); - - @Test - public void testUndoWithWinNewlines() { - final TextOps> segOps = SegmentOps.styledTextOps(); - - String text1 = "abc\r\ndef"; - String text2 = "A\r\nB\r\nC"; - - area.replaceText(text1); - area.getUndoManager().forgetHistory(); - area.insertText(0, text2); - assertEquals("A\nB\nCabc\ndef", area.getText()); - - area.undo(); - assertEquals("abc\ndef", area.getText()); - } - - @Test - public void testForBug216() { - final TextOps segOps = SegmentOps.styledTextOps(); - - // set up area with some styled text content - boolean initialStyle = false; - StyledTextArea area = new StyledTextArea<>( - "", (t, s) -> {}, initialStyle, (t, s) -> {}, - new SimpleEditableStyledDocument<>("", initialStyle), true); - area.replaceText("testtest"); - area.setStyle(0, 8, true); - - // add a space styled by initialStyle - area.setUseInitialStyleForInsertion(true); - area.insertText(4, " "); - - // add another space - area.insertText(5, " "); - - // testing that undo/redo don't throw an exception - area.undo(); - area.redo(); - } -}