Remove dali-any from Property::Value - reimplement multivalue using more efficient...
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-ShaderEffect.cpp
index b069631..dd3c774 100644 (file)
@@ -18,7 +18,7 @@
 #include <iostream>
 
 #include <stdlib.h>
-#include <dali/dali.h>
+#include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
 
 using namespace Dali;
@@ -37,26 +37,16 @@ namespace
 {
 
 static const char* VertexSource =
-"void main()\n"
-"{\n"
-"  gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n"
-"  vTexCoord = aTexCoord;\n"
-"}\n";
+"This is a custom vertex shader\n"
+"made on purpose to look nothing like a normal vertex shader inside dali\n";
 
 static const char* FragmentSource =
-"void main()\n"
-"{\n"
-"  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n"
-"}\n";
+"This is a custom fragment shader\n"
+"made on purpose to look nothing like a normal fragment shader inside dali\n";
 
 static const char* FragmentSourceUsingExtensions =
-"void main()\n"
-"{\n"
-"  float floatValue = 0.5f;\n"
-"  float test = fwidth(floatValue);\n"
-"  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n"
-"  gl_FragColor.a *= test;\n"
-"}\n";
+"This is a custom fragment shader using extensions\n"
+"made on purpose to look nothing like a normal fragment shader inside dali\n";
 
 const int GETSOURCE_BUFFER_SIZE = 0x10000;
 
@@ -68,9 +58,9 @@ struct TestConstraintToVector3
   {
   }
 
-  Vector3 operator()(const Vector3& current)
+  void operator()( Vector3& current, const PropertyInputContainer& /* inputs */ )
   {
-    return mTarget;
+    current = mTarget;
   }
 
   Vector3 mTarget;
@@ -82,10 +72,9 @@ struct TestConstraintFromPositionToVector3
   {
   }
 
-  Vector3 operator()(const Vector3& current, const PropertyInput& position)
+  void operator()( Vector3& current, const PropertyInputContainer& inputs )
   {
-
-    return position.GetVector3();
+    current = inputs[0]->GetVector3();
   }
 };
 
@@ -96,9 +85,9 @@ struct TestConstraintToVector3Double
   {
   }
 
-  Vector3 operator()(const Vector3& current)
+  void operator()( Vector3& current, const PropertyInputContainer& /* inputs */ )
   {
-    return mTarget * 2.0f;
+    current = mTarget * 2.0f;
   }
 
   Vector3 mTarget;
@@ -127,6 +116,19 @@ private:
   bool& mDeleted;
 };
 
+static const char* TestImageFilename = "icon_wrt.png";
+
+Integration::Bitmap* CreateBitmap( unsigned int imageHeight, unsigned int imageWidth, unsigned int initialColor )
+{
+  Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+  Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  imageWidth,imageHeight,imageWidth,imageHeight );
+  unsigned int bytesPerPixel = GetBytesPerPixel(  Pixel::RGBA8888 );
+
+  memset( pixbuffer,  initialColor , imageHeight*imageWidth*bytesPerPixel);
+
+  return bitmap;
+}
+
 } // anon namespace
 
 
@@ -154,21 +156,12 @@ int UtcDaliShaderEffectMethodNew02(void)
   catch (Dali::DaliException& e)
   {
     // Tests that a negative test of an assertion succeeds
-    tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+    DALI_TEST_PRINT_ASSERT( e );
     DALI_TEST_CHECK( !effect );
   }
   END_TEST;
 }
 
-int UtcDaliShaderEffectMethodNew03(void)
-{
-  TestApplication application;
-
-  ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource, VertexSource, FragmentSource, ShaderEffect::HINT_NONE );
-  DALI_TEST_CHECK(effect);
-  END_TEST;
-}
-
 int UtcDaliShaderEffectMethodNew04(void)
 {
   TestApplication application;
@@ -190,7 +183,7 @@ int UtcDaliShaderEffectMethodNew04(void)
                                                        fragmentShaderPrefix, FragmentSourceUsingExtensions,
                                                        GEOMETRY_TYPE_IMAGE, ShaderEffect::HINT_NONE );
 
-    BitmapImage image = CreateBitmapImage();
+    BufferImage image = CreateBufferImage();
     ImageActor actor = ImageActor::New( image );
     actor.SetSize( 100.0f, 100.0f );
     actor.SetName("TestImageFilenameActor");
