(Automated Tests) Synchronize common code with core 20/114220/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 10 Feb 2017 10:12:01 +0000 (10:12 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 10 Feb 2017 12:33:31 +0000 (12:33 +0000)
Change-Id: I8ab5f93c782074322a8cb8a4c62f159bd14ca61e

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-harness.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-native-image.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-native-image.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp

index b50f506..8877a50 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -338,6 +338,21 @@ BufferImage CreateBufferImage()
   return CreateBufferImage(4, 4, Color::WHITE);
 }
 
+void PrepareResourceImage( TestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
+{
+  TestPlatformAbstraction& platform = application.GetPlatform();
+  platform.SetClosestImageSize(Vector2( imageWidth, imageHeight));
+
+  Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
+  Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
+  unsigned int bytesPerPixel = GetBytesPerPixel(  pixelFormat );
+  unsigned int initialColor = 0xFF;
+  memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel);
+
+  Integration::ResourcePointer resourcePtr(bitmap);
+  platform.SetSynchronouslyLoadedResource( resourcePtr );
+}
+
 namespace Test
 {
 
index a3149f4..79d422b 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TEST_SUITE_UTILS_H__
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -162,6 +162,7 @@ inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2,
     return false;
   }
 
+  bool result = false;
   switch(type)
   {
     case Property::BOOLEAN:
@@ -169,7 +170,7 @@ inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2,
       bool a, b;
       q1.Get(a);
       q2.Get(b);
-      return a == b;
+      result =  a == b;
       break;
     }
     case Property::INTEGER:
@@ -177,7 +178,7 @@ inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2,
       int a, b;
       q1.Get(a);
       q2.Get(b);
-      return a == b;
+      result =  a == b;
       break;
     }
     case Property::FLOAT:
@@ -185,7 +186,7 @@ inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2,
       float a, b;
       q1.Get(a);
       q2.Get(b);
-      return CompareType<float>(a, b, epsilon);
+      result =  CompareType<float>(a, b, epsilon);
       break;
     }
     case Property::VECTOR2:
@@ -193,7 +194,7 @@ inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2,
       Vector2 a, b;
       q1.Get(a);
       q2.Get(b);
-      return CompareType<Vector2>(a, b, epsilon);
+      result = CompareType<Vector2>(a, b, epsilon);
       break;
     }
     case Property::VECTOR3:
@@ -201,7 +202,7 @@ inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2,
       Vector3 a, b;
       q1.Get(a);
       q2.Get(b);
-      return CompareType<Vector3>(a, b, epsilon);
+      result = CompareType<Vector3>(a, b, epsilon);
       break;
     }
     case Property::RECTANGLE:
@@ -210,7 +211,7 @@ inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2,
       Vector4 a, b;
       q1.Get(a);
       q2.Get(b);
-      return CompareType<Vector4>(a, b, epsilon);
+      result = CompareType<Vector4>(a, b, epsilon);
       break;
     }
     case Property::ROTATION:
@@ -218,14 +219,28 @@ inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2,
       Quaternion a, b;
       q1.Get(a);
       q2.Get(b);
-      return CompareType<Quaternion>(a, b, epsilon);
+      result = CompareType<Quaternion>(a, b, epsilon);
+      break;
+    }
+    case Property::MATRIX:
+    case Property::MATRIX3:
+    case Property::STRING:
+    case Property::ARRAY:
+    case Property::MAP:
+    {
+      //TODO: Implement this?
+      DALI_ASSERT_ALWAYS( 0 && "Not implemented");
+      result = false;
+      break;
+    }
+    case Property::NONE:
+    {
+      result = false;
       break;
     }
-    default:
-      return false;
   }
 
-  return false;
+  return result;
 }
 
 
@@ -499,6 +514,9 @@ struct DefaultFunctionCoverage
 BufferImage CreateBufferImage();
 BufferImage CreateBufferImage(int width, int height, const Vector4& color);
 
