--- /dev/null
+/*
+ * 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;
+}
// 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;
}
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;
}
application.SendNotification();
application.Render(0);
- Stage::GetCurrent().Remove( actor );
- controlRenderer.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
END_TEST;
}
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;
}
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
*/
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);
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 );
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 );