(ControlRenderer) Hide the APIs whose function are not fully implemented 18/48118/1
authorXiangyin Ma <x1.ma@samsung.com>
Mon, 14 Sep 2015 13:35:54 +0000 (14:35 +0100)
committerXiangyin Ma <x1.ma@samsung.com>
Mon, 14 Sep 2015 13:35:54 +0000 (14:35 +0100)
1. Dali doenot support multiple renderers per actor currently.
   Hide these functions temporarily as their full implementation is not avaible.

2. Add test cases to improve the UTC line coverage.

Change-Id: I55651d1a0635a2b4324a7789ba4dcc2081c181a4

automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/utc-Dali-RendererFactory.cpp
dali-toolkit/devel-api/controls/renderer-factory/control-renderer.cpp
dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h
dali-toolkit/internal/controls/renderers/control-renderer-impl.h

index b1a7c71..9b656a7 100644 (file)
@@ -49,6 +49,7 @@ SET(TC_SOURCES
    utc-Dali-SuperBlurView.cpp
    utc-Dali-Toolkit.cpp
    utc-Dali-Model3dView.cpp
+   utc-Dali-ControlRenderer.cpp
    utc-Dali-RendererFactory.cpp
 )
 
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlRenderer.cpp
new file mode 100644 (file)
index 0000000..be623c2
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali/devel-api/rendering/renderer.h>
+#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/shader.h>
+#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+void dali_control_renderer_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void dali_control_renderer_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcDaliControlRendererCopyAndAssignment(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliControlRendererCopyAndAssignment" );
+
+  RendererFactory factory = RendererFactory::Get();
+  Property::Map propertyMap;
+  propertyMap.Insert("renderer-type", "color-renderer");
+  propertyMap.Insert("blend-color", Color::BLUE);
+  ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+
+  ControlRenderer controlRendererCopy( controlRenderer );
+  DALI_TEST_CHECK(controlRenderer == controlRendererCopy);
+
+  ControlRenderer emptyControlRenderer;
+  ControlRenderer emptyControlRendererCopy( emptyControlRenderer );
+  DALI_TEST_CHECK(emptyControlRenderer == emptyControlRendererCopy);
+
+  ControlRenderer controlRendererEquals;
+  controlRendererEquals = controlRenderer;
+  DALI_TEST_CHECK(controlRenderer == controlRendererEquals);
+
+  ControlRenderer emptyControlRendererEquals;
+  emptyControlRendererEquals = emptyControlRenderer;
+  DALI_TEST_CHECK( emptyControlRenderer == emptyControlRendererEquals );
+
+  //self assignment
+  controlRenderer = controlRenderer;
+  DALI_TEST_CHECK( controlRenderer = controlRendererCopy );
+
+  END_TEST;
+}
+
+int UtcDaliControlRendererSetDepthIndex(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliControlRendererSetDepthIndex" );
+
+  RendererFactory factory = RendererFactory::Get();
+  Property::Map propertyMap;
+  propertyMap.Insert("renderer-type", "color-renderer");
+  propertyMap.Insert("blend-color", Color::BLUE);
+  ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+
+  controlRenderer.SetDepthIndex( 1.f );
+
+  Actor actor = Actor::New();
+  actor.SetSize(200.f, 200.f);
+  Stage::GetCurrent().Add( actor );
+  controlRenderer.SetOnStage( actor );
+
+  DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), 1.f, TEST_LOCATION );
+
+  controlRenderer.SetDepthIndex( -1.f );
+  DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), -1.f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliControlRendererSetOnStage(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliControlRendererSetDepthIndex" );
+
+  RendererFactory factory = RendererFactory::Get();
+  Property::Map propertyMap;
+  propertyMap.Insert("renderer-type", "color-renderer");
+  propertyMap.Insert("blend-color", Color::BLUE);
+  ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+
+  Actor actor = Actor::New();
+  actor.SetSize(200.f, 200.f);
+  Stage::GetCurrent().Add( actor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+  controlRenderer.SetOnStage( actor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+  END_TEST;
+}
index 8da2c94..abd8a27 100644 (file)
@@ -57,8 +57,33 @@ int UtcDaliRendererFactoryGet(void)
   // Check that renderer factory is a singleton
   DALI_TEST_CHECK(factory == newFactory);
 
-  RendererFactory newFactory2(factory);
-  DALI_TEST_CHECK(factory == newFactory2);
+  END_TEST;
+}
+
+int UtcDaliRendererFactoryCopyAndAssignment(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliRendererFactoryCopyAndAssignment" );
+  RendererFactory factory = RendererFactory::Get();
+
+  RendererFactory factoryCopy( factory );
+  DALI_TEST_CHECK(factory == factoryCopy);
+
+  RendererFactory emptyFactory;
+  RendererFactory emptyFactoryCopy( emptyFactory );
+  DALI_TEST_CHECK(emptyFactory == emptyFactoryCopy);
+
+  RendererFactory factoryEquals;
+  factoryEquals = factory;
+  DALI_TEST_CHECK(factory == factoryEquals);
+
+  RendererFactory emptyFactoryEquals;
+  emptyFactoryEquals = emptyFactory;
+  DALI_TEST_CHECK( emptyFactory == emptyFactoryEquals );
+
+  //self assignment
+  factory = factory;
+  DALI_TEST_CHECK( factory = factoryCopy );
 
   END_TEST;
 }
@@ -96,10 +121,6 @@ int UtcDaliRendererFactoryGetColorRenderer(void)
   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uBlendColor", actualValue ) );
   DALI_TEST_EQUALS( actualValue, testColor, TEST_LOCATION );
 
-  Stage::GetCurrent().Remove( actor );
-  controlRenderer.SetOffStage( actor );
-  DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
   END_TEST;
 }
 
