From 9545ba7dd95eba78cf234b2cf63165afca513787 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 12 Apr 2022 07:30:10 +0000 Subject: [PATCH] 8282716: [macos] Enable javax/swing/JScrollPane/TestMouseWheelScroll.java on macos Reviewed-by: serb --- .../swing/JScrollPane/TestMouseWheelScroll.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/jdk/javax/swing/JScrollPane/TestMouseWheelScroll.java b/test/jdk/javax/swing/JScrollPane/TestMouseWheelScroll.java index 180a697a3f3..3a80795b2a4 100644 --- a/test/jdk/javax/swing/JScrollPane/TestMouseWheelScroll.java +++ b/test/jdk/javax/swing/JScrollPane/TestMouseWheelScroll.java @@ -23,6 +23,8 @@ import java.awt.Point; import java.awt.Robot; import java.awt.event.InputEvent; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; import javax.swing.DefaultListModel; import javax.swing.ListModel; import javax.swing.JScrollPane; @@ -35,7 +37,6 @@ import javax.swing.UnsupportedLookAndFeelException; /* * @test * @key headful - * @requires (os.family != "mac") * @bug 6911375 * @summary Verifies mouseWheel effect on JList without scrollBar */ @@ -48,6 +49,7 @@ public class TestMouseWheelScroll { static volatile int height; static volatile Point viewPosition; static volatile Point newPosition; + static volatile int direction; private static void setLookAndFeel(UIManager.LookAndFeelInfo laf) { try { @@ -82,6 +84,13 @@ public class TestMouseWheelScroll { frame.setSize(200,200); frame.setLocationRelativeTo(null); frame.setVisible(true); + scrollPane.addMouseWheelListener(new MouseWheelListener() { + @Override + public void mouseWheelMoved(MouseWheelEvent event) { + System.out.println(event.getWheelRotation()); + direction = event.getWheelRotation(); + } + }); }); robot.waitForIdle(); robot.delay(1000); @@ -100,6 +109,9 @@ public class TestMouseWheelScroll { robot.delay(1000); robot.mouseWheel(1); robot.delay(500); + if (direction == -1) { + robot.mouseWheel(-1); + } SwingUtilities.invokeAndWait(() -> { newPosition = scrollPane.getViewport().getViewPosition(); });