Commit 8792e211 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke

Added a first GUI test

parent 778f2ff9
......@@ -13,6 +13,10 @@
<artifactId>kieker-trace-diagnosis-guitest-architecture</artifactId>
<dependencies>
<dependency>
<groupId>net.kieker-monitoring</groupId>
<artifactId>kieker-trace-diagnosis-application</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
......@@ -21,6 +25,10 @@
<groupId>org.testfx</groupId>
<artifactId>testfx-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>
package kieker.diagnosis.test.architecture.ui;
import org.testfx.api.FxRobotInterface;
public class Button extends Component {
public Button( final FxRobotInterface aRobot, final String aSelectorId ) {
super( aRobot, aSelectorId );
}
public void click( ) {
getRobot( ).clickOn( getNode( ) );
}
}
package kieker.diagnosis.test.architecture.ui;
import java.util.concurrent.TimeoutException;
import org.junit.BeforeClass;
import org.testfx.api.FxRobot;
import org.testfx.api.FxToolkit;
import org.testfx.toolkit.ApplicationFixture;
import javafx.stage.Stage;
import kieker.diagnosis.KiekerTraceDiagnosis;
public abstract class GuiTestBase {
private static final FxRobot cvRobot = new FxRobot( );
@BeforeClass
public static void setUp( ) {
try {
FxToolkit.registerPrimaryStage( );
FxToolkit.setupApplication( new KiekerTraceDiagnosisApplicationFixture( ) );
} catch ( final TimeoutException ex ) {
throw new IllegalStateException( ex );
}
}
public static FxRobot getRobot( ) {
return cvRobot;
}
private static final class KiekerTraceDiagnosisApplicationFixture implements ApplicationFixture {
@Override
public void stop( ) throws Exception {
}
@Override
public void start( final Stage stage ) throws Exception {
final KiekerTraceDiagnosis kiekerTraceDiagnosis = new KiekerTraceDiagnosis( );
kiekerTraceDiagnosis.start( stage );
}
@Override
public void init( ) throws Exception {
}
}
}
......@@ -13,21 +13,11 @@
<artifactId>kieker-trace-diagnosis-guitest</artifactId>
<dependencies>
<dependency>
<groupId>net.kieker-monitoring</groupId>
<artifactId>kieker-trace-diagnosis-application</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.kieker-monitoring</groupId>
<artifactId>kieker-trace-diagnosis-guitest-architecture</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
......@@ -36,7 +26,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw -Dprism.text=t2k -Dtestfx.robot=glass</argLine>
<argLine>-Duser.country=US -Duser.language=us</argLine>
</configuration>
</plugin>
</plugins>
......
package kieker.diagnosis.test.ui;
import java.util.concurrent.TimeoutException;
import org.junit.BeforeClass;
import org.junit.Test;
import org.testfx.api.FxRobot;
import org.testfx.api.FxToolkit;
import org.testfx.toolkit.ApplicationFixture;
import javafx.stage.Stage;
import kieker.diagnosis.KiekerTraceDiagnosis;
import kieker.diagnosis.test.architecture.ui.GuiTestBase;
import kieker.diagnosis.test.ui.main.MainView;
import kieker.diagnosis.test.ui.main.OkCancelDialog;
public class ApplicationCloseTest {
@BeforeClass
public static void setUp( ) {
try {
FxToolkit.registerPrimaryStage( );
FxToolkit.setupApplication( new ApplicationFixture( ) {
@Override
public void stop( ) throws Exception {
}
@Override
public void start( final Stage stage ) throws Exception {
final KiekerTraceDiagnosis kiekerTraceDiagnosis = new KiekerTraceDiagnosis( );
kiekerTraceDiagnosis.start( stage );
}
@Override
public void init( ) throws Exception {
}
} );
} catch ( final TimeoutException ex ) {
throw new IllegalStateException( ex );
}
}
public class ApplicationCloseTest extends GuiTestBase {
@Test
public void closeApplication( ) {
final MainView mainView = new MainView( new FxRobot( ) );
// First we cancel the dialog
final MainView mainView = new MainView( getRobot( ) );
mainView.getFileMenu( ).click( );
mainView.getFileMenu( ).getCloseMenuItem( ).click( );
final OkCancelDialog dialog = new OkCancelDialog( getRobot( ) );
dialog.getCancelButton( ).click( );
// Now we close the application
mainView.getFileMenu( ).click( );
mainView.getFileMenu( ).getCloseMenuItem( ).click( );
dialog.getOkButton( ).click( );
}
}
package kieker.diagnosis.test.ui.main;
import org.testfx.api.FxRobot;
import kieker.diagnosis.test.architecture.ui.Button;
public class OkCancelDialog {
private final Button ivOkButton;
private final Button ivCancelButton;
public OkCancelDialog( final FxRobot aRobot ) {
ivOkButton = new Button( aRobot, "OK" );
ivCancelButton = new Button( aRobot, "Cancel" );
}
public Button getOkButton( ) {
return ivOkButton;
}
public Button getCancelButton( ) {
return ivCancelButton;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment