Skip to content

Commit

Permalink
8196018: java/awt/Scrollbar/ScrollbarMouseWheelTest/ScrollbarMouseWhe…
Browse files Browse the repository at this point in the history
…elTest.java fails

Reviewed-by: psadhukhan, serb, dnguyen
  • Loading branch information
Alexander Zvegintsev committed Nov 21, 2022
1 parent 8b8d848 commit 16ab754
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 38 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ java/awt/event/KeyEvent/KeyTyped/CtrlASCII.java 8252713 linux-all

java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.java 8194947 generic-all
java/awt/Frame/FramesGC/FramesGC.java 8079069 macosx-all
java/awt/Scrollbar/ScrollbarMouseWheelTest/ScrollbarMouseWheelTest.java 8196018 windows-all,linux-all
java/awt/TrayIcon/ActionCommand/ActionCommand.java 8150540 windows-all
java/awt/TrayIcon/ActionEventMask/ActionEventMask.java 8150540,8295300 windows-all,linux-all
java/awt/TrayIcon/ActionEventTest/ActionEventTest.java 8150540,8242801 windows-all,macosx-all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@
* questions.
*/

import java.awt.*;
import java.awt.event.*;
import java.awt.AWTException;
import java.awt.Component;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.Point;
import java.awt.Robot;
import java.awt.Scrollbar;
import java.awt.Toolkit;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;

/**
* @test
Expand All @@ -32,31 +41,28 @@
*/

public final class ScrollbarMouseWheelTest
implements MouseWheelListener, WindowListener {
implements MouseWheelListener {

final static boolean isWindows =
Toolkit.getDefaultToolkit().getClass()
.getName().equals("sun.awt.windows.WToolkit");

final static String tk = Toolkit.getDefaultToolkit().getClass().getName();
final static int REPS = 5;
// There is a bug on Windows: 4616935.
// Wheel events comes to every component in the hierarchy so we should
// check a platform.
// There are two scrollbars within one Panel and both accept 5 clicks, so
// Panel would accept 5*2 clicks on Windows.
final static int PANEL_REPS = tk.equals("sun.awt.windows.WToolkit")? REPS * 2: REPS;
final static int PANEL_REPS = isWindows ? REPS * 2: REPS;

Scrollbar sb1;
Scrollbar sb2;
Panel pnl;
class Sema {
boolean flag;
boolean getVal() { return flag;}
void setVal(boolean b) { flag = b;}
}
Sema sema = new Sema();

Robot robot;

int sb1upevents, sb2upevents, pnlupevents;
int sb1downevents, sb2downevents, pnldownevents;
volatile int sb1upevents, sb2upevents, pnlupevents;
volatile int sb1downevents, sb2downevents, pnldownevents;

public static void main(final String[] args) {
new ScrollbarMouseWheelTest().test();
Expand All @@ -69,15 +75,13 @@ public void test() {
} catch (AWTException e) {
System.out.println("Problem creating Robot. FAIL.");
throw new RuntimeException("Problem creating Robot. FAIL.");

}

robot.setAutoDelay(500);
robot.setAutoDelay(250);
robot.setAutoWaitForIdle(true);

// Show test Frame
Frame frame = new Frame("ScrollbarMouseWheelTest");
frame.addWindowListener(this);
pnl = new Panel();
pnl.setLayout(new GridLayout(1, 2));
pnl.addMouseWheelListener(this);
Expand All @@ -92,14 +96,9 @@ public void test() {
frame.setVisible(true);
frame.toFront();

// When Frame is active, start testing (handled in windowActivated())
while (true) {
synchronized (sema) {
if (sema.getVal()) {
break;
}
}
}
robot.waitForIdle();
robot.delay(1000);

// up on sb1
testComp(sb1, true);
// down on sb1
Expand All @@ -108,7 +107,11 @@ public void test() {
testComp(sb2, true);
// down on sb2
testComp(sb2, false);

robot.delay(500);

frame.dispose();

System.out.println("Test done.");
if (sb1upevents == REPS &&
sb2upevents == 0 &&
Expand Down Expand Up @@ -166,17 +169,4 @@ public void mouseWheelMoved(MouseWheelEvent mwe) {
System.out.println("weird wheel rotation");
}
}

public void windowActivated(WindowEvent we) {
synchronized (sema) {
sema.setVal(true);
}
}

public void windowClosed(WindowEvent we) {}
public void windowClosing(WindowEvent we) {}
public void windowDeactivated(WindowEvent we) {}
public void windowDeiconified(WindowEvent we) {}
public void windowIconified(WindowEvent we) {}
public void windowOpened(WindowEvent we) {}
}// class ScrollbarMouseWheelTest

1 comment on commit 16ab754

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.