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 javafx.application.Platform;
  31 import javafx.scene.Group;
  32 import javafx.scene.Scene;
  33 import javafx.stage.Modality;
  34 import javafx.stage.Stage;
  35 import com.sun.glass.ui.Robot;
  36 import junit.framework.AssertionFailedError;
  37 import org.junit.*;
  38 import org.junit.rules.TestName;
  39 
  40 
  41 public class ModalDialogTest {
  42 
  43     @Rule
  44     public TestName name = new TestName();
  45 
  46     @Before
  47     public void setUpScreen() throws Exception {
  48         TestLogShim.reset();
  49         TestLogShim.log(name.getMethodName());
  50         TestApplication.showFullScreenScene();
  51     }
  52 
  53     @Test
  54     public void test1() throws Exception {
  55         Stage rootStage = TestApplication.getStage();
  56         rootStage.getScene().setOnMouseClicked(
  57                 (e) -> TestLogShim.format("Clicked at %.0f, %.0f",
  58                         e.getScreenX(), e.getScreenY()));
  59         Platform.runLater(() -> {
  60             final Stage p = new Stage();
  61             p.initOwner(rootStage);
  62             p.initModality(Modality.APPLICATION_MODAL);
  63             p.setX(0);
  64             p.setY(0);
  65             p.setWidth(200);
  66             p.setHeight(200);
  67             p.setScene(new Scene(new Group()));
  68             p.getScene().setOnMouseClicked(
  69                     (e) -> TestLogShim.format("Clicked at %.0f, %.0f",
  70                             e.getScreenX(), e.getScreenY()));
  71             p.show();
  72         });
  73         TestLogShim.clear();
  74         Platform.runLater(() -> {
  75             Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();
  76             robot.mouseMove(300, 400);
  77             robot.mousePress(Robot.MOUSE_LEFT_BTN);
  78             robot.mouseRelease(Robot.MOUSE_LEFT_BTN);
  79             robot.mouseMove(100, 100);
  80             robot.mousePress(Robot.MOUSE_LEFT_BTN);
  81             robot.mouseRelease(Robot.MOUSE_LEFT_BTN);
  82         });
  83         TestLogShim.waitForLog("Clicked at 100, 100");
  84         if (TestLogShim.countLog("Clicked at 300, 400") != 0) {
  85             throw new AssertionFailedError("Disabled window should not receive mouse events!");
  86         }
  87     }
  88 }
  89 
--- EOF ---