This commit is contained in:
@@ -18,11 +18,11 @@ from pyWebLayout.core.base import Renderable, Queriable
|
||||
|
||||
class SimpleTestRenderable(Renderable, Queriable):
|
||||
"""A simple test renderable for testing the page system"""
|
||||
|
||||
|
||||
def __init__(self, text: str, size: tuple = (100, 50)):
|
||||
self._text = text
|
||||
self.size = size
|
||||
self.origin = np.array([0, 0])
|
||||
self._origin = np.array([0, 0])
|
||||
|
||||
def render(self):
|
||||
"""Render returns None - drawing is done via the page's draw object"""
|
||||
@@ -145,25 +145,28 @@ class TestPageImplementation(unittest.TestCase):
|
||||
def test_page_query_point(self):
|
||||
"""Test querying points to find children"""
|
||||
page = Page(size=(400, 300))
|
||||
|
||||
|
||||
# Add children with known positions and sizes
|
||||
child1 = SimpleTestRenderable("Child 1", (100, 50))
|
||||
child2 = SimpleTestRenderable("Child 2", (80, 40))
|
||||
|
||||
|
||||
page.add_child(child1).add_child(child2)
|
||||
|
||||
# Query points
|
||||
# Point within first child
|
||||
found_child = page.query_point((90, 30))
|
||||
self.assertEqual(found_child, child1)
|
||||
|
||||
result = page.query_point((90, 30))
|
||||
self.assertIsNotNone(result)
|
||||
self.assertEqual(result.object, child1)
|
||||
|
||||
# Point within second child
|
||||
found_child = page.query_point((30, 30))
|
||||
self.assertEqual(found_child, child2)
|
||||
|
||||
# Point outside any child
|
||||
found_child = page.query_point((300, 250))
|
||||
self.assertIsNone(found_child)
|
||||
result = page.query_point((30, 30))
|
||||
self.assertIsNotNone(result)
|
||||
self.assertEqual(result.object, child2)
|
||||
|
||||
# Point outside any child - returns QueryResult with object_type "empty"
|
||||
result = page.query_point((300, 250))
|
||||
self.assertIsNotNone(result)
|
||||
self.assertEqual(result.object_type, "empty")
|
||||
|
||||
def test_page_in_object(self):
|
||||
"""Test that page correctly implements in_object"""
|
||||
|
||||
Reference in New Issue
Block a user