< prev index next >

src/org/netbeans/jemmy/operators/ComponentOperator.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2016, 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


  42 import java.awt.Toolkit;
  43 import java.awt.Window;
  44 import java.awt.dnd.DropTarget;
  45 import java.awt.event.ComponentListener;
  46 import java.awt.event.FocusListener;
  47 import java.awt.event.InputMethodListener;
  48 import java.awt.event.KeyListener;
  49 import java.awt.event.MouseListener;
  50 import java.awt.event.MouseMotionListener;
  51 import java.awt.im.InputContext;
  52 import java.awt.im.InputMethodRequests;
  53 import java.awt.image.ColorModel;
  54 import java.awt.image.ImageObserver;
  55 import java.awt.image.ImageProducer;
  56 import java.beans.PropertyChangeListener;
  57 import java.io.PrintStream;
  58 import java.io.PrintWriter;
  59 import java.util.Hashtable;
  60 import java.util.Locale;
  61 
  62 import static java.lang.Math.abs;
  63 
  64 import org.netbeans.jemmy.CharBindingMap;
  65 import org.netbeans.jemmy.ComponentChooser;
  66 import org.netbeans.jemmy.ComponentSearcher;
  67 import org.netbeans.jemmy.EventDispatcher;
  68 import org.netbeans.jemmy.JemmyException;
  69 import org.netbeans.jemmy.JemmyProperties;
  70 import org.netbeans.jemmy.Outputable;
  71 import org.netbeans.jemmy.QueueTool;
  72 import org.netbeans.jemmy.TestOut;
  73 import org.netbeans.jemmy.TimeoutExpiredException;
  74 import org.netbeans.jemmy.Timeoutable;
  75 import org.netbeans.jemmy.Timeouts;
  76 import org.netbeans.jemmy.Waitable;
  77 import org.netbeans.jemmy.Waiter;
  78 import org.netbeans.jemmy.drivers.DriverManager;
  79 import org.netbeans.jemmy.drivers.FocusDriver;
  80 import org.netbeans.jemmy.drivers.KeyDriver;
  81 import org.netbeans.jemmy.drivers.MouseDriver;
  82 
  83 /**


1205                         && componentLocation.x <= maxLocation.x
1206                         && componentLocation.y >= minLocation.y
1207                         && componentLocation.y <= maxLocation.y;
1208             }
1209 
1210             @Override
1211             public String getDescription() {
1212                 return "Component reaches location between :" + minLocation
1213                         + "and " + maxLocation;
1214             }
1215 
1216             @Override
1217             public String toString() {
1218                 return "ComponentOperator.waitComponentLocation"
1219                         + ".Waitable{description = " + getDescription() + '}';
1220             }
1221         });
1222     }
1223 
1224     /**










































1225      * Returns information about component.
1226      */
1227     @Override
1228     public Hashtable<String, Object> getDump() {
1229         Hashtable<String, Object> result = super.getDump();
1230         if (getSource().getName() != null) {
1231             result.put(NAME_DPROP, getSource().getName());
1232         }
1233         result.put(IS_VISIBLE_DPROP, getSource().isVisible() ? "true" : "false");
1234         result.put(IS_SHOWING_DPROP, getSource().isShowing() ? "true" : "false");
1235         result.put(X_DPROP, Integer.toString(getSource().getX()));
1236         result.put(Y_DPROP, Integer.toString(getSource().getY()));
1237         result.put(WIDTH_DPROP, Integer.toString(getSource().getWidth()));
1238         result.put(HEIGHT_DPROP, Integer.toString(getSource().getHeight()));
1239         return result;
1240     }
1241 
1242     ////////////////////////////////////////////////////////
1243     //Mapping                                             //
1244     /**


   1 /*
   2  * Copyright (c) 1997, 2018, 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


  42 import java.awt.Toolkit;
  43 import java.awt.Window;
  44 import java.awt.dnd.DropTarget;
  45 import java.awt.event.ComponentListener;
  46 import java.awt.event.FocusListener;
  47 import java.awt.event.InputMethodListener;
  48 import java.awt.event.KeyListener;
  49 import java.awt.event.MouseListener;
  50 import java.awt.event.MouseMotionListener;
  51 import java.awt.im.InputContext;
  52 import java.awt.im.InputMethodRequests;
  53 import java.awt.image.ColorModel;
  54 import java.awt.image.ImageObserver;
  55 import java.awt.image.ImageProducer;
  56 import java.beans.PropertyChangeListener;
  57 import java.io.PrintStream;
  58 import java.io.PrintWriter;
  59 import java.util.Hashtable;
  60 import java.util.Locale;
  61 


  62 import org.netbeans.jemmy.CharBindingMap;
  63 import org.netbeans.jemmy.ComponentChooser;
  64 import org.netbeans.jemmy.ComponentSearcher;
  65 import org.netbeans.jemmy.EventDispatcher;
  66 import org.netbeans.jemmy.JemmyException;
  67 import org.netbeans.jemmy.JemmyProperties;
  68 import org.netbeans.jemmy.Outputable;
  69 import org.netbeans.jemmy.QueueTool;
  70 import org.netbeans.jemmy.TestOut;
  71 import org.netbeans.jemmy.TimeoutExpiredException;
  72 import org.netbeans.jemmy.Timeoutable;
  73 import org.netbeans.jemmy.Timeouts;
  74 import org.netbeans.jemmy.Waitable;
  75 import org.netbeans.jemmy.Waiter;
  76 import org.netbeans.jemmy.drivers.DriverManager;
  77 import org.netbeans.jemmy.drivers.FocusDriver;
  78 import org.netbeans.jemmy.drivers.KeyDriver;
  79 import org.netbeans.jemmy.drivers.MouseDriver;
  80 
  81 /**


1203                         && componentLocation.x <= maxLocation.x
1204                         && componentLocation.y >= minLocation.y
1205                         && componentLocation.y <= maxLocation.y;
1206             }
1207 
1208             @Override
1209             public String getDescription() {
1210                 return "Component reaches location between :" + minLocation
1211                         + "and " + maxLocation;
1212             }
1213 
1214             @Override
1215             public String toString() {
1216                 return "ComponentOperator.waitComponentLocation"
1217                         + ".Waitable{description = " + getDescription() + '}';
1218             }
1219         });
1220     }
1221 
1222     /**
1223      * Wait till the component reaches exact location on screen.
1224      *
1225      * @param exactLocation exact expected screen location.
1226      */
1227     public void waitComponentLocationOnScreen(Point exactlocation) {
1228         waitComponentLocationOnScreen(exactlocation, exactlocation);
1229     }
1230 
1231     /**
1232      * Wait till the component location on screen reaches between minLocation
1233      * and maxLocation
1234      *
1235      * @param minLocation minimum expected location on screen.
1236      * @param maxLocation maximum expected location on screen.
1237      */
1238     public void waitComponentLocationOnScreen(
1239             final Point minLocation, final Point maxLocation) {
1240         waitState(new ComponentChooser() {
1241             @Override
1242             public boolean checkComponent(Component comp) {
1243                 Point location = comp.getLocationOnScreen();
1244                 return location.x >= minLocation.x
1245                         && location.x <= maxLocation.x
1246                         && location.y >= minLocation.y
1247                         && location.y <= maxLocation.y;
1248             }
1249 
1250             @Override
1251             public String getDescription() {
1252                 return "Component location on screen reaches between :"
1253                         + minLocation + "and " + maxLocation;
1254             }
1255 
1256             @Override
1257             public String toString() {
1258                 return "ComponentOperator.waitComponentLocationOnScreen"
1259                         + ".Waitable{description = " + getDescription() + '}';
1260             }
1261         });
1262     }
1263 
1264     /**
1265      * Returns information about component.
1266      */
1267     @Override
1268     public Hashtable<String, Object> getDump() {
1269         Hashtable<String, Object> result = super.getDump();
1270         if (getSource().getName() != null) {
1271             result.put(NAME_DPROP, getSource().getName());
1272         }
1273         result.put(IS_VISIBLE_DPROP, getSource().isVisible() ? "true" : "false");
1274         result.put(IS_SHOWING_DPROP, getSource().isShowing() ? "true" : "false");
1275         result.put(X_DPROP, Integer.toString(getSource().getX()));
1276         result.put(Y_DPROP, Integer.toString(getSource().getY()));
1277         result.put(WIDTH_DPROP, Integer.toString(getSource().getWidth()));
1278         result.put(HEIGHT_DPROP, Integer.toString(getSource().getHeight()));
1279         return result;
1280     }
1281 
1282     ////////////////////////////////////////////////////////
1283     //Mapping                                             //
1284     /**


< prev index next >