-
Notifications
You must be signed in to change notification settings - Fork 146
Conversation
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.
This looks like the right set of tests. I get several failures, though (I only tested Linux).
test.robot.javafx.scene.RobotTest > testKeyRelease FAILED
org.junit.ComparisonFailure: letter 'a' should be RELEASED by Robot expected:<[a]> but was:<[]>
at org.junit.Assert.assertEquals(Assert.java:123)
at test.robot.javafx.scene.RobotTest.testKeyboard(RobotTest.java:190)
at test.robot.javafx.scene.RobotTest.testKeyRelease(RobotTest.java:136)
test.robot.javafx.scene.RobotTest > testMouseReleasePrimary FAILED
java.lang.AssertionError: Timeout while waiting for button.onMouseRELEASED().
at org.junit.Assert.fail(Assert.java:91)
at test.robot.javafx.scene.RobotTest.waitForLatch(RobotTest.java:728)
at test.robot.javafx.scene.RobotTest.testMouseAction(RobotTest.java:417)
at test.robot.javafx.scene.RobotTest.testMouseReleasePrimary(RobotTest.java:311)
test.robot.javafx.scene.RobotTest > testMouseReleaseSecondary FAILED
java.lang.AssertionError: Timeout while waiting for button.onMouseRELEASED().
at org.junit.Assert.fail(Assert.java:91)
at test.robot.javafx.scene.RobotTest.waitForLatch(RobotTest.java:728)
at test.robot.javafx.scene.RobotTest.testMouseAction(RobotTest.java:417)
at test.robot.javafx.scene.RobotTest.testMouseReleaseSecondary(RobotTest.java:316)
test.robot.javafx.scene.RobotTest > testMouseRelaseMiddle FAILED
java.lang.AssertionError: Timeout while waiting for button.onMouseRELEASED().
at org.junit.Assert.fail(Assert.java:91)
at test.robot.javafx.scene.RobotTest.waitForLatch(RobotTest.java:728)
at test.robot.javafx.scene.RobotTest.testMouseAction(RobotTest.java:417)
at test.robot.javafx.scene.RobotTest.testMouseRelaseMiddle(RobotTest.java:321)
test.robot.javafx.scene.RobotTest > testMouseWheelPositiveAmount FAILED
org.junit.ComparisonFailure: mouse wheel should be scrolled 5 vertical units by Robot expected:<Scrolled [5]> but was:<Scrolled [-40.0]>
at org.junit.Assert.assertEquals(Assert.java:123)
at test.robot.javafx.scene.RobotTest.testMouseWheel(RobotTest.java:525)
at test.robot.javafx.scene.RobotTest.testMouseWheelPositiveAmount(RobotTest.java:490)
test.robot.javafx.scene.RobotTest > testMouseWheelNegativeAmount FAILED
org.junit.ComparisonFailure: mouse wheel should be scrolled -5 vertical units by Robot expected:<Scrolled [-5]> but was:<Scrolled [40.0]>
at org.junit.Assert.assertEquals(Assert.java:123)
at test.robot.javafx.scene.RobotTest.testMouseWheel(RobotTest.java:525)
at test.robot.javafx.scene.RobotTest.testMouseWheelNegativeAmount(RobotTest.java:495)
I think the failures (besides the mouse scroll amount which seems to be hardcoded to a value of (-)40 on Linux) are happening because you can't release "in a vacuum" without a preceding press. I will remove the keyboard and mouse tests that only release, but will keep the press only and press and release tests. |
The mouse scroll wheel failure is kind of interesting. Basically the GtkRobot sends multiple fake mouse buttons presses (4 for scroll up, 5 for scroll down), one for each int of the Edit: Actually I may be able to use |
For some reason |
I finally was able to test and fix the new tests on macOS. I have now confirmed that the new tests pass locally for me on all 3 operating systems. I am not really happy with the approach I took in order to get a unified scroll amount between platforms but wasn't sure of an alternative approach. |
The new drag tests pass locally for me on Windows but seem to fail in a Linux virtual machine but I can't tell if that's because it's really slow or because there is an actual problem. Do you have a local Linux install you could test them on? |
I can test them later this morning when I get into the office. |
The tests all PASS on my Linux system (a physical machine running Ubuntu 18.04). I'll run on Windows and Mac and then finish my review. I don't have a good answer to your question about the platform differences regarding the scrolling multiplier (-1 on Mac versus 40 on Windows and Linux). The negative versus positive might be related to the "natural scrolling order" on Mac, which is intentionally backwards by default from the other platforms. However, a difference of 40x in magnitude points to something wrong in the implementation. |
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 ran on 4 different systems: Linux, Mac (Retina display), Windows 10, Windows 7. With 125% scaling on Windows (which is what I run by default), the scroll tests fail with a timeout, but they pass if I set the scale to 100%. I didn't look at the code to see what the problem might be, but if there isn't an an obvious solution, one possible fix is to either skip those tests on Windows if the scale is not 1 or else force it to 1.
I also left a comment in the code about the platform-specific scroll scale.
CountDownLatch onScrollLatch = new CountDownLatch(1); | ||
CountDownLatch setSceneLatch = new CountDownLatch(1); | ||
Button button = new Button("Scroll me"); | ||
InvalidationListener invalidationListener = observable -> setSceneLatch.countDown(); | ||
int[] totalScroll = new int[]{0}; | ||
long[] firstScrollMillis = new long[]{0}; | ||
int scrollMultiplier = System.getProperty("os.name").toLowerCase().startsWith("mac") ? -1 : 40; |
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.
Can you add a comment here? This suggests that there might be an issue with scrolling in the Mac robot implementation. We might want to file a follow-up issue to investigate.
I see why it is failing on non 1.0 scales, I will add a commit as soon as I confirm it's fixed (need to multiply |
Added a commit which addresses both issues. |
@@ -474,10 +474,12 @@ private static void testMouseWheel(int amount) { | |||
InvalidationListener invalidationListener = observable -> setSceneLatch.countDown(); | |||
int[] totalScroll = new int[]{0}; | |||
long[] firstScrollMillis = new long[]{0}; | |||
// The scroll wheel amount is multiplied by 40 on Linux and Windows, but not on macOS. The | |||
// directions are also reversed. |
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 filed JDK-8214580 to investigate this. Can you add to this comment that the difference in behavior is unexpected and might be a bug? Something like:
// This difference in behavior is unexplained and might be a bug. See JDK-8214580.
int scrollMultiplier = System.getProperty("os.name").toLowerCase().startsWith("mac") ? -1 : 40; | ||
Util.runAndWait(() -> { | ||
button.setOnScroll(event -> { | ||
totalScroll[0] += event.getDeltaY(); | ||
totalScroll[0] += event.getDeltaY() * Screen.getPrimary().getOutputScaleY(); |
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.
Looks good. I'll test it on Monday.
int scrollMultiplier = System.getProperty("os.name").toLowerCase().startsWith("mac") ? -1 : 40; | ||
Util.runAndWait(() -> { | ||
button.setOnScroll(event -> { | ||
totalScroll[0] += event.getDeltaY(); | ||
totalScroll[0] += event.getDeltaY() * Screen.getPrimary().getOutputScaleY(); |
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.
Multiplying by the output scale works correctly on Windows. It doesn't work on a Mac with a retina display, though. The test now fails for me. This suggests another platform difference between how Robot::mouseWheel works on Mac versus the other platforms.
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 think we should skip the test on Mac for now and un-skip it as part of JDK-8214580?
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 was starting to think the same thing. That would be fine with me. Please update JDK-8214580 with the additional information.
And then you can add an assumeTrue(!isMac)
at the top of this test with the JBS bug ID in the comment.
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.
Okay, I added a new commit and updated the bug.
That looks good. One quick thought: for consistency, the following could also use
I'll do a quick final test on Mac and Windows and then I think we can get this in. |
Btw, this would have been easier for me to review without the squash / force-push |
Ah, sorry about that. Will keep that in mind going forward. |
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.
Looks good. I'll merge it in shortly.
(Partially? at least a step in the right direction...) resolves robot API follow-up issue JDK-8207369.