< prev index next >

tests/system/src/test/java/test/robot/com/sun/glass/ui/monocle/ScrollTest.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.ScrollTestBase;
  30 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevice;
  31 import org.junit.Assert;
  32 import org.junit.Assume;
  33 import org.junit.Test;
  34 
  35 /**
  36  * Scroll tests generated by one and more touch points.
  37  *  */
  38 public class ScrollTest extends ScrollTestBase {
  39 
  40     public ScrollTest(TestTouchDevice device) {
  41         super(device);
  42     }
  43 
  44     private int getDelta() throws Exception {
  45         int max = Math.max(getScrollThreshold(), device.getTapRadius());
  46         return Math.max(max, 30) + 1;
  47     }
  48 


 195         moveTwoFingers(0, -getDelta() * 2, 2, false, true);
 196         releaseSecondFinger();
 197         moveOneFinger(0, getDelta(), 2, false);
 198         releaseFirstFinger();
 199     }
 200 
 201     /**
 202      * Tap two fingers, scroll them down asymmetrically: first finger's location
 203      * changed by delta, second finger's location changed by (delta * 2)
 204      */
 205     @Test
 206     public void testTwoFingersAsymmetricScroll() throws Exception {
 207         Assume.assumeTrue(device.getPointCount() >= 2);
 208         int deltaY1 = getDelta() + 1;
 209         int deltaY2 = deltaY1 * 2;
 210         int numOfIterations = 4;
 211         Assert.assertTrue(paramsValid(0, deltaY1, numOfIterations,
 212                 point1X, point1Y) &&
 213                 paramsValid(0, deltaY2, numOfIterations,
 214                         point2X, point2Y));
 215         TestLog.reset();
 216         p1 = device.addPoint(point1X, point1Y);
 217         p2 = device.addPoint(point2X, point2Y);
 218         device.sync();
 219         //verify fingers pressed
 220         TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", point1X, point1Y);
 221         TestLog.waitForLogContaining("TouchPoint: PRESSED %d, %d", point2X, point2Y);
 222         point1Y += deltaY1;
 223         point2Y += deltaY2;
 224         int avgDelta = (deltaY1 + deltaY2) / 2;
 225         //scroll fingers
 226         TestLog.reset();
 227         device.setPoint(p1, point1X, point1Y);
 228         device.setPoint(p2, point2X, point2Y);
 229         device.sync();
 230         TestLog.waitForLogContaining("TouchPoint: MOVED %d, %d", point1X, point1Y);
 231         TestLog.waitForLogContaining("TouchPoint: MOVED %d, %d", point2X, point2Y);
 232         totalDeltaY = avgDelta;
 233         TestLog.waitForLogContaining("Scroll started, DeltaX: " + 0
 234                 + ", DeltaY: " + 0
 235                 + ", totalDeltaX: " + 0
 236                 + ", totalDeltaY: " + 0
 237                 + ", touch points: " + 2
 238                 + ", inertia value: false");
 239         TestLog.waitForLogContaining("Scroll, DeltaX: " + 0
 240                 + ", DeltaY: " + avgDelta
 241                 + ", totalDeltaX: " + 0
 242                 + ", totalDeltaY: " + totalDeltaY
 243                 + ", touch points: " + 2
 244                 + ", inertia value: false");
 245         String expectedLog;
 246         for (int i = 2; i <= numOfIterations; i++) {
 247             point1Y += deltaY1;
 248             point2Y += deltaY2;
 249             TestLog.reset();
 250             device.setPoint(p1, point1X, point1Y);
 251             device.setPoint(p2, point2X, point2Y);
 252             device.sync();
 253             TestLog.waitForLogContaining("TouchPoint: MOVED %d, %d", point1X, point1Y);
 254             TestLog.waitForLogContaining("TouchPoint: MOVED %d, %d", point2X, point2Y);
 255             totalDeltaY = avgDelta * i;
 256             expectedLog = "Scroll, DeltaX: " + 0 + ", DeltaY: " + avgDelta
 257                     + ", totalDeltaX: " + 0
 258                     + ", totalDeltaY: " + totalDeltaY
 259                     + ", touch points: " + 2 + ", inertia value: false";
 260             TestLog.waitForLogContaining(expectedLog);
 261         }
 262         releaseAllFingers();
 263     }
 264 }


   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.ScrollTestBase;
  30 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevice;
  31 import org.junit.Assert;
  32 import org.junit.Assume;
  33 import org.junit.Test;
  34 
  35 /**
  36  * Scroll tests generated by one and more touch points.
  37  *  */
  38 public class ScrollTest extends ScrollTestBase {
  39 
  40     public ScrollTest(TestTouchDevice device) {
  41         super(device);
  42     }
  43 
  44     private int getDelta() throws Exception {
  45         int max = Math.max(getScrollThreshold(), device.getTapRadius());
  46         return Math.max(max, 30) + 1;
  47     }
  48 


 195         moveTwoFingers(0, -getDelta() * 2, 2, false, true);
 196         releaseSecondFinger();
 197         moveOneFinger(0, getDelta(), 2, false);
 198         releaseFirstFinger();
 199     }
 200 
 201     /**
 202      * Tap two fingers, scroll them down asymmetrically: first finger's location
 203      * changed by delta, second finger's location changed by (delta * 2)
 204      */
 205     @Test
 206     public void testTwoFingersAsymmetricScroll() throws Exception {
 207         Assume.assumeTrue(device.getPointCount() >= 2);
 208         int deltaY1 = getDelta() + 1;
 209         int deltaY2 = deltaY1 * 2;
 210         int numOfIterations = 4;
 211         Assert.assertTrue(paramsValid(0, deltaY1, numOfIterations,
 212                 point1X, point1Y) &&
 213                 paramsValid(0, deltaY2, numOfIterations,
 214                         point2X, point2Y));
 215         TestLogShim.reset();
 216         p1 = device.addPoint(point1X, point1Y);
 217         p2 = device.addPoint(point2X, point2Y);
 218         device.sync();
 219         //verify fingers pressed
 220         TestLogShim.waitForLogContaining("TouchPoint: PRESSED %d, %d", point1X, point1Y);
 221         TestLogShim.waitForLogContaining("TouchPoint: PRESSED %d, %d", point2X, point2Y);
 222         point1Y += deltaY1;
 223         point2Y += deltaY2;
 224         int avgDelta = (deltaY1 + deltaY2) / 2;
 225         //scroll fingers
 226         TestLogShim.reset();
 227         device.setPoint(p1, point1X, point1Y);
 228         device.setPoint(p2, point2X, point2Y);
 229         device.sync();
 230         TestLogShim.waitForLogContaining("TouchPoint: MOVED %d, %d", point1X, point1Y);
 231         TestLogShim.waitForLogContaining("TouchPoint: MOVED %d, %d", point2X, point2Y);
 232         totalDeltaY = avgDelta;
 233         TestLogShim.waitForLogContaining("Scroll started, DeltaX: " + 0
 234                 + ", DeltaY: " + 0
 235                 + ", totalDeltaX: " + 0
 236                 + ", totalDeltaY: " + 0
 237                 + ", touch points: " + 2
 238                 + ", inertia value: false");
 239         TestLogShim.waitForLogContaining("Scroll, DeltaX: " + 0
 240                 + ", DeltaY: " + avgDelta
 241                 + ", totalDeltaX: " + 0
 242                 + ", totalDeltaY: " + totalDeltaY
 243                 + ", touch points: " + 2
 244                 + ", inertia value: false");
 245         String expectedLog;
 246         for (int i = 2; i <= numOfIterations; i++) {
 247             point1Y += deltaY1;
 248             point2Y += deltaY2;
 249             TestLogShim.reset();
 250             device.setPoint(p1, point1X, point1Y);
 251             device.setPoint(p2, point2X, point2Y);
 252             device.sync();
 253             TestLogShim.waitForLogContaining("TouchPoint: MOVED %d, %d", point1X, point1Y);
 254             TestLogShim.waitForLogContaining("TouchPoint: MOVED %d, %d", point2X, point2Y);
 255             totalDeltaY = avgDelta * i;
 256             expectedLog = "Scroll, DeltaX: " + 0 + ", DeltaY: " + avgDelta
 257                     + ", totalDeltaX: " + 0
 258                     + ", totalDeltaY: " + totalDeltaY
 259                     + ", touch points: " + 2 + ", inertia value: false";
 260             TestLogShim.waitForLogContaining(expectedLog);
 261         }
 262         releaseAllFingers();
 263     }
 264 }
< prev index next >