-
Notifications
You must be signed in to change notification settings - Fork 99
Ui tester api updates4 - Implement locating textbox in RangeEditor and performing KeySequence #1171
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
Changes from 55 commits
ba2378f
a6d28ca
28d5094
684be1c
9973d38
547b52b
7fecb2a
a6ede42
69d5cd5
b97a923
39c034e
57fcdda
dcdfdf8
6266a83
578b280
fe4c597
df81380
9803375
9077c08
400d9d3
33f750f
51e5b45
3149374
c43c88a
e444628
d4d8012
848d513
9753816
db80b28
bc0e7f1
eab72a8
8a59b57
77f5903
12e9d8f
8428778
fb3a535
8b0f2eb
55e0bfa
69b5618
5aeef94
d8baa03
0284280
e1fdef6
38e6ff7
1189ddc
7ba111e
f4f2be2
40ad90a
705a820
405a030
e2b082a
a96fb0d
7577c81
5e75d0a
1a0a7a9
a287c52
7c595ca
7847933
991be83
f08e54f
ee863e5
73a97d4
b806e3a
78a7bf0
c03ef46
f8b4b9c
4f723e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Copyright (c) 2005-2020, Enthought, Inc. | ||
| # All rights reserved. | ||
| # | ||
| # This software is provided without warranty under the terms of the BSD | ||
| # license included in LICENSE.txt and may be redistributed only | ||
| # under the conditions described in the aforementioned license. The license | ||
| # is also available online at http://www.enthought.com/licenses/BSD.txt | ||
| # | ||
| # Thanks for using Enthought open source! | ||
| # | ||
|
|
||
| from traitsui.qt4.range_editor import ( | ||
| LargeRangeSliderEditor, | ||
| LogRangeSliderEditor, | ||
| RangeTextEditor, | ||
| SimpleSliderEditor, | ||
|
Comment on lines
+13
to
+16
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eventually we will want to add SimpleSpinEditor, but this can be done in a later PR. |
||
| SimpleSpinEditor, | ||
| ) | ||
|
|
||
| from traitsui.testing.tester import locator | ||
| from traitsui.testing.tester.qt4.located_object_handlers import LocatedTextbox | ||
|
|
||
|
|
||
| class RangeEditorTextbox(LocatedTextbox): | ||
| pass | ||
|
|
||
|
|
||
| def resolve_location_simple_slider(wrapper, location): | ||
| if location == locator.WidgetType.textbox: | ||
| return RangeEditorTextbox(textbox=wrapper.target.control.text) | ||
|
|
||
| raise NotImplementedError() | ||
aaronayres35 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def resolve_location_range_text(wrapper, location): | ||
| if location == locator.WidgetType.textbox: | ||
| return RangeEditorTextbox(textbox=wrapper.target.control) | ||
|
|
||
| raise NotImplementedError() | ||
aaronayres35 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def register(registry): | ||
|
|
||
| targets = [SimpleSliderEditor, | ||
| LogRangeSliderEditor, | ||
| LargeRangeSliderEditor] | ||
kitchoi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for target_class in targets: | ||
| registry.register_solver( | ||
| target_class=target_class, | ||
| locator_class=locator.WidgetType, | ||
| solver=resolve_location_simple_slider, | ||
| ) | ||
|
|
||
| registry.register_solver( | ||
| target_class=RangeTextEditor, | ||
| locator_class=locator.WidgetType, | ||
| solver=resolve_location_range_text, | ||
| ) | ||
| RangeEditorTextbox.register(registry) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Copyright (c) 2005-2020, Enthought, Inc. | ||
| # All rights reserved. | ||
| # | ||
| # This software is provided without warranty under the terms of the BSD | ||
| # license included in LICENSE.txt and may be redistributed only | ||
| # under the conditions described in the aforementioned license. The license | ||
| # is also available online at http://www.enthought.com/licenses/BSD.txt | ||
| # | ||
| # Thanks for using Enthought open source! | ||
| # | ||
|
|
||
aaronayres35 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| from traitsui.testing.tester import command, locator, query | ||
| from traitsui.testing.tester.qt4 import helpers | ||
|
|
||
| class LocatedTextbox: | ||
| def __init__(self, textbox): | ||
| self.textbox = textbox | ||
|
|
||
| @classmethod | ||
| def register(cls, registry): | ||
| handlers = [ | ||
| (command.KeySequence, (lambda wrapper, interaction: helpers.key_sequence_qwidget( | ||
| wrapper.target.textbox, interaction, wrapper.delay))), | ||
| (command.KeyClick, (lambda wrapper, interaction: helpers.key_click_qwidget( | ||
| wrapper.target.textbox, interaction, wrapper.delay))), | ||
| (command.MouseClick, (lambda wrapper, _: helpers.mouse_click_qwidget( | ||
| wrapper.target.textbox, wrapper.delay))), | ||
| (query.DisplayedText, lambda wrapper, _: wrapper.target.textbox.displayText()), | ||
| ] | ||
| for interaction_class, handler in handlers: | ||
| registry.register_handler( | ||
| target_class=cls, | ||
| interaction_class=interaction_class, | ||
| handler=handler, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Copyright (c) 2005-2020, Enthought, Inc. | ||
| # All rights reserved. | ||
| # | ||
| # This software is provided without warranty under the terms of the BSD | ||
| # license included in LICENSE.txt and may be redistributed only | ||
| # under the conditions described in the aforementioned license. The license | ||
| # is also available online at http://www.enthought.com/licenses/BSD.txt | ||
| # | ||
| # Thanks for using Enthought open source! | ||
| # | ||
| from traitsui.wx.range_editor import ( | ||
| LargeRangeSliderEditor, | ||
| LogRangeSliderEditor, | ||
| RangeTextEditor, | ||
| SimpleSliderEditor, | ||
| SimpleSpinEditor, | ||
| ) | ||
|
|
||
| from traitsui.testing.tester import locator | ||
| from traitsui.testing.tester.wx.located_object_handlers import LocatedTextbox | ||
|
|
||
| class RangeEditorTextbox(LocatedTextbox): | ||
| pass | ||
|
|
||
| def resolve_location_simple_slider(wrapper, location): | ||
| if location == locator.WidgetType.textbox: | ||
| return RangeEditorTextbox(textbox=wrapper.target.control.text) | ||
|
|
||
| raise NotImplementedError() | ||
|
|
||
| def resolve_location_range_text(wrapper, location): | ||
| if location == locator.WidgetType.textbox: | ||
| return RangeEditorTextbox(textbox=wrapper.target.control) | ||
|
|
||
| raise NotImplementedError() | ||
|
|
||
|
|
||
| def register(registry): | ||
|
|
||
| targets = [SimpleSliderEditor, | ||
| LogRangeSliderEditor, | ||
| LargeRangeSliderEditor] | ||
| for target_class in targets: | ||
| registry.register_solver( | ||
| target_class=target_class, | ||
| locator_class=locator.WidgetType, | ||
| solver=resolve_location_simple_slider, | ||
| ) | ||
| registry.register_solver( | ||
| target_class=RangeTextEditor, | ||
| locator_class=locator.WidgetType, | ||
| solver=resolve_location_simple_slider, | ||
| ) | ||
aaronayres35 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| RangeEditorTextbox.register(registry) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Copyright (c) 2005-2020, Enthought, Inc. | ||
| # All rights reserved. | ||
| # | ||
| # This software is provided without warranty under the terms of the BSD | ||
| # license included in LICENSE.txt and may be redistributed only | ||
| # under the conditions described in the aforementioned license. The license | ||
| # is also available online at http://www.enthought.com/licenses/BSD.txt | ||
| # | ||
| # Thanks for using Enthought open source! | ||
| # | ||
|
|
||
| from traitsui.testing.tester import command, locator, query | ||
| from traitsui.testing.tester.wx import helpers | ||
|
|
||
| class LocatedTextbox: | ||
| def __init__(self, textbox): | ||
| self.textbox = textbox | ||
|
|
||
| @classmethod | ||
| def register(cls, registry): | ||
| handlers = [ | ||
| (command.KeySequence, (lambda wrapper, interaction: helpers.key_sequence_text_ctrl( | ||
| wrapper.target.textbox, interaction, wrapper.delay))), | ||
| (command.KeyClick, (lambda wrapper, interaction: helpers.key_click_text_ctrl( | ||
| wrapper.target.textbox, interaction, wrapper.delay))), | ||
| (command.MouseClick, (lambda wrapper, _: helpers.mouse_click_object( | ||
| wrapper.target.textbox, wrapper.delay))), | ||
| (query.DisplayedText, lambda wrapper, _: wrapper.target.textbox.GetValue()), | ||
| ] | ||
| for interaction_class, handler in handlers: | ||
| registry.register_handler( | ||
| target_class=cls, | ||
| interaction_class=interaction_class, | ||
| handler=handler, | ||
| ) |
Uh oh!
There was an error while loading. Please reload this page.