modules/graphics/src/test/java/test/javafx/scene/input/KeyCombinationTest.java

Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:


   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 javafx.scene.input;
  27 
  28 import static javafx.scene.input.KeyCombination.ALT_DOWN;
  29 import static javafx.scene.input.KeyCombination.CONTROL_ANY;
  30 import static javafx.scene.input.KeyCombination.CONTROL_DOWN;
  31 import static javafx.scene.input.KeyCombination.SHIFT_ANY;
  32 import static javafx.scene.input.KeyCombination.SHIFT_DOWN;
  33 import static org.junit.Assert.assertEquals;
  34 import static org.junit.Assert.assertFalse;
  35 import static org.junit.Assert.assertTrue;
  36 
  37 import java.util.HashMap;
  38 import java.util.Map;
  39 
  40 import javafx.event.Event;
  41 import javafx.scene.input.KeyCombination.ModifierValue;
  42 
  43 import org.junit.AfterClass;
  44 import org.junit.BeforeClass;
  45 import org.junit.Test;
  46 
  47 import com.sun.javafx.pgstub.StubToolkit;
  48 import com.sun.javafx.scene.input.KeyCodeMap;
  49 import com.sun.javafx.tk.Toolkit;





  50 
  51 
  52 public class KeyCombinationTest {
  53     final KeyEvent ctrlAltQEvent = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  54             "q", null, KeyCodeMap.valueOf(0x51), false, true, true, false);
  55 
  56     final KeyEvent ctrlAltQUpEvent = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_RELEASED, 
  57             "q", null, KeyCodeMap.valueOf(0x51), false, true, true, false);
  58 
  59     final KeyEvent ctrlShiftQEvent = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  60             "Q", null, KeyCodeMap.valueOf(0x51), true, true, false, false);
  61 
  62     final KeyEvent ctrlAltShiftQEvent = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  63             "Q", null, KeyCodeMap.valueOf(0x51), true, true, true, false);
  64 
  65     final KeyEvent alt2Event = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  66             "2", null, KeyCodeMap.valueOf(0x32), false, false, true, false);
  67 
  68     final KeyEvent altShift2Event = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  69             "@", null, KeyCodeMap.valueOf(0x32), true, false, true, false);




   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.javafx.scene.input;
  27 
  28 import static javafx.scene.input.KeyCombination.ALT_DOWN;
  29 import static javafx.scene.input.KeyCombination.CONTROL_ANY;
  30 import static javafx.scene.input.KeyCombination.CONTROL_DOWN;
  31 import static javafx.scene.input.KeyCombination.SHIFT_ANY;
  32 import static javafx.scene.input.KeyCombination.SHIFT_DOWN;
  33 import static org.junit.Assert.assertEquals;
  34 import static org.junit.Assert.assertFalse;
  35 import static org.junit.Assert.assertTrue;
  36 
  37 import java.util.HashMap;
  38 import java.util.Map;
  39 
  40 import javafx.event.Event;
  41 import javafx.scene.input.KeyCombination.ModifierValue;
  42 
  43 import org.junit.AfterClass;
  44 import org.junit.BeforeClass;
  45 import org.junit.Test;
  46 
  47 import test.com.sun.javafx.pgstub.StubToolkit;
  48 import com.sun.javafx.scene.input.KeyCodeMap;
  49 import com.sun.javafx.tk.Toolkit;
  50 import javafx.scene.input.KeyCharacterCombination;
  51 import javafx.scene.input.KeyCode;
  52 import javafx.scene.input.KeyCodeCombination;
  53 import javafx.scene.input.KeyCombination;
  54 import javafx.scene.input.KeyEvent;
  55 
  56 
  57 public class KeyCombinationTest {
  58     final KeyEvent ctrlAltQEvent = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  59             "q", null, KeyCodeMap.valueOf(0x51), false, true, true, false);
  60 
  61     final KeyEvent ctrlAltQUpEvent = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_RELEASED, 
  62             "q", null, KeyCodeMap.valueOf(0x51), false, true, true, false);
  63 
  64     final KeyEvent ctrlShiftQEvent = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  65             "Q", null, KeyCodeMap.valueOf(0x51), true, true, false, false);
  66 
  67     final KeyEvent ctrlAltShiftQEvent = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  68             "Q", null, KeyCodeMap.valueOf(0x51), true, true, true, false);
  69 
  70     final KeyEvent alt2Event = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  71             "2", null, KeyCodeMap.valueOf(0x32), false, false, true, false);
  72 
  73     final KeyEvent altShift2Event = new KeyEvent(null, Event.NULL_SOURCE_TARGET, KeyEvent.KEY_PRESSED, 
  74             "@", null, KeyCodeMap.valueOf(0x32), true, false, true, false);