Skip to content
Snippets Groups Projects
Commit 27058cbb authored by Nicolas anquetil's avatar Nicolas anquetil
Browse files

updated pom.xml + adapted tests accordingly + started to play with TestFX

parent d7046339
Branches
No related tags found
No related merge requests found
Showing with 186 additions and 71 deletions
......@@ -15,7 +15,6 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
......@@ -24,5 +23,22 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.univlille.iutinfo.m3501</groupId>
<artifactId>TP2</artifactId>
<version>1.0</version>
<groupId>MvnFXML</groupId>
<artifactId>maven-skeleton</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<sonar.host.url>https://sonar.tcweb.org/</sonar.host.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<!-- Java compilation -->
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
<!-- Sonar -->
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.9.0.2155</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- JUnit -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<!-- JavaFX -->
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.4</version>
<version>0.0.6</version>
<configuration>
<mainClass>fr.univlille.iutinfo.m3105.Main</mainClass>
<mainClass>fr.univlille.iutinfo.m3105.MainQ3</mainClass>
</configuration>
</plugin>
</plugins>
......@@ -38,18 +61,39 @@
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>14</version>
<version>12.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>14</version>
<artifactId>javafx-fxml</artifactId>
<version>18-ea+2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-core</artifactId>
<version>4.0.16-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-junit5</artifactId>
<version>4.0.16-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
......@@ -12,6 +12,7 @@ public class JavaFXSimpleExample extends Application {
public void start(Stage stage) {
Label l = new Label(welcomeMessage());
Scene scene = new Scene(new StackPane(l), 640, 480);
System.out.println(getClass().getResource("/toto.ply").getPath());
stage.setScene(scene);
stage.show();
}
......
......@@ -22,8 +22,8 @@ public class MainQ3 extends Application {
Temperature tempN = new Temperature(Echelle.NEWTON);
tempN.biconnectTo(tempF);
new TextView( tempC);
new TextView( tempF);
new SliderView( tempN);
new TextView( tempF);
}
}
......@@ -10,6 +10,7 @@ import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
public class TextView extends AbstractVue {
......@@ -58,8 +59,6 @@ public class TextView extends AbstractVue {
return Double.parseDouble( saisie.getText());
}
public void setDisplayedValue(double val) {
saisie.setText( String.format("%.1f", val) );
}
public void setDisplayedValue(double val) { saisie.setText( String.format("%.1f", val) ); }
}
......@@ -42,6 +42,7 @@ public abstract class AbstractVue extends Stage implements Observer, ITemperatur
@Override
public void update(Subject subj, Object data) {
System.out.println("AbstractVue.update("+modele.getTemperature());
setDisplayedValue(modele.getTemperature());
}
......
......@@ -9,6 +9,7 @@ import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
public class TextView extends AbstractVue {
......@@ -56,6 +57,15 @@ public class TextView extends AbstractVue {
}
public void setDisplayedValue(double val) {
if (val > 25) {
saisie.setStyle("-fx-background-color:red;");
}
else if (val < -5) {
saisie.setStyle("-fx-control-inner-background:blue;");
}
else {
saisie.setStyle("-fx-background-color:white;");
}
saisie.setText( String.format("%.1f", val) );
}
......
......@@ -11,16 +11,16 @@ import fr.univlille.iutinfo.m3105.modelQ1.Thermogeekostat;
import fr.univlille.iutinfo.m3105.viewQ1.ITemperatureView;
import fr.univlille.iutinfo.m3105.viewQ1.TextView;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import org.testfx.framework.junit5.ApplicationTest;
public class TestQ1_3 {
public class TestQ1_3 extends ApplicationTest {
/* JFXPanel is a component that initializes JavaFX without needing a javafx.application.Application
* We need it to be able to create a view but we don't need the attribute after that
* /
@SuppressWarnings("unused")
private JFXPanel fxPanel = new JFXPanel();
*/
protected ITemperature model;
protected ITemperatureView view;
......
......@@ -10,16 +10,16 @@ import fr.univlille.iutinfo.m3105.modelQ2.Temperature;
import fr.univlille.iutinfo.m3105.viewQ1.ITemperatureView;
import fr.univlille.iutinfo.m3105.viewQ3.TextView;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import org.testfx.framework.junit5.ApplicationTest;
public class TestQ3_1 {
public class TestQ3_1 extends ApplicationTest {
public static final double DELTA = 0.005; // rounding to 1/100
/* JFXPanel is a component that initializes JavaFX without needing a javafx.application.Application
* We need it to be able to create a view but we don't need the attribute after that
*/
@SuppressWarnings("unused")
private JFXPanel fxPanel = new JFXPanel();
//private JFXPanel fxPanel = new JFXPanel();
protected Temperature model;
protected ITemperatureView view;
......
......@@ -11,17 +11,11 @@ import fr.univlille.iutinfo.m3105.modelQ2.Temperature;
import fr.univlille.iutinfo.m3105.viewQ1.ITemperatureView;
import fr.univlille.iutinfo.m3105.viewQ3.TextView;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import org.testfx.framework.junit5.ApplicationTest;
public class TestQ3_2 {
public class TestQ3_2 extends ApplicationTest {
public static final double DELTA = 0.005; // rounding to 1/100
/* JFXPanel is a component that initializes JavaFX without needing a javafx.application.Application
* We need it to be able to create a IVueThermogeekostat but we don't need the attribute after that
*/
@SuppressWarnings("unused")
private JFXPanel fxPanel = new JFXPanel();
protected Temperature modelC;
protected ITemperatureView viewC;
......
package fr.univlille.iutinfo.m3105.q3;
import fr.univlille.iutinfo.m3105.MainQ3;
import fr.univlille.iutinfo.m3105.modelQ2.Echelle;
import fr.univlille.iutinfo.m3105.modelQ2.Temperature;
import fr.univlille.iutinfo.m3105.viewQ3.TextView;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testfx.api.FxAssert;
import org.testfx.api.FxRobot;
import org.testfx.framework.junit5.ApplicationExtension;
import org.testfx.framework.junit5.ApplicationTest;
import org.testfx.matcher.control.TextInputControlMatchers;
@ExtendWith(ApplicationExtension.class)
public class TestQ3_3 /*extends ApplicationTest */{
@BeforeEach
public void setup() throws Exception {
ApplicationTest.launch(fr.univlille.iutinfo.m3105.MainQ3.class);
}
//@ Start
public void start(Stage stage) throws Exception {
System.err.println("in START !!!");
Temperature temp = new Temperature(Echelle.CELSIUS);
temp.setTemperature(18.0);
new TextView(temp).show();
}
@Test
public void test1(FxRobot robot) {
//robot.clickOn(".button");
/*
for (Window w : robot.listWindows()) {
System.out.println("window type:" + w.getClass().getName());
}
Window wndw = wndw = robot.listWindows().get(2);
System.out.println("window 2 type:" + wndw.getClass().getName());
*/
FxAssert.verifyThat( robot.lookup(node -> node instanceof TextField) , TextInputControlMatchers.hasText("18.0"));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment