Skip to content

Commit

Permalink
Fixed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
arapte committed Jan 23, 2020
1 parent d64f6c8 commit 7c20469
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 55 deletions.
Expand Up @@ -43,8 +43,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
import test.util.Util;
import static org.junit.Assert.assertTrue;

public class TabPaneHeaderLeakTest extends Application {
public class TabPaneHeaderLeakTest {

private static CountDownLatch startupLatch;
private static StackPane root;
Expand All @@ -53,37 +54,34 @@ public class TabPaneHeaderLeakTest extends Application {
private static WeakReference<TextField> textFieldWeakRef;
private static WeakReference<Tab> tabWeakRef;

@Override
public void start(Stage primaryStage) throws Exception {
stage = primaryStage;
TextField tf = new TextField("Weak ref TF");
textFieldWeakRef = new WeakReference<>(tf);
Tab tab = new Tab("Tab", tf);
tabWeakRef = new WeakReference<>(tab);
tabPane = new TabPane(tab, new Tab("Tab1"));
tab = null;
tf = null;
public static class TestApp extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
stage = primaryStage;
TextField tf = new TextField("Weak ref TF");
textFieldWeakRef = new WeakReference<>(tf);
Tab tab = new Tab("Tab", tf);
tabWeakRef = new WeakReference<>(tab);
tabPane = new TabPane(tab, new Tab("Tab1"));
tab = null;
tf = null;

root = new StackPane(tabPane);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setOnShown(l -> {
startupLatch.countDown();
});
primaryStage.show();
root = new StackPane(tabPane);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setOnShown(l -> {
Platform.runLater(() -> startupLatch.countDown());
});
primaryStage.show();
}
}

@BeforeClass
public static void initFX() {
public static void initFX() throws Exception {
startupLatch = new CountDownLatch(1);
new Thread(() -> Application.launch(TabPaneHeaderLeakTest.class, (String[]) null)).start();
try {
if (!startupLatch.await(15, TimeUnit.SECONDS)) {
Assert.fail("Timeout waiting for FX runtime to start");
}
} catch (InterruptedException ex) {
Assert.fail("Unexpected exception: " + ex);
}
new Thread(() -> Application.launch(TestApp.class, (String[]) null)).start();
assertTrue("Timeout waiting for FX runtime to start",
startupLatch.await(15, TimeUnit.SECONDS));
}

@Test
Expand Down
Expand Up @@ -44,48 +44,46 @@
import org.junit.BeforeClass;
import org.junit.Test;
import test.util.Util;
import static org.junit.Assert.assertTrue;

public class ShapeViewOrderLeakTest extends Application {
public class ShapeViewOrderLeakTest {

private static CountDownLatch startupLatch;
private static StackPane root;
private static Stage stage;
private static Group group;
private static WeakReference<Shape> shapeWeakRef;

@Override
public void start(Stage primaryStage) throws Exception {
stage = primaryStage;
Shape shape1 = new Rectangle();
Shape shape2 = new Circle();
shape1.setViewOrder(1);
shape2.setViewOrder(0);
shapeWeakRef = new WeakReference<>(shape1);
public static class TestApp extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
stage = primaryStage;
Shape shape1 = new Rectangle();
Shape shape2 = new Circle();
shape1.setViewOrder(1);
shape2.setViewOrder(0);
shapeWeakRef = new WeakReference<>(shape1);

group = new Group(shape1, shape2);
shape1 = null;
shape2 = null;
group = new Group(shape1, shape2);
shape1 = null;
shape2 = null;

root = new StackPane(group);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setOnShown(l -> {
startupLatch.countDown();
});
primaryStage.show();
root = new StackPane(group);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setOnShown(l -> {
Platform.runLater(() -> startupLatch.countDown());
});
primaryStage.show();
}
}

@BeforeClass
public static void initFX() {
public static void initFX() throws Exception {
startupLatch = new CountDownLatch(1);
new Thread(() -> Application.launch(ShapeViewOrderLeakTest.class, (String[]) null)).start();
try {
if (!startupLatch.await(15, TimeUnit.SECONDS)) {
Assert.fail("Timeout waiting for FX runtime to start");
}
} catch (InterruptedException ex) {
Assert.fail("Unexpected exception: " + ex);
}
new Thread(() -> Application.launch(TestApp.class, (String[]) null)).start();
assertTrue("Timeout waiting for FX runtime to start",
startupLatch.await(15, TimeUnit.SECONDS));
}

@Test
Expand Down

0 comments on commit 7c20469

Please sign in to comment.