#include <gtest/gtest.h>
#include "Surface.h"
+#include "Layer.h"
class SurfaceTest : public ::testing::Test
{
Surface surface;
/// make sure, surface was not added to any layer
- //EXPECT_EQ(INVALID_ID, surface.getContainingLayerId());
+ EXPECT_EQ(GraphicalObject::INVALID_ID, surface.getContainingLayerId());
/// make sure, surface has default size
EXPECT_EQ(0, surface.OriginalSourceHeight);
EXPECT_EQ(0, destRect.width);
EXPECT_EQ(0, destRect.x);
EXPECT_EQ(0, destRect.y);
+
+ /// make sure, surface has no native content associated
+ EXPECT_FALSE(m_pSurface->hasNativeContent());
}
TEST_F(SurfaceTest, specialConstructor)
EXPECT_EQ(expectedId, surface.getID());
/// make sure, surface was not added to any layer
- //EXPECT_EQ(INVALID_ID, surface.getContainingLayerId());
+ EXPECT_EQ(GraphicalObject::INVALID_ID, surface.getContainingLayerId());
/// make sure, surface has default size
EXPECT_EQ(0, surface.OriginalSourceHeight);
EXPECT_EQ(0, destRect.width);
EXPECT_EQ(0, destRect.x);
EXPECT_EQ(0, destRect.y);
+
+ /// make sure, surface has no native content associated
+ EXPECT_FALSE(m_pSurface->hasNativeContent());
}
TEST_F(SurfaceTest, getPixelFormat)
{
+ PixelFormat expected1 = PIXELFORMAT_RGBA5551;
+ PixelFormat expected2 = PIXELFORMAT_RGB565;
+
+ /// set pixel format of surface to expected value
+ m_pSurface->setPixelFormat(expected1);
+
+ /// make sure, surface has expected pixel format
+ EXPECT_EQ(expected1, m_pSurface->getPixelFormat());
+
+ /// set pixel format of surface to other expected value
+ m_pSurface->setPixelFormat(expected2);
+ /// make sure, surface has other expected pixel format
+ EXPECT_EQ(expected2, m_pSurface->getPixelFormat());
}
TEST_F(SurfaceTest, setPixelFormat)
{
+ PixelFormat expected1 = PIXELFORMAT_R8;
+ PixelFormat expected2 = PIXELFORMAT_RGBA8888;
+ /// set pixel format of surface to expected value
+ m_pSurface->setPixelFormat(expected1);
+
+ /// make sure, surface has expected pixel format
+ EXPECT_EQ(expected1, m_pSurface->getPixelFormat());
+
+ /// set pixel format of surface to other expected value
+ m_pSurface->setPixelFormat(expected2);
+
+ /// make sure, surface has other expected pixel format
+ EXPECT_EQ(expected2, m_pSurface->getPixelFormat());
}
TEST_F(SurfaceTest, getContainingLayerId)
{
+ unsigned int expectedLayerId = 202;
+ Layer layer(expectedLayerId);
+
+ /// make sure, surface has no containg layer
+ EXPECT_EQ(GraphicalObject::INVALID_ID, m_pSurface->getContainingLayerId());
+ /// add surface to layer
+ layer.addSurface(m_pSurface);
+
+ /// make sure, surface is contained by layer
+ EXPECT_EQ(expectedLayerId, m_pSurface->getContainingLayerId());
+
+ /// remove surface from layer
+ layer.removeSurface(m_pSurface);
+
+ /// make sure, surface is no longer contained by layer
+ EXPECT_EQ(GraphicalObject::INVALID_ID, m_pSurface->getContainingLayerId());
}
TEST_F(SurfaceTest, setContainingLayerId)
{
+ unsigned int expectedLayerId = 207;
+
+ /// make sure, surface has no containing layer
+ EXPECT_EQ(GraphicalObject::INVALID_ID, m_pSurface->getContainingLayerId());
+
+ /// set surface to be contained by expected layer
+ m_pSurface->setContainingLayerId(expectedLayerId);
+ /// make sure, surface is contained by layer
+ EXPECT_EQ(expectedLayerId, m_pSurface->getContainingLayerId());
+
+ /// set surface to be contained by no layer
+ m_pSurface->setContainingLayerId(GraphicalObject::INVALID_ID);
+
+ /// make sure, surface is no longer contained by layer
+ EXPECT_EQ(GraphicalObject::INVALID_ID, m_pSurface->getContainingLayerId());
}
TEST_F(SurfaceTest, hasNativeContent)
{
+ unsigned int expectedNativeHandle = 211;
+
+ /// make sure, surface has no native content associated
+ EXPECT_FALSE(m_pSurface->hasNativeContent());
+
+ /// set expected native content of surface
+ m_pSurface->setNativeContent(expectedNativeHandle);
+ /// make sure, surface has native content associated
+ EXPECT_TRUE(m_pSurface->hasNativeContent());
+
+ /// remove native content of surface
+ m_pSurface->removeNativeContent();
+
+ /// make sure, surface has no native content associated
+ EXPECT_FALSE(m_pSurface->hasNativeContent());
}
TEST_F(SurfaceTest, removeNativeContent)
{
+ unsigned int expectedNativeHandle = 213;
+
+ /// set expected native content of surface
+ m_pSurface->setNativeContent(expectedNativeHandle);
+
+ /// make sure, surface has native content associated
+ EXPECT_TRUE(m_pSurface->hasNativeContent());
+
+ /// remove native content of surface
+ m_pSurface->removeNativeContent();
+ /// make sure, surface has no native content associated
+ EXPECT_FALSE(m_pSurface->hasNativeContent());
}
TEST_F(SurfaceTest, setNativeContent)
{
+ unsigned int expectedNativeHandle1 = 217;
+ unsigned int expectedNativeHandle2 = 218;
+
+ /// make sure, surface has no native content associated
+ EXPECT_FALSE(m_pSurface->hasNativeContent());
+
+ /// set 1st expected native content of surface
+ m_pSurface->setNativeContent(expectedNativeHandle1);
+
+ /// make sure, surface has 1st expected native content associated
+ EXPECT_TRUE(m_pSurface->hasNativeContent());
+ EXPECT_EQ(expectedNativeHandle1, m_pSurface->getNativeContent());
+
+ /// set 2nd expected native content of surface
+ m_pSurface->setNativeContent(expectedNativeHandle2);
+ /// make sure, surface still has 1st expected native content associated
+ EXPECT_TRUE(m_pSurface->hasNativeContent());
+ EXPECT_EQ(expectedNativeHandle1, m_pSurface->getNativeContent());
+
+ /// remove native content of surface
+ m_pSurface->removeNativeContent();
+
+ /// set 2nd expected native content of surface again
+ m_pSurface->setNativeContent(expectedNativeHandle2);
+
+ /// make sure, surface has 2nd expected native content associated
+ EXPECT_TRUE(m_pSurface->hasNativeContent());
+ EXPECT_EQ(expectedNativeHandle2, m_pSurface->getNativeContent());
}
TEST_F(SurfaceTest, getNativeContent)
{
+ unsigned int expectedNativeHandle1 = 217;
+ unsigned int expectedNativeHandle2 = 218;
+
+ /// make sure, surface has no native content associated
+ EXPECT_FALSE(m_pSurface->hasNativeContent());
+
+ /// set 1st expected native content of surface
+ m_pSurface->setNativeContent(expectedNativeHandle1);
+
+ /// make sure, surface has 1st expected native content associated
+ EXPECT_TRUE(m_pSurface->hasNativeContent());
+ EXPECT_EQ(expectedNativeHandle1, m_pSurface->getNativeContent());
+
+ /// remove native content of surface
+ m_pSurface->removeNativeContent();
+
+ /// set 2nd expected native content of surface again
+ m_pSurface->setNativeContent(expectedNativeHandle2);
+ /// make sure, surface has 2nd expected native content associated
+ EXPECT_TRUE(m_pSurface->hasNativeContent());
+ EXPECT_EQ(expectedNativeHandle2, m_pSurface->getNativeContent());
}