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

Cleanup integration test #601

Merged
merged 23 commits into from
Oct 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0f2f194
Move SingleLineTests into (new) navigation package
JordanMartinez Sep 30, 2017
e2c0e9a
Move MultiLineGridlikeTextTests into navigation package
JordanMartinez Sep 30, 2017
28eb926
Move MultiLineJaggedTextTests into navigation package
JordanMartinez Sep 30, 2017
612965a
Move ViewportTests to separate file: PageUpDownTests
JordanMartinez Sep 30, 2017
e630546
Move helper fields/methods to base test if need different area flavor
JordanMartinez Sep 30, 2017
12b029b
Only set context menu is ContextMenuTests
JordanMartinez Sep 30, 2017
c2196f2
Prevent super class stage dimension changes from messing up assertions
JordanMartinez Sep 30, 2017
3a38522
Initialize text and padding only once
JordanMartinez Sep 30, 2017
5f8d00b
Use more accurate way to determine caret's paragraph
JordanMartinez Sep 30, 2017
6577e78
Run prev/next page tests on every OS
JordanMartinez Oct 1, 2017
a13af4d
Add "_" in-between words in class/test names; optimize string creation
JordanMartinez Oct 1, 2017
cff61a4
Copy test's testLogging config to integrationTest's config
JordanMartinez Oct 1, 2017
8b6c718
Allow builds to specify which robot to use
JordanMartinez Oct 1, 2017
249d297
Move test to more appropriate test file; include backspace counterpart
JordanMartinez Oct 1, 2017
efe4239
Move miscellaneous case to more appropriate test file
JordanMartinez Oct 1, 2017
c2d2f97
Correct test name: care does not move when shortcut is down
JordanMartinez Oct 1, 2017
fe65d3f
Clear clipboard before tests to insure no interference
JordanMartinez Oct 1, 2017
6216264
Add the right index number to the line of text
JordanMartinez Oct 1, 2017
a9036e5
Use character bounds to test for more accurate caret position
JordanMartinez Oct 1, 2017
b7d5734
Fix bug in test code: mouse should not be released before moving again
JordanMartinez Oct 1, 2017
9ee5435
Skip COPY test on Linux
JordanMartinez Oct 1, 2017
7f4b164
Skip test on Mac until bug/test is fixed
JordanMartinez Oct 1, 2017
b105dc4
No longer ignore some tests since they pass now; fix whitespace issue
JordanMartinez Oct 1, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion richtextfx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ testSets {

check.dependsOn integrationTest
integrationTest.mustRunAfter test
integrationTest.systemProperty "testfx.robot", "glass"
if (gradle.gradleVersion.substring(0, 1) >= "4") {
// required for Gradle 4 to see custom integrationTest test suite
integrationTest.testClassesDirs = sourceSets.integrationTest.output.classesDirs
Expand Down Expand Up @@ -106,6 +105,35 @@ test {
}
}

integrationTest {
testLogging {
// Fancy formatting from http://stackoverflow.com/a/36130467/3634630
// set options for log level LIFECYCLE
events TestLogEvent.PASSED, TestLogEvent.SKIPPED,
TestLogEvent.FAILED, TestLogEvent.STANDARD_OUT
showExceptions true
exceptionFormat TestExceptionFormat.FULL
showCauses true
showStackTraces true

// set options for log level DEBUG and INFO
debug {
events TestLogEvent.STARTED, TestLogEvent.PASSED,
TestLogEvent.SKIPPED, TestLogEvent.FAILED,
TestLogEvent.STANDARD_OUT, TestLogEvent.STANDARD_ERROR
}
info.events = debug.events
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,21 @@
package org.fxmisc.richtext;

import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.MouseButton;
import javafx.stage.Stage;
import javafx.stage.Window;
import org.testfx.api.FxRobotInterface;
import org.testfx.framework.junit.ApplicationTest;
import org.testfx.service.query.PointQuery;

import static org.junit.Assume.assumeTrue;

/**
* TestFX tests should subclass this if it needs to run tests on a simple area. Any view-related API needs to be
* wrapped in a {@link #interact(Runnable)} call, but model API does not need to be wrapped in it.
*/
public class InlineCssTextAreaAppTest extends ApplicationTest {

static {
String osName = System.getProperty("os.name").toLowerCase();

isWindows = osName.startsWith("win");
isMac = osName.startsWith("mac");
isLinux = osName.startsWith("linux");
}

public static final boolean isWindows;
public static final boolean isMac;
public static final boolean isLinux;
public class InlineCssTextAreaAppTest extends RichTextFXTestBase {

public Stage stage;
public Scene scene;
public InlineCssTextArea area;
public ContextMenu menu;

@Override
public void start(Stage stage) throws Exception {
Expand All @@ -48,28 +28,10 @@ public void start(Stage stage) throws Exception {
stage.setHeight(400);
stage.show();

menu = new ContextMenu(new MenuItem("A menu item"));
area.setContextMenu(menu);
// offset needs to be 5+ to prevent test failures
area.setContextMenuXOffset(30);
area.setContextMenuYOffset(30);

// so tests don't need to do this themselves
area.requestFocus();
}

public final PointQuery position(Scene scene, Pos pos, double xOffset, double yOffset) {
return point(scene).atPosition(pos).atOffset(xOffset, yOffset);
}

public final PointQuery position(Window window, Pos pos, double xOffset, double yOffset) {
return point(window).atPosition(pos).atOffset(xOffset, yOffset);
}

public final PointQuery position(Node node, Pos pos, double xOffset, double yOffset) {
return point(node).atPosition(pos).atOffset(xOffset, yOffset);
}

public final PointQuery position(Pos pos, double xOffset, double yOffset) {
return position(area, pos, xOffset, yOffset);
}
Expand Down Expand Up @@ -98,51 +60,4 @@ public final FxRobotInterface rightClickOnFirstLine() {
return clickOnFirstLine(MouseButton.SECONDARY);
}

/**
* If not on Windows environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void run_only_on_windows() {
assumeTrue(isWindows);
}

/**
* If not on Linux environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void run_only_on_linux() {
assumeTrue(isLinux);
}

/**
* If not on Mac environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void run_only_on_mac() {
assumeTrue(isMac);
}

/**
* If on Windows environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void skip_if_on_windows() {
assumeTrue(!isWindows);
}

/**
* If on Linux environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void skip_if_on_linux() {
assumeTrue(!isLinux);
}

/**
* If on Mac environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void skip_if_on_mac() {
assumeTrue(!isMac);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package org.fxmisc.richtext;

import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.stage.Window;
import org.testfx.framework.junit.ApplicationTest;
import org.testfx.service.query.PointQuery;

import static org.junit.Assume.assumeTrue;

/**
* Provides useful static fields and helper methods for RichTextFX integration tests.
*
* <ul>
* <li>
* Helps determine which OS is currently running the test and whether to run/skip a test on that OS
* </li>
* <li>
* Getting the position o
* </li>
* </ul>
*/
public abstract class RichTextFXTestBase extends ApplicationTest {

static {
String osName = System.getProperty("os.name").toLowerCase();

IS_WINDOWS = osName.startsWith("win");
IS_MAC = osName.startsWith("mac");
IS_LINUX = osName.startsWith("linux");
}

/* *********************************************** *
* OS-RELATED
* *********************************************** */

public static final boolean IS_WINDOWS;
public static final boolean IS_MAC;
public static final boolean IS_LINUX;

/**
* If not on Windows environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void run_only_on_windows() {
assumeTrue(IS_WINDOWS);
}

/**
* If not on Linux environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void run_only_on_linux() {
assumeTrue(IS_LINUX);
}

/**
* If not on Mac environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void run_only_on_mac() {
assumeTrue(IS_MAC);
}

/**
* If on Windows environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void skip_if_on_windows() {
assumeTrue(!IS_WINDOWS);
}

/**
* If on Linux environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void skip_if_on_linux() {
assumeTrue(!IS_LINUX);
}

/**
* If on Mac environment, calling this in @Before method will skip the entire test suite whereas calling
* this in @Test will skip just that test method
*/
public final void skip_if_on_mac() {
assumeTrue(!IS_MAC);
}

/* *********************************************** *
* Position-Related
* *********************************************** */

/**
* Returns a specific position in the scene, starting at {@code pos} and offsetting from that place by
* {@code xOffset} and {@code yOffset}
*/
public final PointQuery position(Scene scene, Pos pos, double xOffset, double yOffset) {
return point(scene).atPosition(pos).atOffset(xOffset, yOffset);
}

/**
* Returns a specific position in the window, starting at {@code pos} and offsetting from that place by
* {@code xOffset} and {@code yOffset}
*/
public final PointQuery position(Window window, Pos pos, double xOffset, double yOffset) {
return point(window).atPosition(pos).atOffset(xOffset, yOffset);
}

/**
* Returns a specific position in the node, starting at {@code pos} and offsetting from that place by
* {@code xOffset} and {@code yOffset}
*/
public final PointQuery position(Node node, Pos pos, double xOffset, double yOffset) {
return point(node).atPosition(pos).atOffset(xOffset, yOffset);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,30 @@

public class CaretTests extends InlineCssTextAreaAppTest {

private static final String FIFTY_PARS_OF_TEXT;

static {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 50; i++) {
sb.append(i).append("\n");
}
sb.append(50);
FIFTY_PARS_OF_TEXT = sb.toString();
}

@Override
public void start(Stage stage) throws Exception {
super.start(stage);

// insure caret is always visible
area.setShowCaret(Caret.CaretVisibility.ON);

StringBuilder sb = new StringBuilder();
for (int i = 0; i < 50; i++) {
sb.append(i).append("\n");
}
area.replaceText(sb.toString());
area.replaceText(FIFTY_PARS_OF_TEXT);
area.moveTo(0);
area.showParagraphAtTop(0);
}

@Test
public void testMoveCaretAndFollowIt() {
public void caret_bounds_are_present_after_moving_caret_and_following_it() {
assertTrue(area.getCaretBounds().isPresent());

// move caret outside of viewport
Expand All @@ -43,7 +49,7 @@ public void testMoveCaretAndFollowIt() {
}

@Test
public void testMoveCaretWithoutFollowingIt() {
public void caret_bounds_are_absent_after_moving_caret_without_following_it() {
assertTrue(area.getCaretBounds().isPresent());

// move caret outside of viewport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void start(Stage stage) throws Exception {
}

@Test
public void selectionBoundsUnchangedWhenCallGetCharacterBounds() {
public void selection_bounds_are_unchanged_when_call_getCharacterBounds() {
area.selectAll();
Bounds bounds = area.getSelectionBounds().get();

Expand Down

This file was deleted.

Loading