This commit is contained in:
@@ -442,28 +442,37 @@ class TestInteractionCallbacks(unittest.TestCase):
|
||||
self.font = Font(font_size=12, colour=(0, 0, 0))
|
||||
self.mock_draw = Mock()
|
||||
self.callback_result = "callback_executed"
|
||||
self.callback = Mock(return_value=self.callback_result)
|
||||
|
||||
|
||||
# Link callback: receives (location, point, **params)
|
||||
def link_callback(location, point, **params):
|
||||
return "callback_executed"
|
||||
self.link_callback = link_callback
|
||||
|
||||
# Button callback: receives (point, **params)
|
||||
def button_callback(point, **params):
|
||||
return "callback_executed"
|
||||
self.button_callback = button_callback
|
||||
|
||||
def test_link_text_interaction(self):
|
||||
"""Test that LinkText properly handles interaction"""
|
||||
# Use a FUNCTION link type which calls the callback, not INTERNAL which returns location
|
||||
link = Link("test_function", LinkType.FUNCTION, self.callback)
|
||||
link = Link("test_function", LinkType.FUNCTION, self.link_callback)
|
||||
renderable = LinkText(link, "Test Link", self.font, self.mock_draw)
|
||||
|
||||
|
||||
# Simulate interaction
|
||||
result = renderable.interact(np.array([10, 10]))
|
||||
|
||||
|
||||
# Should execute the link's callback
|
||||
self.assertEqual(result, self.callback_result)
|
||||
|
||||
|
||||
def test_button_text_interaction(self):
|
||||
"""Test that ButtonText properly handles interaction"""
|
||||
button = Button("Test Button", self.callback)
|
||||
button = Button("Test Button", self.button_callback)
|
||||
renderable = ButtonText(button, self.font, self.mock_draw)
|
||||
|
||||
|
||||
# Simulate interaction
|
||||
result = renderable.interact(np.array([10, 10]))
|
||||
|
||||
|
||||
# Should execute the button's callback
|
||||
self.assertEqual(result, self.callback_result)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user