LayerManagerClient: Add test code of chromakey to IlmCOmmandTest and GraphicalObjectTest
authorNobuhiko Tanibata <ntanibata@jp.adit-jv.com>
Thu, 26 Jul 2012 00:26:47 +0000 (09:26 +0900)
committerMichael Schuldt <michael.schuldt@bmw.de>
Wed, 12 Sep 2012 09:34:01 +0000 (11:34 +0200)
LayerManagerClient/ilmClient/tests/IlmCommandTest.cpp
LayerManagerService/tests/GraphicalObjectTest.cpp

index df86dbf..7a45d23 100644 (file)
@@ -1,6 +1,7 @@
 /***************************************************************************
  *
  * Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
  *
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +22,6 @@
  *
  *     ilm_displaySetRenderOrder
  *     ilm_surfaceInvalidateRectangle
- *     ilm_surfaceSetChromaKey
  *     ilm_layerSetChromaKey
  *     ilm_layerSetRenderOrder
  *     ilm_getNumberOfHardwareLayers
@@ -617,8 +617,9 @@ TEST_F(IlmCommandTest, ilm_layerAddSurface_ilm_layerRemoveSurface_ilm_getSurface
     ASSERT_EQ(length,0);
 }
 
-TEST_F(IlmCommandTest, ilm_getPropertiesOfSurface_ilm_surfaceSetSourceRectangle_ilm_surfaceSetDestinationRectangle) {
+TEST_F(IlmCommandTest, ilm_getPropertiesOfSurface_ilm_surfaceSetSourceRectangle_ilm_surfaceSetDestinationRectangle_ilm_surfaceSetChromaKey) {
     t_ilm_uint surface;
+    t_ilm_int chromaKey[3] = {3, 22, 111};
     ilm_surfaceCreate(0,0,0,ILM_PIXELFORMAT_RGBA_8888,&surface);
     ilm_commitChanges();
 
@@ -627,6 +628,7 @@ TEST_F(IlmCommandTest, ilm_getPropertiesOfSurface_ilm_surfaceSetSourceRectangle_
     ilm_surfaceSetDestinationRectangle(surface,54,47,947,9);
     ilm_surfaceSetOrientation(surface,ILM_NINETY);
     ilm_surfaceSetVisibility(surface,true);
+    ilm_surfaceSetChromaKey(surface,&chromaKey[0]);
     ilm_commitChanges();
 
     ilmSurfaceProperties surfaceProperties;
@@ -642,12 +644,17 @@ TEST_F(IlmCommandTest, ilm_getPropertiesOfSurface_ilm_surfaceSetSourceRectangle_
     ASSERT_EQ(9u, surfaceProperties.destHeight);
     ASSERT_EQ(ILM_NINETY, surfaceProperties.orientation);
     ASSERT_TRUE( surfaceProperties.visibility);
+    ASSERT_TRUE( surfaceProperties.chromaKeyEnabled);
+    ASSERT_EQ(3u, surfaceProperties.chromaKeyRed);
+    ASSERT_EQ(22u, surfaceProperties.chromaKeyGreen);
+    ASSERT_EQ(111u, surfaceProperties.chromaKeyBlue);
 
     ilm_surfaceSetOpacity(surface,0.436);
     ilm_surfaceSetSourceRectangle(surface,784,546,235,78);
     ilm_surfaceSetDestinationRectangle(surface,536,5372,3,4316);
     ilm_surfaceSetOrientation(surface,ILM_TWOHUNDREDSEVENTY);
     ilm_surfaceSetVisibility(surface,false);
+    ilm_surfaceSetChromaKey(surface,NULL);
     ilm_commitChanges();
 
     ilmSurfaceProperties surfaceProperties2;
@@ -663,6 +670,7 @@ TEST_F(IlmCommandTest, ilm_getPropertiesOfSurface_ilm_surfaceSetSourceRectangle_
     ASSERT_EQ(4316u, surfaceProperties2.destHeight);
     ASSERT_EQ(ILM_TWOHUNDREDSEVENTY, surfaceProperties2.orientation);
     ASSERT_FALSE(surfaceProperties2.visibility);
+    ASSERT_FALSE(surfaceProperties2.chromaKeyEnabled);
 }
 
 TEST_F(IlmCommandTest, ilm_getPropertiesOfLayer_ilm_layerSetSourceRectangle_ilm_layerSetDestinationRectangle) {
index 615c3ae..6e4e698 100644 (file)
@@ -1,6 +1,7 @@
 /***************************************************************************
  *
  * Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
  *
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -72,6 +73,13 @@ TEST_F(GraphicalObjectTest, constructor_SurfaceWithoutId)
 {
     unsigned int expectedOpacity = 0.3;
     unsigned int expectedVisibility = 0;
+    unsigned int expectedChromaKeyEnabled = 0;
+    unsigned char expectedChromaKeyRed = 0;
+    unsigned char expectedChromaKeyGreen = 0;
+    unsigned char expectedChromaKeyBlue = 0;
+    unsigned char chromaKeyRed = 3;
+    unsigned char chromaKeyGreen = 22;
+    unsigned char chromaKeyBlue = 111;
 
     /// Create graphical object of type surface without specific id
     GraphicalObject surface(TypeSurface, expectedOpacity, expectedVisibility);
@@ -84,6 +92,15 @@ TEST_F(GraphicalObjectTest, constructor_SurfaceWithoutId)
 
     /// make sure, surface has expected visibility
     EXPECT_EQ(expectedVisibility, surface.getVisibility());
+
+    /// make sure, surface has expected chromaKeyEnabled
+    EXPECT_EQ(expectedChromaKeyEnabled, surface.getChromaKeyEnabled());
+
+    /// make sure, surface has expected chromaKey
+    surface.getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
+    EXPECT_EQ(expectedChromaKeyRed, chromaKeyRed);
+    EXPECT_EQ(expectedChromaKeyGreen, chromaKeyGreen);
+    EXPECT_EQ(expectedChromaKeyBlue, chromaKeyBlue);
 }
 
 TEST_F(GraphicalObjectTest, constructor_LayerWithId)
@@ -110,6 +127,13 @@ TEST_F(GraphicalObjectTest, constructor_SurfaceWithId)
     unsigned int expectedOpacity = 0.7;
     unsigned int expectedVisibility = 1;
     unsigned int expectedId = 411;
+    unsigned int expectedChromaKeyEnabled = 0;
+    unsigned char expectedChromaKeyRed = 0;
+    unsigned char expectedChromaKeyGreen = 0;
+    unsigned char expectedChromaKeyBlue = 0;
+    unsigned char chromaKeyRed = 3;
+    unsigned char chromaKeyGreen = 22;
+    unsigned char chromaKeyBlue = 111;
 
     /// Create graphical object of type surface without specific id
     GraphicalObject surface(expectedId, TypeSurface, expectedOpacity, expectedVisibility);
@@ -122,6 +146,15 @@ TEST_F(GraphicalObjectTest, constructor_SurfaceWithId)
 
     /// make sure, surface has expected visibility
     EXPECT_EQ(expectedVisibility, surface.getVisibility());
+
+    /// make sure, surface has expected chromaKeyEnabled
+    EXPECT_EQ(expectedChromaKeyEnabled, surface.getChromaKeyEnabled());
+
+    /// make sure, surface has expected chromaKey
+    surface.getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
+    EXPECT_EQ(expectedChromaKeyRed, chromaKeyRed);
+    EXPECT_EQ(expectedChromaKeyGreen, chromaKeyGreen);
+    EXPECT_EQ(expectedChromaKeyBlue, chromaKeyBlue);
 }
 
 TEST_F(GraphicalObjectTest, setOpacity_Layer)
@@ -268,6 +301,90 @@ TEST_F(GraphicalObjectTest, getID_Surface)
     EXPECT_EQ(expectedSurfaceId, surface.getID());
 }
 
+TEST_F(GraphicalObjectTest, setChromaKeyEnabled_Surface)
+{
+    /// set surface to enable chromakey
+    m_pSurface->setChromaKeyEnabled(true);
+
+    /// make sure, surface has expected chromakey enabled
+    EXPECT_TRUE(m_pSurface->getChromaKeyEnabled());
+
+    /// set surface to disable chromakey
+    m_pSurface->setChromaKeyEnabled(false);
+
+    /// make sure, surface has expected
+    EXPECT_FALSE(m_pSurface->getChromaKeyEnabled());
+}
+
+TEST_F(GraphicalObjectTest, getChromaKeyEnabled_Surface)
+{
+    /// set surface to enable chromakey
+    m_pSurface->setChromaKeyEnabled(true);
+
+    /// make sure, surface has expected chromakey enabled
+    EXPECT_TRUE(m_pSurface->getChromaKeyEnabled());
+
+    /// set surface to disable chromakey
+    m_pSurface->setChromaKeyEnabled(false);
+
+    /// make sure, surface has expected chromakey enabled
+    EXPECT_FALSE(m_pSurface->getChromaKeyEnabled());
+}
+
+TEST_F(GraphicalObjectTest, setChromaKey_Surface)
+{
+    unsigned char expectedChromaKeyRed   = 3;
+    unsigned char expectedChromaKeyGreen = 22;
+    unsigned char expectedChromaKeyBlue  = 111;
+    unsigned char chromaKeyRed = 0xFF;
+    unsigned char chromaKeyGreen = 0xFF;
+    unsigned char chromaKeyBlue = 0xFF;
+
+    /// make sure, surface has default chromakey
+    m_pSurface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
+    EXPECT_EQ(0, chromaKeyRed);
+    EXPECT_EQ(0, chromaKeyGreen);
+    EXPECT_EQ(0, chromaKeyBlue);
+
+    /// set chromakey of surface to expected value
+    m_pSurface->setChromaKey(expectedChromaKeyRed,
+                             expectedChromaKeyGreen,
+                             expectedChromaKeyBlue);
+
+    /// make sure, surface has expected chromakey
+    m_pSurface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
+    EXPECT_EQ(expectedChromaKeyRed, chromaKeyRed);
+    EXPECT_EQ(expectedChromaKeyGreen, chromaKeyGreen);
+    EXPECT_EQ(expectedChromaKeyBlue, chromaKeyBlue);
+}
+
+TEST_F(GraphicalObjectTest, getChromaKey_Surface)
+{
+    unsigned char expectedChromaKeyRed   = 3;
+    unsigned char expectedChromaKeyGreen = 22;
+    unsigned char expectedChromaKeyBlue  = 111;
+    unsigned char chromaKeyRed = 0xFF;
+    unsigned char chromaKeyGreen = 0xFF;
+    unsigned char chromaKeyBlue = 0xFF;
+
+    /// make sure, surface has default chromakey
+    m_pSurface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
+    EXPECT_EQ(0, chromaKeyRed);
+    EXPECT_EQ(0, chromaKeyGreen);
+    EXPECT_EQ(0, chromaKeyBlue);
+
+    /// set chromakey of surface to expected value
+    m_pSurface->setChromaKey(expectedChromaKeyRed,
+                             expectedChromaKeyGreen,
+                             expectedChromaKeyBlue);
+
+    /// make sure, surface has expected chromakey
+    m_pSurface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
+    EXPECT_EQ(expectedChromaKeyRed, chromaKeyRed);
+    EXPECT_EQ(expectedChromaKeyGreen, chromaKeyGreen);
+    EXPECT_EQ(expectedChromaKeyBlue, chromaKeyBlue);
+}
+
 TEST_F(GraphicalObjectTest, DISABLED_setShader)
 {
     // TODO: requires Shader object and shader code in files