< prev index next >

tests/system/src/test/java/test/robot/com/sun/glass/ui/monocle/DragTouchInAndOutAWindowTest.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.geometry.Rectangle2D;
  33 import javafx.stage.Stage;
  34 import org.junit.Assert;
  35 import org.junit.Assume;
  36 import org.junit.Before;
  37 import org.junit.Test;
  38 import org.junit.Ignore;
  39 import org.junit.runners.Parameterized;
  40 
  41 import java.util.Collection;
  42 import test.com.sun.glass.ui.monocle.TestRunnable;
  43 
  44 /**
  45  * This is a regression test for RT-33771 - Lens:FXML-LoginDemo throws
  46  * java.lang.RuntimeException: Platform reported wrong touch point ID. 
  47  *  
  48  * and  RT-33687 - Lens:some touch events are been dropped in native 


  52 public class DragTouchInAndOutAWindowTest extends ParameterizedTestBase {
  53 
  54     public DragTouchInAndOutAWindowTest(TestTouchDevice device) {
  55         super(device);
  56     }
  57 
  58     @Parameterized.Parameters
  59     public static Collection<Object[]> data() {
  60         return TestTouchDevices.getTouchDeviceParameters(1);
  61     }
  62 
  63 
  64     @Before
  65     public void setUpScreen() throws Exception {
  66         TestApplication.showInMiddleOfScreen();
  67         TestApplication.addTouchListeners();
  68         int p = device.addPoint(0, 0);
  69         device.sync();
  70         device.removePoint(p);
  71         device.sync();
  72         TestLog.reset();
  73     }
  74 
  75     /**
  76      * RT-33771 stated that exceptions are been thrown because the state of the
  77      * point, when entering the window, is wrong.
  78      * Test check that states are ok and no exception is been thrown
  79      *
  80      * Test update for RT-34191 - make sure no touch event received if drag
  81      * started outside the window
  82      */
  83     @Test
  84     public void singleTouch_dragPointIntoTheWindow() throws Exception {
  85         Stage stage = TestApplication.getStage();
  86         int windowRightEnd = (int)(stage.getX() + stage.getWidth());
  87         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
  88 
  89         //start outside the window and drag point into it (move in big steps
  90         //to avoid filtering)
  91         //expected:
  92         //1) no exception
  93         //2) no  press | move | release notifications
  94         int p = device.addPoint(windowRightEnd + 50, windowMiddleHeight);
  95         device.sync();
  96         for (int i = 49; i >= -50 ; i -= 3) {
  97             device.setPoint(p, windowRightEnd + i, windowMiddleHeight);
  98             device.sync();
  99         }
 100 
 101         //
 102         device.removePoint(p);
 103         device.sync();
 104 
 105         //check that tested window didn't recive any notifications
 106 
 107         //wait for results and make sure no event received
 108         Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: PRESSED"));
 109         Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: MOVED"));
 110         Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: RELEASED"));
 111     }
 112 
 113     @Test
 114     /**
 115      * This test is also related to RT-33687 - Lens:some touch events are been
 116      * dropped in native causing exceptions to be thrown.
 117      * In short there was a problem that when touch point moved outside a window
 118      * no notifications were sent, especially releases.
 119      *
 120      */
 121     public void singleTouch_dragPointoutsideAwindow() throws Exception {
 122         Stage stage = TestApplication.getStage();
 123         int windowMiddleWidth = (int)(stage.getX() + stage.getWidth() / 2);
 124         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
 125 
 126         //touch inside the window and drag the touch point to the end of the screen
 127         int p = device.addPoint(windowMiddleWidth, windowMiddleHeight);
 128         device.sync();
 129         for (int i = 0; i + windowMiddleWidth < width ; i += 5) {
 130             device.setPoint(p, windowMiddleWidth + i, windowMiddleHeight);
 131             device.sync();
 132         }
 133 
 134         //wait for results
 135         TestLog.waitForLogContaining("TouchPoint: PRESSED", 3000);
 136 
 137         //release outside the window
 138         device.removePoint(p);
 139         device.sync();
 140         //check that we get the event
 141         TestLog.waitForLogContaining("TouchPoint: RELEASED", 3000);
 142     }
 143 
 144      @Test
 145     /**
 146      * Combining the two test cases above, start a touch sequence inside a
 147      * window, drag the 'finger' out and in again and see that we gat the
 148      * events.
 149      *
 150      */
 151     public void singleTouch_dragPointInandOutAwindow() throws Exception {
 152         Stage stage = TestApplication.getStage();
 153         int windowMiddleWidth = (int)(stage.getX() + stage.getWidth() / 2);
 154         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
 155         int windowRightEnd = (int)(stage.getX() + stage.getWidth());
 156         int i;
 157 
 158         //start inside the window and drag point outside
 159         int p = device.addPoint(windowMiddleWidth, windowMiddleHeight);
 160         device.sync();
 161         for (i = windowMiddleWidth; i <= windowRightEnd + 100 ; i += 10) {
 162             device.setPoint(p, i, windowMiddleHeight);
 163             device.sync();
 164         }
 165 
 166         //wait for results
 167         TestLog.waitForLogContaining("TouchPoint: PRESSED", 3000);
 168         TestLog.waitForLogContaining("TouchPoint: MOVED", 3000);
 169 
 170         //continue from where we stopped and drag point back to window
 171         for (; i >= windowMiddleWidth  ; i -= 10) {
 172             device.setPoint(p, i, windowMiddleHeight);
 173             device.sync();
 174         }
 175 
 176         //release inside the window
 177         device.removePoint(p);
 178         device.sync();
 179         //check that we get the event
 180         TestLog.waitForLogContaining("TouchPoint: RELEASED", 3000);
 181     }
 182 
 183      @Test
 184     /**
 185      * Same test as above, but for multi touch.
 186      * Test should pass in either single touch mode or multi touch mode
 187      * Main point is to see that no exception is been thrown
 188      *
 189      */
 190     public void multiTouch_dragPointInandOutAwindow() throws Exception {
 191         Assume.assumeTrue(device.getPointCount() >= 2);
 192         Stage stage = TestApplication.getStage();
 193         int windowMiddleWidth = (int)(stage.getX() + stage.getWidth() / 2);
 194         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
 195         int windowRightEnd = (int)(stage.getX() + stage.getWidth());
 196         int i;
 197         int p1 = device.addPoint(windowRightEnd + 15, windowMiddleHeight);
 198         int p2 = device.addPoint(windowRightEnd + 15, windowMiddleHeight + 10);
 199         device.sync();
 200         //start outside the window and drag point into the center of window


 205             device.setPoint(p2, i, windowMiddleHeight + 10);
 206             device.sync();
 207         }
 208 
 209         //continue from where we stopped and drag point outside the window to
 210         //the end of screen
 211         for (; i + windowMiddleWidth < width ; i += 5) {
 212             //first finger
 213             device.setPoint(p1, i, windowMiddleHeight);
 214             //second finger
 215             device.setPoint(p2, i, windowMiddleHeight + 10);
 216             device.sync();
 217         }
 218 
 219         //release all points outside the window
 220         device.removePoint(p1);
 221         device.removePoint(p2);
 222         device.sync();
 223 
 224         //wait for results and make sure no event received
 225         Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: PRESSED"));
 226         Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: MOVED"));
 227         Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: RELEASED"));
 228     }
 229     @Ignore("RT-38482")
 230     @Test
 231     /**
 232      * Drag two touch points simultaneously from outside the window (from the
 233      * right side) to the window's center.
 234      * No "move", "press" or "release" events should be sent.
 235      */
 236     public void multiTouch_dragTwoPointsIntoTheWindow() throws Exception {
 237         Assume.assumeTrue(device.getPointCount() >= 2);
 238         Stage stage = TestApplication.getStage();
 239         double[] bounds = {0.0, 0.0, 0.0, 0.0};
 240         TestRunnable.invokeAndWait(() -> {
 241             bounds[0] = stage.getX();
 242             bounds[1] = stage.getY();
 243             bounds[2] = stage.getWidth();
 244             bounds[3] = stage.getHeight();
 245         });
 246         Rectangle2D stageBounds = new Rectangle2D(bounds[0], bounds[1],
 247                                                   bounds[2], bounds[3]);


 265         //drag the fingers into the center of window
 266         for (int i = x1 - 3; i >= windowMiddleX; i -= 3) {
 267             device.setPoint(p1, i, windowMiddleY);
 268             device.setPoint(p2, i + distance, windowMiddleY);
 269             device.sync();
 270         }
 271 
 272         //release all points
 273         device.removePoint(p1);
 274         device.removePoint(p2);
 275         device.sync();
 276 
 277         //tap in the window in order to verify all events were received
 278         int x3 = windowX;
 279         int y3 = windowY;
 280         int p = device.addPoint(x3, y3);
 281         device.sync();
 282         device.removePoint(p);
 283         device.sync();
 284         //verify events press/release were received
 285         TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", x3, y3);
 286         TestLog.waitForLogContaining("TouchPoint: RELEASED %d, %d", x3, y3);
 287 
 288         //Verify press/release events were received only once
 289         Assert.assertEquals(1, TestLog.countLogContaining("TouchPoint: PRESSED"));
 290         Assert.assertEquals(1, TestLog.countLogContaining("TouchPoint: RELEASED"));
 291 
 292         //make sure no move event was received
 293         Assert.assertEquals(0, TestLog.countLogContaining("TouchPoint: MOVED"));
 294     }
 295 }


   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.geometry.Rectangle2D;
  33 import javafx.stage.Stage;
  34 import org.junit.Assert;
  35 import org.junit.Assume;
  36 import org.junit.Before;
  37 import org.junit.Test;
  38 import org.junit.Ignore;
  39 import org.junit.runners.Parameterized;
  40 
  41 import java.util.Collection;
  42 import test.com.sun.glass.ui.monocle.TestRunnable;
  43 
  44 /**
  45  * This is a regression test for RT-33771 - Lens:FXML-LoginDemo throws
  46  * java.lang.RuntimeException: Platform reported wrong touch point ID. 
  47  *  
  48  * and  RT-33687 - Lens:some touch events are been dropped in native 


  52 public class DragTouchInAndOutAWindowTest extends ParameterizedTestBase {
  53 
  54     public DragTouchInAndOutAWindowTest(TestTouchDevice device) {
  55         super(device);
  56     }
  57 
  58     @Parameterized.Parameters
  59     public static Collection<Object[]> data() {
  60         return TestTouchDevices.getTouchDeviceParameters(1);
  61     }
  62 
  63 
  64     @Before
  65     public void setUpScreen() throws Exception {
  66         TestApplication.showInMiddleOfScreen();
  67         TestApplication.addTouchListeners();
  68         int p = device.addPoint(0, 0);
  69         device.sync();
  70         device.removePoint(p);
  71         device.sync();
  72         TestLogShim.reset();
  73     }
  74 
  75     /**
  76      * RT-33771 stated that exceptions are been thrown because the state of the
  77      * point, when entering the window, is wrong.
  78      * Test check that states are ok and no exception is been thrown
  79      *
  80      * Test update for RT-34191 - make sure no touch event received if drag
  81      * started outside the window
  82      */
  83     @Test
  84     public void singleTouch_dragPointIntoTheWindow() throws Exception {
  85         Stage stage = TestApplication.getStage();
  86         int windowRightEnd = (int)(stage.getX() + stage.getWidth());
  87         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
  88 
  89         //start outside the window and drag point into it (move in big steps
  90         //to avoid filtering)
  91         //expected:
  92         //1) no exception
  93         //2) no  press | move | release notifications
  94         int p = device.addPoint(windowRightEnd + 50, windowMiddleHeight);
  95         device.sync();
  96         for (int i = 49; i >= -50 ; i -= 3) {
  97             device.setPoint(p, windowRightEnd + i, windowMiddleHeight);
  98             device.sync();
  99         }
 100 
 101         //
 102         device.removePoint(p);
 103         device.sync();
 104 
 105         //check that tested window didn't recive any notifications
 106 
 107         //wait for results and make sure no event received
 108         Assert.assertEquals(0, TestLogShim.countLogContaining("TouchPoint: PRESSED"));
 109         Assert.assertEquals(0, TestLogShim.countLogContaining("TouchPoint: MOVED"));
 110         Assert.assertEquals(0, TestLogShim.countLogContaining("TouchPoint: RELEASED"));
 111     }
 112 
 113     @Test
 114     /**
 115      * This test is also related to RT-33687 - Lens:some touch events are been
 116      * dropped in native causing exceptions to be thrown.
 117      * In short there was a problem that when touch point moved outside a window
 118      * no notifications were sent, especially releases.
 119      *
 120      */
 121     public void singleTouch_dragPointoutsideAwindow() throws Exception {
 122         Stage stage = TestApplication.getStage();
 123         int windowMiddleWidth = (int)(stage.getX() + stage.getWidth() / 2);
 124         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
 125 
 126         //touch inside the window and drag the touch point to the end of the screen
 127         int p = device.addPoint(windowMiddleWidth, windowMiddleHeight);
 128         device.sync();
 129         for (int i = 0; i + windowMiddleWidth < width ; i += 5) {
 130             device.setPoint(p, windowMiddleWidth + i, windowMiddleHeight);
 131             device.sync();
 132         }
 133 
 134         //wait for results
 135         TestLogShim.waitForLogContaining("TouchPoint: PRESSED", 3000);
 136 
 137         //release outside the window
 138         device.removePoint(p);
 139         device.sync();
 140         //check that we get the event
 141         TestLogShim.waitForLogContaining("TouchPoint: RELEASED", 3000);
 142     }
 143 
 144      @Test
 145     /**
 146      * Combining the two test cases above, start a touch sequence inside a
 147      * window, drag the 'finger' out and in again and see that we gat the
 148      * events.
 149      *
 150      */
 151     public void singleTouch_dragPointInandOutAwindow() throws Exception {
 152         Stage stage = TestApplication.getStage();
 153         int windowMiddleWidth = (int)(stage.getX() + stage.getWidth() / 2);
 154         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
 155         int windowRightEnd = (int)(stage.getX() + stage.getWidth());
 156         int i;
 157 
 158         //start inside the window and drag point outside
 159         int p = device.addPoint(windowMiddleWidth, windowMiddleHeight);
 160         device.sync();
 161         for (i = windowMiddleWidth; i <= windowRightEnd + 100 ; i += 10) {
 162             device.setPoint(p, i, windowMiddleHeight);
 163             device.sync();
 164         }
 165 
 166         //wait for results
 167         TestLogShim.waitForLogContaining("TouchPoint: PRESSED", 3000);
 168         TestLogShim.waitForLogContaining("TouchPoint: MOVED", 3000);
 169 
 170         //continue from where we stopped and drag point back to window
 171         for (; i >= windowMiddleWidth  ; i -= 10) {
 172             device.setPoint(p, i, windowMiddleHeight);
 173             device.sync();
 174         }
 175 
 176         //release inside the window
 177         device.removePoint(p);
 178         device.sync();
 179         //check that we get the event
 180         TestLogShim.waitForLogContaining("TouchPoint: RELEASED", 3000);
 181     }
 182 
 183      @Test
 184     /**
 185      * Same test as above, but for multi touch.
 186      * Test should pass in either single touch mode or multi touch mode
 187      * Main point is to see that no exception is been thrown
 188      *
 189      */
 190     public void multiTouch_dragPointInandOutAwindow() throws Exception {
 191         Assume.assumeTrue(device.getPointCount() >= 2);
 192         Stage stage = TestApplication.getStage();
 193         int windowMiddleWidth = (int)(stage.getX() + stage.getWidth() / 2);
 194         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
 195         int windowRightEnd = (int)(stage.getX() + stage.getWidth());
 196         int i;
 197         int p1 = device.addPoint(windowRightEnd + 15, windowMiddleHeight);
 198         int p2 = device.addPoint(windowRightEnd + 15, windowMiddleHeight + 10);
 199         device.sync();
 200         //start outside the window and drag point into the center of window


 205             device.setPoint(p2, i, windowMiddleHeight + 10);
 206             device.sync();
 207         }
 208 
 209         //continue from where we stopped and drag point outside the window to
 210         //the end of screen
 211         for (; i + windowMiddleWidth < width ; i += 5) {
 212             //first finger
 213             device.setPoint(p1, i, windowMiddleHeight);
 214             //second finger
 215             device.setPoint(p2, i, windowMiddleHeight + 10);
 216             device.sync();
 217         }
 218 
 219         //release all points outside the window
 220         device.removePoint(p1);
 221         device.removePoint(p2);
 222         device.sync();
 223 
 224         //wait for results and make sure no event received
 225         Assert.assertEquals(0, TestLogShim.countLogContaining("TouchPoint: PRESSED"));
 226         Assert.assertEquals(0, TestLogShim.countLogContaining("TouchPoint: MOVED"));
 227         Assert.assertEquals(0, TestLogShim.countLogContaining("TouchPoint: RELEASED"));
 228     }
 229     @Ignore("RT-38482")
 230     @Test
 231     /**
 232      * Drag two touch points simultaneously from outside the window (from the
 233      * right side) to the window's center.
 234      * No "move", "press" or "release" events should be sent.
 235      */
 236     public void multiTouch_dragTwoPointsIntoTheWindow() throws Exception {
 237         Assume.assumeTrue(device.getPointCount() >= 2);
 238         Stage stage = TestApplication.getStage();
 239         double[] bounds = {0.0, 0.0, 0.0, 0.0};
 240         TestRunnable.invokeAndWait(() -> {
 241             bounds[0] = stage.getX();
 242             bounds[1] = stage.getY();
 243             bounds[2] = stage.getWidth();
 244             bounds[3] = stage.getHeight();
 245         });
 246         Rectangle2D stageBounds = new Rectangle2D(bounds[0], bounds[1],
 247                                                   bounds[2], bounds[3]);


 265         //drag the fingers into the center of window
 266         for (int i = x1 - 3; i >= windowMiddleX; i -= 3) {
 267             device.setPoint(p1, i, windowMiddleY);
 268             device.setPoint(p2, i + distance, windowMiddleY);
 269             device.sync();
 270         }
 271 
 272         //release all points
 273         device.removePoint(p1);
 274         device.removePoint(p2);
 275         device.sync();
 276 
 277         //tap in the window in order to verify all events were received
 278         int x3 = windowX;
 279         int y3 = windowY;
 280         int p = device.addPoint(x3, y3);
 281         device.sync();
 282         device.removePoint(p);
 283         device.sync();
 284         //verify events press/release were received
 285         TestLogShim.waitForLogContaining("TouchPoint: PRESSED %d, %d", x3, y3);
 286         TestLogShim.waitForLogContaining("TouchPoint: RELEASED %d, %d", x3, y3);
 287 
 288         //Verify press/release events were received only once
 289         Assert.assertEquals(1, TestLogShim.countLogContaining("TouchPoint: PRESSED"));
 290         Assert.assertEquals(1, TestLogShim.countLogContaining("TouchPoint: RELEASED"));
 291 
 292         //make sure no move event was received
 293         Assert.assertEquals(0, TestLogShim.countLogContaining("TouchPoint: MOVED"));
 294     }
 295 }
< prev index next >