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