Skip to content

Commit

Permalink
Updated recording file and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
karandeepSJ committed Jun 16, 2018
1 parent 3ec7401 commit 25c2e24
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
Binary file modified dipy/data/files/test_ui_listbox_2d.log.gz
Binary file not shown.
Binary file modified dipy/data/files/test_ui_listbox_2d.pkl
Binary file not shown.
47 changes: 43 additions & 4 deletions dipy/viz/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,31 @@ def test_ui_listbox_2d(interactive=False):

# Values that will be displayed by the listbox.
values = list(range(1, 42 + 1))

if interactive:
listbox = ui.ListBox2D(values=values,
size=(500, 500),
multiselection=True,
reverse_scrolling=False)
listbox.center = (300, 300)

show_manager = window.ShowManager(size=(600, 600),
title="DIPY ListBox")
show_manager.ren.add(listbox)
show_manager.start()

# Recorded events:
# 1. Click on 1
# 2. Ctrl + click on 2,
# 3. Ctrl + click on 2.
# 4. Use scroll bar to scroll to the bottom.
# 5. Click on 42.
# 6. Use scroll bar to scroll to the top.
# 7. Click on 1
# 8. Use mouse wheel to scroll down.
# 9. Shift + click on 42.
# 10. Use mouse wheel to scroll back up.

listbox = ui.ListBox2D(values=values,
size=(500, 500),
multiselection=True,
Expand All @@ -565,13 +590,27 @@ def _on_change():
event_counter = EventCounter()
event_counter.monitor(listbox)

# Create a show manager and record/play events.
show_manager = window.ShowManager(size=(600, 600),
title="DIPY ListBox")
show_manager.ren.add(listbox)

if interactive:
show_manager.start()
show_manager.play_events_from_file(recording_filename)
expected = EventCounter.load(expected_events_counts_filename)
event_counter.check_counts(expected)

# Check if the right values were selected.
expected = [[1], [1, 2], [1], [42], [1], values]
assert len(selected_values) == len(expected)
assert_arrays_equal(selected_values, expected)

# Test without multiselection enabled.
listbox.multiselection = False
del selected_values[:] # Clear the list.
show_manager.play_events_from_file(recording_filename)

# Check if the right values were selected.
expected = [[1], [2], [2], [42], [1], [42]]
assert len(selected_values) == len(expected)
assert_arrays_equal(selected_values, expected)


@npt.dec.skipif(not have_vtk or skip_it)
Expand Down

0 comments on commit 25c2e24

Please sign in to comment.