X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ImageAtlas.cpp;h=25d83ba54ee6fb4e4636689cb1d7438e6971a6bc;hp=17b44322bc1c1c48e5f736c60eb273b9a85f9392;hb=6b38c6c213808ada74270118045e7e23d8b4910d;hpb=34c7e90e1a2542994e329fe19875701cfe52c66e;ds=sidebyside diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp index 17b4432..25d83ba 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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,7 +21,7 @@ #include #include #include -#include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -35,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) @@ -191,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 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; @@ -275,7 +276,7 @@ int UtcDaliImageAtlasUploadP(void) int UtcDaliImageAtlasUploadWithObserver01(void) { - TestApplication application; + ToolkitTestApplication application; ImageAtlas atlas = ImageAtlas::New( 200, 200 ); @@ -302,7 +303,7 @@ int UtcDaliImageAtlasUploadWithObserver01(void) int UtcDaliImageAtlasUploadWithObserver02(void) { - TestApplication application; + ToolkitTestApplication application; ImageAtlas atlas = ImageAtlas::New( 200, 200 ); gCountOfTestFuncCall = 0; @@ -332,7 +333,7 @@ int UtcDaliImageAtlasUploadWithObserver02(void) int UtcDaliImageAtlasUploadWithObserver03(void) { - TestApplication application; + ToolkitTestApplication application; gCountOfTestFuncCall = 0; TestUploadObserver* uploadObserver = new TestUploadObserver; @@ -363,7 +364,7 @@ int UtcDaliImageAtlasUploadWithObserver03(void) int UtcDaliImageAtlasRemove(void) { - TestApplication application; + ToolkitTestApplication application; unsigned int size = 100; ImageAtlas atlas = ImageAtlas::New( size, size ); Vector4 textureRect1; @@ -390,19 +391,36 @@ int UtcDaliImageAtlasImageView(void) callStack.Reset(); callStack.Enable(true); - ImageView imageView1 = ImageView::New( gImage_34_RGBA, ImageDimensions(34, 34) ); - ImageView imageView2 = ImageView::New( gImage_50_RGBA, ImageDimensions(50, 50) ); + Property::Map imageMap1; + + imageMap1[ ImageVisual::Property::URL ] = gImage_34_RGBA; + imageMap1[ ImageVisual::Property::DESIRED_HEIGHT ] = 34; + imageMap1[ ImageVisual::Property::DESIRED_WIDTH ] = 34; + 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[ ImageVisual::Property::ATLASING ] = true; + + ImageView imageView1 = ImageView::New(); + imageView1.SetProperty( ImageView::Property::IMAGE, imageMap1 ); + + ImageView imageView2 = ImageView::New(); + 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 ); @@ -431,14 +449,23 @@ 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); - ImageView imageView3 = ImageView::New( gImage_128_RGB, ImageDimensions(100, 100) ); + + Property::Map imageMap3; + imageMap3[ ImageVisual::Property::URL ] = gImage_128_RGB; + imageMap3[ ImageVisual::Property::DESIRED_HEIGHT ] = 100; + imageMap3[ ImageVisual::Property::DESIRED_WIDTH ] = 100; + 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( 3 ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); application.SendNotification(); application.Render(RENDER_FRAME_INTERVAL);