< prev index next >

modules/javafx.controls/src/test/java/test/javafx/scene/control/TextAreaTest.java

Print this page


   1 /*
   2  * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 464         assertEquals(dummyTxtArea.getParagraphs().size(), 2.0, 0.0);
 465     }
 466 
 467     @Test public void deleteNormalTextAndCheckParagraphContents() {
 468         dummyTxtArea.appendText("\nanother");
 469         dummyTxtArea.deleteText(0,5);//Retain the \n character
 470         assertEquals(dummyTxtArea.getParagraphs().get(0).toString(), "");
 471         assertEquals(dummyTxtArea.getParagraphs().get(1).toString(), "another");
 472     }
 473 
 474     @Test public void deleteParagraphAndCheckParagraphCount() {
 475         dummyTxtArea.appendText("\nanother");
 476         dummyTxtArea.deleteText(0,6);//This will delete a paragraph coz next line char is also deleted
 477         assertEquals(dummyTxtArea.getParagraphs().size(), 1.0, 0.0);
 478     }
 479 
 480     @Test public void deleteParagraphAndCheckParagraphContents() {
 481         dummyTxtArea.appendText("\nanother");
 482         dummyTxtArea.deleteText(0,6);
 483         assertEquals(dummyTxtArea.getParagraphs().get(0).toString(), "another");


























 484     }
 485 }
   1 /*
   2  * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 464         assertEquals(dummyTxtArea.getParagraphs().size(), 2.0, 0.0);
 465     }
 466 
 467     @Test public void deleteNormalTextAndCheckParagraphContents() {
 468         dummyTxtArea.appendText("\nanother");
 469         dummyTxtArea.deleteText(0,5);//Retain the \n character
 470         assertEquals(dummyTxtArea.getParagraphs().get(0).toString(), "");
 471         assertEquals(dummyTxtArea.getParagraphs().get(1).toString(), "another");
 472     }
 473 
 474     @Test public void deleteParagraphAndCheckParagraphCount() {
 475         dummyTxtArea.appendText("\nanother");
 476         dummyTxtArea.deleteText(0,6);//This will delete a paragraph coz next line char is also deleted
 477         assertEquals(dummyTxtArea.getParagraphs().size(), 1.0, 0.0);
 478     }
 479 
 480     @Test public void deleteParagraphAndCheckParagraphContents() {
 481         dummyTxtArea.appendText("\nanother");
 482         dummyTxtArea.deleteText(0,6);
 483         assertEquals(dummyTxtArea.getParagraphs().get(0).toString(), "another");
 484     }
 485 
 486     @Test public void test_jdk_8171229_replaceText() {
 487         txtArea.setText("");
 488         assertEquals("", txtArea.getText());
 489 
 490         txtArea.replaceText(0, 0, "a");
 491         assertEquals("a", txtArea.getText());
 492 
 493         txtArea.replaceText(1, 1, "b");
 494         assertEquals("ab", txtArea.getText());
 495 
 496         txtArea.replaceText(2, 2, "c");
 497         assertEquals("abc", txtArea.getText());
 498 
 499         txtArea.replaceText(3, 3, "d");
 500         assertEquals("abcd", txtArea.getText());
 501 
 502         txtArea.replaceText(3, 4, "efg");
 503         assertEquals("abcefg", txtArea.getText());
 504 
 505         txtArea.replaceText(3, 6, "d");
 506         assertEquals("abcd", txtArea.getText());
 507 
 508         txtArea.replaceText(0, 4, "");
 509         assertEquals("", txtArea.getText());
 510     }
 511 }
< prev index next >