1 /*
   2  * Copyright (c) 2011, 2015, 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 test.javafx.scene;
  27 
  28 import java.util.Arrays;
  29 import java.util.Collection;
  30 import java.util.List;
  31 
  32 import javafx.scene.effect.BlendMode;
  33 import javafx.scene.effect.Shadow;
  34 import javafx.scene.shape.Rectangle;
  35 import javafx.scene.transform.Rotate;
  36 
  37 import org.junit.runner.RunWith;
  38 import org.junit.runners.Parameterized;
  39 import org.junit.runners.Parameterized.Parameters;
  40 
  41 import javafx.css.CssMetaData;
  42 import com.sun.javafx.scene.DirtyBits;
  43 import test.com.sun.javafx.test.OnInvalidateMethodsTestBase;
  44 import javafx.css.Styleable;
  45 import javafx.scene.CacheHint;
  46 import javafx.scene.Cursor;
  47 import javafx.scene.Node;
  48 
  49 @RunWith(Parameterized.class)
  50 public class Node_onInvalidate_Test extends OnInvalidateMethodsTestBase {
  51 
  52     public Node_onInvalidate_Test(Configuration configuration) {
  53         super(configuration);
  54     }
  55 
  56     @Parameters
  57     public static Collection<Object[]>data() {
  58         Object[][] data = new Object[][] {
  59             {new Configuration(Rectangle.class, "visible", false, new DirtyBits[] {DirtyBits.NODE_VISIBLE, DirtyBits.NODE_BOUNDS})},
  60             {new Configuration(Rectangle.class, "cursor", Cursor.WAIT, new CssMetaData[] {findCssCSSProperty("-fx-cursor")})},
  61             {new Configuration(Rectangle.class, "opacity", 0.5, new CssMetaData[] {findCssCSSProperty("-fx-opacity")})},
  62             {new Configuration(Rectangle.class, "opacity", 0.5, new DirtyBits[] {DirtyBits.NODE_OPACITY})},
  63             {new Configuration(Rectangle.class, "blendMode", BlendMode.DARKEN, new CssMetaData[] {findCssCSSProperty("-fx-blend-mode")})},
  64             {new Configuration(Rectangle.class, "blendMode", BlendMode.DARKEN, new DirtyBits[] {DirtyBits.NODE_BLENDMODE})},
  65             {new Configuration(Rectangle.class, "cache", true, new DirtyBits[] {DirtyBits.NODE_CACHE})},
  66             {new Configuration(Rectangle.class, "cacheHint", CacheHint.QUALITY, new DirtyBits[] {DirtyBits.NODE_CACHE})},
  67             {new Configuration(Rectangle.class, "effect", new Shadow(), new CssMetaData[] {findCssCSSProperty("-fx-effect")})},
  68             {new Configuration(Rectangle.class, "translateX", 1.5, new CssMetaData[] {findCssCSSProperty("-fx-translate-x")})},
  69             {new Configuration(Rectangle.class, "translateX", 1.5, new DirtyBits[] {DirtyBits.NODE_TRANSFORM})},
  70             {new Configuration(Rectangle.class, "translateY", 1.5, new CssMetaData[] {findCssCSSProperty("-fx-translate-y")})},
  71             {new Configuration(Rectangle.class, "translateY", 1.5, new DirtyBits[] {DirtyBits.NODE_TRANSFORM})},
  72             {new Configuration(Rectangle.class, "translateZ", 1.5, new CssMetaData[] {findCssCSSProperty("-fx-translate-z")})},
  73             {new Configuration(Rectangle.class, "translateZ", 1.5, new DirtyBits[] {DirtyBits.NODE_TRANSFORM})},
  74             {new Configuration(Rectangle.class, "scaleX", 5.5, new CssMetaData[] {findCssCSSProperty("-fx-scale-x")})},
  75             {new Configuration(Rectangle.class, "scaleX", 5.5, new DirtyBits[] {DirtyBits.NODE_TRANSFORM})},
  76             {new Configuration(Rectangle.class, "scaleY", 5.5, new CssMetaData[] {findCssCSSProperty("-fx-scale-y")})},
  77             {new Configuration(Rectangle.class, "scaleY", 5.5, new DirtyBits[] {DirtyBits.NODE_TRANSFORM})},
  78             {new Configuration(Rectangle.class, "scaleZ", 5.5, new CssMetaData[] {findCssCSSProperty("-fx-scale-z")})},
  79             {new Configuration(Rectangle.class, "scaleZ", 5.5, new DirtyBits[] {DirtyBits.NODE_TRANSFORM})},
  80             {new Configuration(Rectangle.class, "rotate", 55, new CssMetaData[] {findCssCSSProperty("-fx-rotate")})},
  81             {new Configuration(Rectangle.class, "rotate", 55, new DirtyBits[] {DirtyBits.NODE_TRANSFORM})},
  82             {new Configuration(Rectangle.class, "rotationAxis", Rotate.X_AXIS, new DirtyBits[] {DirtyBits.NODE_TRANSFORM})},
  83             {new Configuration(Rectangle.class, "clip", new Rectangle(10, 10), new DirtyBits[] {DirtyBits.NODE_CLIP})},
  84             {new Configuration(Rectangle.class, "focusTraversable", true, new CssMetaData[] {findCssCSSProperty("-fx-focus-traversable")})}
  85         };
  86         return Arrays.asList(data);
  87     }
  88 
  89 
  90     public static CssMetaData findCssCSSProperty(String propertyName) {
  91         final List<CssMetaData<? extends Styleable, ?>> keys = Node.getClassCssMetaData();
  92         for(CssMetaData styleable : keys) {
  93             if (styleable.getProperty().equals(propertyName)) return styleable;
  94         }
  95         return null;
  96     }
  97 
  98 }