modules/graphics/src/test/java/javafx/scene/input/TouchEventTest.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 com.sun.javafx.pgstub.StubScene;
  29 import java.util.ArrayList;
  30 import java.util.Arrays;
  31 import java.util.Random;
  32 import javafx.event.Event;
  33 import javafx.scene.Group;
  34 import javafx.scene.Scene;
  35 import javafx.scene.shape.Rectangle;
  36 import javafx.stage.Stage;
  37 import javafx.event.EventHandler;
  38 import javafx.geometry.Point3D;
  39 import org.junit.Ignore;

  40 import org.junit.Test;
  41 import static org.junit.Assert.*;
  42 
  43 public class TouchEventTest {




  44     private static final int SANE_BENCHMARK_CYCLES = 1000000;
  45     private static final int CRAZY_BENCHMARK_CYCLES = 500000;
  46 
  47     private int touched;
  48 
  49     @Test public void testTouchPointConstructor() {
  50         Rectangle node = new Rectangle();
  51         node.setTranslateX(3);
  52         node.setTranslateY(2);
  53         node.setTranslateZ(50);
  54         PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33);
  55         TouchPoint tp = new TouchPoint(2, TouchPoint.State.STATIONARY,
  56                 10, 20, 30, 40, node, pickRes);
  57 
  58         assertEquals(2, tp.getId());
  59         assertSame(TouchPoint.State.STATIONARY, tp.getState());
  60         assertEquals(18, tp.getX(), 10e-20);
  61         assertEquals(27, tp.getY(), 10e-20);
  62         assertEquals(150, tp.getZ(), 10e-20);
  63         assertEquals(10, tp.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 com.sun.javafx.pgstub.StubScene;
  30 import java.util.ArrayList;
  31 import java.util.Arrays;
  32 import java.util.Random;
  33 import javafx.event.Event;
  34 import javafx.scene.Group;
  35 import javafx.scene.Scene;
  36 import javafx.scene.shape.Rectangle;
  37 import javafx.stage.Stage;
  38 import javafx.event.EventHandler;
  39 import javafx.geometry.Point3D;
  40 import org.junit.Ignore;
  41 import org.junit.Rule;
  42 import org.junit.Test;
  43 import static org.junit.Assert.*;
  44 
  45 public class TouchEventTest {
  46 
  47     @Rule
  48     public FXUnit fx = new FXUnit();
  49 
  50     private static final int SANE_BENCHMARK_CYCLES = 1000000;
  51     private static final int CRAZY_BENCHMARK_CYCLES = 500000;
  52 
  53     private int touched;
  54 
  55     @Test public void testTouchPointConstructor() {
  56         Rectangle node = new Rectangle();
  57         node.setTranslateX(3);
  58         node.setTranslateY(2);
  59         node.setTranslateZ(50);
  60         PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33);
  61         TouchPoint tp = new TouchPoint(2, TouchPoint.State.STATIONARY,
  62                 10, 20, 30, 40, node, pickRes);
  63 
  64         assertEquals(2, tp.getId());
  65         assertSame(TouchPoint.State.STATIONARY, tp.getState());
  66         assertEquals(18, tp.getX(), 10e-20);
  67         assertEquals(27, tp.getY(), 10e-20);
  68         assertEquals(150, tp.getZ(), 10e-20);
  69         assertEquals(10, tp.getSceneX(), 10e-20);