(Layer) Added a test for clipping 51/27751/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 18 Sep 2014 13:09:11 +0000 (14:09 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 18 Sep 2014 13:38:03 +0000 (14:38 +0100)
Change-Id: I35e74c13f84d5ac10fa75d60441d20cee4427573

automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h
automated-tests/src/dali/utc-Dali-Layer.cpp

index 47a5b3a..b094fde 100644 (file)
@@ -729,6 +729,10 @@ public:
 
   inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
   {
+    mScissorParams.x = x;
+    mScissorParams.y = y;
+    mScissorParams.width = width;
+    mScissorParams.height = height;
   }
 
   inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
@@ -1643,6 +1647,18 @@ public: // TEST FUNCTIONS
     ATTRIB_TYPE_LAST
   };
 
+  struct ScissorParams
+  {
+    GLint x;
+    GLint y;
+    GLsizei width;
+    GLsizei height;
+
+    ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
+  };
+
+  // Methods to check scissor tests
+  inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
 
 private:
   GLuint     mCurrentProgram;
@@ -1820,6 +1836,8 @@ private:
     mVertexAttribArrayState[ index ] = state;
     mVertexAttribArrayChanged = true;
   }
+
+  ScissorParams mScissorParams;
 };
 
 template <>
index f92cef0..5ec2a06 100644 (file)
@@ -523,3 +523,30 @@ int UtcDaliLayerTouchConsumed(void)
   DALI_TEST_EQUALS( layer.IsTouchConsumed(), true, TEST_LOCATION );
   END_TEST;
 }
+
+int UtcDaliLayerClippingGLCalls(void)
+{
+  TestApplication application;
+  const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
+  Stage stage( Stage::GetCurrent() );
+
+  ClippingBox testBox( 5, 6, 77, 83 );
+  Layer layer = Stage::GetCurrent().GetRootLayer();
+  layer.SetClipping( true );
+  layer.SetClippingBox( testBox );
+
+  // Add at least one renderable actor so the GL calls are actually made
+  Actor textActor = TextActor::New("Hello");
+  stage.Add( textActor );
+
+  // flush the queue and render once
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( testBox.x, glScissorParams.x, TEST_LOCATION );
+  DALI_TEST_EQUALS( testBox.y, stage.GetSize().height - glScissorParams.y - testBox.height, TEST_LOCATION ); // GL Coordinates are from bottom left
+  DALI_TEST_EQUALS( testBox.width, glScissorParams.width, TEST_LOCATION );
+  DALI_TEST_EQUALS( testBox.height, glScissorParams.height, TEST_LOCATION );
+
+  END_TEST;
+}