modules/graphics/src/test/java/test/javafx/scene/layout/BackgroundImageTest.java

Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:


   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
  23  * questions.
  24  */
  25 
  26 package javafx.scene.layout;
  27 
  28 import javafx.geometry.Side;
  29 import javafx.scene.image.Image;



  30 import org.junit.Test;
  31 
  32 import static javafx.scene.layout.BackgroundRepeat.*;
  33 import static org.junit.Assert.*;
  34 
  35 /**
  36  */
  37 public class BackgroundImageTest {
  38     private static final BackgroundPosition POS_1 = new BackgroundPosition(Side.LEFT, .5, true, Side.TOP, 10, false);
  39     private static final BackgroundPosition POS_2 = BackgroundPosition.DEFAULT;
  40 
  41     private static final BackgroundSize SIZE_1 = new BackgroundSize(1, 1, true, true, false, true);
  42     private static final BackgroundSize SIZE_2 = BackgroundSize.DEFAULT;
  43 
  44     private static final Image IMAGE_1 = new Image("javafx/scene/layout/red.png");
  45     private static final Image IMAGE_2 = new Image("javafx/scene/layout/blue.png");
  46 
  47     @Test public void instanceCreation() {
  48         BackgroundImage image = new BackgroundImage(IMAGE_1, REPEAT, REPEAT, POS_1, SIZE_1);
  49         assertEquals(IMAGE_1,  image.getImage());
  50         assertEquals(REPEAT, image.getRepeatX());
  51         assertEquals(REPEAT, image.getRepeatY());
  52         assertEquals(POS_1, image.getPosition());
  53         assertEquals(SIZE_1, image.getSize());
  54     }
  55 
  56     @Test public void instanceCreation2() {
  57         BackgroundImage image = new BackgroundImage(IMAGE_2, NO_REPEAT, ROUND, POS_2, SIZE_2);
  58         assertEquals(IMAGE_2,  image.getImage());
  59         assertEquals(NO_REPEAT, image.getRepeatX());
  60         assertEquals(ROUND, image.getRepeatY());
  61         assertEquals(POS_2, image.getPosition());
  62         assertEquals(SIZE_2, image.getSize());
  63     }
  64 
  65     @Test(expected = NullPointerException.class)




   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
  23  * questions.
  24  */
  25 
  26 package test.javafx.scene.layout;
  27 
  28 import javafx.geometry.Side;
  29 import javafx.scene.image.Image;
  30 import javafx.scene.layout.BackgroundImage;
  31 import javafx.scene.layout.BackgroundPosition;
  32 import javafx.scene.layout.BackgroundSize;
  33 import org.junit.Test;
  34 
  35 import static javafx.scene.layout.BackgroundRepeat.*;
  36 import static org.junit.Assert.*;
  37 
  38 /**
  39  */
  40 public class BackgroundImageTest {
  41     private static final BackgroundPosition POS_1 = new BackgroundPosition(Side.LEFT, .5, true, Side.TOP, 10, false);
  42     private static final BackgroundPosition POS_2 = BackgroundPosition.DEFAULT;
  43 
  44     private static final BackgroundSize SIZE_1 = new BackgroundSize(1, 1, true, true, false, true);
  45     private static final BackgroundSize SIZE_2 = BackgroundSize.DEFAULT;
  46 
  47     private static final Image IMAGE_1 = new Image("test/javafx/scene/layout/red.png");
  48     private static final Image IMAGE_2 = new Image("test/javafx/scene/layout/blue.png");
  49 
  50     @Test public void instanceCreation() {
  51         BackgroundImage image = new BackgroundImage(IMAGE_1, REPEAT, REPEAT, POS_1, SIZE_1);
  52         assertEquals(IMAGE_1,  image.getImage());
  53         assertEquals(REPEAT, image.getRepeatX());
  54         assertEquals(REPEAT, image.getRepeatY());
  55         assertEquals(POS_1, image.getPosition());
  56         assertEquals(SIZE_1, image.getSize());
  57     }
  58 
  59     @Test public void instanceCreation2() {
  60         BackgroundImage image = new BackgroundImage(IMAGE_2, NO_REPEAT, ROUND, POS_2, SIZE_2);
  61         assertEquals(IMAGE_2,  image.getImage());
  62         assertEquals(NO_REPEAT, image.getRepeatX());
  63         assertEquals(ROUND, image.getRepeatY());
  64         assertEquals(POS_2, image.getPosition());
  65         assertEquals(SIZE_2, image.getSize());
  66     }
  67 
  68     @Test(expected = NullPointerException.class)