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 test to check basic interactions with layer controls widgets #5757

Merged
merged 17 commits into from
May 15, 2023

Conversation

dalthviz
Copy link
Member

@dalthviz dalthviz commented Apr 21, 2023

Fixes/Closes

Initial effort towards improving GUI testing automation: https://napari.zulipchat.com/#narrow/stream/212875-general/topic/GUI.20testing

Description

This is an initial attempt to add more tests for code related with GUI elements. The new parametrized test proposed creates an instance of a layer (Image, Labels, Points, Shapes, Surface, Tracks or Vectors) and then operates over the layer control widgets simulating user usage (QCombox, QSpinBox and QSlider based widgets value changes, clicking QCheckbox and buttons widgets, QColorSwatch widgets color changes typing colors, etc)

This also fixes a little issue that I noticed while working on the test. The error is related with the value of the color mode combobox for a Vectors layer controls. The combobox was not showing the correct value after a fallback to a valid value is done (when a ValueError exception is raised, the color mode value of the layer is changed to the previous one, but the combobox value was missing being updated too):

  • Before:

vectors_before

  • After:

vectors_after

Besides that, the test structure also has some logic to skip some tracebacks from issues which are still open/were discovered while writing the test like #5798 and #4864

References

Type of change

  • Add more tests

How has this been tested?

  • all tests pass with my change
  • I check if my changes works with both PySide and PyQt backends
    as there are small differences between the two Qt bindings.

Final checklist:

  • My PR is the minimum possible work for the desired functionality
  • I have commented my code, particularly in hard-to-understand areas

@dalthviz dalthviz added the tests Something related to our tests label Apr 21, 2023
@dalthviz dalthviz self-assigned this Apr 21, 2023
@github-actions github-actions bot added the qt Relates to qt label Apr 21, 2023
@dalthviz dalthviz added the maintenance PR with maintance changes, label Apr 21, 2023
Copy link
Contributor

@alisterburt alisterburt left a comment

Choose a reason for hiding this comment

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

Great stuff @dalthviz - thank you

Would love to see this in but the test failures on pyside look real
https://github.com/napari/napari/actions/runs/4768301656/jobs/8477468793?pr=5757

Any ideas how we could get around those?

@dalthviz
Copy link
Member Author

Hi @alisterburt, thank you for giving this a check! I think the problem comes from PySide2/6 not having the findChildren signature that supports passing a tuple of types (which seems like is only available for PyQt 5/6 bindings). Will push a fix for that 👍

@codecov
Copy link

codecov bot commented Apr 24, 2023

Codecov Report

Merging #5757 (32c078c) into main (d91f4ee) will increase coverage by 0.14%.
The diff coverage is 78.01%.

@@            Coverage Diff             @@
##             main    #5757      +/-   ##
==========================================
+ Coverage   89.79%   89.93%   +0.14%     
==========================================
  Files         614      614              
  Lines       52196    52327     +131     
==========================================
+ Hits        46870    47062     +192     
+ Misses       5326     5265      -61     
Impacted Files Coverage Δ
napari/_qt/layer_controls/qt_vectors_controls.py 80.62% <0.00%> (+7.96%) ⬆️
...qt/layer_controls/_tests/test_qt_layer_controls.py 87.34% <78.57%> (-12.66%) ⬇️

... and 19 files with indirect coverage changes

@dalthviz dalthviz marked this pull request as ready for review April 24, 2023 17:38
@dalthviz dalthviz marked this pull request as draft April 25, 2023 15:34
@dalthviz dalthviz marked this pull request as ready for review April 25, 2023 17:03
@dalthviz dalthviz marked this pull request as draft April 27, 2023 19:26
@kephale
Copy link
Contributor

kephale commented May 2, 2023

Looks great!

@kne42 any thoughts on this one? In particular, are there some other parts of the GUI you were thinking needed more automated testing?

