Skip to content

Commit 76788db

Browse files
committed
2nd attempt to fix unit test for previous commit (select moved text after drag-and-drop)
1 parent 51b2edf commit 76788db

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

richtextfx/src/integrationTest/java/org/fxmisc/richtext/mouse/ClickAndDragTests.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public class AndTextIsSelected extends InlineCssTextAreaAppTest {
132132

133133
private String firstWord = "Some";
134134
private String firstParagraph = firstWord + " text goes here";
135+
private String extraText = "This is extra text";
135136

136137
@Test
137138
public void singleClickingWithinSelectedTextMovesCaretToThatPosition() {
@@ -238,38 +239,40 @@ public void pressingMouseOnUnselectedTextAndDraggingMakesNewSelection() {
238239
public void pressingMouseOnSelectionAndDraggingDisplacesCaret() {
239240
// setup
240241
interact(() -> {
241-
area.replaceText(firstParagraph + "\n" + "This is extra text");
242+
area.replaceText(firstParagraph + "\n" + extraText);
242243
area.selectRange(0, firstWord.length());
243244
});
244245

245246
String selText = area.getSelectedText();
246-
int caretPos = area.getCaretPosition();
247247

248248
moveTo(firstLineOfArea())
249249
.press(PRIMARY)
250-
.moveBy(0, 14);
250+
.moveBy(0, 22);
251251

252-
assertTrue(caretPos != area.getCaretPosition());
252+
assertEquals(firstParagraph.length() + 1, area.getCaretPosition());
253253
assertEquals(selText, area.getSelectedText());
254254
}
255255

256256
@Test
257257
public void pressingMouseOnSelectionAndDraggingAndReleasingMovesSelectedTextToThatPosition() {
258258
// setup
259259
interact(() -> {
260-
area.replaceText(firstParagraph + "\n" + "This is extra text");
260+
area.replaceText(firstParagraph + "\n" + extraText);
261261
area.selectRange(0, firstWord.length());
262262
});
263263

264264
String selText = area.getSelectedText();
265-
int caretPos = area.getCaretPosition();
266265

267266
moveTo(firstLineOfArea())
268267
.press(PRIMARY)
269-
.dropBy(0, 14);
268+
.dropBy(0, 22);
270269

271-
assertTrue(caretPos != area.getCaretPosition());
270+
String expectedText = firstParagraph.substring(firstWord.length())
271+
+ "\n" + firstWord + extraText;
272+
273+
assertEquals(firstParagraph.length() + 1, area.getCaretPosition());
272274
assertEquals(selText, area.getSelectedText());
275+
assertEquals(expectedText, area.getText());
273276
}
274277

275278
}

0 commit comments

Comments
 (0)