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

Add missing position info in ScrollEvent #2204

Merged
merged 2 commits into from Apr 28, 2021

Conversation

andydotxyz
Copy link
Member

Fixes #2199

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

@fpabl0
Copy link
Member

fpabl0 commented Apr 27, 2021

I am not sure why, but I cannot make the tests pass locally, I always get:

=== RUN   TestWindow_Scrolled
    .../fyne/internal/driver/glfw/window_test.go:547:
        	Error Trace:	window_test.go:547
        	Error:      	Expected value not to be nil.
        	Test:       	TestWindow_Scrolled
        	Messages:   	scroll event

internal/driver/glfw/window_test.go Outdated Show resolved Hide resolved
@andydotxyz
Copy link
Member Author

I am not sure why, but I cannot make the tests pass locally, I always get:

=== RUN   TestWindow_Scrolled
    .../fyne/internal/driver/glfw/window_test.go:547:
        	Error Trace:	window_test.go:547
        	Error:      	Expected value not to be nil.
        	Test:       	TestWindow_Scrolled
        	Messages:   	scroll event

Strange. Does it work if you apply this change?

--- a/internal/driver/glfw/window_test.go
+++ b/internal/driver/glfw/window_test.go
@@ -537,14 +537,14 @@ func TestWindow_HoverableOnDragging(t *testing.T) {
 func TestWindow_Scrolled(t *testing.T) {
        w := createWindow("Test").(*window)
        o := &scrollable{Rectangle: canvas.NewRectangle(color.White)}
-       o.SetMinSize(fyne.NewSize(100, 100))
        w.SetContent(o)
+       w.Resize(fyne.NewSize(100, 100))

@andydotxyz andydotxyz requested a review from fpabl0 April 28, 2021 14:06
@fpabl0
Copy link
Member

fpabl0 commented Apr 28, 2021

@andydotxyz

However it works just fine because ScrollEvent is a PointEvent as well

Hmm, not sure, as far as I know, that is not possible in any go version. When you assert a type by pointer, it should be exactly that type. Partial asserts is only possible when you are asserting behaviors (using interfaces) not values.

That test would fail in go playground too:
https://play.golang.org/p/-oldmGnFedA

@fpabl0
Copy link
Member

fpabl0 commented Apr 28, 2021

Strange. Does it work if you apply this change?

The problem was only the type assertion, using ScrollEvent instead of PointEvent is enough :)

Copy link
Member

@fpabl0 fpabl0 left a comment

Choose a reason for hiding this comment

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

Tests work now :). However I am still worried about the fact that it works before, it should not.

@andydotxyz andydotxyz merged commit 0e5dd0c into fyne-io:release/v2.0.x Apr 28, 2021
@andydotxyz andydotxyz deleted the fix/2199 branch April 28, 2021 17:54
@andydotxyz
Copy link
Member Author

However I am still worried about the fact that it works before, it should not.

Yes, I agree. It seems that test file is not running on CI - so the logical solution is that my git hooks did not fire AND that I did not run the test on its final version. Which is sadly possible.

Glad it's all running now :)

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.

None yet

2 participants