< prev index next >

test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.java

Print this page
rev 51542 : 8210039: move OSInfo to top level testlibrary
Reviewed-by: duke


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25   test
  26   @bug 6190768 6190778
  27   @summary Tests that triggering events on AWT list by pressing CTRL + HOME, CTRL + END, PG-UP, PG-DOWN similar Motif behavior
  28   @author Dmitry.Cherepanov@SUN.COM area=awt.list
  29   @library ../../../../lib/testlibrary
  30   @build jdk.testlibrary.OSInfo
  31   @run applet KeyEventsTest.html
  32 */
  33 
  34 /**
  35  * KeyEventsTest.html
  36  *
  37  * summary:
  38  */
  39 
  40 import java.applet.Applet;
  41 import java.awt.*;
  42 import java.awt.event.*;
  43 import java.util.Set;
  44 import java.lang.reflect.*;
  45 
  46 import jdk.testlibrary.OSInfo;
  47 
  48 public class KeyEventsTest extends Applet implements ItemListener, FocusListener, KeyListener
  49 {
  50     TestState currentState;
  51     final Object LOCK = new Object();
  52     final int ACTION_TIMEOUT = 500;
  53 
  54     List single = new List(3, false);
  55     List multiple = new List(3, true);
  56 
  57     Panel p1 = new Panel ();
  58     Panel p2 = new Panel ();
  59 
  60     public void init()
  61     {
  62         setLayout (new BorderLayout ());
  63 
  64         single.add("0");
  65         single.add("1");
  66         single.add("2");


 256 
 257             if (currentState.getKeyID() == KeyEvent.VK_HOME ||
 258                 currentState.getKeyID() == KeyEvent.VK_END){
 259                 r.keyRelease(KeyEvent.VK_CONTROL);
 260             }
 261 
 262             r.waitForIdle();
 263             r.delay(200);
 264 
 265             if (currentState.getTemplate() != currentState.getAction())
 266                 throw new RuntimeException("Test failed.");
 267 
 268         }
 269 
 270     }
 271 
 272     private void doTest()
 273       throws InterruptedException, InvocationTargetException {
 274 
 275         boolean isWin = false;
 276         if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
 277             isWin = true;
 278         }else if(OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
 279             System.out.println("Not for OS X");
 280             return;
 281         }
 282 
 283         System.out.println("multiple? selectedMoved? ?scrollMoved keyID? template? action?");
 284         test(new TestState(false, false, false, KeyEvent.VK_PAGE_UP, isWin?false:false));
 285         // SelectedMoved (false) != ScrollMoved (true) for single list not emulated
 286         test(new TestState(false, true, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
 287         test(new TestState(false, true, true, KeyEvent.VK_PAGE_UP, isWin?true:true));
 288         test(new TestState(true, false, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
 289         test(new TestState(true, false, true, KeyEvent.VK_PAGE_UP, isWin?true:false));
 290         test(new TestState(true, true, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
 291         test(new TestState(true, true, true, KeyEvent.VK_PAGE_UP, isWin?true:false));
 292 
 293         test(new TestState(false, false, false, KeyEvent.VK_PAGE_DOWN, isWin?false:false));
 294         test(new TestState(false, true, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
 295         test(new TestState(false, true, true, KeyEvent.VK_PAGE_DOWN, isWin?true:true));
 296         test(new TestState(true, false, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
 297         test(new TestState(true, false, true, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
 298         test(new TestState(true, true, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25   test
  26   @bug 6190768 6190778
  27   @summary Tests that triggering events on AWT list by pressing CTRL + HOME, CTRL + END, PG-UP, PG-DOWN similar Motif behavior
  28   @author Dmitry.Cherepanov@SUN.COM area=awt.list
  29   @library /test/lib
  30   @build jdk.test.lib.Platform
  31   @run applet KeyEventsTest.html
  32 */
  33 
  34 /**
  35  * KeyEventsTest.html
  36  *
  37  * summary:
  38  */
  39 
  40 import java.applet.Applet;
  41 import java.awt.*;
  42 import java.awt.event.*;
  43 import java.util.Set;
  44 import java.lang.reflect.*;
  45 
  46 import jdk.test.lib.Platform;
  47 
  48 public class KeyEventsTest extends Applet implements ItemListener, FocusListener, KeyListener
  49 {
  50     TestState currentState;
  51     final Object LOCK = new Object();
  52     final int ACTION_TIMEOUT = 500;
  53 
  54     List single = new List(3, false);
  55     List multiple = new List(3, true);
  56 
  57     Panel p1 = new Panel ();
  58     Panel p2 = new Panel ();
  59 
  60     public void init()
  61     {
  62         setLayout (new BorderLayout ());
  63 
  64         single.add("0");
  65         single.add("1");
  66         single.add("2");


 256 
 257             if (currentState.getKeyID() == KeyEvent.VK_HOME ||
 258                 currentState.getKeyID() == KeyEvent.VK_END){
 259                 r.keyRelease(KeyEvent.VK_CONTROL);
 260             }
 261 
 262             r.waitForIdle();
 263             r.delay(200);
 264 
 265             if (currentState.getTemplate() != currentState.getAction())
 266                 throw new RuntimeException("Test failed.");
 267 
 268         }
 269 
 270     }
 271 
 272     private void doTest()
 273       throws InterruptedException, InvocationTargetException {
 274 
 275         boolean isWin = false;
 276         if (Platform.isWindows()) {
 277             isWin = true;
 278         } else if (Platform.isOSX()) {
 279             System.out.println("Not for OS X");
 280             return;
 281         }
 282 
 283         System.out.println("multiple? selectedMoved? ?scrollMoved keyID? template? action?");
 284         test(new TestState(false, false, false, KeyEvent.VK_PAGE_UP, isWin?false:false));
 285         // SelectedMoved (false) != ScrollMoved (true) for single list not emulated
 286         test(new TestState(false, true, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
 287         test(new TestState(false, true, true, KeyEvent.VK_PAGE_UP, isWin?true:true));
 288         test(new TestState(true, false, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
 289         test(new TestState(true, false, true, KeyEvent.VK_PAGE_UP, isWin?true:false));
 290         test(new TestState(true, true, false, KeyEvent.VK_PAGE_UP, isWin?true:false));
 291         test(new TestState(true, true, true, KeyEvent.VK_PAGE_UP, isWin?true:false));
 292 
 293         test(new TestState(false, false, false, KeyEvent.VK_PAGE_DOWN, isWin?false:false));
 294         test(new TestState(false, true, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
 295         test(new TestState(false, true, true, KeyEvent.VK_PAGE_DOWN, isWin?true:true));
 296         test(new TestState(true, false, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
 297         test(new TestState(true, false, true, KeyEvent.VK_PAGE_DOWN, isWin?true:false));
 298         test(new TestState(true, true, false, KeyEvent.VK_PAGE_DOWN, isWin?true:false));


< prev index next >