Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8265439: [TestBug] Enable and fix ignored unit tests in MenuItemTest #466

Closed
wants to merge 3 commits into from

Conversation

aghaisas
Copy link
Collaborator

@aghaisas aghaisas commented Apr 19, 2021

This PR enables ignored unit tests from MenuItemTest and fixes them.
4 ignored tests are fixed.
2 ignored tests are removed.

Before fix :
total tests = 89
failures = 0
ignored tests = 6

After fix :
total tests = 87
failures = 0
ignored tests = 0


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8265439: [TestBug] Enable and fix ignored unit tests in MenuItemTest

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/466/head:pull/466
$ git checkout pull/466

Update a local copy of the PR:
$ git checkout pull/466
$ git pull https://git.openjdk.java.net/jfx pull/466/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 466

View PR using the GUI difftool:
$ git pr show -t 466

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/466.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 19, 2021

👋 Welcome back aghaisas! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Apr 19, 2021
@aghaisas aghaisas changed the title 8234486: [TestBug] Enable and fix ignored unit tests in MenuItemTest 8265439: [TestBug] Enable and fix ignored unit tests in MenuItemTest Apr 19, 2021
@mlbridge
Copy link

mlbridge bot commented Apr 19, 2021

Webrevs

@kevinrushforth
Copy link
Member

kevinrushforth commented Apr 19, 2021

It looks like you concluded that the implementation is correct, and that the ignored tests were making bad assumptions. Can you add your evaluation to this PR explaining why the tests are incorrect?

@Ignore // keyCharacter for keyCodeCombination cannot be null
@Test public void setSpecifiedAccelerator1() {
@Test(expected=NullPointerException.class)
public void setSpecifiedAccelerator_nullKeyCombination1() {
Copy link
Collaborator Author

@aghaisas aghaisas Apr 19, 2021

Choose a reason for hiding this comment

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

Constructing KeyCodeCombination with a null KeyCode & constructing a KeyCharacterCombination with null key character results in NullPointerException as present in KeyCombinationTest.java.

These tests were ignored with a comment on similar lines. I have enabled them and added expected NullPointerException.

Copy link
Member

@kevinrushforth kevinrushforth Apr 19, 2021

Choose a reason for hiding this comment

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

Where is the NPE thrown? I see that your change makes the test pass, but if it never gets to the setAccelerator call or the assertEquals statements maybe you could remove them?

Copy link
Collaborator Author

@aghaisas aghaisas Apr 20, 2021

Choose a reason for hiding this comment

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

You are right. We can remove these test cases.
The NPE is thrown from KeyCodeCombination and KeyCharacterCombination constructors and not from the method of MenuItem that is under test.

SimpleObjectProperty<KeyCombination> other = new SimpleObjectProperty<KeyCombination>(menuItem, "accelerator", kc);
menuItem.acceleratorProperty().bind(other);
assertEquals(kc, menuItem.getAccelerator());
}

@Ignore
@Test public void getUnspecifiedMnemonicParsing() {
Copy link
Collaborator Author

@aghaisas aghaisas Apr 19, 2021

Choose a reason for hiding this comment

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

Test was incorrect. I have corrected it.
Default value of mnemonicParsing property of MenuItem is true.

@Test public void acceleratorCanBeBound() {
Modifier[] modifierArray = {};
KeyCombination kc = new KeyCharacterCombination(null, modifierArray);
KeyCombination kc = new KeyCharacterCombination("A", KeyCombination.ALT_DOWN);
Copy link
Collaborator Author

@aghaisas aghaisas Apr 19, 2021

Choose a reason for hiding this comment

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

Corrected the test case by creating a valid KeyCombination.


@Ignore // Again, calling graphicPropery() is not ensuring a non null graphic
// node.
@Test public void unsetGraphicButNotNull() {
Copy link
Collaborator Author

@aghaisas aghaisas Apr 19, 2021

Choose a reason for hiding this comment

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

Test was incorrect. The value of the 'graphic' property is not set and asserting on not null is incorrect.

}

@Test public void getUnspecifiedTextProperty2() {
MenuItem mi2 = new MenuItem("");
assertEquals("", mi2.getText());
}

@Ignore // calling textProperty will no ensure text value is non null
@Test public void unsetTextButNotNull() {
MenuItem mi2 = new MenuItem();
Copy link
Collaborator Author

@aghaisas aghaisas Apr 19, 2021

Choose a reason for hiding this comment

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

Test was incorrect. The value of the 'text' property is not set and asserting on not null is incorrect.

Modifier[] modifierArray = {};
KeyCombination kc = new KeyCharacterCombination(null, modifierArray);
menuItem.setAccelerator(kc);
assertEquals(kc, menuItem.getAccelerator());
}

@Test public void setSpecifiedAccelerator1() {
Modifier[] modifierArray = {};
Copy link
Collaborator Author

@aghaisas aghaisas Apr 19, 2021

Choose a reason for hiding this comment

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

Added a test case for valid KeyCodeCombination.

assertEquals(kc, menuItem.getAccelerator());
}

@Test public void setSpecifiedAccelerator2() {
Copy link
Collaborator Author

@aghaisas aghaisas Apr 19, 2021

Choose a reason for hiding this comment

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

Added a test case for valid KeyCharacterCombination.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Thanks for the evaluation. I only have one remaining question on the tests that now expect NPE.

@Ignore // keyCharacter for keyCodeCombination cannot be null
@Test public void setSpecifiedAccelerator1() {
@Test(expected=NullPointerException.class)
public void setSpecifiedAccelerator_nullKeyCombination1() {
Copy link
Member

@kevinrushforth kevinrushforth Apr 19, 2021

Choose a reason for hiding this comment

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

Where is the NPE thrown? I see that your change makes the test pass, but if it never gets to the setAccelerator call or the assertEquals statements maybe you could remove them?

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Looks good.

@openjdk
Copy link

openjdk bot commented Apr 20, 2021

@aghaisas This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8265439: [TestBug] Enable and fix ignored unit tests in MenuItemTest

Reviewed-by: kcr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 2 new commits pushed to the master branch:

  • e02cee9: 8264990: WebEngine crashes with segfault when not loaded through system classloader
  • a683558: 8259356: MediaPlayer's seek freezes video

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Ready to be integrated label Apr 20, 2021
@aghaisas
Copy link
Collaborator Author

aghaisas commented Apr 20, 2021

/integrate

@openjdk openjdk bot closed this Apr 20, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Ready to be integrated rfr Ready for review labels Apr 20, 2021
@openjdk
Copy link

openjdk bot commented Apr 20, 2021

@aghaisas Since your change was applied there have been 2 commits pushed to the master branch:

  • e02cee9: 8264990: WebEngine crashes with segfault when not loaded through system classloader
  • a683558: 8259356: MediaPlayer's seek freezes video

Your commit was automatically rebased without conflicts.

Pushed as commit af75a1f.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@aghaisas aghaisas deleted the MenuItemTest_fix branch Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
2 participants