Merge "Add parameter (bool immediate) to TextChanged signal in interface" into devel...
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ImageAtlas.cpp
index cca026f..9276f50 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -21,9 +21,6 @@
 #include <dali-toolkit-test-suite-utils.h>
 #include <toolkit-event-thread-callback.h>
 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
-#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
-
-#include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali-toolkit/dali-toolkit.h>
 
 using namespace Dali;
@@ -38,8 +35,8 @@ static const char* gImage_50_RGBA = TEST_RESOURCE_DIR "/icon-delete.png";
 // resolution: 128*128, pixel format: RGB888
 static const char* gImage_128_RGB = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
 
-// this is image is not exist, for negative test
-static const char* gImageNonExist = "non-exist.jpg";
+// Empty image, for testing broken image loading
+static const char* gEmptyImage = TEST_RESOURCE_DIR "/empty.bmp";
 
 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
 
@@ -194,26 +191,27 @@ int UtcDaliImageAtlasSetBrokenImage(void)
   unsigned int size = 200;
   ImageAtlas atlas = ImageAtlas::New( size, size );
 
-  Vector4 textureRect;
-  atlas.Upload( textureRect, gImageNonExist );
-  DALI_TEST_EQUALS( textureRect, Vector4::ZERO, TEST_LOCATION );
-
   // Set broken image
   TestPlatformAbstraction& platform = application.GetPlatform();
   platform.SetClosestImageSize(Vector2( 34, 34));
   atlas.SetBrokenImage( gImage_34_RGBA );
 
-  // the non-exit image will be replaced with the broken image
-  platform.SetClosestImageSize(Vector2( 0, 0));
-  atlas.Upload( textureRect, gImageNonExist );
+  Vector4 textureRect;
+
+  // the empty image will be replaced with the broken image
+  platform.SetClosestImageSize(Vector2( 20, 20));
+  atlas.Upload( textureRect, gEmptyImage );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
   Rect<int> pixelArea = TextureCoordinateToPixelArea(textureRect, size);
-  DALI_TEST_EQUALS( pixelArea.width, 34, TEST_LOCATION );
-  DALI_TEST_EQUALS( pixelArea.height, 34, TEST_LOCATION );
+  DALI_TEST_EQUALS( pixelArea.width, 20, TEST_LOCATION );
+  DALI_TEST_EQUALS( pixelArea.height, 20, TEST_LOCATION );
 
   END_TEST;
 }
 
+
+
 int UtcDaliImageAtlasUploadP(void)
 {
   ToolkitTestApplication application;
@@ -243,30 +241,32 @@ int UtcDaliImageAtlasUploadP(void)
   DALI_TEST_EQUALS( pixelArea1.height, 34, TEST_LOCATION );
 
   TraceCallStack::NamedParams params;
-  params["width"] = ToString(pixelArea1.width);
-  params["height"] = ToString(pixelArea1.height);
-  params["xoffset"] = ToString(pixelArea1.x);
-  params["yoffset"] = ToString(pixelArea1.y);
+  params["width"] <<pixelArea1.width;
+  params["height"] <<pixelArea1.height;
+  params["xoffset"] <<pixelArea1.x;
+  params["yoffset"] <<pixelArea1.y;
   DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", params ));
 
   Rect<int> pixelArea2 = TextureCoordinateToPixelArea(textureRect2, size);
   DALI_TEST_EQUALS( pixelArea2.width, 50, TEST_LOCATION );
   DALI_TEST_EQUALS( pixelArea2.height, 50, TEST_LOCATION );
 
-  params["width"] = ToString(pixelArea2.width);
-  params["height"] = ToString(pixelArea2.height);
-  params["xoffset"] = ToString(pixelArea2.x);
-  params["yoffset"] = ToString(pixelArea2.y);
+  params.mParams.clear();
+  params["width"] <<pixelArea2.width;
+  params["height"] <<pixelArea2.height;
+  params["xoffset"] <<pixelArea2.x;
+  params["yoffset"] <<pixelArea2.y;
   DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", params ) );
 
   Rect<int> pixelArea3 = TextureCoordinateToPixelArea(textureRect3, size);
   DALI_TEST_EQUALS( pixelArea3.width, 128, TEST_LOCATION );
   DALI_TEST_EQUALS( pixelArea3.height, 128, TEST_LOCATION );
 
-  params["width"] = ToString(pixelArea3.width);
-  params["height"] = ToString(pixelArea3.height);
-  params["xoffset"] = ToString(pixelArea3.x);
-  params["yoffset"] = ToString(pixelArea3.y);
+  params.mParams.clear();
+  params["width"] <<pixelArea3.width;
+  params["height"] <<pixelArea3.height;
+  params["xoffset"] <<pixelArea3.x;
+  params["yoffset"] <<pixelArea3.y;
   DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", params ) );
 
   DALI_TEST_CHECK( ! IsOverlap(pixelArea1, pixelArea2) );
@@ -278,7 +278,7 @@ int UtcDaliImageAtlasUploadP(void)
 
 int UtcDaliImageAtlasUploadWithObserver01(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
   ImageAtlas atlas = ImageAtlas::New( 200, 200 );
 
 
@@ -305,7 +305,7 @@ int UtcDaliImageAtlasUploadWithObserver01(void)
 
 int UtcDaliImageAtlasUploadWithObserver02(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
   ImageAtlas atlas = ImageAtlas::New( 200, 200 );
 
   gCountOfTestFuncCall = 0;
@@ -335,7 +335,7 @@ int UtcDaliImageAtlasUploadWithObserver02(void)
 
 int UtcDaliImageAtlasUploadWithObserver03(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   gCountOfTestFuncCall = 0;
   TestUploadObserver* uploadObserver = new TestUploadObserver;
@@ -366,7 +366,7 @@ int UtcDaliImageAtlasUploadWithObserver03(void)
 
 int UtcDaliImageAtlasRemove(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
   unsigned int size = 100;
   ImageAtlas atlas = ImageAtlas::New( size, size );
   Vector4 textureRect1;
@@ -398,14 +398,14 @@ int UtcDaliImageAtlasImageView(void)
   imageMap1[ ImageVisual::Property::URL ] = gImage_34_RGBA;
   imageMap1[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
   imageMap1[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
-  imageMap1[ DevelImageVisual::Property::ATLASING] = true;
+  imageMap1[ ImageVisual::Property::ATLASING] = true;
 
   Property::Map imageMap2;
 
   imageMap2[ ImageVisual::Property::URL ] = gImage_50_RGBA;
   imageMap2[ ImageVisual::Property::DESIRED_HEIGHT ] = 50;
   imageMap2[ ImageVisual::Property::DESIRED_WIDTH ] = 50;
-  imageMap2[ DevelImageVisual::Property::ATLASING ] = true;
+  imageMap2[ ImageVisual::Property::ATLASING ] = true;
 
   ImageView imageView1 = ImageView::New();
   imageView1.SetProperty( ImageView::Property::IMAGE, imageMap1 );
@@ -414,15 +414,15 @@ int UtcDaliImageAtlasImageView(void)
   imageView2.SetProperty( ImageView::Property::IMAGE, imageMap2 );
 
   // ImageView doesn't do size negotiation properly: it only listens to OnSizeSet:
-  imageView1.SetSize( 100, 100 );
-  imageView2.SetSize( 100, 100 );
+  imageView1.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
+  imageView2.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
   imageView1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
   imageView2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
 
   application.GetPlatform().SetClosestImageSize(  Vector2(34, 34) );
-  Stage::GetCurrent().Add( imageView1 );
+  application.GetScene().Add( imageView1 );
   application.GetPlatform().SetClosestImageSize(  Vector2(50, 50) );
-  Stage::GetCurrent().Add( imageView2 );
+  application.GetScene().Add( imageView2 );
 
   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
 
@@ -432,16 +432,16 @@ int UtcDaliImageAtlasImageView(void)
   callStack.Enable(false);
 
   TraceCallStack::NamedParams params1;
-  params1["width"] = "34";
-  params1["height"] = "34";
-  params1["xoffset"] = "0";
-  params1["yoffset"] = "0";
+  params1["width"] << 34;
+  params1["height"] << 34;
+  params1["xoffset"] << 0;
+  params1["yoffset"] << 0;
 
   TraceCallStack::NamedParams params2;
-  params2["width"] = "50";
-  params2["height"] = "50";
-  params2["xoffset"] = "0";
-  params2["yoffset"] = "34";
+  params2["width"] << 50;
+  params2["height"] << 50;
+  params2["xoffset"] << 0;
+  params2["yoffset"] << 34;
 
   DALI_TEST_EQUALS(  callStack.FindMethodAndParams("TexSubImage2D", params1 ), true, TEST_LOCATION );
   DALI_TEST_EQUALS(  callStack.FindMethodAndParams("TexSubImage2D", params2 ), true, TEST_LOCATION );
@@ -451,7 +451,7 @@ int UtcDaliImageAtlasImageView(void)
 
   // remove the imageView2 from stage, the second image will also be removed from atlas
   // then the space on the atlas will be used by the third image added.
-  Stage::GetCurrent().Remove( imageView2 );
+  application.GetScene().Remove( imageView2 );
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
 
@@ -459,13 +459,13 @@ int UtcDaliImageAtlasImageView(void)
   imageMap3[ ImageVisual::Property::URL ] = gImage_128_RGB;
   imageMap3[ ImageVisual::Property::DESIRED_HEIGHT ] = 100;
   imageMap3[ ImageVisual::Property::DESIRED_WIDTH ] = 100;
-  imageMap3[ DevelImageVisual::Property::ATLASING ] = true;
+  imageMap3[ ImageVisual::Property::ATLASING ] = true;
 
   ImageView imageView3 = ImageView::New();
   imageView3.SetProperty( ImageView::Property::IMAGE, imageMap3 );
 
   application.GetPlatform().SetClosestImageSize(  Vector2(100, 100) );
-  Stage::GetCurrent().Add( imageView3 );
+  application.GetScene().Add( imageView3 );
 
   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
@@ -475,10 +475,10 @@ int UtcDaliImageAtlasImageView(void)
   callStack.Enable(false);
 
   TraceCallStack::NamedParams params3;
-  params3["width"] = "100";
-  params3["height"] = "100";
-  params3["xoffset"] = "0";
-  params3["yoffset"] = "34";
+  params3["width"] << 100;
+  params3["height"] << 100;
+  params3["xoffset"] << 0;
+  params3["yoffset"] << 34;
 
   DALI_TEST_EQUALS(  callStack.FindMethodAndParams("TexSubImage2D", params3 ), true, TEST_LOCATION );