@@ -202,32 +195,31 @@ int UtcDaliShaderEffectMethodNew04(void)
     GLuint lastShaderCompiledAfter = application.GetGlAbstraction().GetLastShaderCompiled();
     bool testResult = false;
 
-    // we should have compiled 4 shaders.
-    if (lastShaderCompiledAfter - lastShaderCompiledBefore == 4)
-    {
-      char testVertexSourceResult[GETSOURCE_BUFFER_SIZE];
-      char testFragmentSourceResult[GETSOURCE_BUFFER_SIZE];
+    // we should have compiled 2 shaders.
+    DALI_TEST_EQUALS( lastShaderCompiledAfter, lastShaderCompiledBefore + 2, TEST_LOCATION );
+
+    char testVertexSourceResult[GETSOURCE_BUFFER_SIZE];
+    char testFragmentSourceResult[GETSOURCE_BUFFER_SIZE];
 
-      // we are interested in the first two.
-      GLuint vertexShaderId = lastShaderCompiledBefore + 1;
-      GLuint fragmentShaderId = lastShaderCompiledBefore + 2;
+     // we are interested in the first two.
+    GLuint vertexShaderId = lastShaderCompiledBefore + 1;
+    GLuint fragmentShaderId = lastShaderCompiledBefore + 2;
 
-      GLsizei lengthVertexResult;
-      GLsizei lengthFragmentResult;
+    GLsizei lengthVertexResult;
+    GLsizei lengthFragmentResult;
 
-      application.GetGlAbstraction().GetShaderSource(vertexShaderId, GETSOURCE_BUFFER_SIZE, &lengthVertexResult, testVertexSourceResult);
-      application.GetGlAbstraction().GetShaderSource(fragmentShaderId, GETSOURCE_BUFFER_SIZE, &lengthFragmentResult, testFragmentSourceResult);
+    application.GetGlAbstraction().GetShaderSource(vertexShaderId, GETSOURCE_BUFFER_SIZE, &lengthVertexResult, testVertexSourceResult);
+    application.GetGlAbstraction().GetShaderSource(fragmentShaderId, GETSOURCE_BUFFER_SIZE, &lengthFragmentResult, testFragmentSourceResult);
 
-      int vertexShaderHasPrefix = strncmp(testVertexSourceResult, "#define ", strlen("#define "));
-      int fragmentShaderHasPrefix = strncmp(testFragmentSourceResult, "#define ", strlen("#define "));
-      testResult = (vertexShaderHasPrefix == 0) && (fragmentShaderHasPrefix == 0);
-    }
+    int vertexShaderHasPrefix = strncmp(testVertexSourceResult, "#define ", strlen("#define "));
+    int fragmentShaderHasPrefix = strncmp(testFragmentSourceResult, "#define ", strlen("#define "));
+    testResult = (vertexShaderHasPrefix == 0) && (fragmentShaderHasPrefix == 0);
 
     DALI_TEST_CHECK(testResult);
   }
   catch(Dali::DaliException& e)
   {
-    tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+    DALI_TEST_PRINT_ASSERT( e );
     tet_result( TET_FAIL );
   }
   END_TEST;
@@ -244,21 +236,6 @@ int UtcDaliShaderEffectMethodNew05(void)
   END_TEST;
 }
 
