Skip to content

Commit

Permalink
8233648: [TESTBUG] DefaultMenuBarTest.java failing on macos
Browse files Browse the repository at this point in the history
Reviewed-by: pbansal, serb, psadhukhan, prr
  • Loading branch information
Alexander Zvegintsev committed Oct 20, 2021
1 parent bbc6061 commit 46b5bfb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ java/awt/event/MouseEvent/MultipleMouseButtonsTest/MultipleMouseButtonsTest.java
java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java 8233568 macosx-all
java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java 8233568 macosx-all
java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java 8233568 macosx-all
com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java 8233648 macosx-all
java/awt/Choice/ChoiceKeyEventReaction/ChoiceKeyEventReaction.java 7185258 macosx-all
java/awt/TrayIcon/RightClickWhenBalloonDisplayed/RightClickWhenBalloonDisplayed.java 8238720 windows-all
java/awt/PopupMenu/PopupMenuLocation.java 8238720 windows-all
Expand Down
38 changes: 16 additions & 22 deletions test/jdk/com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, 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 @@ -24,18 +24,21 @@
/**
* @test
* @key headful
* @bug 8007267
* @bug 8007267 8233648
* @summary [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
* @requires (os.family == "mac")
* @author leonid.romanov@oracle.com
* @modules java.desktop/sun.awt
* java.desktop/com.apple.eawt
* @run main DefaultMenuBarTest
* @modules java.desktop/com.apple.eawt
* @run main/othervm DefaultMenuBarTest
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Robot;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.lang.reflect.Method;


Expand All @@ -50,14 +53,11 @@ public static void main(String[] args) throws Exception {
}

System.setProperty("apple.laf.useScreenMenuBar", "true");
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
SwingUtilities.invokeAndWait(DefaultMenuBarTest::createAndShowGUI);

Robot robot = new Robot();
robot.setAutoDelay(100);
robot.waitForIdle();

robot.keyPress(KeyEvent.VK_META);
robot.keyPress(ks.getKeyCode());
Expand All @@ -76,13 +76,7 @@ private static void createAndShowGUI() {
JMenuItem newItem = new JMenuItem("Open");

newItem.setAccelerator(ks);
newItem.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e) {
listenerCallCounter++;
}
}
);
newItem.addActionListener(e -> listenerCallCounter++);
menu.add(newItem);

JMenuBar defaultMenu = new JMenuBar();
Expand All @@ -104,7 +98,7 @@ public void actionPerformed(ActionEvent e) {
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

5 comments on commit 46b5bfb

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@Rudometov
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@Rudometov
Copy link
Member

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 46b5bfb Oct 26, 2022

Choose a reason for hiding this comment

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

@Rudometov Could not automatically backport 46b5bfbc to openjdk/jdk11u-dev due to conflicts in the following files:

  • test/jdk/ProblemList.txt

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk11u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk11u-dev master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b Rudometov-backport-46b5bfbc

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk 46b5bfbc38f14607f0db686a42f1fa96d2f61891

# Backport the commit
$ git cherry-pick --no-commit 46b5bfbc38f14607f0db686a42f1fa96d2f61891
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 46b5bfbc38f14607f0db686a42f1fa96d2f61891'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 46b5bfbc38f14607f0db686a42f1fa96d2f61891.

@openjdk
Copy link

@openjdk openjdk bot commented on 46b5bfb Oct 26, 2022

Choose a reason for hiding this comment

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

@Rudometov the backport was successfully created on the branch Rudometov-backport-46b5bfbc 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 46b5bfbc from the openjdk/jdk repository.

The commit being backported was authored by Alexander Zvegintsev on 20 Oct 2021 and was reviewed by Pankaj Bansal, Sergey Bylokhov, Prasanta Sadhukhan and Phil Race.

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 Rudometov-backport-46b5bfbc:Rudometov-backport-46b5bfbc
$ git checkout Rudometov-backport-46b5bfbc
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev Rudometov-backport-46b5bfbc

Please sign in to comment.