1 /*
2 * Copyright (c) 2010, 2015, 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 test.javafx.scene.control;
27
28 import static test.com.sun.javafx.scene.control.infrastructure.ControlTestUtils.assertPseudoClassDoesNotExist;
29 import static test.com.sun.javafx.scene.control.infrastructure.ControlTestUtils.assertPseudoClassExists;
30 import static test.com.sun.javafx.scene.control.infrastructure.ControlTestUtils.assertStyleClassContains;
31 import static org.junit.Assert.assertEquals;
32 import static org.junit.Assert.assertFalse;
33 import static org.junit.Assert.assertNull;
34 import static org.junit.Assert.assertSame;
35 import static org.junit.Assert.assertTrue;
36 import javafx.beans.property.BooleanProperty;
37 import javafx.beans.property.ObjectProperty;
38 import javafx.beans.property.SimpleBooleanProperty;
39 import javafx.beans.property.SimpleObjectProperty;
40 import javafx.css.CssMetaData;
41 import javafx.css.StyleableProperty;
42 import javafx.geometry.Pos;
43 import javafx.scene.Node;
44 import javafx.scene.Scene;
45 import javafx.scene.input.KeyCode;
46 import javafx.scene.input.MouseEvent;
47 import javafx.scene.layout.StackPane;
323 }
324
325 @Test public void mouseFocusOnNonCollapsibleTitledPane_RT19660() {
326 Button button = new Button("Button");
327
328 titledPane.setCollapsible(false);
329 titledPane.setExpanded(true);
330 titledPane.setAnimated(false);
331 titledPane.setContent(button);
332
333 root.getChildren().add(titledPane);
334 show();
335
336 tk.firePulse();
337 assertTrue(titledPane.isFocused());
338
339 double xval = (titledPane.localToScene(titledPane.getLayoutBounds())).getMinX();
340 double yval = (titledPane.localToScene(titledPane.getLayoutBounds())).getMinY();
341
342 final MouseEventGenerator generator = new MouseEventGenerator();
343 scene.impl_processMouseEvent(
344 generator.generateMouseEvent(MouseEvent.MOUSE_PRESSED, xval+20, yval+20));
345 scene.impl_processMouseEvent(
346 generator.generateMouseEvent(MouseEvent.MOUSE_RELEASED, xval+20, yval+20));
347
348 tk.firePulse();
349 assertTrue(titledPane.isExpanded());
350 assertTrue(titledPane.isFocused());
351
352 KeyEventFirer keyboard = new KeyEventFirer(titledPane);
353 keyboard.doKeyPress(KeyCode.TAB);
354 tk.firePulse();
355 assertFalse(titledPane.isFocused());
356 assertTrue(button.isFocused());
357 }
358 }
|
1 /*
2 * Copyright (c) 2010, 2016, 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 test.javafx.scene.control;
27
28 import com.sun.javafx.scene.SceneHelper;
29 import static test.com.sun.javafx.scene.control.infrastructure.ControlTestUtils.assertPseudoClassDoesNotExist;
30 import static test.com.sun.javafx.scene.control.infrastructure.ControlTestUtils.assertPseudoClassExists;
31 import static test.com.sun.javafx.scene.control.infrastructure.ControlTestUtils.assertStyleClassContains;
32 import static org.junit.Assert.assertEquals;
33 import static org.junit.Assert.assertFalse;
34 import static org.junit.Assert.assertNull;
35 import static org.junit.Assert.assertSame;
36 import static org.junit.Assert.assertTrue;
37 import javafx.beans.property.BooleanProperty;
38 import javafx.beans.property.ObjectProperty;
39 import javafx.beans.property.SimpleBooleanProperty;
40 import javafx.beans.property.SimpleObjectProperty;
41 import javafx.css.CssMetaData;
42 import javafx.css.StyleableProperty;
43 import javafx.geometry.Pos;
44 import javafx.scene.Node;
45 import javafx.scene.Scene;
46 import javafx.scene.input.KeyCode;
47 import javafx.scene.input.MouseEvent;
48 import javafx.scene.layout.StackPane;
324 }
325
326 @Test public void mouseFocusOnNonCollapsibleTitledPane_RT19660() {
327 Button button = new Button("Button");
328
329 titledPane.setCollapsible(false);
330 titledPane.setExpanded(true);
331 titledPane.setAnimated(false);
332 titledPane.setContent(button);
333
334 root.getChildren().add(titledPane);
335 show();
336
337 tk.firePulse();
338 assertTrue(titledPane.isFocused());
339
340 double xval = (titledPane.localToScene(titledPane.getLayoutBounds())).getMinX();
341 double yval = (titledPane.localToScene(titledPane.getLayoutBounds())).getMinY();
342
343 final MouseEventGenerator generator = new MouseEventGenerator();
344 SceneHelper.processMouseEvent(scene,
345 generator.generateMouseEvent(MouseEvent.MOUSE_PRESSED, xval+20, yval+20));
346 SceneHelper.processMouseEvent(scene,
347 generator.generateMouseEvent(MouseEvent.MOUSE_RELEASED, xval+20, yval+20));
348
349 tk.firePulse();
350 assertTrue(titledPane.isExpanded());
351 assertTrue(titledPane.isFocused());
352
353 KeyEventFirer keyboard = new KeyEventFirer(titledPane);
354 keyboard.doKeyPress(KeyCode.TAB);
355 tk.firePulse();
356 assertFalse(titledPane.isFocused());
357 assertTrue(button.isFocused());
358 }
359 }
|