Merge "(Automated Tests) Synchronised common files with Core" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-gl-abstraction.h
index 90ed38b..f910d51 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <sstream>
 #include <string>
+#include <cstring>
 #include <map>
 #include <cstdio>
 #include <cstring> // for strcmp
@@ -54,7 +55,7 @@ public:
   void Initialize();
 
   void PreRender();
-  void PostRender(unsigned int timeDelta);
+  void PostRender();
 
   /* OpenGL ES 2.0 */
 
@@ -350,11 +351,11 @@ public:
   inline void DeleteTextures(GLsizei n, const GLuint* textures)
   {
     std::stringstream out;
-    out << n << ", " << textures << " = [" ;
+    out << n << ", " << textures << " = [";
 
     for(GLsizei i=0; i<n; i++)
     {
-      out << textures[i] << ", " ;
+      out << textures[i] << ", ";
       mDeletedTextureIds.push_back(textures[i]);
     }
     out << "]";
@@ -388,6 +389,9 @@ public:
 
   inline void DepthFunc(GLenum func)
   {
+    std::stringstream out;
+    out << func;
+    mDepthFunctionTrace.PushCall("DepthFunc", out.str());
   }
 
   inline void DepthMask(GLboolean flag)
@@ -409,7 +413,7 @@ public:
   {
     std::stringstream out;
     out << cap;
-    mCullFaceTrace.PushCall("Disable", out.str());
+    mEnableDisableTrace.PushCall("Disable", out.str());
   }
 
   inline void DisableVertexAttribArray(GLuint index)
@@ -435,7 +439,7 @@ public:
   {
     std::stringstream out;
     out << cap;
-    mCullFaceTrace.PushCall("Enable", out.str());
+    mEnableDisableTrace.PushCall("Enable", out.str());
   }
 
   inline void EnableVertexAttribArray(GLuint index)
@@ -487,6 +491,9 @@ public:
 
   inline void GenerateMipmap(GLenum target)
   {
+    std::stringstream out;
+    out<<target;
+    mTextureTrace.PushCall("GenerateMipmap", out.str());
   }
 
   inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
@@ -555,6 +562,21 @@ public:
 
   inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
   {
+    switch(index)
+    {
+      case 0:
+        *length = snprintf(name, bufsize, "sTexture");
+        *type = GL_SAMPLER_2D;
+        *size = 1;
+        break;
+      case 1:
+        *length = snprintf(name, bufsize, "sEffect");
+        *type = GL_SAMPLER_2D;
+        *size = 1;
+        break;
+      default:
+        break;
+    }
   }
 
   inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
@@ -619,13 +641,20 @@ public:
 
   inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
   {
-    switch( pname ) {
+    switch( pname )
+    {
       case GL_LINK_STATUS:
         *params = mLinkStatus;
         break;
       case GL_PROGRAM_BINARY_LENGTH_OES:
         *params = mProgramBinaryLength;
         break;
+      case GL_ACTIVE_UNIFORMS:
+        *params = mNumberOfActiveUniforms;
+        break;
+      case GL_ACTIVE_UNIFORM_MAX_LENGTH:
+        *params = 100;
+        break;
     }
   }
 
@@ -633,7 +662,6 @@ public:
   {
   }
 
-
   inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
   {
   }
@@ -758,6 +786,10 @@ public:
     std::stringstream out;
     out << program;
     mShaderTrace.PushCall("LinkProgram", out.str());
+
+    mNumberOfActiveUniforms=2;
+    GetUniformLocation(program, "sTexture");
+    GetUniformLocation(program, "sEffect");
   }
 
   inline void PixelStorei(GLenum pname, GLint param)
@@ -855,7 +887,7 @@ public:
   inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
   {
     std::stringstream out;
-    out << width << ", " << height;
+    out << target<<", "<<level<<", "<<width << ", " << height;
     mTextureTrace.PushCall("TexImage2D", out.str());
   }
 
@@ -890,7 +922,7 @@ public:
   inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
   {
     std::stringstream out;
-    out << xoffset << ", " << yoffset << ", " << width << ", " << height;
+    out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
     mTextureTrace.PushCall("TexSubImage2D", out.str());
   }
 
@@ -1583,6 +1615,11 @@ public: // TEST FUNCTIONS
   inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
   inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
 
+  //Methods for Enable/Disable call verification
+  inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
+  inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
+  inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
+
   //Methods for Shader verification
   inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
   inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
@@ -1603,6 +1640,11 @@ public: // TEST FUNCTIONS
   inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
   inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
 
+  //Methods for Depth function verification
+  inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
+  inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
+  inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
+
   template <typename T>
   inline bool GetUniformValue( const char* name, T& value ) const
   {
@@ -1705,8 +1747,6 @@ public: // TEST FUNCTIONS
     return false;
   }
 
-
-
   inline GLuint GetLastShaderCompiled() const
   {
     return mLastShaderCompiled;
@@ -1765,6 +1805,7 @@ private:
   BufferDataCalls mBufferDataCalls;
   BufferSubDataCalls mBufferSubDataCalls;
   GLuint     mLinkStatus;
+  GLint      mNumberOfActiveUniforms;
   GLint      mGetAttribLocationResult;
   GLenum     mGetErrorResult;
   GLubyte*   mGetStringResult;
@@ -1815,10 +1856,12 @@ private:
   ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
 
   TraceCallStack mCullFaceTrace;
+  TraceCallStack mEnableDisableTrace;
   TraceCallStack mShaderTrace;
   TraceCallStack mTextureTrace;
   TraceCallStack mTexParamaterTrace;
   TraceCallStack mDrawTrace;
+  TraceCallStack mDepthFunctionTrace;
 
   // Shaders & Uniforms
   GLuint mLastShaderIdUsed;