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 java.lang.reflect.Field;
29 import javafx.geometry.Insets;
30 import javafx.scene.image.Image;
31 import javafx.scene.paint.Color;
32 import javafx.scene.shape.StrokeType;
33 import org.junit.Test;
34
35 import static javafx.scene.layout.BorderRepeat.*;
36 import static org.junit.Assert.*;
37
38 /**
39 * Tests for Border.
40 */
41 public class BorderTest {
42 private static final BorderStroke[] STROKES_1 = new BorderStroke[] {
43 new BorderStroke(Color.RED, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.EMPTY)
44 };
45 private static final BorderStroke[] STROKES_2 = new BorderStroke[] {
46 new BorderStroke(Color.GREEN, BorderStrokeStyle.DASHED, new CornerRadii(3), new BorderWidths(4)),
47 new BorderStroke(Color.BLUE, BorderStrokeStyle.DOTTED, new CornerRadii(6), new BorderWidths(8))
48 };
49
50 private static final Image IMAGE_1 = new Image("javafx/scene/layout/red.png");
51 private static final Image IMAGE_2 = new Image("javafx/scene/layout/blue.png");
52 private static final Image IMAGE_3 = new Image("javafx/scene/layout/green.png");
53 private static final Image IMAGE_4 = new Image("javafx/scene/layout/yellow.png");
54
55 private static final BorderImage[] IMAGES_1 = new BorderImage[] {
56 new BorderImage(IMAGE_1, BorderWidths.DEFAULT, Insets.EMPTY, BorderWidths.EMPTY, false, SPACE, SPACE)
57 };
58
59 private static final BorderImage[] IMAGES_2 = new BorderImage[] {
60 new BorderImage(IMAGE_2, new BorderWidths(3), new Insets(4), BorderWidths.EMPTY, false, REPEAT, REPEAT),
61 new BorderImage(IMAGE_3, new BorderWidths(6), new Insets(2), BorderWidths.EMPTY, false, SPACE, ROUND),
62 new BorderImage(IMAGE_4, new BorderWidths(3), Insets.EMPTY, new BorderWidths(3, 4, 5, 6), true, STRETCH, SPACE)
63 };
64
65 @Test public void instanceCreation() {
66 Border b = new Border(STROKES_1, IMAGES_1);
67 assertEquals(STROKES_1.length, b.getStrokes().size(), 0);
68 assertEquals(STROKES_1[0], b.getStrokes().get(0));
69 assertEquals(IMAGES_1.length, b.getImages().size(), 0);
70 assertEquals(IMAGES_1[0], b.getImages().get(0));
71 }
72
73 @Test public void instanceCreation2() {
|
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 java.lang.reflect.Field;
29 import javafx.geometry.Insets;
30 import javafx.scene.image.Image;
31 import javafx.scene.layout.Border;
32 import javafx.scene.layout.BorderImage;
33 import javafx.scene.layout.BorderStroke;
34 import javafx.scene.layout.BorderStrokeStyle;
35 import javafx.scene.layout.BorderWidths;
36 import javafx.scene.layout.CornerRadii;
37 import javafx.scene.paint.Color;
38 import javafx.scene.shape.StrokeType;
39 import org.junit.Test;
40
41 import static javafx.scene.layout.BorderRepeat.*;
42 import static org.junit.Assert.*;
43
44 /**
45 * Tests for Border.
46 */
47 public class BorderTest {
48 private static final BorderStroke[] STROKES_1 = new BorderStroke[] {
49 new BorderStroke(Color.RED, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.EMPTY)
50 };
51 private static final BorderStroke[] STROKES_2 = new BorderStroke[] {
52 new BorderStroke(Color.GREEN, BorderStrokeStyle.DASHED, new CornerRadii(3), new BorderWidths(4)),
53 new BorderStroke(Color.BLUE, BorderStrokeStyle.DOTTED, new CornerRadii(6), new BorderWidths(8))
54 };
55
56 private static final Image IMAGE_1 = new Image("test/javafx/scene/layout/red.png");
57 private static final Image IMAGE_2 = new Image("test/javafx/scene/layout/blue.png");
58 private static final Image IMAGE_3 = new Image("test/javafx/scene/layout/green.png");
59 private static final Image IMAGE_4 = new Image("test/javafx/scene/layout/yellow.png");
60
61 private static final BorderImage[] IMAGES_1 = new BorderImage[] {
62 new BorderImage(IMAGE_1, BorderWidths.DEFAULT, Insets.EMPTY, BorderWidths.EMPTY, false, SPACE, SPACE)
63 };
64
65 private static final BorderImage[] IMAGES_2 = new BorderImage[] {
66 new BorderImage(IMAGE_2, new BorderWidths(3), new Insets(4), BorderWidths.EMPTY, false, REPEAT, REPEAT),
67 new BorderImage(IMAGE_3, new BorderWidths(6), new Insets(2), BorderWidths.EMPTY, false, SPACE, ROUND),
68 new BorderImage(IMAGE_4, new BorderWidths(3), Insets.EMPTY, new BorderWidths(3, 4, 5, 6), true, STRETCH, SPACE)
69 };
70
71 @Test public void instanceCreation() {
72 Border b = new Border(STROKES_1, IMAGES_1);
73 assertEquals(STROKES_1.length, b.getStrokes().size(), 0);
74 assertEquals(STROKES_1[0], b.getStrokes().get(0));
75 assertEquals(IMAGES_1.length, b.getImages().size(), 0);
76 assertEquals(IMAGES_1[0], b.getImages().get(0));
77 }
78
79 @Test public void instanceCreation2() {
|