modules/graphics/src/test/java/javafx/scene/input/MouseDragEventTest.java

Print this page
rev 6167 : RT-35330 [Monocle] Remove StubToolkit and replace it with headless glass implementation


   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.input;
  27 

  28 import javafx.event.EventHandler;
  29 import javafx.event.EventType;
  30 import javafx.scene.Group;
  31 import javafx.scene.Node;
  32 import javafx.scene.Scene;
  33 import javafx.scene.shape.Rectangle;
  34 import javafx.stage.Stage;
  35 
  36 import com.sun.javafx.test.MouseEventGenerator;
  37 import javafx.event.Event;
  38 import javafx.geometry.Point3D;
  39 
  40 import static org.junit.Assert.*;


  41 import org.junit.Test;
  42 
  43 public class MouseDragEventTest {
  44 



  45     @Test public void testShortConstructor() {
  46         Rectangle node = new Rectangle();
  47         node.setTranslateX(3);
  48         node.setTranslateY(2);
  49         node.setTranslateZ(50);
  50         Rectangle gsrc = new Rectangle();
  51 
  52         PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33);
  53 
  54         MouseDragEvent e = new MouseDragEvent(MouseDragEvent.MOUSE_DRAG_OVER,
  55                 10, 20, 30, 40, MouseButton.MIDDLE, 3,
  56                 true, false, false, true,
  57                 false, true, false,
  58                 true, false, pickRes, gsrc);
  59 
  60         assertSame(MouseDragEvent.MOUSE_DRAG_OVER, e.getEventType());
  61         assertEquals(18, e.getX(), 10e-20);
  62         assertEquals(27, e.getY(), 10e-20);
  63         assertEquals(150, e.getZ(), 10e-20);
  64         assertEquals(10, e.getSceneX(), 10e-20);




   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.input;
  27 
  28 import com.sun.javafx.FXUnit;
  29 import javafx.event.EventHandler;
  30 import javafx.event.EventType;
  31 import javafx.scene.Group;
  32 import javafx.scene.Node;
  33 import javafx.scene.Scene;
  34 import javafx.scene.shape.Rectangle;
  35 import javafx.stage.Stage;
  36 
  37 import com.sun.javafx.test.MouseEventGenerator;
  38 import javafx.event.Event;
  39 import javafx.geometry.Point3D;
  40 
  41 import static org.junit.Assert.*;
  42 
  43 import org.junit.Rule;
  44 import org.junit.Test;
  45 
  46 public class MouseDragEventTest {
  47 
  48     @Rule
  49     public FXUnit fx = new FXUnit();
  50 
  51     @Test public void testShortConstructor() {
  52         Rectangle node = new Rectangle();
  53         node.setTranslateX(3);
  54         node.setTranslateY(2);
  55         node.setTranslateZ(50);
  56         Rectangle gsrc = new Rectangle();
  57 
  58         PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33);
  59 
  60         MouseDragEvent e = new MouseDragEvent(MouseDragEvent.MOUSE_DRAG_OVER,
  61                 10, 20, 30, 40, MouseButton.MIDDLE, 3,
  62                 true, false, false, true,
  63                 false, true, false,
  64                 true, false, pickRes, gsrc);
  65 
  66         assertSame(MouseDragEvent.MOUSE_DRAG_OVER, e.getEventType());
  67         assertEquals(18, e.getX(), 10e-20);
  68         assertEquals(27, e.getY(), 10e-20);
  69         assertEquals(150, e.getZ(), 10e-20);
  70         assertEquals(10, e.getSceneX(), 10e-20);