1 #include "canvas/group.h"
2 #include "canvas/types.h"
3 #include "canvas/polygon.h"
4 #include "canvas/canvas.h"
8 using namespace ArdourCanvas;
10 CPPUNIT_TEST_SUITE_REGISTRATION (PolygonTest);
13 PolygonTest::bounding_box ()
16 Group group (canvas.root ());
17 Polygon polygon (&group);
19 /* should have no initial bounding box */
20 CPPUNIT_ASSERT (!polygon.bounding_box().is_initialized());
23 points.push_back (Duple (-6, -6));
24 points.push_back (Duple ( 6, -6));
25 points.push_back (Duple ( 6, 6));
26 points.push_back (Duple (-6, 6));
29 /* should now have a bounding box around those points,
30 taking into account default line width
32 boost::optional<Rect> bbox = polygon.bounding_box ();
33 CPPUNIT_ASSERT (bbox.is_initialized ());
34 CPPUNIT_ASSERT (bbox.get().x0 == -6.25);
35 CPPUNIT_ASSERT (bbox.get().x1 == 6.25);
36 CPPUNIT_ASSERT (bbox.get().y0 == -6.25);
37 CPPUNIT_ASSERT (bbox.get().y1 == 6.25);
39 /* and its parent group should have noticed and adjusted
43 bbox = group.bounding_box ();
44 CPPUNIT_ASSERT (bbox.is_initialized ());
45 CPPUNIT_ASSERT (bbox.get().x0 == -6.25);
46 CPPUNIT_ASSERT (bbox.get().x1 == 6.25);
47 CPPUNIT_ASSERT (bbox.get().y0 == -6.25);
48 CPPUNIT_ASSERT (bbox.get().y1 == 6.25);