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

Don't assume window is MockWindow when dealing with pointer position #232

Merged
merged 4 commits into from
Jun 14, 2016

Conversation

corranwebster
Copy link
Contributor

Fixes #211.

@@ -256,7 +256,9 @@ def mouse_move(self, interactor, x, y, window=None,
alt_down=alt_down,
control_down=control_down,
shift_down=shift_down)
window.get_pointer_position.return_value = (x, y)
if isinstance(window, _MockWindow):
Copy link
Member

@itziakos itziakos May 26, 2016

Choose a reason for hiding this comment

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

If one passes a real window how does the mouse_move actually happen? When a real window get_pointer_position is called it will not have the right (x, y) value. In short the call will not fail but the desired affect will probably not happen either.

Copy link
Member

@itziakos itziakos May 26, 2016

Choose a reason for hiding this comment

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

Please also note that it is get_pointer_position that should be a mock not the window. Thus the check needs to be on get_pointer_position.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The get_pointer_position function isn't used by most consumers of the mouse_move event - in most cases the event position is sufficient. But you are right, we should check to see if the method is mocked, not the window.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And needless to say, if you pass a real window in a test, you'll need to mock the get_pointer_position yourself if you need that handled.

Copy link
Member

@itziakos itziakos May 26, 2016

Choose a reason for hiding this comment

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

The get_pointer_position function isn't used by most consumers of the mouse_move

This is True but it is not always clear when this is the case (e.g. using a subclass of a Tool). So the user will end up with a very weird error down the line.

And needless to say, if you pass a real window in a test, you'll need to mock the get_pointer_position yourself if you need that handled.

Ideally we should be able to fake the mouse move in any Window (e.g maybe sent the mouse move event to the Qt widget) . However, for the moment, I would suggest to raise a warning if the get_pointer_position is not mocked and update the docstring to mention that for the mouse_move to properly fake the operation get_pointer_position needs to be a mock instance

Copy link
Member

Choose a reason for hiding this comment

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

It would also be nice to create a test using a real Window so that users can see how it is done.

Copy link
Member

Choose a reason for hiding this comment

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

opened feature request #233 for supporting a more native way for faking mouse moves in real windows

@codecov-io
Copy link

codecov-io commented May 26, 2016

Current coverage is 51.98%

Merging #232 into master will increase coverage by 0.07%

@@             master       #232   diff @@
==========================================
  Files           126        126          
  Lines         13184      13185     +1   
  Methods           0          0          
  Messages          0          0          
  Branches       1943       1944     +1   
==========================================
+ Hits           6844       6854    +10   
+ Misses         5897       5887    -10   
- Partials        443        444     +1   

Powered by Codecov. Last updated by e685f76...f8fedce

@itziakos
Copy link
Member

itziakos commented May 26, 2016

👍 as soon as we have a test

@corranwebster
Copy link
Contributor Author

@itziakos We have a test :)

@itziakos
Copy link
Member

👍

@corranwebster corranwebster merged commit b8eea9c into master Jun 14, 2016
@corranwebster corranwebster deleted the fix/non-mock-pointer-position branch June 14, 2016 13:25
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.

3 participants