+// Prepare a resource image to be loaded. Should be called before creating the ResourceImage
+void PrepareResourceImage( TestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat );
+
 // Test namespace to prevent pollution of Dali namespace, add Test helper functions here
 namespace Test
 {
index d89d4d2..6636676 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
index c5ecc4f..5c94252 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TEST_APPLICATION_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
index 76b391b..840ef0d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
index 135476e..da4e7e8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -38,4 +38,19 @@ TestNativeImage::~TestNativeImage()
 {
 }
 
+
+TestNativeImageNoExtPointer TestNativeImageNoExt::New(int width, int height)
+{
+  return new TestNativeImageNoExt(width, height);
+}
+
+TestNativeImageNoExt::TestNativeImageNoExt(int width, int height)
+: mWidth(width), mHeight(height), mExtensionCreateCalls(0), mExtensionDestroyCalls(0), mTargetTextureCalls(0),createResult(true)
+{
+}
+
+TestNativeImageNoExt::~TestNativeImageNoExt()
+{
+}
+
 } // namespace dali
index f1938c3..896ce52 100644 (file)
@@ -2,7 +2,7 @@
 #define __TEST_NATIVE_IMAGE_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -19,8 +19,6 @@
  */
 
 // INTERNAL INCLUDES
-
-// EXTERNAL INCLUDES
 #include <dali/public-api/images/native-image-interface.h>
 #include <dali/devel-api/images/native-image-interface-extension.h>
 #include <dali/integration-api/gl-defines.h>
@@ -28,7 +26,9 @@
 namespace Dali
 {
 class TestNativeImage;
+class TestNativeImageNoExt;
 typedef IntrusivePtr<TestNativeImage> TestNativeImagePointer;
+typedef IntrusivePtr<TestNativeImageNoExt> TestNativeImageNoExtPointer;
 
 class DALI_IMPORT_API TestNativeImageExtension: public Dali::NativeImageInterface::Extension
 {
@@ -36,7 +36,7 @@ public:
   inline const char* GetCustomFragmentPreFix(){return "#extension GL_OES_EGL_image_external:require\n";}
   inline const char* GetCustomSamplerTypename(){return "samplerExternalOES";}
 
-  inline int GetEglImageTextureTarget(){return GL_TEXTURE_2D;}
+  inline int GetEglImageTextureTarget(){return GL_TEXTURE_EXTERNAL_OES;}
 
 };
 
@@ -48,7 +48,7 @@ public:
   inline void SetGlExtensionCreateResult(bool result){ createResult = result;}
   inline virtual bool GlExtensionCreate() { ++mExtensionCreateCalls; return createResult;};
   inline virtual void GlExtensionDestroy() { ++mExtensionDestroyCalls; };
-  inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 1;};
+  inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 0;};
   inline virtual void PrepareTexture() {};
   inline virtual unsigned int GetWidth() const {return mWidth;};
   inline virtual unsigned int GetHeight() const {return mHeight;};
@@ -70,6 +70,34 @@ public:
   TestNativeImageExtension* mExtension;
 };
 
+
+class DALI_IMPORT_API TestNativeImageNoExt : public Dali::NativeImageInterface
+{
+public:
+  static TestNativeImageNoExtPointer New(int width, int height);
+
+  inline void SetGlExtensionCreateResult(bool result){ createResult = result;}
+  inline virtual bool GlExtensionCreate() { ++mExtensionCreateCalls; return createResult;};
+  inline virtual void GlExtensionDestroy() { ++mExtensionDestroyCalls; };
+  inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 1;};
+  inline virtual void PrepareTexture() {};
+  inline virtual unsigned int GetWidth() const {return mWidth;};
+  inline virtual unsigned int GetHeight() const {return mHeight;};
+  inline virtual bool RequiresBlending() const {return true;};
+
+private:
+  TestNativeImageNoExt(int width, int height);
+  virtual ~TestNativeImageNoExt();
+
+  int mWidth;
+  int mHeight;
+public:
+  int mExtensionCreateCalls;
+  int mExtensionDestroyCalls;
+  int mTargetTextureCalls;
+  bool createResult;
+};
+
 } // Dali
 
 #endif
