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 com.sun.javafx.scene.control.skin;
27
28 import static org.junit.Assert.assertEquals;
29 import static org.junit.Assert.assertTrue;
30 import javafx.geometry.Insets;
31 import javafx.scene.control.Button;
32
33 import javafx.scene.Group;
34 import javafx.scene.Scene;
35 import javafx.stage.Stage;
36 import javafx.scene.input.Mnemonic;
37 import javafx.collections.ObservableList;
38 import javafx.scene.input.KeyCombination;
39
40 import com.sun.javafx.scene.control.behavior.TextBinding.MnemonicKeyCombination;
41
42 import org.junit.Before;
43 import org.junit.Test;
44
45 /**
46 */
47 public class ButtonSkinTest {
48 private Button button;
49 private ButtonSkinMock skin;
50
51 @Before public void setup() {
52 button = new Button("Test");
53 skin = new ButtonSkinMock(button);
54 // Set some padding so that any places where padding was being
131
132 mnemonicsList = scene.getMnemonics().get(mnemonicKeyCombo);
133 if (mnemonicsList != null) {
134 for (int i = 0 ; i < mnemonicsList.size() ; i++) {
135 if (mnemonicsList.get(i).getNode() == button) {
136 nodeFound = true;
137 }
138 }
139 }
140 assertTrue(!nodeFound);
141 }
142 }
143
144 public static final class ButtonSkinMock extends ButtonSkin {
145 boolean propertyChanged = false;
146 int propertyChangeCount = 0;
147 public ButtonSkinMock(Button button) {
148 super(button);
149 }
150
151 @Override protected void handleControlPropertyChanged(String p) {
152 super.handleControlPropertyChanged(p);
153 propertyChanged = true;
154 propertyChangeCount++;
155 }
156 }
157 }
|
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.control.skin;
27
28 import static org.junit.Assert.assertEquals;
29 import static org.junit.Assert.assertTrue;
30
31 import javafx.beans.value.ObservableValue;
32 import javafx.geometry.Insets;
33 import javafx.scene.control.Button;
34
35 import javafx.scene.Group;
36 import javafx.scene.Scene;
37 import javafx.scene.control.skin.ButtonSkin;
38 import javafx.stage.Stage;
39 import javafx.scene.input.Mnemonic;
40 import javafx.collections.ObservableList;
41 import javafx.scene.input.KeyCombination;
42
43 import com.sun.javafx.scene.control.behavior.TextBinding.MnemonicKeyCombination;
44
45 import org.junit.Before;
46 import org.junit.Test;
47
48 /**
49 */
50 public class ButtonSkinTest {
51 private Button button;
52 private ButtonSkinMock skin;
53
54 @Before public void setup() {
55 button = new Button("Test");
56 skin = new ButtonSkinMock(button);
57 // Set some padding so that any places where padding was being
134
135 mnemonicsList = scene.getMnemonics().get(mnemonicKeyCombo);
136 if (mnemonicsList != null) {
137 for (int i = 0 ; i < mnemonicsList.size() ; i++) {
138 if (mnemonicsList.get(i).getNode() == button) {
139 nodeFound = true;
140 }
141 }
142 }
143 assertTrue(!nodeFound);
144 }
145 }
146
147 public static final class ButtonSkinMock extends ButtonSkin {
148 boolean propertyChanged = false;
149 int propertyChangeCount = 0;
150 public ButtonSkinMock(Button button) {
151 super(button);
152 }
153
154 public void addWatchedProperty(ObservableValue<?> p) {
155 p.addListener(o -> {
156 propertyChanged = true;
157 propertyChangeCount++;
158 });
159 }
160 }
161 }
|