1 /* 2 * Copyright (c) 2011, 2014, 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 23 * questions. 24 */ 25 26 package javafx.scene; 27 28 import java.util.Arrays; 29 import java.util.Collection; 30 31 import javafx.scene.effect.BlendMode; 32 import javafx.scene.effect.Shadow; 33 import javafx.scene.image.Image; 34 import javafx.scene.shape.Rectangle; 35 36 import org.junit.BeforeClass; 37 import org.junit.Ignore; 38 import org.junit.runner.RunWith; 39 import org.junit.runners.Parameterized; 40 import org.junit.runners.Parameterized.Parameters; 41 42 import com.sun.javafx.pgstub.StubImageLoaderFactory; 43 import com.sun.javafx.pgstub.StubPlatformImageInfo; 44 import com.sun.javafx.pgstub.StubToolkit; 45 import com.sun.javafx.test.CssMethodsTestBase; 46 import com.sun.javafx.test.ValueComparator; 47 import com.sun.javafx.tk.Toolkit; 48 49 @Ignore ("pending RT-35594") 50 @RunWith(Parameterized.class) 51 public final class Node_cssMethods_Test extends CssMethodsTestBase { 52 private static final Node TEST_NODE = new Rectangle(); 53 private static final String TEST_CURSOR_URL = "file:cursor.png"; 54 55 @BeforeClass 56 public static void configureImageLoaderFactory() { 57 final StubImageLoaderFactory imageLoaderFactory = 58 ((StubToolkit) Toolkit.getToolkit()).getImageLoaderFactory(); 59 imageLoaderFactory.reset(); 60 imageLoaderFactory.registerImage( 61 TEST_CURSOR_URL, 62 new StubPlatformImageInfo(32, 32)); 63 } 64 65 @Parameters 66 public static Collection data() { 67 return Arrays.asList(new Object[] { 68 config(TEST_NODE, "cursor", null, "-fx-cursor", Cursor.cursor(TEST_CURSOR_URL), 69 new ValueComparator() { 70 @Override 71 public boolean equals(final Object expected, 72 final Object actual) { 73 if (actual instanceof ImageCursor) { 74 final Image cursorImage = 75 ((ImageCursor) actual).getImage(); 76 77 if ((cursorImage != null) 78 && cursorImage.impl_getUrl().equals( 79 TEST_CURSOR_URL)) { 80 return true; 81 } 82 } 83 84 return false; 85 } 86 }), 87 config("cursor", null, "-fx-cursor", Cursor.MOVE), 88 config("effect", null, "-fx-effect", new Shadow()), 89 config("focusTraversable", false, 90 "-fx-focus-traversable", true), 91 config("opacity", 1.0, "-fx-opacity", 0.5), 92 config("opacity", 0.5, "-fx-opacity", null, 0.0), 93 config("blendMode", BlendMode.SRC_OVER, "-fx-blend-mode", BlendMode.SRC_ATOP), 94 config("rotate", 0.0, "-fx-rotate", 45.0), 95 config("rotate", 0.5, "-fx-rotate", null, 0.0), 96 config("scaleX", 1.0, "-fx-scale-x", 0.5), 97 config("scaleX", 0.5, "-fx-scale-x", null, 0.0), 98 config("scaleY", 1.0, "-fx-scale-y", 2.0), 99 config("scaleY", 0.5, "-fx-scale-y", null, 0.0), 100 config("scaleZ", 1.0, "-fx-scale-z", 1.5), 101 config("scaleZ", 0.5, "-fx-scale-z", null, 0.0), 102 config("translateX", 0.0, "-fx-translate-x", 10.0), 103 config("translateX", 1.0, "-fx-translate-x", null, 0.0), 104 config("translateY", 0.0, "-fx-translate-y", 20.0), 105 config("translateY", 1.0, "-fx-translate-y", null, 0.0), 106 config("translateZ", 0.0, "-fx-translate-z", 30.0), 107 config("translateZ", 1.0, "-fx-translate-z", null, 0.0), 108 }); 109 } 110 111 public static Object[] config( 112 final String propertyName, 113 final Object initialValue, 114 final String cssPropertyKey, 115 final Object cssPropertyValue) { 116 return config(TEST_NODE, propertyName, initialValue, 117 cssPropertyKey, cssPropertyValue); 118 } 119 120 public static Object[] config( 121 final String propertyName, 122 final Object initialValue, 123 final String cssPropertyKey, 124 final Object cssPropertyValue, 125 final Object expectedFinalValue) { 126 return config(TEST_NODE, propertyName, initialValue, 127 cssPropertyKey, cssPropertyValue, expectedFinalValue); 128 } 129 130 public Node_cssMethods_Test(final Configuration configuration) { 131 super(configuration); 132 } 133 }