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

Tie-break closest point in rendering order and allow overriding more methods in DataPointTooltip #457

Merged
merged 4 commits into from
Jul 13, 2021

Conversation

domenicquirl
Copy link
Contributor

Closes #454.

I got a tooltip-related test failure from testThatTooltipIsShown on check-out, which persists after my small changes:

Trace
--- Exception in Async Thread ---
java.lang.reflect.InvocationTargetException: null
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
        java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.base/java.lang.reflect.Method.invoke(Method.java:564)
        org.testfx.service.adapter.impl.PublicGlassRobotAdapter.lambda$getScreenCapture$8(PublicGlassRobotAdapter.java:120)
        java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
        java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
        com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
        com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
        com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
        java.base/java.lang.Thread.run(Thread.java:832)
java.lang.UnsupportedOperationException: null
        java.base/java.nio.IntBuffer.array(IntBuffer.java:1336)
        com.sun.glass.ui.monocle.MonocleRobot.getScreenCapture(MonocleRobot.java:223)
        com.sun.glass.ui.GlassRobot.getScreenCapture(GlassRobot.java:202)
        javafx.scene.robot.Robot.getScreenCapture(Robot.java:313)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
        java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.base/java.lang.reflect.Method.invoke(Method.java:564)
        org.testfx.service.adapter.impl.PublicGlassRobotAdapter.lambda$getScreenCapture$8(PublicGlassRobotAdapter.java:120)
        java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
        java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
        com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
        com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
        com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
        java.base/java.lang.Thread.run(Thread.java:832)
--- Trace of caller of unhandled exception in Async Thread ---
        java.base/java.lang.Thread.getStackTrace(Thread.java:1598)
        org.testfx.util.WaitForAsyncUtils$ASyncFXCallable.<init>(WaitForAsyncUtils.java:649)
        org.testfx.util.WaitForAsyncUtils.asyncFx(WaitForAsyncUtils.java:257)
        org.testfx.util.WaitForAsyncUtils.waitForAsyncFx(WaitForAsyncUtils.java:442)
        org.testfx.service.adapter.impl.PublicGlassRobotAdapter.getScreenCapture(PublicGlassRobotAdapter.java:118)
        org.testfx.service.adapter.impl.GlassRobotAdapter.getCaptureRegion(GlassRobotAdapter.java:72)
        org.testfx.robot.impl.BaseRobotImpl.captureRegion(BaseRobotImpl.java:107)
        org.testfx.service.support.impl.CaptureSupportImpl.captureRegion(CaptureSupportImpl.java:61)
        org.testfx.util.DebugUtils.lambda$captureBounds$11(DebugUtils.java:339)
        org.testfx.util.DebugUtils.lambda$saveTestImage$14(DebugUtils.java:552)
        java.base/java.util.function.Function.lambda$compose$0(Function.java:68)
        java.base/java.util.function.Function.lambda$compose$0(Function.java:68)
        java.base/java.util.function.Function.lambda$compose$0(Function.java:68)
        java.base/java.util.function.Function.lambda$compose$0(Function.java:68)
        org.testfx.api.FxAssert.verifyThatImpl(FxAssert.java:162)
        org.testfx.api.FxAssert.verifyThat(FxAssert.java:129)
        de.gsi.chart.plugins.DataPointTooltipTest.testThatTooltipIsShown(DataPointTooltipTest.java:90)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
        java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        java.base/java.lang.reflect.Method.invoke(Method.java:564)
        org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
        org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
        org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
        org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
        org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
        org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
        org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
        org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
        org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
        org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
        org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
        org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
        org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
        org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
        org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
        org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
        org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
        org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
        org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
        org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
        org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
        java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
        org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
        org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
        org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
        java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
        org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
        org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
        org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
        org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
        org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
        org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
        org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
        org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
        org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
        org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
        org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
        org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
        org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
        org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
        org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:188)
        org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154)
        org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128)
        org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
        org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
        org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
        org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)