-int UtcDaliShaderEffectMethodNew06(void)
-{
-  TestApplication application;
-  tet_infoline("Testing Dali::ShaderEffect::New() with shader sources for different geometry types");
-
-  ShaderEffect effect = ShaderEffect::New( "imageVertexShader", "imageFragmentShader",
-                                           "textVertexShader", "textFragmentShader",
-                                           "texturedMeshVertexShader", "texturedMeshFragmentShader",
-                                           "meshVertexShader", "meshFragmentShader",
-                                           ShaderEffect::HINT_NONE );
-  DALI_TEST_CHECK(effect);
-  END_TEST;
-}
-
-
 int UtcDaliShaderEffectMethodDownCast(void)
 {
   TestApplication application;
@@ -287,24 +264,16 @@ int UtcDaliShaderEffectMethodDelete01(void)
 {
    TestApplication application;
 
-   // Only want to test the first few characters
-   std::string customFontPrefixVertShader =
-     "\n"
-     "  attribute mediump vec3  aPosition;\n"
-     "  attribute mediump vec2  aTexCoord;\n";
-
-
    // get the default shaders built, this is not required but makes it
    // easier to debug the TET case and isolate the custom shader compilation.
    application.SendNotification();
    application.Render();
 
-   application.SendNotification();
-   application.Render();
+   GLuint beforeShaderCompiled = application.GetGlAbstraction().GetLastShaderCompiled();
 
    // create a new shader effect
    // the vertex and fragment shader will be cached in the ShaderFactory
-   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource);
+   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
 
    // destroy the shader effect
    effect.Reset();
@@ -318,23 +287,10 @@ int UtcDaliShaderEffectMethodDelete01(void)
    application.Render();
 
    GLuint lastShaderCompiled = application.GetGlAbstraction().GetLastShaderCompiled();
+   // no shaders were compiled as they are now compiled on demand and this shader was not used
+   DALI_TEST_EQUALS( beforeShaderCompiled, lastShaderCompiled, TEST_LOCATION );
 
-   // get the vertex shader (compiled before fragment shader).
-   // this last shaders compiled is for text.
-   GLuint vertexShaderId = lastShaderCompiled-1;
-   GLsizei lengthVertexResult;
-
-   char testVertexSourceResult[GETSOURCE_BUFFER_SIZE];
-   application.GetGlAbstraction().GetShaderSource(vertexShaderId, GETSOURCE_BUFFER_SIZE, &lengthVertexResult, testVertexSourceResult);
-
-   // compare the first 40 bytes of the vertex shader sent to be compiled, with
-   // the shader string that ended up being compiled (in the render task)
-   // this is to confirm the string hasn't been deleted / corrupted.
-   int testPassed = strncmp( testVertexSourceResult , customFontPrefixVertShader.c_str(), 40 ) ;
-
-   DALI_TEST_CHECK( testPassed == 0 );
    END_TEST;
-
 }
 
 int UtcDaliShaderEffectMethodSetUniformFloat(void)
