< prev index next >

tests/system/src/test/java/test/robot/com/sun/glass/ui/monocle/MonocleApplicationTest.java

Print this page
rev 9491 : 8145203: Refactor systemTests for clear separation of tests
Reviewed-by: kcr


   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 package com.sun.glass.ui.monocle;
  26 

  27 import com.sun.glass.events.KeyEvent;
  28 import com.sun.glass.ui.Application;
  29 import org.junit.Assert;
  30 import org.junit.Assume;
  31 import org.junit.Test;

  32 
  33 public class MonocleApplicationTest {
  34 
  35     /** Tests a US keyboard */
  36     private static int[][] TEST_CASES = {
  37             { 'a', KeyEvent.VK_A },
  38             { 'b', KeyEvent.VK_B },
  39             { 'c', KeyEvent.VK_C },
  40             { 'd', KeyEvent.VK_D },
  41             { 'e', KeyEvent.VK_E },
  42             { 'f', KeyEvent.VK_F },
  43             { 'g', KeyEvent.VK_G },
  44             { 'h', KeyEvent.VK_H },
  45             { 'i', KeyEvent.VK_I },
  46             { 'j', KeyEvent.VK_J },
  47             { 'k', KeyEvent.VK_K },
  48             { 'l', KeyEvent.VK_L },
  49             { 'm', KeyEvent.VK_M },
  50             { 'n', KeyEvent.VK_N },
  51             { 'o', KeyEvent.VK_O },


 118             { ']', KeyEvent.VK_BRACERIGHT },
 119             { '|', KeyEvent.VK_BACK_SLASH },
 120             { '\\', KeyEvent.VK_BACK_SLASH },
 121             { ':', KeyEvent.VK_SEMICOLON },
 122             { ';', KeyEvent.VK_SEMICOLON },
 123             { '\"', KeyEvent.VK_QUOTE },
 124             { '\'', KeyEvent.VK_QUOTE },
 125             { '<', KeyEvent.VK_COMMA },
 126             { ',', KeyEvent.VK_COMMA },
 127             { '>', KeyEvent.VK_PERIOD },
 128             { '.', KeyEvent.VK_PERIOD },
 129             { '?', KeyEvent.VK_SLASH },
 130             { '/', KeyEvent.VK_SLASH },
 131     };
 132 
 133     @Test
 134     public void testCharToKeyCode() throws Exception {
 135         TestApplication.getStage();
 136         Assume.assumeTrue(TestApplication.isMonocle());
 137         TestRunnable.invokeAndWait(() -> {
 138             MonocleApplication app = (MonocleApplication)
 139                     Application.GetApplication();
 140             for (int i = 0; i < TEST_CASES.length; i++) {
 141                 char ch = (char) TEST_CASES[i][0];
 142                 int expectedCode = TEST_CASES[i][1];
 143                 int code = app._getKeyCodeForChar(ch);
 144                 Assert.assertEquals("Code for character "
 145                                     + ((int) ch) + " ('" + ch + "')",
 146                                     expectedCode, code);
 147             }
 148         });
 149     }
 150 }


   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 package test.robot.com.sun.glass.ui.monocle;
  26 
  27 import test.robot.com.sun.glass.ui.monocle.TestApplication;
  28 import com.sun.glass.events.KeyEvent;
  29 import com.sun.glass.ui.monocle.MonocleApplicationShim;
  30 import org.junit.Assert;
  31 import org.junit.Assume;
  32 import org.junit.Test;
  33 import test.com.sun.glass.ui.monocle.TestRunnable;
  34 
  35 public class MonocleApplicationTest {
  36 
  37     /** Tests a US keyboard */
  38     private static int[][] TEST_CASES = {
  39             { 'a', KeyEvent.VK_A },
  40             { 'b', KeyEvent.VK_B },
  41             { 'c', KeyEvent.VK_C },
  42             { 'd', KeyEvent.VK_D },
  43             { 'e', KeyEvent.VK_E },
  44             { 'f', KeyEvent.VK_F },
  45             { 'g', KeyEvent.VK_G },
  46             { 'h', KeyEvent.VK_H },
  47             { 'i', KeyEvent.VK_I },
  48             { 'j', KeyEvent.VK_J },
  49             { 'k', KeyEvent.VK_K },
  50             { 'l', KeyEvent.VK_L },
  51             { 'm', KeyEvent.VK_M },
  52             { 'n', KeyEvent.VK_N },
  53             { 'o', KeyEvent.VK_O },


 120             { ']', KeyEvent.VK_BRACERIGHT },
 121             { '|', KeyEvent.VK_BACK_SLASH },
 122             { '\\', KeyEvent.VK_BACK_SLASH },
 123             { ':', KeyEvent.VK_SEMICOLON },
 124             { ';', KeyEvent.VK_SEMICOLON },
 125             { '\"', KeyEvent.VK_QUOTE },
 126             { '\'', KeyEvent.VK_QUOTE },
 127             { '<', KeyEvent.VK_COMMA },
 128             { ',', KeyEvent.VK_COMMA },
 129             { '>', KeyEvent.VK_PERIOD },
 130             { '.', KeyEvent.VK_PERIOD },
 131             { '?', KeyEvent.VK_SLASH },
 132             { '/', KeyEvent.VK_SLASH },
 133     };
 134 
 135     @Test
 136     public void testCharToKeyCode() throws Exception {
 137         TestApplication.getStage();
 138         Assume.assumeTrue(TestApplication.isMonocle());
 139         TestRunnable.invokeAndWait(() -> {


 140             for (int i = 0; i < TEST_CASES.length; i++) {
 141                 char ch = (char) TEST_CASES[i][0];
 142                 int expectedCode = TEST_CASES[i][1];
 143                 int code = MonocleApplicationShim._getKeyCodeForChar(ch);
 144                 Assert.assertEquals("Code for character "
 145                                     + ((int) ch) + " ('" + ch + "')",
 146                                     expectedCode, code);
 147             }
 148         });
 149     }
 150 }
< prev index next >