@@ -148,10 +169,6 @@ int UtcDaliRendererFactoryGetLinearGradientRenderer(void)
   application.SendNotification();
   application.Render(0);
 
-  Stage::GetCurrent().Remove( actor );
-  controlRenderer.SetOffStage( actor );
-  DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
   END_TEST;
 }
 
@@ -208,9 +225,5 @@ int UtcDaliRendererFactoryGetRadialGradientRenderer(void)
   DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uAlignmentMatrix", actualValue ) );
   DALI_TEST_EQUALS( actualValue, alignMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
 
-  Stage::GetCurrent().Remove( actor );
-  controlRenderer.SetOffStage( actor );
-  DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
   END_TEST;
 }
index 687949c..e460b77 100644 (file)
@@ -56,16 +56,6 @@ void ControlRenderer::SetSize( const Vector2& size )
   GetImplementation( *this ).SetSize(size);
 }
 
-void ControlRenderer::SetClipRect( const Rect<int>& clipRect )
-{
-  GetImplementation( *this ).SetClipRect(clipRect);
-}
-
-void ControlRenderer::SetOffset( const Vector2& offset )
-{
-  GetImplementation( *this ).SetOffset(offset);
-}
-
 void ControlRenderer::SetDepthIndex( float index )
 {
   GetImplementation( *this ).SetDepthIndex(index);
@@ -76,11 +66,6 @@ void ControlRenderer::SetOnStage( Actor& actor )
   GetImplementation( *this ).SetOnStage(actor);
 }
 
-void ControlRenderer::SetOffStage( Actor& actor )
-{
-  GetImplementation( *this ).SetOffStage(actor);
-}
-
 } // namespace Toolkit
 
 } // namespace Dali
index 8d47e36..d5f0df4 100644 (file)
@@ -77,21 +77,6 @@ public:
   void SetSize( const Vector2& size );
 
   /**
-   * Set the clip rectangular of this renderer.
-   * The contents of the renderer will not be visible outside this rectangular.
-   *
-   * @param [in] clipRect The clipping rectangular.
-   */
-  void SetClipRect( const Rect<int>& clipRect );
-
-  /**
-   * Reposition this renderer with a 2D offset.
-   *
-   * @param[in] offset The offset to reposition the renderer.
-   */
-  void SetOffset( const Vector2& offset );
-
-  /**
    * Set the depth index of this renderer.
    * Depth-index controls draw-order for overlapping renderers.
    * Renderer with higher depth indices are rendered in front of other renderer with smaller values
@@ -108,14 +93,6 @@ public:
    */
   void SetOnStage( Actor& actor );
 
-  /**
-   * Renderer is destroyed when control is off stage.
-   * This function should be called when the control removes from stage
-   *
-   * @param[in] actor The actor applying this renderer.
-   */
-  void SetOffStage( Actor& actor );
-
 public: // Not intended for application developers
 
   explicit DALI_INTERNAL ControlRenderer(Internal::ControlRenderer *impl);
index cfa2da7..56cef7e 100644 (file)
@@ -61,12 +61,21 @@ public:
   virtual void SetSize( const Vector2& size );
 
   /**
-   * @copydoc Toolkit::ControlRenderer::SetCipRect
+   * ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
+   *
+   * Set the clip rectangular of this renderer.
+   * The contents of the renderer will not be visible outside this rectangular.
+   *
+   * @param [in] clipRect The clipping rectangular.
    */
   virtual void SetClipRect( const Rect<int>& clipRect );
 
   /**
-   * @copydoc Toolkit::ControlRenderer::SetOffset
+   *ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
+   *
+   * Reposition this renderer with a 2D offset.
+   *
+   * @param[in] offset The offset to reposition the renderer.
    */
   virtual void SetOffset( const Vector2& offset );
 
@@ -81,7 +90,12 @@ public:
   virtual void SetOnStage( Actor& actor );
 
   /**
-   * @copydoc Toolkit::ControlRenderer::SetOffStage
+   * ToDo: Add this function to Toolkit::ControlRenderer when the Renderer can be removed from actor properly.
+   *
+   * Renderer is destroyed when control is off stage.
+   * This function should be called when the control removes from stage
+   *
+   * @param[in] actor The actor applying this renderer.
    */
   void SetOffStage( Actor& actor );