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 test.javafx.scene;
  27 
  28 import java.util.Arrays;
  29 import java.util.Collection;
  30 
  31 import javafx.event.Event;
  32 import javafx.event.EventHandler;
  33 import javafx.geometry.Point2D;
  34 import javafx.scene.effect.BlendMode;
  35 import javafx.scene.effect.Glow;
  36 import javafx.scene.input.InputMethodRequests;
  37 import javafx.scene.shape.Rectangle;
  38 import javafx.scene.transform.Rotate;
  39 
  40 import org.junit.runner.RunWith;
  41 import org.junit.runners.Parameterized;
  42 import org.junit.runners.Parameterized.Parameters;
  43 
  44 import com.sun.javafx.event.EventHandlerManager;
  45 import test.com.sun.javafx.test.PropertiesTestBase;
  46 import javafx.geometry.NodeOrientation;
  47 import javafx.scene.CacheHint;
  48 import javafx.scene.Cursor;
  49 import javafx.scene.DepthTest;
  50 import javafx.scene.Group;
  51 import javafx.scene.Node;
  52 
  53 @RunWith(Parameterized.class)
  54 public final class Node_properties_Test extends PropertiesTestBase {
  55     @Parameters
  56     public static Collection data() {
  57         final Group testParent = new Group();
  58         final Node testNode = new Rectangle();
  59         testParent.getChildren().add(testNode);
  60         
  61         final EventHandler testEventHandler =
  62                 event -> {
  63                 };
  64 
  65         return Arrays.asList(new Object[] {
  66 //            config(testNode, "parent", , ),
  67 //            config(testNode, "scene", , ),
  68             config(testNode, "id", "rect_1", "rect_2"),
  69             config(testNode, "style", "style_1", "style_2"),
  70             config(testNode, "visible", true, false),
  71             config(testNode, "cursor", Cursor.DEFAULT, Cursor.CROSSHAIR),
  72             config(testNode, "opacity", 1.0, 0.5),
  73             config(testNode, "blendMode",
  74                    BlendMode.SRC_OVER, BlendMode.SRC_ATOP),
  75             config(testNode, "clip", null, new Rectangle(0, 0, 100, 100)),
  76             config(testNode, "cache", false, true),
  77             config(testNode, "cacheHint", CacheHint.QUALITY, CacheHint.SPEED),
  78             config(testNode, "effect", null, new Glow()),
  79             config(testNode, "depthTest", DepthTest.DISABLE, DepthTest.ENABLE),
  80             config(testNode, "disable", false, true),
  81             config(testNode, "pickOnBounds", false, true),
  82             config(testParent, "disable", false, true,
  83                    testNode, "disabled", false, true),
  84             config(testNode, "onDragEntered", null, testEventHandler),
  85             config(testNode, "onDragExited", null, testEventHandler),
  86             config(testNode, "onDragOver", null, testEventHandler),
  87             config(testNode, "onDragDropped", null, testEventHandler),
  88             config(testNode, "onDragDone", null, testEventHandler),
  89             config(testNode, "managed", false, true),
  90             config(testNode, "layoutX", 0.0, 100.0),
  91             config(testNode, "layoutY", 0.0, 100.0),
  92 //            config(testNode, "boundsInParent", , ),
  93 //            config(testNode, "boundsInLocal", , ),
  94 //            config(testNode, "layoutBounds", , ),
  95 //            config(testNode, "transforms", , ),
  96             config(testNode, "translateX", 0.0, 100.0),
  97             config(testNode, "translateY", 0.0, 100.0),
  98             config(testNode, "translateZ", 0.0, 100.0),
  99             config(testNode, "scaleX", 1.0, 0.5),
 100             config(testNode, "scaleY", 1.0, 0.5),
 101             config(testNode, "scaleZ", 1.0, 0.5),
 102             config(testNode, "rotate", 0.0, 45.0),
 103             config(testNode, "rotationAxis", Rotate.Z_AXIS, Rotate.X_AXIS),
 104             config(testNode, "mouseTransparent", false, true),
 105 //            config(testNode, "hover", , ),
 106 //            config(testNode, "pressed", , ),
 107             config(testNode, "onMouseClicked", null, testEventHandler),
 108             config(testNode, "onMouseDragged", null, testEventHandler),
 109             config(testNode, "onMouseEntered", null, testEventHandler),
 110             config(testNode, "onMouseExited", null, testEventHandler),
 111             config(testNode, "onMouseMoved", null, testEventHandler),
 112             config(testNode, "onMousePressed", null, testEventHandler),
 113             config(testNode, "onMouseReleased", null, testEventHandler),
 114             config(testNode, "onDragDetected", null, testEventHandler),
 115             config(testNode, "onKeyPressed", null, testEventHandler),
 116             config(testNode, "onKeyReleased", null, testEventHandler),
 117             config(testNode, "onKeyTyped", null, testEventHandler),
 118             config(testNode, "onInputMethodTextChanged",
 119                    null, testEventHandler),
 120             config(testNode, "inputMethodRequests",
 121                    null,
 122                    new InputMethodRequests() {
 123                        @Override
 124                        public Point2D getTextLocation(final int offset) {
 125                            return new Point2D(0, 0);
 126                        }
 127 
 128                        @Override
 129                        public int getLocationOffset(final int x, final int y) {
 130                            return 0;
 131                        }
 132 
 133                        @Override
 134                        public void cancelLatestCommittedText() {
 135                        }
 136 
 137                        @Override
 138                        public String getSelectedText() {
 139                            return "";
 140                        }
 141                    }),
 142 //            config(testNode, "focused", , ),
 143             config(testNode, "focusTraversable", false, true),
 144 //            config(testNode, "treeVisible", , ),
 145             config(testNode, "eventDispatcher", 
 146                    null,
 147                    new EventHandlerManager(null)),
 148             config(testNode,
 149                    "nodeOrientation", NodeOrientation.INHERIT,
 150                                       NodeOrientation.RIGHT_TO_LEFT,
 151                    "effectiveNodeOrientation", NodeOrientation.LEFT_TO_RIGHT,
 152                                                NodeOrientation.RIGHT_TO_LEFT),
 153             config(testParent, "nodeOrientation",
 154                        NodeOrientation.LEFT_TO_RIGHT,
 155                        NodeOrientation.RIGHT_TO_LEFT,
 156                    testNode, "effectiveNodeOrientation",
 157                        NodeOrientation.LEFT_TO_RIGHT,
 158                        NodeOrientation.RIGHT_TO_LEFT)
 159         });
 160     }
 161 
 162     public Node_properties_Test(final Configuration configuration) {
 163         super(configuration);
 164     }
 165 }