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

8208088: Memory Leak in ControlAcceleratorSupport #429

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,24 @@
import test.com.sun.javafx.scene.control.infrastructure.StageLoader;

import org.junit.Test;
import org.junit.BeforeClass;
import static org.junit.Assert.assertEquals;

public class ControlAcceleratorSupportTest {

@Test
public void sanityTestListenerMapShouldBeEmpty() {
assertEquals(0, ControlAcceleratorSupportShim.get_ListenerMapSize());
private static int numListeners;

@BeforeClass
public static void setup() throws Exception {
for (int i = 0; i < 4; i++) {
System.gc();
arapte marked this conversation as resolved.
Show resolved Hide resolved
Thread.sleep(500);
}
numListeners = ControlAcceleratorSupportShim.get_ListenerMapSize();
}

@Test
public void testNumberOfListenersByRemovingAndAddingMenuItems() {

Menu menu1 = new Menu("1");
MenuItem item11 = new MenuItem("Item 1");
MenuItem item12 = new MenuItem("Item 2");
Expand All @@ -62,19 +69,24 @@ public void testNumberOfListenersByRemovingAndAddingMenuItems() {

StageLoader sl = new StageLoader(pane);

assertEquals(4, ControlAcceleratorSupportShim.get_ListenerMapSize());
assertEquals(numListeners + 4, ControlAcceleratorSupportShim.get_ListenerMapSize());

menu1.getItems().clear();
assertEquals(2, ControlAcceleratorSupportShim.get_ListenerMapSize());
assertEquals(numListeners + 2, ControlAcceleratorSupportShim.get_ListenerMapSize());

menu2.getItems().clear();
assertEquals(0, ControlAcceleratorSupportShim.get_ListenerMapSize());
assertEquals(numListeners + 0, ControlAcceleratorSupportShim.get_ListenerMapSize());

menu1.getItems().addAll(item11, item12);
assertEquals(2, ControlAcceleratorSupportShim.get_ListenerMapSize());
assertEquals(numListeners + 2, ControlAcceleratorSupportShim.get_ListenerMapSize());

menu2.getItems().addAll(item21, item22);
assertEquals(4, ControlAcceleratorSupportShim.get_ListenerMapSize());
assertEquals(numListeners + 4, ControlAcceleratorSupportShim.get_ListenerMapSize());

menu2.getItems().clear();
menu1.getItems().clear();

assertEquals(numListeners + 0, ControlAcceleratorSupportShim.get_ListenerMapSize());

sl.dispose();
}
Expand Down