To be honest, I don't have much of an idea what's happening there. Apart from the error, do you want explicit testing for the now-fixed tie-breaking behaviour or do you prefer to leave this open for change in the future? In the former case, I think it is sufficient to duplicate one of the data sets in the existing test exactly and test that the current tooltips are unchanged regardless, though due to the above error I couldn't actually run that test.

@domenicquirl
Copy link
Contributor Author

Hm, apparently some of the CI does not run automatically, otherwise I would have been interested to see whether the test fails there too. Following my thoughts in #454, the Codacy suggestion is not something I'd like to action 🤔

@codecov
Copy link

codecov bot commented Jul 13, 2021

Codecov Report

Merging #457 (c2e2320) into master (e992c27) will increase coverage by 0.56%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #457      +/-   ##
============================================
+ Coverage     52.91%   53.48%   +0.56%     
- Complexity     7268     7469     +201     
============================================
  Files           383      389       +6     
  Lines         40349    40925     +576     
  Branches       6512     6598      +86     
============================================
+ Hits          21349    21887     +538     
- Misses        17461    17464       +3     
- Partials       1539     1574      +35     
Impacted Files Coverage Δ
...in/java/de/gsi/chart/plugins/DataPointTooltip.java 72.22% <0.00%> (ø)
...ain/java/de/gsi/chart/plugins/YValueIndicator.java 68.29% <0.00%> (-3.51%) ⬇️
...ain/java/de/gsi/chart/plugins/XValueIndicator.java 66.66% <0.00%> (-3.34%) ⬇️
...derer/spi/financial/AbstractFinancialRenderer.java 97.36% <0.00%> (-1.32%) ⬇️
...ava/de/gsi/chart/plugins/YWatchValueIndicator.java 86.27% <0.00%> (-1.05%) ⬇️
...src/main/java/de/gsi/math/MultiDimDataSetMath.java 94.07% <0.00%> (-0.55%) ⬇️
.../main/java/de/gsi/chart/viewer/DataViewWindow.java 79.85% <0.00%> (-0.10%) ⬇️
.../main/java/de/gsi/chart/axes/spi/AbstractAxis.java 76.19% <0.00%> (-0.08%) ⬇️
...ava/de/gsi/dataset/utils/trees/IndexedTreeMap.java 10.30% <0.00%> (-0.03%) ⬇️
chartfx-math/src/main/java/de/gsi/math/Spline.java 0.00% <0.00%> (ø)
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e992c27...c2e2320. Read the comment docs.

@wirew0rm
Copy link
Member

Thanks for the PR, looks very good, that case just wasn't considered when the code was written. I don't see how this change could have negative impacts generally.

Regarding the test error, we do not have much experience with running TestFX on Windows. You could try to run them from your IDE in non-headless mode to see if it works when using the native toolkit instead of of the monocle software renderer. The error doesn't really look like it is related to the changes you added. Locally the tests pass for me and i also started the CI run. The failure there is only due to CI configuration for external PRs (it is missing a secret for submitting the coverage report).

Making the tests also assert that the order is correct would be nice, but if you cannot get the testFx tests running locally, i guess we could add that ourselves, your suggested approach seems reasonable.

Regarding the codacy suggestion, I would say that inequality operations on floats are generally not a problem. From a correctness pov both statements are equivalent and I would tend to agree with Codacy on readability.

@domenicquirl
Copy link
Contributor Author

Swapped the comparison and added the test anyways - if CI can run everything and does not have the issue I have on my machine, then it should be able to validate that the behaviour is correct (I've not been able to get this working locally).

Copy link
Member

@wirew0rm wirew0rm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, CI failure is only due to the missing coverage secret.

@wirew0rm wirew0rm merged commit aab1ffa into fair-acc:master Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataPointTooltip tie-breaking does not agree with ErrorDataSetRenderer rendering order
2 participants