-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7090 from pabender/cucumber
Move application start tests to cucumber.
- Loading branch information
Showing
34 changed files
with
229 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
java/acceptancetest/features/apps/ApplicationStart.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@apptest @Headed | ||
Feature: JMRI Applications | ||
|
||
Scenario Outline: Application Start | ||
Given I am using profile <profile> | ||
When starting application <application> with <name> | ||
Then <infoline> is printed to the console | ||
And a frame with title <name> is displayed | ||
|
||
@FailingTests @Ignore | ||
Examples: Tests that are failing | ||
| application | profile | name | infoline | | ||
| apps.PanelPro.PanelPro | java/test/apps/PanelPro/profiles/EasyDcc_Simulator | PanelProPro | Main initialization done | | ||
| apps.DecoderPro.DecoderPro | java/test/apps/PanelPro/profiles/Grapevine_Simulator | DispatcherPro | DecoderPro version | | ||
|
||
@PanelProTest | ||
Examples: PanelPro Tests | ||
| application | profile | name | infoline | | ||
| apps.PanelPro.PanelPro | java/test/apps/PanelPro/profiles/LocoNet_Simulator | PanelPro | Main initialization done | | ||
| apps.PanelPro.PanelPro | java/test/apps/PanelPro/profiles/TMCC_Simulator | PanelPro | Main initialization done | | ||
| apps.PanelPro.PanelPro | java/test/apps/PanelPro/profiles/Prevent_Init_Loop | PanelPro | Main initialization done | | ||
| apps.PanelPro.PanelPro | java/test/apps/PanelPro/profiles/Grapevine_Simulator | PanelPro | Main initialization done | | ||
| apps.PanelPro.PanelPro | java/test/apps/PanelPro/profiles/Sprog_Simulator | PanelPro | Main initialization done | | ||
|
||
@DecoderProTest | ||
Examples: DecoderPro Tests | ||
| application | profile | name | infoline | | ||
| apps.DecoderPro.DecoderPro | java/test/apps/PanelPro/profiles/LocoNet_Simulator | DecoderPro | DecoderPro version | | ||
| apps.DecoderPro.DecoderPro | java/test/apps/PanelPro/profiles/EasyDcc_Simulator | DecoderPro | DecoderPro version | | ||
| apps.DecoderPro.DecoderPro | java/test/apps/PanelPro/profiles/TMCC_Simulator | DecoderPro | DecoderPro version | | ||
| apps.DecoderPro.DecoderPro | java/test/apps/PanelPro/profiles/Prevent_Init_Loop | DecoderPro | DecoderPro version | | ||
| apps.DecoderPro.DecoderPro | java/test/apps/PanelPro/profiles/Sprog_Simulator | DecoderPro | DecoderPro version | | ||
|
||
@DecoderPro3Test | ||
Examples: DecoderPro3 Tests | ||
| application | profile | name | infoline | | ||
| apps.gui3.dp3.DecoderPro3 | java/test/apps/PanelPro/profiles/LocoNet_Simulator | DecoderPro: All Entries | DecoderPro version | | ||
| apps.gui3.dp3.DecoderPro3 | java/test/apps/PanelPro/profiles/EasyDcc_Simulator | DecoderPro: All Entries | DecoderPro version | | ||
| apps.gui3.dp3.DecoderPro3 | java/test/apps/PanelPro/profiles/TMCC_Simulator | DecoderPro: All Entries | DecoderPro version | | ||
| apps.gui3.dp3.DecoderPro3 | java/test/apps/PanelPro/profiles/Prevent_Init_Loop | DecoderPro: All Entries | DecoderPro version | | ||
| apps.gui3.dp3.DecoderPro3 | java/test/apps/PanelPro/profiles/Grapevine_Simulator | DecoderPro: All Entries | DecoderPro version | | ||
| apps.gui3.dp3.DecoderPro3 | java/test/apps/PanelPro/profiles/Sprog_Simulator | DecoderPro: All Entries | DecoderPro version | | ||
|
||
@SoundProTest | ||
Examples: SoundPro Tests | ||
| application | profile | name | infoline | | ||
| apps.SoundPro.SoundPro | java/test/apps/PanelPro/profiles/LocoNet_Simulator | SoundPro | SoundPro version | | ||
| apps.SoundPro.SoundPro | java/test/apps/PanelPro/profiles/EasyDcc_Simulator | SoundPro | SoundPro version | | ||
| apps.SoundPro.SoundPro | java/test/apps/PanelPro/profiles/TMCC_Simulator | SoundPro | SoundPro version | | ||
| apps.SoundPro.SoundPro | java/test/apps/PanelPro/profiles/Prevent_Init_Loop | SoundPro | SoundPro version | | ||
| apps.SoundPro.SoundPro | java/test/apps/PanelPro/profiles/Grapevine_Simulator | SoundPro | SoundPro version | | ||
| apps.SoundPro.SoundPro | java/test/apps/PanelPro/profiles/Sprog_Simulator | SoundPro | SoundPro version | | ||
|
||
@DispatcherProTest | ||
Examples: DispatcherPro Tests | ||
| application | profile | name | infoline | | ||
| apps.DispatcherPro.DispatcherPro | java/test/apps/PanelPro/profiles/LocoNet_Simulator | DispatcherPro | DispatcherPro version | | ||
| apps.DispatcherPro.DispatcherPro | java/test/apps/PanelPro/profiles/EasyDcc_Simulator | DispatcherPro | DispatcherPro version | | ||
| apps.DispatcherPro.DispatcherPro | java/test/apps/PanelPro/profiles/TMCC_Simulator | DispatcherPro | DispatcherPro version | | ||
| apps.DispatcherPro.DispatcherPro | java/test/apps/PanelPro/profiles/Prevent_Init_Loop | DispatcherPro | DispatcherPro version | | ||
| apps.DispatcherPro.DispatcherPro | java/test/apps/PanelPro/profiles/Grapevine_Simulator | DispatcherPro | DispatcherPro version | | ||
| apps.DispatcherPro.DispatcherPro | java/test/apps/PanelPro/profiles/Sprog_Simulator | DispatcherPro | DispatcherPro version | |
15 changes: 15 additions & 0 deletions
15
java/acceptancetest/features/apps/HeadlessApplicationStart.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@apptest @Headless | ||
Feature: Headless JMRI Applications | ||
|
||
Scenario Outline: Application Start | ||
Given I am using profile <profile> | ||
When starting application <application> with <name> | ||
Then <infoline> is printed to the console | ||
|
||
@JmriFacelessTest @Ignore | ||
Examples: Headless Tests | ||
| application | profile | name | infoline | | ||
| apps.JmriFaceless | java/test/apps/PanelPro/profiles/LocoNet_Simulator | JmriFaceless | JmriFaceless version | | ||
| apps.JmriFaceless | java/test/apps/PanelPro/profiles/EasyDcc_Simulator | JmriFaceless | JmriFaceless version | | ||
| apps.JmriFaceless | java/test/apps/PanelPro/profiles/TMCC_Simulator | JmriFaceless | JmriFaceless version | | ||
| apps.JmriFaceless | java/test/apps/PanelPro/profiles/Grapevine_Simulator | JmriFaceless | JmriFaceless version | |
112 changes: 112 additions & 0 deletions
112
java/acceptancetest/step_definitions/apps/ApplicationTestAcceptanceSteps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package apps; | ||
|
||
import cucumber.api.java8.En; | ||
import cucumber.api.PendingException; | ||
import org.junit.Assert; | ||
import java.io.File; | ||
import org.apache.commons.io.FileUtils; | ||
import java.nio.file.Files; | ||
import java.lang.reflect.Method; | ||
import jmri.managers.DefaultShutDownManager; | ||
import jmri.util.JmriJFrame; | ||
import jmri.util.JUnitAppender; | ||
import jmri.util.JUnitUtil; | ||
import org.netbeans.jemmy.operators.JButtonOperator; | ||
import org.netbeans.jemmy.operators.JDialogOperator; | ||
|
||
/** | ||
* Cucumber step definitions for Application Acceptance tests. | ||
* | ||
* @author Paul Bender Copyright (C) 2018 | ||
*/ | ||
public class ApplicationTestAcceptanceSteps implements En { | ||
|
||
String[] tags = {"@apptest"}; | ||
File tempFolder; | ||
|
||
public ApplicationTestAcceptanceSteps(jmri.InstanceManager instance) { | ||
|
||
|
||
Before(tags,() -> { | ||
JUnitUtil.setUp(); | ||
JUnitUtil.clearShutDownManager(); | ||
JUnitUtil.resetApplication(); | ||
}); | ||
|
||
Given("^I am using profile (.*)$", (String profile) -> { | ||
try { | ||
// create a custom profile | ||
tempFolder =Files.createTempDirectory("AppTest").toFile(); | ||
File profileDir = new File(tempFolder.getAbsolutePath() + File.separator + "Name" ); | ||
FileUtils.copyDirectory(new File(profile), profileDir ); | ||
System.setProperty("jmri.prefsdir",tempFolder.getAbsolutePath()); | ||
System.setProperty("org.jmri.profile", profileDir.getAbsolutePath() ); | ||
} catch(java.io.IOException ioe) { | ||
Assert.fail("Unable to create temporary profile"); | ||
} | ||
}); | ||
|
||
When("^starting application (.*) with (.*)", (String application,String frametitle ) -> { | ||
try { | ||
// use redirection to start the application. | ||
Class appclass = Class.forName(application); | ||
Method method = appclass.getMethod("main",String[].class); | ||
String[] params = new String[]{frametitle}; | ||
method.invoke(null,(Object)params); | ||
} catch(java.lang.ClassNotFoundException cnf){ | ||
Assert.fail("Class " + application + " not found"); | ||
} catch(java.lang.NoSuchMethodException | | ||
java.lang.IllegalAccessException ex){ | ||
Assert.fail("Error calling main method"); | ||
} | ||
}); | ||
|
||
Then("^a frame with title (.*) is displayed$", (String frameTitle) -> { | ||
JUnitUtil.waitFor(()->{return JmriJFrame.getFrame(frameTitle) != null;}, "window up"); | ||
}); | ||
|
||
Then("^(.*) is printed to the console$", (String infoLine) -> { | ||
JUnitUtil.waitFor(()->{return JUnitAppender.checkForMessageStartingWith(infoLine) != null;}, "first Info line seen"); | ||
}); | ||
|
||
After(tags,() -> { | ||
dismissClosingDialogs(); // this method starts a new thread | ||
try{ | ||
// gracefully shutdown, but don't exit | ||
((DefaultShutDownManager)instance.getDefault(jmri.ShutDownManager.class)).shutdown(0, false); | ||
} finally { | ||
// wait for threads, etc | ||
jmri.util.JUnitUtil.releaseThread(this, 5000); | ||
} | ||
FileUtils.deleteDirectory(tempFolder); | ||
System.clearProperty("jmri.prefsdir"); | ||
System.clearProperty("org.jmri.profile"); | ||
JUnitUtil.clearShutDownManager(); | ||
JUnitUtil.tearDown(); | ||
}); | ||
|
||
} | ||
|
||
private void dismissClosingDialogs(){ | ||
// the Unsaved Changes dialog doesn't appear every time we close, | ||
// so put pressing No button in that dialog into a thread by itself. | ||
// If the dialog appears, the button will be clicked, but it's not | ||
// an error if the dialog doesn't appear. | ||
Thread t = new Thread( () -> { | ||
try { | ||
JDialogOperator d = new JDialogOperator(Bundle.getMessage("UnsavedChangesTitle")); | ||
// Find the button that deletes the panel | ||
JButtonOperator bo = new JButtonOperator(d,Bundle.getMessage("ButtonNo")); | ||
|
||
// Click button to delete panel and close window | ||
bo.push(); | ||
} catch (Exception e) { | ||
// exceptions in this thread are not considered an error. | ||
return; | ||
} | ||
}); | ||
t.setName("Unsaved Changes Dialog Close Thread"); | ||
t.start(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.