-
Notifications
You must be signed in to change notification settings - Fork 507
8347359: RichTextArea API Tests #1677
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
8347359: RichTextArea API Tests #1677
Conversation
👋 Welcome back angorya! A progress list of the required criteria for merging this PR into |
@andy-goryachev-oracle This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
|
one reviewer is probably fine, but feel free to take a look everyone. |
@andy-goryachev-oracle This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
keep-alive |
@andy-goryachev-oracle This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First batch of comments. This looks like a good start for RichTextArea and CodeArea. I presume you'll handle the rest of the API with other bugs / PRs?
Some of my comments are about expanding the test coverage to handle more cases, and that could be done when you add functional tests.
if (throwable instanceof RuntimeException) { | ||
throw (RuntimeException)throwable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is RuntimeException treated differently than checked Exception and Error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm... This pattern was copied from some other test. We have 32 more instances of this pattern elsewhere.
I suspect it is not avoid declaring a checked exception.
What would you suggest? Forward the throwable
to Thread.currentThread().getThreadGroup().uncaughtException(thread, throwable);
unconditionally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting that other tests do this. When re-throwing an exception you often need to special case checked exceptions (to wrap them so that the caller doesn't need to explicitly declare it), but the UncaughtExceptionHandler can handle both, so I don't know why it was done that way.
You might try just unconditionally forwarding all throwables, but not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out, this is required by junit framework to properly handle the failed tests.
If we pass all the Throwables to the thread group, then a RuntimeException thrown from a @Test
does not mark the unit test as failed, though the stacktrace does appear in stderr
; a thrown Error
will mark the test as failed.
import javafx.beans.property.SimpleObjectProperty; | ||
|
||
/** | ||
* There should be a common place for module-agnostic test utilities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javafx.base might eventually be a good place for this sort of utility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might, or perhaps it could be packaged into a jar so we can run single source files + library via JEP 458 --class-path 'libs/*'
argument?
see "Using pre-compiled classes" section in
https://openjdk.org/jeps/458
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit tests already need to load the JavaFX modules, so I don't see how packaging it in a jar would help. All it would do it add one more thing to put on the path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the single-file manual tests, continuing discussion in #1747
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I didn't get that from the context of this discussion, since we are discussing automated tests in this PR.
I'm not sure there is enough value in sharing utilities between manual tests and our JUnit-based automated tests for us to want to deal with the complexities that it would bring, but we can discuss that separately (not here).
/** | ||
* There should be a common place for module-agnostic test utilities. | ||
*/ | ||
public class TUtil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is intended to be a static utility class, maybe add a private constructor to underscore this?
/** | ||
* Utilities for RichTextArea-based tests. | ||
*/ | ||
public class RTUtil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: add a private constructor
String[] lines = text.split("\n"); | ||
ArrayList<StyledSegment> ss = new ArrayList<>(); | ||
for (int i = 0; i < lines.length; i++) { | ||
if(i > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: space after if
} | ||
|
||
// @Test | ||
// public void insertLineBreak() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out? A comment explaining why would be good. Or if there is a functional bug that prevents it, uncomment it and skip it with @Disabled("JDK-8888888")
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// } | ||
|
||
@Test | ||
public void isRedoable() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you also have functional tests for undo/redo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, undo()
and redo()
I tried to exercise every public method to some extent.
} | ||
|
||
@Test | ||
public void modelChangeClearsSelection() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the actual data is sorted in the model, it might also be good to test that a model change clears all of the text that you have previously appended (in another test method).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the actual data is sorted
Typo, I meant "stored"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each test starts with a freshly created model, but it's a good idea to add a check for the content.
} | ||
|
||
@Test | ||
public void redo() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test of the undo / redo stack would be helpful (this tests a single undo/redo value, so is a good first step, but doesn't test its "stack" nature).
assertTrue(control.getModel() == null); | ||
|
||
control = new CodeArea(null); | ||
control.setModel(new CodeTextModel() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Check that the model you set can be read back.
Thank you, Kevin, good suggestions.
Correct - the idea is to follow up with headful behavioral test(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'll reapprove if you make further changes.
@Disabled("JDK-8355415") | ||
// TODO combine with copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I might switch these two lines to keep all the annotations together.
/integrate |
Going to push as commit 1b2f022d0c08d556d0decdf71d6e0c9d13dbe6f8.
Your commit was automatically rebased without conflicts. |
@andy-goryachev-oracle Pushed as commit 1b2f022. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Additional RichTextArea API tests.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1677/head:pull/1677
$ git checkout pull/1677
Update a local copy of the PR:
$ git checkout pull/1677
$ git pull https://git.openjdk.org/jfx.git pull/1677/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1677
View PR using the GUI difftool:
$ git pr show -t 1677
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1677.diff
Using Webrev
Link to Webrev Comment