< prev index next >

tests/system/src/test/java/test/robot/com/sun/glass/ui/monocle/SwipeSimpleTest.java

Print this page
rev 9504 : need to fix test log and others


   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.robot.com.sun.glass.ui.monocle;
  27 
  28 import com.sun.glass.ui.monocle.TestLog;
  29 import test.robot.com.sun.glass.ui.monocle.TestApplication;
  30 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevice;
  31 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevices;
  32 import javafx.scene.input.GestureEvent;
  33 import org.junit.*;
  34 import org.junit.runners.Parameterized;
  35 
  36 import java.util.Collection;
  37 
  38 public class SwipeSimpleTest extends ParameterizedTestBase {
  39 
  40     private final int SWIPE_THRESHOLD = 10;
  41     int startPointX;
  42     int startPointY;
  43 
  44     static {
  45         System.setProperty("com.sun.javafx.isEmbedded", "true");
  46     }
  47 
  48     public SwipeSimpleTest(TestTouchDevice device) {


  51 
  52     @Parameterized.Parameters
  53     public static Collection<Object[]> data() {
  54         return TestTouchDevices.getTouchDeviceParameters(1);
  55     }
  56 
  57     private int getDelta() throws Exception {
  58         int max = Math.max(SWIPE_THRESHOLD, device.getTapRadius());
  59         return max + 1;
  60     }
  61 
  62     @BeforeClass
  63     public static void beforeInit() {
  64         System.setProperty("com.sun.javafx.gestures.swipe.maxduration", "1200");
  65     }
  66     
  67     @Before
  68     public void addListener() throws Exception {
  69         TestApplication.getStage().getScene().addEventHandler(
  70                 GestureEvent.ANY,
  71                 e -> TestLog.format("%s at %.0f, %.0f",
  72                         e.getEventType(),
  73                         e.getScreenX(),
  74                         e.getScreenY()));
  75         startPointX = (int) Math.round(width * 0.5);
  76         startPointY = (int) Math.round(height * 0.5);
  77     }
  78 
  79     private void swipe(Point[] points, String expectedSwipe) throws Exception {
  80         Assert.assertTrue(points.length > 1);
  81         int x = points[0].getX();
  82         int y = points[0].getY();
  83         TestLog.reset();
  84         int p1 = device.addPoint(x, y);
  85         device.sync();
  86         for (int i = 1; i < points.length; i++) {
  87             device.setPoint(p1, points[i].getX(), points[i].getY());
  88             device.sync();
  89         }
  90         device.removePoint(p1);
  91         device.sync();
  92         int finalX = points[points.length - 1].getX();
  93         int finalY = points[points.length - 1].getY();
  94         TestLog.waitForLogContaining("Touch released: %d, %d", finalX, finalY);
  95         TestLog.waitForLogContaining("Mouse released: %d, %d", finalX, finalY);
  96         TestLog.waitForLogContaining("Mouse clicked: %d, %d", finalX, finalY);
  97         if (expectedSwipe != null) {
  98             TestLog.waitForLogContaining(expectedSwipe);
  99         } else {
 100             Assert.assertEquals(0, TestLog.countLogContaining("SWIPE"));
 101         }
 102     }
 103 
 104     @Test
 105     public void testSwipeRight1() throws Exception {
 106         Point[] path = {new Point(startPointX, startPointY),
 107                 new Point(startPointX + getDelta(), startPointY)};
 108         swipe(path, "SWIPE_RIGHT");
 109     }
 110 
 111     @Test
 112     public void testSwipeRight2() throws Exception {
 113         Point[] path = {new Point(startPointX, startPointY), new Point(65,
 114                 getDelta(), startPointX, startPointY)};
 115         swipe(path, "SWIPE_RIGHT");
 116     }
 117 
 118     @Test
 119     public void testSwipeRight3() throws Exception {
 120         Point[] path = {new Point(startPointX, startPointY), new Point(80,




   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.robot.com.sun.glass.ui.monocle;
  27 
  28 import com.sun.glass.ui.monocle.TestLogShim;
  29 import test.robot.com.sun.glass.ui.monocle.TestApplication;
  30 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevice;
  31 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevices;
  32 import javafx.scene.input.GestureEvent;
  33 import org.junit.*;
  34 import org.junit.runners.Parameterized;
  35 
  36 import java.util.Collection;
  37 
  38 public class SwipeSimpleTest extends ParameterizedTestBase {
  39 
  40     private final int SWIPE_THRESHOLD = 10;
  41     int startPointX;
  42     int startPointY;
  43 
  44     static {
  45         System.setProperty("com.sun.javafx.isEmbedded", "true");
  46     }
  47 
  48     public SwipeSimpleTest(TestTouchDevice device) {


  51 
  52     @Parameterized.Parameters
  53     public static Collection<Object[]> data() {
  54         return TestTouchDevices.getTouchDeviceParameters(1);
  55     }
  56 
  57     private int getDelta() throws Exception {
  58         int max = Math.max(SWIPE_THRESHOLD, device.getTapRadius());
  59         return max + 1;
  60     }
  61 
  62     @BeforeClass
  63     public static void beforeInit() {
  64         System.setProperty("com.sun.javafx.gestures.swipe.maxduration", "1200");
  65     }
  66     
  67     @Before
  68     public void addListener() throws Exception {
  69         TestApplication.getStage().getScene().addEventHandler(
  70                 GestureEvent.ANY,
  71                 e -> TestLogShim.format("%s at %.0f, %.0f",
  72                         e.getEventType(),
  73                         e.getScreenX(),
  74                         e.getScreenY()));
  75         startPointX = (int) Math.round(width * 0.5);
  76         startPointY = (int) Math.round(height * 0.5);
  77     }
  78 
  79     private void swipe(Point[] points, String expectedSwipe) throws Exception {
  80         Assert.assertTrue(points.length > 1);
  81         int x = points[0].getX();
  82         int y = points[0].getY();
  83         TestLogShim.reset();
  84         int p1 = device.addPoint(x, y);
  85         device.sync();
  86         for (int i = 1; i < points.length; i++) {
  87             device.setPoint(p1, points[i].getX(), points[i].getY());
  88             device.sync();
  89         }
  90         device.removePoint(p1);
  91         device.sync();
  92         int finalX = points[points.length - 1].getX();
  93         int finalY = points[points.length - 1].getY();
  94         TestLogShim.waitForLogContaining("Touch released: %d, %d", finalX, finalY);
  95         TestLogShim.waitForLogContaining("Mouse released: %d, %d", finalX, finalY);
  96         TestLogShim.waitForLogContaining("Mouse clicked: %d, %d", finalX, finalY);
  97         if (expectedSwipe != null) {
  98             TestLogShim.waitForLogContaining(expectedSwipe);
  99         } else {
 100             Assert.assertEquals(0, TestLogShim.countLogContaining("SWIPE"));
 101         }
 102     }
 103 
 104     @Test
 105     public void testSwipeRight1() throws Exception {
 106         Point[] path = {new Point(startPointX, startPointY),
 107                 new Point(startPointX + getDelta(), startPointY)};
 108         swipe(path, "SWIPE_RIGHT");
 109     }
 110 
 111     @Test
 112     public void testSwipeRight2() throws Exception {
 113         Point[] path = {new Point(startPointX, startPointY), new Point(65,
 114                 getDelta(), startPointX, startPointY)};
 115         swipe(path, "SWIPE_RIGHT");
 116     }
 117 
 118     @Test
 119     public void testSwipeRight3() throws Exception {
 120         Point[] path = {new Point(startPointX, startPointY), new Point(80,


< prev index next >