Skip to content

Commit

Permalink
8345468: test/jdk/javax/swing/JScrollBar/4865918/bug4865918.java fail…
Browse files Browse the repository at this point in the history
…s in ubuntu22.04

Reviewed-by: abhiscxk
  • Loading branch information
prsadhuk committed Dec 4, 2024
1 parent 6c1ed0b commit 6f30762
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions test/jdk/javax/swing/JScrollBar/4865918/bug4865918.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,14 +26,17 @@
* @key headful
* @bug 4865918
* @summary REGRESSION:JCK1.4a-runtime api/javax_swing/interactive/JScrollBarTests.html#JScrollBar
* @author Andrey Pikalev
* @run main bug4865918
*/

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.awt.Dimension;
import java.awt.Robot;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import javax.swing.SwingUtilities;
import java.awt.event.MouseEvent;

import java.util.Date;

public class bug4865918 {

Expand All @@ -43,29 +46,18 @@ public class bug4865918 {
public static void main(String[] argv) throws Exception {
try {
Robot robot = new Robot();
SwingUtilities.invokeAndWait(new Runnable() {

public void run() {
createAndShowGUI();
}
});
SwingUtilities.invokeAndWait(() -> createAndShowGUI());

robot.waitForIdle();
robot.delay(1000);

SwingUtilities.invokeAndWait(new Runnable() {

@Override
public void run() {
sbar.pressMouse();
}
});
SwingUtilities.invokeAndWait(() -> sbar.pressMouse());

robot.waitForIdle();
robot.delay(200);

int value = getValue();

if (value != 9) {
throw new Error("The scrollbar block increment is incorect");
if (getValue() != 9) {
throw new RuntimeException("The scrollbar block increment is incorrect");
}
} finally {
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
Expand All @@ -75,11 +67,8 @@ public void run() {
private static int getValue() throws Exception {
final int[] result = new int[1];

SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
result[0] = sbar.getValue();
}
SwingUtilities.invokeAndWait(() -> {
result[0] = sbar.getValue();
});

return result[0];
Expand All @@ -95,8 +84,9 @@ private static void createAndShowGUI() {

frame.getContentPane().add(sbar);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);

frame.toFront();
}

static class TestScrollBar extends JScrollBar {
Expand All @@ -111,7 +101,7 @@ public void pressMouse() {
MouseEvent me = new MouseEvent(sbar,
MouseEvent.MOUSE_PRESSED,
(new Date()).getTime(),
MouseEvent.BUTTON1_MASK,
MouseEvent.BUTTON1_DOWN_MASK,
3 * getWidth() / 4, getHeight() / 2,
1, true);
processMouseEvent(me);
Expand Down

5 comments on commit 6f30762

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@mrserb
Copy link
Member

@mrserb mrserb commented on 6f30762 Jan 28, 2025

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 6f30762 Jan 28, 2025

Choose a reason for hiding this comment

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

@mrserb the backport was successfully created on the branch backport-mrserb-6f307623-master in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 6f307623 from the openjdk/jdk repository.

The commit being backported was authored by Prasanta Sadhukhan on 4 Dec 2024 and was reviewed by Abhishek Kumar.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-mrserb-6f307623-master:backport-mrserb-6f307623-master
$ git checkout backport-mrserb-6f307623-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-mrserb-6f307623-master

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 6f30762 Feb 5, 2025

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 6f30762 Feb 5, 2025

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch backport-GoeLin-6f307623-master in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 6f307623 from the openjdk/jdk repository.

The commit being backported was authored by Prasanta Sadhukhan on 4 Dec 2024 and was reviewed by Abhishek Kumar.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-6f307623-master:backport-GoeLin-6f307623-master
$ git checkout backport-GoeLin-6f307623-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-6f307623-master

Please sign in to comment.