@@ -344,7 +300,7 @@ int UtcDaliShaderEffectMethodSetUniformFloat(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uFloat", 1.0f );
 
@@ -370,7 +326,7 @@ int UtcDaliShaderEffectMethodSetUniformVector2(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uVec2", Vector2( 2.0f, 3.0f ) );
 
@@ -396,7 +352,7 @@ int UtcDaliShaderEffectMethodSetUniformVector3(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uVec3", Vector3( 4.0f, 5.0f, 6.0f ) );
 
@@ -422,7 +378,7 @@ int UtcDaliShaderEffectMethodSetUniformVector4(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uVec4", Vector4( 7.0f, 8.0f, 9.0f, 10.0f ) );
 
@@ -448,7 +404,7 @@ int UtcDaliShaderEffectMethodSetUniformMatrix(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uModelView", Matrix::IDENTITY );
 
@@ -474,7 +430,7 @@ int UtcDaliShaderEffectMethodSetUniformMatrix3(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   Matrix3 matIdentity(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
   effect.SetUniform( "uMatrix3", matIdentity );
@@ -499,7 +455,7 @@ int UtcDaliShaderEffectMethodSetUniformViewport(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   ImageActor actor = ImageActor::New( image );
   actor.SetSize( 100.0f, 100.0f );
@@ -515,13 +471,25 @@ int UtcDaliShaderEffectMethodSetUniformViewport(void)
 
   const Vector2& stageSize(Stage::GetCurrent().GetSize());
 
-  DALI_TEST_CHECK(
-      application.GetGlAbstraction().CheckUniformValue(
-          "uVec2", Vector2( stageSize.x/2, -stageSize.y/2 ) ) );
+  DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uVec2", Vector2( stageSize.x/2, -stageSize.y/2 ) ) );
+
+  DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uVec2Dir", Vector2( -1.0f, 2.0f ) ) );
+
+  // change coordinate types
+  effect.SetUniform( "uVec2", Vector2( 0.1f, 0.2f ), ShaderEffect::COORDINATE_TYPE_DEFAULT );
+  effect.SetUniform( "uVec2Dir", Vector2( 1.0f, 2.0f ), ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION );
+  actor.SetPixelArea( ImageActor::PixelArea( 0, 0, 10, 10 ) );
+
+  application.SendNotification();
+  application.Render();
+
+  Vector2 outValue;
+  application.GetGlAbstraction().GetUniformValue( "uVec2", outValue );
+  DALI_TEST_EQUALS( outValue, Vector2( 0.1f, 0.2f ), TEST_LOCATION );
+
+  application.GetGlAbstraction().GetUniformValue( "uVec2Dir", outValue );
+  DALI_TEST_EQUALS( outValue, Vector2( stageSize.x *.5f - 1.f, -stageSize.y * .5f + 2.f), TEST_LOCATION );
 
-  DALI_TEST_CHECK(
-      application.GetGlAbstraction().CheckUniformValue(
-          "uVec2Dir", Vector2( -1.0f, 2.0f ) ) );
   END_TEST;
 }
 
@@ -532,7 +500,7 @@ int UtcDaliShaderEffectMethodSetEffectImage(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetEffectImage(image);
 
@@ -548,7 +516,10 @@ int UtcDaliShaderEffectMethodSetEffectImage(void)
   application.Render(16);
   application.SendNotification();
 
-  DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "sEffect", 1 ) );
+  GLuint programId, uniformId;
+  bool uniformWasSet = application.GetGlAbstraction().GetUniformIds( "sEffect", programId, uniformId );
+  // we dont care about the value of the sampler uniform as thats internal to DALi core and subject to change
+  DALI_TEST_CHECK( uniformWasSet );
   END_TEST;
 }
 
@@ -558,7 +529,7 @@ int UtcDaliShaderEffectMethodSetEffectImageAndDelete(void)
 
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
 
-  BitmapImage effectImage = CreateBitmapImage();
+  BufferImage effectImage = CreateBufferImage();
   effect.SetEffectImage(effectImage);
 
   ImageActor actor = ImageActor::New();
@@ -626,7 +597,7 @@ int UtcDaliShaderEffectMethodApplyConstraint(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
 
@@ -646,10 +617,8 @@ int UtcDaliShaderEffectMethodApplyConstraint(void)
       application.GetGlAbstraction().CheckUniformValue(
           "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) );
 
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
-
-  effect.ApplyConstraint(constraint);
+  Constraint constraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
+  constraint.Apply();
 
   application.SendNotification();
   application.Render();
@@ -672,7 +641,7 @@ int UtcDaliShaderEffectMethodApplyConstraintFromActor(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uVec3", Vector3( 50.0f, 25.0f, 0.0f ) );
 
@@ -685,11 +654,9 @@ int UtcDaliShaderEffectMethodApplyConstraintFromActor(void)
 
   Property::Index uVecProperty = effect.GetPropertyIndex("uVec3");
 
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    Source(actor, Actor::POSITION),
-                                                    TestConstraintFromPositionToVector3() );
-
-  effect.ApplyConstraint(constraint);
+  Constraint constraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintFromPositionToVector3() );
+  constraint.AddSource( Source( actor, Actor::Property::POSITION ) );
+  constraint.Apply();
 
   application.SendNotification();
   application.Render();
@@ -712,7 +679,7 @@ int UtcDaliShaderEffectMethodApplyConstraintFromActor2(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uVec3", Vector3( 50.0f, 25.0f, 0.0f ) );
 
@@ -725,16 +692,12 @@ int UtcDaliShaderEffectMethodApplyConstraintFromActor2(void)
 
   Property::Index uVecProperty = effect.GetPropertyIndex("uVec3");
 
-  Constraint shaderConstraint = Constraint::New<Vector3>( uVecProperty,
-                                                    Source(actor, Actor::POSITION),
-                                                    TestConstraintFromPositionToVector3() );
-
-  effect.ApplyConstraint(shaderConstraint);
-
-  Constraint actorConstraint = Constraint::New<Vector3>( Actor::POSITION,
-                                                         TestConstraintToVector3Double(targetPosition) );
+  Constraint shaderConstraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintFromPositionToVector3() );
+  shaderConstraint.AddSource( Source(actor, Actor::Property::POSITION) );
+  shaderConstraint.Apply();
 
-  actor.ApplyConstraint(actorConstraint);
+  Constraint actorConstraint = Constraint::New<Vector3>( actor, Actor::Property::POSITION, TestConstraintToVector3Double(targetPosition) );
+  actorConstraint.Apply();
 
   application.SendNotification();
   application.Render();
@@ -746,78 +709,6 @@ int UtcDaliShaderEffectMethodApplyConstraintFromActor2(void)
   END_TEST;
 }
 
-int UtcDaliShaderEffectMethodApplyConstraintCallback(void)
-{
-  // Test whether Shader's uniform can be constrained to a stationary constraint.
-  TestApplication application;
-
-  ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
-  DALI_TEST_CHECK( effect );
-
-  BitmapImage image = CreateBitmapImage();
-
-  effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
-
-  ImageActor actor = ImageActor::New( image );
-  actor.SetSize( 100.0f, 100.0f );
-  actor.SetName("TestImageFilenameActor");
-  actor.SetShaderEffect(effect);
-  Stage::GetCurrent().Add(actor);
-
-  Property::Index uVecProperty = effect.GetPropertyIndex("uVec3");
-
-  application.SendNotification();
-  application.Render();
-
-  // Test effects of SetUniform...
-  DALI_TEST_CHECK(
-      application.GetGlAbstraction().CheckUniformValue(
-          "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) );
-
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
-
-  constraint.SetApplyTime( 10.0f );
-
-  bool constraintCheck( false );
-  ConstraintAppliedCheck appliedCheck( constraintCheck );
-
-  // We should receive the "Applied" signal after 10 seconds
-  ActiveConstraint active = effect.ApplyConstraint(constraint);
-  active.AppliedSignal().Connect( &application, appliedCheck );
-
-  application.SendNotification();
-  application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
-
-  // Check signal has not fired
-  application.SendNotification();
-  appliedCheck.CheckSignalNotReceived();
-
-  application.Render(static_cast<unsigned int>(4000.0f)); // 5 elapsed seconds
-
-  // Check signal has not fired
-  application.SendNotification();
-  appliedCheck.CheckSignalNotReceived();
-
-  application.Render(static_cast<unsigned int>(5000.0f - 1.0f)); // <10 elapsed seconds
-
-  // Check signal has not fired
-  application.SendNotification();
-  appliedCheck.CheckSignalNotReceived();
-
-  application.Render(static_cast<unsigned int>(2.0f)); // >10 elapsed seconds
-
-  // Signal should have fired
-  application.SendNotification();
-  appliedCheck.CheckSignalReceived();
-
-  // Test effects of Constraint.
-  DALI_TEST_CHECK(
-      application.GetGlAbstraction().CheckUniformValue(
-          "uVec3", Vector3( 4.0f, 9.0f, 16.0f ) ) );
-  END_TEST;
-}
-
 int UtcDaliShaderEffectMethodRemoveConstraints(void)
 {
   // Test if constrains can be removed before they are ever applyed.
@@ -826,7 +717,7 @@ int UtcDaliShaderEffectMethodRemoveConstraints(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
 
@@ -846,10 +737,8 @@ int UtcDaliShaderEffectMethodRemoveConstraints(void)
       application.GetGlAbstraction().CheckUniformValue(
           "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) );
 
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
-
-  effect.ApplyConstraint(constraint);
+  Constraint constraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
+  constraint.Apply();
 
   // Remove the constraints
   effect.RemoveConstraints();
@@ -872,7 +761,7 @@ int UtcDaliShaderEffectMethodRemoveConstraints2(void)
   ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
   DALI_TEST_CHECK( effect );
 
-  BitmapImage image = CreateBitmapImage();
+  BufferImage image = CreateBufferImage();
 
   effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
 
@@ -892,10 +781,8 @@ int UtcDaliShaderEffectMethodRemoveConstraints2(void)
       application.GetGlAbstraction().CheckUniformValue(
           "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) );
 
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
-
-  effect.ApplyConstraint(constraint);
+  Constraint constraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
+  constraint.Apply();
 
   application.SendNotification();
   application.Render();
@@ -945,7 +832,7 @@ int UtcDaliShaderEffectMethodCreateExtension2(void)
     ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
     DALI_TEST_CHECK( effect );
 
-    BitmapImage image = CreateBitmapImage();
+    BufferImage image = CreateBufferImage();
 
     effect.SetUniform( "uFloat", 1.0f );
 
@@ -992,7 +879,7 @@ int UtcDaliShaderEffectMethodNoExtension(void)
   catch (Dali::DaliException& e)
   {
     // Tests that a negative test of an assertion succeeds
-    tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+    DALI_TEST_PRINT_ASSERT( e );
     DALI_TEST_CHECK( !effect );
   }
   END_TEST;
@@ -1006,7 +893,199 @@ int UtcDaliShaderEffectPropertyIndices(void)
 
   Property::IndexContainer indices;
   effect.GetPropertyIndices( indices );
-  DALI_TEST_CHECK( ! indices.empty() );
-  DALI_TEST_EQUALS( indices.size(), effect.GetPropertyCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( indices.Size() );
+  DALI_TEST_EQUALS( indices.Size(), effect.GetPropertyCount(), TEST_LOCATION );
+  END_TEST;
+}
+
+int UtcDaliShaderBinaries(void)
+{
+  TestApplication application;
+  // these will not affect the "first round" of dali render as core is already initialized and it has queried the defaults
+  application.GetGlAbstraction().SetBinaryFormats( 1 );
+  application.GetGlAbstraction().SetNumBinaryFormats( 1 );
+  application.GetGlAbstraction().SetProgramBinaryLength( 1 );
+
+  GLuint lastShaderCompiledBefore = application.GetGlAbstraction().GetLastShaderCompiled();
+
+  ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
+  DALI_TEST_CHECK( effect );
+
+  BufferImage image = CreateBufferImage();
+  ImageActor actor = ImageActor::New( image );
+  actor.SetSize( 100.0f, 100.0f );
+  actor.SetName("TestImageFilenameActor");
+  actor.SetShaderEffect(effect);
+  Stage::GetCurrent().Add(actor);
+
+  application.SendNotification();
+  application.Render(16);
+  // binary was not requested by DALi
+  DALI_TEST_CHECK( !(application.GetGlAbstraction().GetProgramBinaryCalled()) );
+
+  GLuint lastShaderCompiledAfter = application.GetGlAbstraction().GetLastShaderCompiled();
+
+  // check that the shader was compiled
+  DALI_TEST_EQUALS( lastShaderCompiledAfter, lastShaderCompiledBefore + 2, TEST_LOCATION );
+
+  // simulate context loss to get core to re-initialize its GL
+  application.GetCore().ContextDestroyed();
+  application.GetCore().ContextCreated();
+
+  application.SendNotification();
+  application.Render(16);
+
+  // shader is recompiled
+  GLuint finalShaderCompiled = application.GetGlAbstraction().GetLastShaderCompiled();
+  // check that the shader was compiled
+  DALI_TEST_EQUALS( lastShaderCompiledAfter + 2, finalShaderCompiled, TEST_LOCATION );
+
+  // binary was requested by DALi
+  DALI_TEST_CHECK( application.GetGlAbstraction().GetProgramBinaryCalled() );
+
+  END_TEST;
+}
+
+int UtcDaliShaderEffectFromPropertiesP(void)
+{
+  TestApplication application;
+  tet_infoline("UtcDaliShaderEffectFromProperties01()");
+
+  std::string fragmentShaderPrefix = "#define TEST_FS 1\n#extension GL_OES_standard_derivatives : enable";
+  std::string vertexShaderPrefix = "#define TEST_VS 1";
+  std::string vertexShader(VertexSource);
+  std::string fragmentShader(FragmentSource);
+
+  // Call render to compile default shaders.
+  application.SendNotification();
+  application.Render();
+
+  GLuint lastShaderCompiledBefore = application.GetGlAbstraction().GetLastShaderCompiled();
+
+  // create from type registry
+
+  TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ShaderEffect" );
+  DALI_TEST_CHECK( typeInfo );
+  ShaderEffect effect = ShaderEffect::DownCast( typeInfo.CreateInstance() );
+  DALI_TEST_CHECK( effect );
+
+  Property::Value programValue = Property::Value(Property::MAP);
+  Property::Map* programMap = programValue.GetMap();
+  DALI_TEST_CHECK( programMap );
+
+  programMap->Insert("vertex", vertexShader);
+  programMap->Insert("fragment", fragmentShader);
+
+  programMap->Insert("vertex-prefix", vertexShaderPrefix);
+  programMap->Insert("fragment-prefix", fragmentShaderPrefix);
+
+  programMap->Insert("geometry-type", "GEOMETRY_TYPE_IMAGE");
+
+  effect.SetProperty(effect.GetPropertyIndex("program"), programValue);
+
+  Property::Value imageValue = Property::Value(Property::MAP);
+  Property::Map* imageMap = imageValue.GetMap();
+  DALI_TEST_CHECK( imageMap );
+  imageMap->Insert("filename", Property::Value(TestImageFilename));
+  effect.SetProperty(effect.GetPropertyIndex("image"), imageValue);
+
+  // do a update & render to get the image request
+  application.SendNotification();
+  application.Render();
+
+  Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+  // create the image
+  Integration::Bitmap* bitmap = CreateBitmap( 10, 10, 0xFF );
+  Integration::ResourcePointer resourcePtr(bitmap);
+  TestPlatformAbstraction& platform = application.GetPlatform();
+  platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resourcePtr);
+
+  BufferImage image(CreateBufferImage());
+  ImageActor actor = ImageActor::New( image );
+  actor.SetSize( 100.0f, 100.0f );
+  actor.SetName("TestImageFilenameActor");
+  actor.SetShaderEffect(effect);
+  Stage::GetCurrent().Add(actor);
+
+  application.SendNotification();
+  application.Render();
+  GLuint lastShaderCompiledAfter = application.GetGlAbstraction().GetLastShaderCompiled();
+
+  // we should have compiled 2 shaders.
+  DALI_TEST_EQUALS(lastShaderCompiledAfter, lastShaderCompiledBefore + 2, TEST_LOCATION );
+
+  std::string actualVertexShader = application.GetGlAbstraction().GetShaderSource( lastShaderCompiledBefore + 1 );
+  DALI_TEST_EQUALS( vertexShaderPrefix, actualVertexShader.substr( 0, vertexShaderPrefix.length() ), TEST_LOCATION );
+  DALI_TEST_EQUALS( vertexShader, actualVertexShader.substr( actualVertexShader.length() - vertexShader.length() ), TEST_LOCATION );
+
+  std::string actualFragmentShader = application.GetGlAbstraction().GetShaderSource( lastShaderCompiledBefore + 2 );
+  DALI_TEST_EQUALS( fragmentShaderPrefix, actualFragmentShader.substr( 0, fragmentShaderPrefix.length() ), TEST_LOCATION );
+  DALI_TEST_EQUALS( fragmentShader, actualFragmentShader.substr( actualFragmentShader.length() - fragmentShader.length() ), TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliShaderEffectFromPropertiesN(void)
+{
+  try
+  {
+    TestApplication application;
+    tet_infoline("UtcDaliShaderEffectFromProperties02()");
+
+    // Call render to compile default shaders.
+    application.SendNotification();
+    application.Render();
+
+    // create from type registry (currently only way to get ShaderEffect with no shader setup in constructor
+    TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ShaderEffect" );
+    DALI_TEST_CHECK( typeInfo );
+    ShaderEffect effect = ShaderEffect::DownCast( typeInfo.CreateInstance() );
+    DALI_TEST_CHECK( effect );
+
+    Property::Value programValue = Property::Value(Property::MAP);
+    Property::Map* programMap = programValue.GetMap();
+    DALI_TEST_CHECK( programMap );
+
+    programMap->Insert("vertex",   std::string(VertexSource));
+    programMap->Insert("fragment", std::string(FragmentSource));
+
+    // use wrong index on purpose
+    effect.SetProperty(effect.GetPropertyIndex("program") + 1, programValue );
+
+    tet_result( TET_FAIL );
+  }
+  catch(Dali::DaliException& e)
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+  }
+  END_TEST;
+}
+
+int UtcDaliShaderEffectFromProperties2N(void)
+{
+  try
+  {
+    TestApplication application;
+    tet_infoline("UtcDaliShaderEffectFromProperties03()");
+
+    // Call render to compile default shaders.
+    application.SendNotification();
+    application.Render();
+
+    // create from type registry (currently only way to get ShaderEffect with no shader setup in constructor
+    TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ShaderEffect" );
+    DALI_TEST_CHECK( typeInfo );
+    ShaderEffect effect = ShaderEffect::DownCast( typeInfo.CreateInstance() );
+    DALI_TEST_CHECK( effect );
+
+    // dont set unknown
+    effect.SetProperty( effect.GetPropertyIndex("geometry-hints"), "HINT_2" );
+
+    tet_result( TET_FAIL );
+  }
+  catch(Dali::DaliException& e)
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+  }
   END_TEST;
 }