index 61f88f0..86b5430 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -94,7 +94,7 @@ Integration::ResourcePointer TestPlatformAbstraction::LoadResourceSynchronously(
 Integration::BitmapPtr TestPlatformAbstraction::DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t size )
 {
   mTrace.PushCall("DecodeBuffer", "");
-  return Integration::BitmapPtr();
+  return mDecodedBitmap;
 }
 
 void TestPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId)
@@ -182,6 +182,7 @@ void TestPlatformAbstraction::Initialize()
   mResourceRequests.Clear();
   mIsLoadingResult=false;
   mSynchronouslyLoadedResource.Reset();
+  mDecodedBitmap.Reset();
 }
 
 bool TestPlatformAbstraction::WasCalled(TestFuncEnum func)
@@ -215,6 +216,7 @@ void TestPlatformAbstraction::ClearReadyResources()
   mLoadedResourcesQueue.clear();
   mFailedLoadQueue.clear();
   mSynchronouslyLoadedResource.Reset();
+  mDecodedBitmap.Reset();
 }
 
 void TestPlatformAbstraction::SetResourceLoaded(Integration::ResourceId  loadedId,
@@ -317,4 +319,9 @@ void TestPlatformAbstraction::SetSynchronouslyLoadedResource( Integration::Resou
   mSynchronouslyLoadedResource = resource;
 }
 
+void TestPlatformAbstraction::SetDecodedBitmap( Integration::BitmapPtr bitmap )
+{
+  mDecodedBitmap = bitmap;
+}
+
 } // namespace Dali
index d9d3247..42e2d98 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TEST_PLATFORM_ABSTRACTION_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -264,6 +264,17 @@ public: // TEST FUNCTIONS
    */
   void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource );
 
+  /**
+   * @brief Sets the bitmap returned by DecodeBuffer()
+   * @param[in] bitmap The decoded bitmap
+   */
+  void SetDecodedBitmap( Integration::BitmapPtr bitmap );
+
+private:
+
+  TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined
+  TestPlatformAbstraction& operator=( const TestPlatformAbstraction& ); ///< Undefined
+
 private:
 
   struct LoadedResource
@@ -307,6 +318,7 @@ private:
   bool                          mSaveFileResult;
 
   Integration::ResourcePointer  mSynchronouslyLoadedResource;
+  Integration::BitmapPtr        mDecodedBitmap;
 };
 
 } // Dali
index 76ccff7..f57dc50 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
index 3921404..721bfec 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -1000,7 +1000,7 @@ int UtcDaliImageViewSetImageNativeImage(void)
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
 
   std::stringstream params;
-  params << GL_TEXTURE_2D << ", " << 23;
+  params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
 
   END_TEST;
@@ -1050,7 +1050,7 @@ int UtcDaliImageViewSetImageBufferImageToNativeImage(void)
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
 
   std::stringstream nextTextureParams;
-  nextTextureParams << GL_TEXTURE_2D << ", " << 24;
+  nextTextureParams << GL_TEXTURE_EXTERNAL_OES << ", " << 24;
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nextTextureParams.str()) );
 
   END_TEST;
@@ -1082,7 +1082,7 @@ int UtcDaliImageViewSetImageNativeImageToBufferImage(void)
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
 
   std::stringstream params;
-  params << GL_TEXTURE_2D << ", " << 23;
+  params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
 
   width = 200;
@@ -1149,7 +1149,7 @@ int UtcDaliImageViewSetImageNativeImageWithCustomShader(void)
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
 
   std::stringstream params;
-  params << GL_TEXTURE_2D << ", " << 23;
+  params << GL_TEXTURE_EXTERNAL_OES << ", " << 23;
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", params.str()) );
 
   END_TEST;
@@ -1214,7 +1214,7 @@ int UtcDaliImageViewSetImageBufferImageWithCustomShaderToNativeImage(void)
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethod("BindTexture") );
 
   std::stringstream nativeImageParams;
-  nativeImageParams << GL_TEXTURE_2D << ", " << 24;
+  nativeImageParams << GL_TEXTURE_EXTERNAL_OES << ", " << 24;
   DALI_TEST_CHECK( gl.GetTextureTrace().FindMethodAndParams("BindTexture", nativeImageParams.str()) );