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

Internal graphics not initialized yet #739

Open
perNyfelt opened this issue Feb 25, 2022 · 0 comments
Open

Internal graphics not initialized yet #739

perNyfelt opened this issue Feb 25, 2022 · 0 comments

Comments

@perNyfelt
Copy link

The following test fails about once every 10 runs with Internal graphics not initialized yet (i.e. the test works 90% of the time) :

package se.alipsa.rideutils;

import javafx.application.Platform;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;;
import org.testfx.api.FxRobot;
import org.testfx.framework.junit5.ApplicationExtension;
import org.testfx.framework.junit5.Start;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertNotNull;

@ExtendWith(ApplicationExtension.class)
public class ReadImageTest  {

  @Start
  public void start(Stage stage) {
    stage.show();
  }

  @Test
  public void testReadSvg() throws IOException {
    Image img = ReadImage.read("sinplot.svg");
    assertNotNull(img);
  }

  @Test
  public void testReadPng() throws IOException {
    Image img = ReadImage.read("plot.png");
    assertNotNull(img);
  }

  @Test
  public void testReadJpg() throws IOException {
    Image img = ReadImage.read("dino.jpg");
    assertNotNull(img);
  }
}

the stack trace produced when it fails is:

Tests run: 3, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.773 sec <<< FAILURE!
se.alipsa.rideutils.ReadImageTest.testReadJpg()  Time elapsed: 0.286 sec  <<< FAILURE!
java.lang.RuntimeException: Internal graphics not initialized yet
        at javafx.graphics/com.sun.glass.ui.Screen.getScreens(Screen.java:70)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.getScreens(QuantumToolkit.java:710)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.getMaxRenderScale(QuantumToolkit.java:737)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.loadImage(QuantumToolkit.java:746)
        at javafx.graphics/javafx.scene.image.Image.loadImage(Image.java:1052)
        at javafx.graphics/javafx.scene.image.Image.initialize(Image.java:802)
        at javafx.graphics/javafx.scene.image.Image.<init>(Image.java:618)
        at se.alipsa.rideutils.ReadImage.read(ReadImage.java:42)
        at se.alipsa.rideutils.ReadImageTest.testReadJpg(ReadImageTest.java:38)

I am using
openjdk version "11.0.14" 2022-01-18 LTS
OpenJDK Runtime Environment (build 11.0.14+9-LTS)
OpenJDK 64-Bit Server VM (build 11.0.14+9-LTS, mixed mode)

with the following dependencies

    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>17.0.2</version>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.8.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testfx</groupId>
      <artifactId>testfx-junit5</artifactId>
      <version>4.0.16-alpha</version>
      <scope>test</scope>
    </dependency>

Is there something I can do prevent tests from running before the environment has finished initializing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant