2611N/A * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. 2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <p>This class contains utilities useful for regression testing. 0N/A * <p>When using jtreg you would include this class into the build 0N/A * list via something like: 0N/A @library ../../../regtesthelpers 0N/A * Note that if you are about to create a test based on 0N/A * Applet-template, then put those lines into html-file, not in java-file. 0N/A * into the java source of test. 0N/A private Util() {}
// this is a helper class with static methods :) 0N/A * @throws RuntimeException when creation failed 0N/A * Makes the window visible and waits until it's shown. 0N/A * Moves mouse pointer in the center of given {@code comp} component 0N/A * using {@code robot} parameter. 0N/A * Moves mouse pointer in the center of a given {@code comp} component 0N/A * and performs a left mouse button click using the {@code robot} parameter 0N/A * with the {@code delay} delay between press and release. 0N/A * Moves mouse pointer in the center of a given {@code comp} component 0N/A * and performs a left mouse button click using the {@code robot} parameter 0N/A * with the default delay between press and release. 0N/A * WARNING: it may fail on some platforms when the window is not wide enough. 0N/A // we do not use robot for now, use SunToolkit.realSync() instead 0N/A * Waits for a notification and for a boolean condition to become true. 0N/A * The method returns when the above conditions are fullfilled or when the timeout 0N/A * @param condition the object to be notified and the booelan condition to wait for 0N/A * @param timeout the maximum time to wait in milliseconds 0N/A * @param catchExceptions if {@code true} the method catches InterruptedException 0N/A * @return the final boolean value of the {@code condition} 0N/A * @throws InterruptedException if the awaiting proccess has been interrupted 0N/A * The same as {@code waitForConditionEx(AtomicBoolean, long)} except that it 0N/A * doesn't throw InterruptedException. 0N/A * The same as {@code waitForConditionEx(AtomicBoolean, long)} but without a timeout. 0N/A * The same as {@code waitForConditionEx(AtomicBoolean)} except that it 0N/A * doesn't throw InterruptedException. 0N/A * Drags from one point to another with the specified mouse button pressed. 0N/A * @param robot a robot to use for moving the mouse, etc. 0N/A * @param startPoint a start point of the drag 0N/A * @param endPoint an end point of the drag 0N/A * @param button one of {@code InputEvent.BUTTON1_MASK}, 0N/A * {@code InputEvent.BUTTON2_MASK}, {@code InputEvent.BUTTON3_MASK} 0N/A * @throws IllegalArgumentException if {@code button} is not one of 0N/A * {@code InputEvent.BUTTON1_MASK}, {@code InputEvent.BUTTON2_MASK}, 0N/A * {@code InputEvent.BUTTON3_MASK} 0N/A * Moves the mouse pointer from one point to another. 0N/A * Uses Bresenham's algorithm. 0N/A * @param robot a robot to use for moving the mouse 0N/A * @param startPoint a start point of the drag 0N/A * @param endPoint an end point of the drag 0N/A return (i >
0)?
1: -
1;
0N/A return n <
0 ? -
1 : n ==
0 ?
0 :
1;
0N/A /** Returns {@code WindowListener} instance that diposes {@code Window} on 0N/A * "window closing" event. 0N/A * @return the {@code WindowListener} instance that could be set 0N/A * on a {@code Window}. After that 0N/A * the {@code Window} is disposed when "window closed" 2611N/A * event is sent to the {@code Window} 0N/A * The values directly map to the ones of 0N/A * sun.awt.X11.XWM & sun.awt.motif.MToolkit classes. 0N/A public final static int 0N/A * Returns -1 in case of not X Window or any problems. //////////////////////////// // Some stuff to test focus. //////////////////////////// * Tracks WINDOW_GAINED_FOCUS event for a window caused by an action. * @param window the window to track the event for * @param action the action to perform * @param time the max time to wait for the event * @param printEvent should the event received be printed or doesn't * @return true if the event has been received, otherwise false * Tracks FOCUS_GAINED event for a component caused by an action. * @see #trackWindowGainedFocus * Tracks ACTION_PERFORMED event for a button caused by an action. * @see #trackWindowGainedFocus * Requests focus on the component provided and waits for the result. * @return true if the component has been focused, false otherwise. * Invokes the <code>task</code> on the EDT thread. * @return result of the <code>task</code>