Skip to content

Commit

Permalink
Added unittest for back event
Browse files Browse the repository at this point in the history
  • Loading branch information
ppizarror committed Aug 15, 2019
1 parent 25bee64 commit e1f2daf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/test_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_get_selected_widget(self):
widget = self.menu.add_text_input('test', 'some_id')
self.assertEqual(widget, self.menu.get_selected_widget())

def test_events(self):
def test_generic_events(self):
"""
Test key events.
"""
Expand Down Expand Up @@ -209,6 +209,19 @@ def _some_event():
click_pos = PygameUtils.get_middle_rect(first_button.get_rect())
self.menu._main(PygameUtils.mouse_click(click_pos[0], click_pos[1]))

def test_back_event(self):
"""
Test back event.
"""
self.menu.clear()
self.assertEqual(self.menu._get_depth(), 0)
menu = PygameMenuUtils.generic_menu('submenu')
button = self.menu.add_option('open', menu)
button.apply()
self.assertEqual(self.menu._get_depth(), 1)
self.menu._main(PygameUtils.key(pygameMenu.controls.KEY_BACK, keydown=True)) # go back
self.assertEqual(self.menu._get_depth(), 0)

def test_mouse_empty_submenu(self):
"""
Test mouse event where the following submenu has less elements.
Expand Down

0 comments on commit e1f2daf

Please sign in to comment.