< prev index next >

tests/system/src/test/java/test/javafx/embed/swing/JFXPanelTest.java

Print this page

120                 scene.addEventHandler(javafx.scene.input.MouseEvent.MOUSE_PRESSED, (event -> {
121                     pressedEventCounter[0] += 1;
122                     firstPressedEventLatch.countDown();
123                 }));
124 
125                 SwingUtilities.invokeLater(() -> {
126                     MouseEvent e = new MouseEvent(fxPnl, MouseEvent.MOUSE_PRESSED, 0, MouseEvent.BUTTON1_DOWN_MASK,
127                             5, 5, 1, false, MouseEvent.BUTTON1);
128 
129                     fxPnl.processMouseEventPublic(e);
130                 });
131             });
132         });
133 
134         Assert.assertTrue(firstPressedEventLatch.await(5000, TimeUnit.MILLISECONDS));
135 
136         Thread.sleep(500); // there should be no pressed event after the initial one. Let's wait for 0.5s and check again.
137 
138         Assert.assertEquals(1, pressedEventCounter[0]);
139     }


















140 }
141 

120                 scene.addEventHandler(javafx.scene.input.MouseEvent.MOUSE_PRESSED, (event -> {
121                     pressedEventCounter[0] += 1;
122                     firstPressedEventLatch.countDown();
123                 }));
124 
125                 SwingUtilities.invokeLater(() -> {
126                     MouseEvent e = new MouseEvent(fxPnl, MouseEvent.MOUSE_PRESSED, 0, MouseEvent.BUTTON1_DOWN_MASK,
127                             5, 5, 1, false, MouseEvent.BUTTON1);
128 
129                     fxPnl.processMouseEventPublic(e);
130                 });
131             });
132         });
133 
134         Assert.assertTrue(firstPressedEventLatch.await(5000, TimeUnit.MILLISECONDS));
135 
136         Thread.sleep(500); // there should be no pressed event after the initial one. Let's wait for 0.5s and check again.
137 
138         Assert.assertEquals(1, pressedEventCounter[0]);
139     }
140 
141     @Test
142     public void testClickOnEmptyJFXPanel() throws Exception {
143         CountDownLatch firstPressedEventLatch = new CountDownLatch(1);
144 
145         SwingUtilities.invokeLater(() -> {
146             TestFXPanel fxPnl = new TestFXPanel();
147 
148             MouseEvent e = new MouseEvent(fxPnl, MouseEvent.MOUSE_PRESSED, 0, MouseEvent.BUTTON1_DOWN_MASK,
149                     5, 5, 1, false, MouseEvent.BUTTON1);
150 
151             fxPnl.processMouseEventPublic(e);
152 
153             firstPressedEventLatch.countDown();
154         });
155 
156         Assert.assertTrue(firstPressedEventLatch.await(5000, TimeUnit.MILLISECONDS));
157     }
158 }
159 
< prev index next >