Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
tov101 committed Oct 11, 2023
1 parent 10e8286 commit dfc8d59
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/asammdf/gui/widgets/test_PlotWidget_ContextMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,3 +956,39 @@ def test_Menu_ShowHide_Action_HideDisabledItems(self):
)
# Evaluate
self.assertTrue(self.plot_channel_b.isHidden())

def test_Menu_ShowHide_Action_ShowDisabledItems(self):
"""
Test Scope:
- Ensure that item is showed on channel selection when is disabled.
Events:
- Disable 1 channel by key Space
- Disable 1 channel by mouseClick on item CheckBox
Evaluate:
- Evaluate that items that are unchecked are not present anymore on channel selection
"""

with self.subTest("DisableBySpace"):
self.context_menu(action_text="Hide disabled items")
# Select one channel
self.mouseClick_WidgetItem(self.plot_channel_a)
# Event
QtTest.QTest.keyClick(self.plot.channel_selection, QtCore.Qt.Key_Space)
# Evaluate
self.assertTrue(self.plot_channel_a.isHidden())
self.context_menu(action_text="Show disabled items")
self.assertFalse(self.plot_channel_a.isHidden())

with self.subTest("DisableByClick"):
self.context_menu(action_text="Hide disabled items")
pos = self.plot.channel_selection.visualItemRect(self.plot_channel_b).center()
# Magic Number to detect center of checkbox
pos = QtCore.QPoint(28, pos.y())
# Event
QtTest.QTest.mouseClick(
self.plot.channel_selection.viewport(), QtCore.Qt.LeftButton, QtCore.Qt.KeyboardModifiers(), pos
)
# Evaluate
self.assertTrue(self.plot_channel_b.isHidden())
self.context_menu(action_text="Show disabled items")
self.assertFalse(self.plot_channel_b.isHidden())

0 comments on commit dfc8d59

Please sign in to comment.