-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bug: getVisibleParagraph does not work with blank lines * trim paragraphs using reference instead of object comparison (issues #777 and #788)
- Loading branch information
1 parent
fa72c42
commit 6d49399
Showing
2 changed files
with
225 additions
and
1 deletion.
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
richtextfx/src/integrationTest/java/org/fxmisc/richtext/api/VisibleParagraphTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package org.fxmisc.richtext.api; | ||
|
||
import org.fxmisc.richtext.InlineCssTextAreaAppTest; | ||
import org.fxmisc.richtext.model.Paragraph; | ||
import org.junit.Test; | ||
import org.junit.Assert; | ||
import org.reactfx.collection.LiveList; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
public class VisibleParagraphTest extends InlineCssTextAreaAppTest { | ||
|
||
@Test | ||
public void get_first_visible_paragraph_index_with_non_blank_lines() { | ||
String[] lines = { | ||
"abc", | ||
"def", | ||
"ghi" | ||
}; | ||
interact(() -> { | ||
area.setWrapText(true); | ||
stage.setWidth(120); | ||
area.replaceText(String.join("\n", lines)); | ||
}); | ||
assertEquals(0, area.firstVisibleParToAllParIndex()); | ||
assertEquals(2, area.lastVisibleParToAllParIndex()); | ||
assertEquals(1, area.visibleParToAllParIndex(1)); | ||
} | ||
@Test | ||
public void get_last_visible_paragraph_index_with_non_blank_lines() { | ||
String[] lines = { | ||
"abc", | ||
"def", | ||
"ghi" | ||
}; | ||
interact(() -> { | ||
area.setWrapText(true); | ||
stage.setWidth(120); | ||
area.replaceText(String.join("\n", lines)); | ||
}); | ||
assertEquals(2, area.lastVisibleParToAllParIndex()); | ||
} | ||
@Test | ||
public void get_specific_visible_paragraph_index_with_non_blank_lines() { | ||
String[] lines = { | ||
"abc", | ||
"def", | ||
"ghi" | ||
}; | ||
interact(() -> { | ||
area.setWrapText(true); | ||
stage.setWidth(120); | ||
area.replaceText(String.join("\n", lines)); | ||
}); | ||
assertEquals(2, area.visibleParToAllParIndex(2)); | ||
} | ||
@Test | ||
public void get_first_visible_paragraph_index_with_all_blank_lines() { | ||
String[] lines = { | ||
"", | ||
"", | ||
"" | ||
}; | ||
interact(() -> { | ||
area.setWrapText(true); | ||
stage.setWidth(120); | ||
area.replaceText(String.join("\n", lines)); | ||
}); | ||
assertEquals(0, area.firstVisibleParToAllParIndex()); | ||
} | ||
@Test | ||
public void get_last_visible_paragraph_index_with_all_blank_lines() { | ||
String[] lines = { | ||
"", | ||
"", | ||
"" | ||
}; | ||
interact(() -> { | ||
area.setWrapText(true); | ||
stage.setWidth(120); | ||
area.replaceText(String.join("\n", lines)); | ||
}); | ||
assertEquals(2, area.lastVisibleParToAllParIndex()); | ||
} | ||
@Test | ||
public void get_specific_visible_paragraph_index_with_all_blank_lines() { | ||
String[] lines = { | ||
"", | ||
"", | ||
"" | ||
}; | ||
interact(() -> { | ||
area.setWrapText(true); | ||
stage.setWidth(120); | ||
area.replaceText(String.join("\n", lines)); | ||
}); | ||
assertEquals(2, area.visibleParToAllParIndex(2)); | ||
} | ||
|
||
@Test | ||
public void get_first_visible_paragraph_index_with_some_blank_lines() { | ||
String[] lines = { | ||
"abc", | ||
"", | ||
"", | ||
"", | ||
"def", | ||
"" | ||
}; | ||
interact(() -> { | ||
area.setWrapText(true); | ||
stage.setWidth(120); | ||
area.replaceText(String.join("\n", lines)); | ||
}); | ||
assertEquals(0, area.firstVisibleParToAllParIndex()); | ||
} | ||
@Test | ||
public void get_last_visible_paragraph_index_with_some_blank_lines() { | ||
String[] lines = { | ||
"abc", | ||
"", | ||
"", | ||
"", | ||
"def", | ||
"" | ||
}; | ||
interact(() -> { | ||
area.setWrapText(true); | ||
stage.setWidth(120); | ||
area.replaceText(String.join("\n", lines)); | ||
}); | ||
assertEquals(5, area.lastVisibleParToAllParIndex()); | ||
} | ||
@Test | ||
public void get_specific_visible_paragraph_index_with_some_blank_lines() { | ||
String[] lines = { | ||
"abc", | ||
"", | ||
"", | ||
"", | ||
"def", | ||
"" | ||
}; | ||
interact(() -> { | ||
area.setWrapText(true); | ||
stage.setWidth(120); | ||
area.replaceText(String.join("\n", lines)); | ||
}); | ||
assertEquals(3, area.visibleParToAllParIndex(3)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters