From aaea166135ace01709f7e0be64f40be80f4107ec Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 4 Apr 2013 00:32:52 -0400 Subject: initial commit of hand merging, plus getting "ancient" waf script to work correctly --- libs/canvas/test/polygon.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 libs/canvas/test/polygon.cc (limited to 'libs/canvas/test/polygon.cc') diff --git a/libs/canvas/test/polygon.cc b/libs/canvas/test/polygon.cc new file mode 100644 index 0000000000..353246ffe0 --- /dev/null +++ b/libs/canvas/test/polygon.cc @@ -0,0 +1,49 @@ +#include "canvas/group.h" +#include "canvas/types.h" +#include "canvas/polygon.h" +#include "canvas/canvas.h" +#include "polygon.h" + +using namespace std; +using namespace ArdourCanvas; + +CPPUNIT_TEST_SUITE_REGISTRATION (PolygonTest); + +void +PolygonTest::bounding_box () +{ + ImageCanvas canvas; + Group group (canvas.root ()); + Polygon polygon (&group); + + /* should have no initial bounding box */ + CPPUNIT_ASSERT (!polygon.bounding_box().is_initialized()); + + Points points; + points.push_back (Duple (-6, -6)); + points.push_back (Duple ( 6, -6)); + points.push_back (Duple ( 6, 6)); + points.push_back (Duple (-6, 6)); + polygon.set (points); + + /* should now have a bounding box around those points, + taking into account default line width + */ + boost::optional bbox = polygon.bounding_box (); + CPPUNIT_ASSERT (bbox.is_initialized ()); + CPPUNIT_ASSERT (bbox.get().x0 == -6.25); + CPPUNIT_ASSERT (bbox.get().x1 == 6.25); + CPPUNIT_ASSERT (bbox.get().y0 == -6.25); + CPPUNIT_ASSERT (bbox.get().y1 == 6.25); + + /* and its parent group should have noticed and adjusted + its bounding box + */ + + bbox = group.bounding_box (); + CPPUNIT_ASSERT (bbox.is_initialized ()); + CPPUNIT_ASSERT (bbox.get().x0 == -6.25); + CPPUNIT_ASSERT (bbox.get().x1 == 6.25); + CPPUNIT_ASSERT (bbox.get().y0 == -6.25); + CPPUNIT_ASSERT (bbox.get().y1 == 6.25); +} -- cgit v1.2.3