From 842a112be837ed3f7e947674fe61fc2751ae116c Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 1 Oct 2015 10:53:46 +0200 Subject: [PATCH] Added Frame tests --- src/tests/FrameTest.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/tests/FrameTest.cpp diff --git a/src/tests/FrameTest.cpp b/src/tests/FrameTest.cpp new file mode 100644 index 0000000..57f9712 --- /dev/null +++ b/src/tests/FrameTest.cpp @@ -0,0 +1,41 @@ +#include +#include "PrecompiledHeader.h" +#include "Core/EventBroker.h" +#include "GUI/Frame.h" + +using namespace dd; + +BOOST_AUTO_TEST_CASE(FrameTest) +{ + EventBroker eb; + + GUI::Frame baseFrame(&eb); + baseFrame.X = 100; + baseFrame.Y = 100; + + // Create a frame with a relative position to baseFrame + GUI::Frame f1(&baseFrame, "f1"); + f1.X = 50; + f1.Y = 50; + f1.Width = 50; + f1.Height = 50; + + BOOST_CHECK(f1.Left() == 150); BOOST_CHECK(baseFrame.X + f1.X == 150); + BOOST_CHECK(f1.Top() == 150); BOOST_CHECK(baseFrame.Y + f1.Y == 150); + BOOST_CHECK(f1.Right() == 200); BOOST_CHECK(baseFrame.X + f1.X + f1.Width == 200); + BOOST_CHECK(f1.Bottom() == 200); BOOST_CHECK(baseFrame.Y + f1.Y + f1.Height == 200); + + // Create a frame to the right of f1 + GUI::Frame f2(&baseFrame, "f2"); + f2.SetLeft(f1.Right()); + f2.SetTop(f1.Bottom()); + f2.Width = 50; + f2.Height = 50; + + BOOST_CHECK(f2.X == 100); BOOST_CHECK(f2.X == f1.X + f1.Width); + BOOST_CHECK(f2.Left() == 200); BOOST_CHECK(f2.Left() == f1.Right()); + BOOST_CHECK(f2.Y == 100); BOOST_CHECK(f2.Y == f1.Y + f1.Height); + BOOST_CHECK(f2.Top() == 150); BOOST_CHECK(f2.Top() == f1.Bottom()); + BOOST_CHECK(f2.Right() == 250); BOOST_CHECK(f2.Right() == f1.Right() + f2.Width); + BOOST_CHECK(f2.Bottom() == 200); BOOST_CHECK(f2.Bottom() == f1.Bottom() + f2.Height); +} \ No newline at end of file