Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2539de7
commit ddb4384
Showing
2 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package jp.toastkid.script; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.IOException; | ||
|
||
import org.fxmisc.richtext.CodeArea; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.testfx.framework.junit.ApplicationTest; | ||
|
||
import javafx.application.Platform; | ||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Scene; | ||
import javafx.scene.layout.VBox; | ||
import javafx.stage.Stage; | ||
|
||
/** | ||
* {@link Controller}'s test. | ||
* | ||
* @author Toast kid | ||
* | ||
*/ | ||
public class ControllerTest extends ApplicationTest { | ||
|
||
/** Logger. */ | ||
private static final Logger LOGGER = LoggerFactory.getLogger(ControllerTest.class); | ||
|
||
/** | ||
* UI test. | ||
* @throws InterruptedException | ||
*/ | ||
@Test | ||
public void test() throws InterruptedException { | ||
final CodeArea input = (CodeArea) lookup("#scripterInput").query(); | ||
final String text = "println 'Hello world.'"; | ||
Platform.runLater(() -> { | ||
input.replaceText(text); | ||
assertEquals(text, input.getText()); | ||
lookup("#runButton").query().fireEvent(new ActionEvent()); | ||
assertEquals("Hello world.", ((CodeArea) lookup("#scripterOutput").query()).getText().trim()); | ||
}); | ||
} | ||
|
||
@Override | ||
public void start(final Stage stage) throws Exception { | ||
try { | ||
final FXMLLoader loader | ||
= new FXMLLoader(getClass().getClassLoader().getResource("scenes/Main.fxml")); | ||
final VBox loaded = (VBox) loader.load(); | ||
final Scene scene = new Scene(loaded); | ||
stage.setScene(scene); | ||
} catch (final IOException e) { | ||
LOGGER.error("Scene Reading Error", e); | ||
} | ||
stage.show(); | ||
} | ||
|
||
} |