Skip to content

Commit 690d266

Browse files
committed
8255337: [TestBug] Controls unit tests - ButtonTest and ComboBoxTest - log ClassCastException
Reviewed-by: fastegal, kcr
1 parent 2c67555 commit 690d266

File tree

2 files changed

+63
-144
lines changed

2 files changed

+63
-144
lines changed

modules/javafx.controls/src/test/java/test/javafx/scene/control/ButtonTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@
6464
import static org.junit.Assert.assertTrue;
6565
import static org.junit.Assert.fail;
6666

67-
//import com.sun.javafx.test.MouseEventGenerator;
68-
6967
/**
7068
* action (which can be bound, and can be null),
7169
* and that action is called when the button is fired.
@@ -76,7 +74,8 @@ public class ButtonTest {
7674
private Scene scene;
7775
private Stage stage;
7876
private StackPane root;
79-
private MouseEventFirer mouse;
77+
private MouseEventFirer mouse; //Note : It is created and used by individual tests that need it
78+
8079

8180
@Before public void setup() {
8281
btn = new Button();
@@ -85,12 +84,14 @@ public class ButtonTest {
8584
scene = new Scene(root);
8685
stage = new Stage();
8786
stage.setScene(scene);
88-
mouse = new MouseEventFirer(btn);
8987
}
9088

9189
@After public void after() {
9290
stage.hide();
93-
mouse.dispose();
91+
92+
if (mouse != null) {
93+
mouse.dispose();
94+
}
9495
}
9596

9697
/*********************************************************************
@@ -420,6 +421,8 @@ private void show() {
420421
btn.fireEvent(new ActionEvent());
421422
btn.fire();
422423

424+
mouse = new MouseEventFirer(btn);
425+
423426
mouse.fireMousePressed();
424427
mouse.fireMouseReleased();
425428
mouse.fireMouseClicked();
@@ -446,6 +449,8 @@ private void show() {
446449

447450
assertEquals(0, count);
448451

452+
mouse = new MouseEventFirer(btn);
453+
449454
/* Note that right-mouse press events don't force the popup open */
450455
mouse.fireMousePressed(MouseButton.SECONDARY);
451456
assertEquals(0, count);

0 commit comments

Comments
 (0)