@@ -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,37 +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
264- int caretPos = area .getCaretPosition ();
264+ String selText = area .getSelectedText ();
265265
266266 moveTo (firstLineOfArea ())
267267 .press (PRIMARY )
268- .dropBy (0 , 14 );
268+ .dropBy (0 , 22 );
269269
270- assertTrue (caretPos != area .getCaretPosition ());
271- assertTrue (area .getSelectedText ().isEmpty ());
270+ String expectedText = firstParagraph .substring (firstWord .length ())
271+ + "\n " + firstWord + extraText ;
272+
273+ assertEquals (firstParagraph .length () + 1 , area .getCaretPosition ());
274+ assertEquals (selText , area .getSelectedText ());
275+ assertEquals (expectedText , area .getText ());
272276 }
273277
274278 }
0 commit comments