1 /*
   2  * Copyright (c) 2011, 2013, 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
  23  * questions.
  24  */
  25 
  26 package javafx.scene.input;
  27 
  28 import static javafx.scene.input.KeyCombination.ALT_ANY;
  29 import static javafx.scene.input.KeyCombination.CONTROL_DOWN;
  30 import static javafx.scene.input.KeyCombination.META_DOWN;
  31 import static javafx.scene.input.KeyCombination.SHIFT_ANY;
  32 import static javafx.scene.input.KeyCombination.SHORTCUT_ANY;
  33 import static javafx.scene.input.KeyCombination.SHORTCUT_DOWN;
  34 
  35 import java.util.Arrays;
  36 import java.util.Collection;
  37 
  38 import javafx.scene.input.KeyCombination.ModifierValue;
  39 
  40 import org.junit.runner.RunWith;
  41 import org.junit.runners.Parameterized;
  42 import org.junit.runners.Parameterized.Parameters;
  43 
  44 import com.sun.javafx.test.ObjectMethodsTestBase;
  45 
  46 @RunWith(Parameterized.class)
  47 public final class KeyCombination_objectMethods_Test
  48         extends ObjectMethodsTestBase {
  49     @Parameters
  50     public static Collection data() {
  51         return Arrays.asList(new Object[] {
  52                 equalObjects(
  53                         new KeyCodeCombination(KeyCode.R,
  54                                                ModifierValue.ANY,
  55                                                ModifierValue.DOWN,
  56                                                ModifierValue.UP,
  57                                                ModifierValue.UP,
  58                                                ModifierValue.ANY),
  59                         new KeyCodeCombination(KeyCode.R,
  60                                                CONTROL_DOWN,
  61                                                SHIFT_ANY,
  62                                                SHORTCUT_ANY),
  63                         KeyCombination.keyCombination(
  64                                 "Ignore Shortcut + Ctrl + Ignore Shift + R")),
  65                 equalObjects(
  66                         new KeyCodeCombination(KeyCode.C,
  67                                                ModifierValue.UP,
  68                                                ModifierValue.UP,
  69                                                ModifierValue.UP,
  70                                                ModifierValue.UP,
  71                                                ModifierValue.DOWN),
  72                         new KeyCodeCombination(KeyCode.C,
  73                                                SHORTCUT_DOWN),
  74                         KeyCombination.keyCombination("Shortcut + C")),
  75                 equalObjects(
  76                         new KeyCharacterCombination("x",
  77                                                     ModifierValue.UP,
  78                                                     ModifierValue.UP,
  79                                                     ModifierValue.ANY,
  80                                                     ModifierValue.DOWN,
  81                                                     ModifierValue.UP),
  82                         new KeyCharacterCombination(
  83                                 "x",
  84                                 ALT_ANY,
  85                                 META_DOWN),
  86                         KeyCombination.keyCombination(
  87                                 "Ignore Alt + Meta + 'x'")),
  88                 differentObjects(
  89                         new KeyCodeCombination(KeyCode.R,
  90                                                ModifierValue.ANY,
  91                                                ModifierValue.DOWN,
  92                                                ModifierValue.UP,
  93                                                ModifierValue.UP,
  94                                                ModifierValue.UP),
  95                         new KeyCodeCombination(KeyCode.A,
  96                                                CONTROL_DOWN,
  97                                                SHIFT_ANY),
  98                         new KeyCodeCombination(KeyCode.R,
  99                                                CONTROL_DOWN,
 100                                                SHIFT_ANY,
 101                                                ALT_ANY),
 102                         KeyCombination.keyCombination(
 103                                 "Ctrl + Shift + R"),
 104                         KeyCombination.keyCombination(
 105                                 "Ignore Shift + R"),
 106                         KeyCombination.keyCombination(
 107                                 "Ctrl + Ignore Shift + K")),
 108                 differentObjects(
 109                         new KeyCharacterCombination("x",
 110                                                     ModifierValue.UP,
 111                                                     ModifierValue.UP,
 112                                                     ModifierValue.ANY,
 113                                                     ModifierValue.DOWN,
 114                                                     ModifierValue.UP),
 115                         new KeyCharacterCombination("X",
 116                                                     ModifierValue.UP,
 117                                                     ModifierValue.UP,
 118                                                     ModifierValue.ANY,
 119                                                     ModifierValue.DOWN,
 120                                                     ModifierValue.UP),
 121                         new KeyCharacterCombination(
 122                                 "y",
 123                                 ALT_ANY,
 124                                 META_DOWN),
 125                         new KeyCharacterCombination(
 126                                 "x",
 127                                 ALT_ANY,
 128                                 META_DOWN,
 129                                 SHORTCUT_DOWN),
 130                         new KeyCharacterCombination(
 131                                 "x",
 132                                 ALT_ANY),
 133                         KeyCombination.keyCombination(
 134                                 "Alt + Meta + 'x'"),
 135                         KeyCombination.keyCombination(
 136                                 "Ignore Alt + Meta + Ctrl + 'x'"),
 137                         KeyCombination.keyCombination(
 138                                 "Ignore Alt + Meta + 'z'")),
 139                 differentObjectsMediumHashcode(
 140                         new KeyCodeCombination(KeyCode.Q,
 141                                                ModifierValue.UP,
 142                                                ModifierValue.UP,
 143                                                ModifierValue.ANY,
 144                                                ModifierValue.DOWN,
 145                                                ModifierValue.UP),
 146                         new KeyCharacterCombination("Q",
 147                                                     ModifierValue.UP,
 148                                                     ModifierValue.UP,
 149                                                     ModifierValue.ANY,
 150                                                     ModifierValue.DOWN,
 151                                                     ModifierValue.UP),
 152                         KeyCombination.keyCombination("Ctrl + Alt + 'X'"),
 153                         KeyCombination.keyCombination("Ctrl + Alt + X"),
 154                         new KeyCombination() {
 155                         },
 156                         new Object())
 157             });
 158     }
 159 
 160     public KeyCombination_objectMethods_Test(
 161             final Configuration configuration) {
 162         super(configuration);
 163     }
 164 }