@dalthviz dalthviz marked this pull request as ready for review May 2, 2023 18:45
Comment on lines +215 to +221
expected_errors = [
"MemoryError: Unable to allocate", # See https://github.com/napari/napari/issues/5798
"ValueError: array is too big; `arr.size * arr.dtype.itemsize` is larger than the maximum possible size.", # See https://github.com/napari/napari/issues/5798
"ValueError: Maximum allowed dimension exceeded", # See https://github.com/napari/napari/issues/5798
"IndexError: index ", # See https://github.com/napari/napari/issues/4864
"RuntimeWarning: overflow encountered", # See https://github.com/napari/napari/issues/4864
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make a note in each of these issues that any PR to close them should also remove these lines from this test? (You might have to do it after this PR is merged, in order to link to the line(s) directly)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the feedback! Will do 👍

@GenevieveBuckley GenevieveBuckley merged commit 39b42e6 into napari:main May 15, 2023
32 checks passed
@GenevieveBuckley
Copy link
Contributor

Nice work! Thank you @dalthviz 🎉

If you can follow up on this suggestion that would be fantastic.

@Czaki Czaki mentioned this pull request Jun 7, 2023
@Czaki Czaki added this to the 0.5.0 milestone Jun 16, 2023
@Czaki Czaki added the triaged-0.4.18 To mark PR that is triaged in 0.4.18 release process label Jun 16, 2023
@Czaki Czaki modified the milestones: 0.5.0, 0.4.18 Jun 19, 2023
Czaki pushed a commit that referenced this pull request Jun 19, 2023
Initial effort towards improving GUI testing automation:
https://napari.zulipchat.com/#narrow/stream/212875-general/topic/GUI.20testing

This is an initial attempt to add more tests for code related with GUI
elements. The new parametrized test proposed creates an instance of a
layer (`Image`, `Labels`, `Points`, `Shapes`, `Surface`, `Tracks` or
`Vectors`) and then operates over the layer control widgets simulating
user usage (`QCombox`, `QSpinBox` and `QSlider` based widgets value
changes, clicking `QCheckbox` and buttons widgets, `QColorSwatch`
widgets color changes typing colors, etc)

This also fixes a little issue that I noticed while working on the test.
The error is related with the value of the color mode combobox for a
Vectors layer controls. The combobox was not showing the correct value
after a fallback to a valid value is done (when a `ValueError` exception
is raised, the color mode value of the layer is changed to the previous
one, but the combobox value was missing being updated too):

* Before:

![vectors_before](https://user-images.githubusercontent.com/16781833/234071199-5d22d1b4-0653-489a-be92-68ca138033a0.gif)

* After:

![vectors_after](https://user-images.githubusercontent.com/16781833/234070708-52a41085-eea8-4cd9-bcde-03c5b71395b5.gif)

Besides that, the test structure also has some logic to skip some
tracebacks from issues which are still open/were discovered while
writing the test like #5798 and #4864

<!-- Please delete options that are not relevant. -->
- [x] Add more tests

<!-- Please describe the tests that you ran to verify your changes. -->
- [x] all tests pass with my change
- [x] I check if my changes works with both PySide and PyQt backends
      as there are small differences between the two Qt bindings.

- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas
Czaki pushed a commit that referenced this pull request Jun 21, 2023
Initial effort towards improving GUI testing automation:
https://napari.zulipchat.com/#narrow/stream/212875-general/topic/GUI.20testing

This is an initial attempt to add more tests for code related with GUI
elements. The new parametrized test proposed creates an instance of a
layer (`Image`, `Labels`, `Points`, `Shapes`, `Surface`, `Tracks` or
`Vectors`) and then operates over the layer control widgets simulating
user usage (`QCombox`, `QSpinBox` and `QSlider` based widgets value
changes, clicking `QCheckbox` and buttons widgets, `QColorSwatch`
widgets color changes typing colors, etc)

This also fixes a little issue that I noticed while working on the test.
The error is related with the value of the color mode combobox for a
Vectors layer controls. The combobox was not showing the correct value
after a fallback to a valid value is done (when a `ValueError` exception
is raised, the color mode value of the layer is changed to the previous
one, but the combobox value was missing being updated too):

* Before:

![vectors_before](https://user-images.githubusercontent.com/16781833/234071199-5d22d1b4-0653-489a-be92-68ca138033a0.gif)

* After:

![vectors_after](https://user-images.githubusercontent.com/16781833/234070708-52a41085-eea8-4cd9-bcde-03c5b71395b5.gif)

Besides that, the test structure also has some logic to skip some
tracebacks from issues which are still open/were discovered while
writing the test like #5798 and #4864

<!-- Please delete options that are not relevant. -->
- [x] Add more tests

<!-- Please describe the tests that you ran to verify your changes. -->
- [x] all tests pass with my change
- [x] I check if my changes works with both PySide and PyQt backends
      as there are small differences between the two Qt bindings.

- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas
Czaki pushed a commit that referenced this pull request Jun 21, 2023
Initial effort towards improving GUI testing automation:
https://napari.zulipchat.com/#narrow/stream/212875-general/topic/GUI.20testing

This is an initial attempt to add more tests for code related with GUI
elements. The new parametrized test proposed creates an instance of a
layer (`Image`, `Labels`, `Points`, `Shapes`, `Surface`, `Tracks` or
`Vectors`) and then operates over the layer control widgets simulating
user usage (`QCombox`, `QSpinBox` and `QSlider` based widgets value
changes, clicking `QCheckbox` and buttons widgets, `QColorSwatch`
widgets color changes typing colors, etc)

This also fixes a little issue that I noticed while working on the test.
The error is related with the value of the color mode combobox for a
Vectors layer controls. The combobox was not showing the correct value
after a fallback to a valid value is done (when a `ValueError` exception
is raised, the color mode value of the layer is changed to the previous
one, but the combobox value was missing being updated too):

* Before:

![vectors_before](https://user-images.githubusercontent.com/16781833/234071199-5d22d1b4-0653-489a-be92-68ca138033a0.gif)

* After:

![vectors_after](https://user-images.githubusercontent.com/16781833/234070708-52a41085-eea8-4cd9-bcde-03c5b71395b5.gif)

Besides that, the test structure also has some logic to skip some
tracebacks from issues which are still open/were discovered while
writing the test like #5798 and #4864

<!-- Please delete options that are not relevant. -->
- [x] Add more tests

<!-- Please describe the tests that you ran to verify your changes. -->
- [x] all tests pass with my change
- [x] I check if my changes works with both PySide and PyQt backends
      as there are small differences between the two Qt bindings.

- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Initial effort towards improving GUI testing automation:
https://napari.zulipchat.com/#narrow/stream/212875-general/topic/GUI.20testing

# Description
This is an initial attempt to add more tests for code related with GUI
elements. The new parametrized test proposed creates an instance of a
layer (`Image`, `Labels`, `Points`, `Shapes`, `Surface`, `Tracks` or
`Vectors`) and then operates over the layer control widgets simulating
user usage (`QCombox`, `QSpinBox` and `QSlider` based widgets value
changes, clicking `QCheckbox` and buttons widgets, `QColorSwatch`
widgets color changes typing colors, etc)

This also fixes a little issue that I noticed while working on the test.
The error is related with the value of the color mode combobox for a
Vectors layer controls. The combobox was not showing the correct value
after a fallback to a valid value is done (when a `ValueError` exception
is raised, the color mode value of the layer is changed to the previous
one, but the combobox value was missing being updated too):

* Before:

![vectors_before](https://user-images.githubusercontent.com/16781833/234071199-5d22d1b4-0653-489a-be92-68ca138033a0.gif)

* After:

![vectors_after](https://user-images.githubusercontent.com/16781833/234070708-52a41085-eea8-4cd9-bcde-03c5b71395b5.gif)

Besides that, the test structure also has some logic to skip some
tracebacks from issues which are still open/were discovered while
writing the test like #5798 and #4864

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Add more tests

# How has this been tested?
<!-- Please describe the tests that you ran to verify your changes. -->
- [x] all tests pass with my change
- [x] I check if my changes works with both PySide and PyQt backends
      as there are small differences between the two Qt bindings.  

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance PR with maintance changes, qt Relates to qt tests Something related to our tests triaged-0.4.18 To mark PR that is triaged in 0.4.18 release process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants