rev 9504 : need to fix test log and others

   1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   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 org.junit.Test;
  33 import org.junit.runners.Parameterized;
  34 
  35 import java.util.Collection;
  36 
  37 public class DoubleClickTest extends ParameterizedTestBase {
  38 
  39     public DoubleClickTest(TestTouchDevice device) {
  40         super(device);
  41     }
  42 
  43     @Parameterized.Parameters
  44     public static Collection<Object[]> data() {
  45         return TestTouchDevices.getTouchDeviceParameters(1);
  46     }
  47 
  48     /** Test that double taps in the same area generate synthesized
  49      * multi-click mouse events. */
  50     @Test
  51     public void testDoubleClick1() throws Exception {
  52         int x = (int) Math.round(width / 2.0);
  53         int y = (int) Math.round(height / 2.0);
  54         TestApplication.getStage().getScene().setOnMouseClicked((e) -> TestLogShim.format("Mouse clicked: %d, %d: clickCount %d",
  55                        (int) e.getScreenX(), (int) e.getScreenY(),
  56                        e.getClickCount()));
  57         TestLogShim.reset();
  58         int p = device.addPoint(x, y);
  59         device.sync();
  60         device.removePoint(p);
  61         device.sync();
  62         p = device.addPoint(x, y);
  63         device.sync();
  64         device.removePoint(p);
  65         device.sync();
  66         TestLogShim.waitForLog("Mouse clicked: " + x + ", " + y + ": clickCount 1", 3000l);
  67         TestLogShim.waitForLog("Mouse clicked: " + x + ", " + y + ": clickCount 2", 3000l);
  68     }
  69 
  70     @Test
  71     public void testDoubleClick2() throws Exception {
  72         int x1 = (int) Math.round(width / 2.0);
  73         int y1 = (int) Math.round(height / 2.0);
  74         int x2 = x1 + device.getTapRadius();
  75         int y2 = y1 + device.getTapRadius();
  76 
  77         TestApplication.getStage().getScene().setOnMouseClicked((e) -> TestLogShim.format("Mouse clicked: %d, %d: clickCount %d",
  78                        (int) e.getScreenX(), (int) e.getScreenY(),
  79                        e.getClickCount()));
  80         TestLogShim.reset();
  81         int p = device.addPoint(x1, y1);
  82         device.sync();
  83         device.removePoint(p);
  84         device.sync();
  85         p = device.addPoint(x2, y2);
  86         device.sync();
  87         device.removePoint(p);
  88         device.sync();
  89         TestLogShim.waitForLog("Mouse clicked: " + x1 + ", " + y1 + ": clickCount 1", 3000l);
  90         TestLogShim.waitForLog("Mouse clicked: " + x2 + ", " + y2 + ": clickCount 2", 3000l);
  91     }
  92 
  93 }
--- EOF ---