Total 1907 tests, 1 less than combined total before.
This is because UtcLinearConstrainerApply was duplicated in both dali and dali-devel.
Change-Id: I52ae9e9da91d10259db0d7cc5dd1dc2ba45ecd63
+++ /dev/null
-SET(PKG_NAME "dali-devel")
-
-SET(EXEC_NAME "tct-${PKG_NAME}-core")
-SET(RPM_NAME "core-${PKG_NAME}-tests")
-
-SET(CAPI_LIB "dali-devel")
-
-SET(TC_SOURCES
- utc-Dali-Actor.cpp
- utc-Dali-Atlas.cpp
- utc-Dali-ConditionalWait.cpp
- utc-Dali-Context.cpp
- utc-Dali-Constrainer.cpp
- utc-Dali-DistanceField.cpp
- utc-Dali-Hash.cpp
- utc-Dali-HitTestAlgorithm.cpp
- utc-Dali-Mutex.cpp
- utc-Dali-SignalDelegate.cpp
- utc-Dali-Scripting.cpp
- utc-Dali-Thread.cpp
- utc-Dali-WeakHandle.cpp
-)
-
-LIST(APPEND TC_SOURCES
- ../dali/dali-test-suite-utils/mesh-builder.cpp
- ../dali/dali-test-suite-utils/dali-test-suite-utils.cpp
- ../dali/dali-test-suite-utils/test-actor-utils.cpp
- ../dali/dali-test-suite-utils/test-harness.cpp
- ../dali/dali-test-suite-utils/test-application.cpp
- ../dali/dali-test-suite-utils/test-gesture-manager.cpp
- ../dali/dali-test-suite-utils/test-gl-abstraction.cpp
- ../dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp
- ../dali/dali-test-suite-utils/test-native-image.cpp
- ../dali/dali-test-suite-utils/test-platform-abstraction.cpp
- ../dali/dali-test-suite-utils/test-render-controller.cpp
- ../dali/dali-test-suite-utils/test-trace-call-stack.cpp
-)
-
-PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
- dali-core
-)
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${CAPI_LIB}_CFLAGS_OTHER} -O0 -ggdb --coverage -Wall -Werror")
-
-FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
- SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
-ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
-
-INCLUDE_DIRECTORIES(
- ../../..
- .
- ${${CAPI_LIB}_INCLUDE_DIRS}
- ../dali/dali-test-suite-utils
-)
-
-ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
-TARGET_LINK_LIBRARIES(${EXEC_NAME}
- ${${CAPI_LIB}_LIBRARIES}
- -lpthread
-)
-
-INSTALL(PROGRAMS ${EXEC_NAME}
- DESTINATION ${BIN_DIR}/${EXEC_NAME}
-)
+++ /dev/null
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
-#include <test-harness.h>
-#include "tct-dali-devel-core.h"
-
-int main(int argc, char * const argv[])
-{
- int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
- const char* optString = "rs";
- bool optRerunFailed(true);
- bool optRunSerially(false);
-
- int nextOpt = 0;
- do
- {
- nextOpt = getopt( argc, argv, optString );
- switch(nextOpt)
- {
- case 'r':
- optRerunFailed = true;
- break;
- case 's':
- optRunSerially = true;
- break;
- case '?':
- TestHarness::Usage(argv[0]);
- exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
- break;
- }
- } while( nextOpt != -1 );
-
- if( optind == argc ) // no testcase name in argument list
- {
- if( optRunSerially )
- {
- result = TestHarness::RunAll( argv[0], tc_array );
- }
- else
- {
- result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
- }
- }
- else
- {
- // optind is index of next argument - interpret as testcase name
- result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
- }
- return result;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-#include <mesh-builder.h>
-
-//& set: DaliActor
-
-using std::string;
-using namespace Dali;
-
-
-int UtcDaliActorAddRendererP(void)
-{
- tet_infoline("Testing Actor::AddRenderer");
- TestApplication application;
-
- Actor actor = Actor::New();
-
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
-
- Geometry geometry = CreateQuadGeometry();
- Shader shader = CreateShader();
- Renderer renderer = Renderer::New(geometry, shader);
-
- actor.AddRenderer( renderer );
- DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliActorAddRendererN(void)
-{
- tet_infoline("Testing Actor::AddRenderer");
- TestApplication application;
-
- Actor actor = Actor::New();
- Renderer renderer;
-
- // try illegal Add
- try
- {
- actor.AddRenderer( renderer );
- tet_printf("Assertion test failed - no Exception\n" );
- tet_result(TET_FAIL);
- }
- catch(Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
- }
- catch(...)
- {
- tet_printf("Assertion test failed - wrong Exception\n" );
- tet_result(TET_FAIL);
- }
-
- END_TEST;
-}
-
-int UtcDaliActorAddRendererOnStage(void)
-{
- tet_infoline("Testing Actor::AddRenderer");
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(0);
-
- Geometry geometry = CreateQuadGeometry();
- Shader shader = CreateShader();
- Renderer renderer = Renderer::New(geometry, shader);
-
- application.SendNotification();
- application.Render(0);
-
- try
- {
- actor.AddRenderer( renderer );
- tet_result(TET_PASS);
- }
- catch(...)
- {
- tet_result(TET_FAIL);
- }
-
- END_TEST;
-}
-
-int UtcDaliActorRemoveRendererP1(void)
-{
- tet_infoline("Testing Actor::RemoveRenderer");
- TestApplication application;
-
- Actor actor = Actor::New();
-
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
-
- Geometry geometry = CreateQuadGeometry();
- Shader shader = CreateShader();
- Renderer renderer = Renderer::New(geometry, shader);
-
- actor.AddRenderer( renderer );
- DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
-
- actor.RemoveRenderer(renderer);
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
-
-
- END_TEST;
-}
-
-int UtcDaliActorRemoveRendererP2(void)
-{
- tet_infoline("Testing Actor::RemoveRenderer");
- TestApplication application;
-
- Actor actor = Actor::New();
-
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
-
- Geometry geometry = CreateQuadGeometry();
- Shader shader = CreateShader();
- Renderer renderer = Renderer::New(geometry, shader);
-
- actor.AddRenderer( renderer );
- DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
-
- actor.RemoveRenderer(0);
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
-
-
- END_TEST;
-}
-
-
-int UtcDaliActorRemoveRendererN(void)
-{
- tet_infoline("Testing Actor::RemoveRenderer");
- TestApplication application;
-
- Actor actor = Actor::New();
-
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
-
- Geometry geometry = CreateQuadGeometry();
- Shader shader = CreateShader();
- Renderer renderer = Renderer::New(geometry, shader);
-
- actor.AddRenderer( renderer );
- DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
-
- actor.RemoveRenderer(10);
- DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
- DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <algorithm>
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/devel-api/images/atlas.h>
-#include <dali-test-suite-utils.h>
-#include <test-native-image.h>
-
-using namespace Dali;
-
-namespace
-{
-static const char* gTestImageFilename = "icon_wrt.png";
-
-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 );
-}
-
-PixelData CreatePixelData(unsigned int width, unsigned int height, Pixel::Format pixelFormat)
-{
- unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( pixelFormat );
- unsigned char* buffer = new unsigned char [ bufferSize ];
-
- return PixelData::New( buffer, bufferSize, width, height, pixelFormat, PixelData::DELETE_ARRAY );
-}
-
-}
-
-void utc_dali_atlas_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_atlas_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliAtlasNew(void)
-{
- TestApplication application;
-
- // invoke default handle constructor
- Atlas atlas;
-
- DALI_TEST_CHECK( !atlas );
-
- // initialise handle
- atlas = Atlas::New( 16, 16 );
-
- DALI_TEST_CHECK( atlas );
- END_TEST;
-}
-
-int UtcDaliAtlasCopyConstructor(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 16);
- Atlas atlasCopy(atlas);
-
-
- DALI_TEST_EQUALS( (bool)atlasCopy, true, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAtlasAssignmentOperator(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 16);
-
- Atlas atlas2;
- DALI_TEST_EQUALS( (bool)atlas2, false, TEST_LOCATION );
-
- atlas2 = atlas;
- DALI_TEST_EQUALS( (bool)atlas2, true, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliAtlasDownCast(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 16);
-
- BaseHandle handle(atlas);
- Atlas atlasDowncast = Atlas::DownCast(handle);
- DALI_TEST_EQUALS( (bool)atlasDowncast, true, TEST_LOCATION );
-
- Handle handle2 = Handle::New(); // Create a custom object
- Atlas atlas2 = Atlas::DownCast(handle2);
- DALI_TEST_EQUALS( (bool)atlas2, false, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliAtlasClear(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 32, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- atlas.Clear(Color::TRANSPARENT);
-
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- callStack.Enable(false);
-
- std::stringstream out;
- out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 32u;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
-
- END_TEST;
-}
-
-
-// Upload resource image, buffer image & pixel data with same pixel format
-int UtcDaliAtlasUpload01P(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 40, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using same pixel format
- PixelBuffer* buffer = new PixelBuffer[16 * 16 * 4];
- BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
-
- PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 16 ) );
-
- PixelData pixelData = CreatePixelData( 6,8,Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas.Upload( pixelData, 2, 32 ) );
-
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- callStack.Enable(false);
-
- {
- std::stringstream out;
- out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 16u;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
- }
- {
- std::stringstream out;
- out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 16u << ", " << 16u <<", "<< 16u;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
- }
- {
- std::stringstream out;
- out << GL_TEXTURE_2D <<", "<< 0u << ", " << 2u << ", " << 32u << ", " << 6u <<", "<< 8u;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
- }
-
- END_TEST;
-}
-
-// Upload resource image, buffer image & pixel data with different pixel format
-int UtcDaliAtlasUpload02P(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 20, 20, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using different pixel format
- PixelBuffer* buffer = new PixelBuffer[16 * 16 * 3];
- BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGB888 );
- DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
-
- PrepareResourceImage( application, 12, 12, Pixel::A8 );
- DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 6, 6 ) );
-
- PixelData pixelData = CreatePixelData( 8,8,Pixel::LA88 );
- DALI_TEST_CHECK( atlas.Upload( pixelData, 10, 10 ) );
-
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- callStack.Enable(false);
-
- {
- std::stringstream out;
- out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 16u;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
- }
- {
- std::stringstream out;
- out << GL_TEXTURE_2D <<", "<< 0u << ", " << 6u << ", " << 6u << ", " << 12u <<", "<< 12u;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
- }
- {
- std::stringstream out;
- out << GL_TEXTURE_2D <<", "<< 0u << ", " << 10u << ", " << 10u << ", " << 8u <<", "<< 8u;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
- }
-
- END_TEST;
-}
-
-// Upload resource image, buffer image & pixel data which cannot fit into the atlas with given offset
-int UtcDaliAtlasUploadN(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using image cannot fit into atlas at the given offsets
- PixelBuffer* buffer = new PixelBuffer[24 * 24 * 4];
- BufferImage image = BufferImage::New( buffer, 24, 24, Pixel::RGBA8888 );
- DALI_TEST_CHECK( !atlas.Upload( image, 0, 0 ) );
-
- PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 10, 10 ) );
-
- PixelData pixelData = CreatePixelData( 6,6,Pixel::RGBA8888 );
- DALI_TEST_CHECK( !atlas.Upload( pixelData, 11, 11 ) );
-
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- callStack.Enable(false);
-
- // none of these three upload() call sends texture to GPU
- DALI_TEST_CHECK( ! callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 24, 24") );
- DALI_TEST_CHECK( ! callStack.FindMethodAndParams("TexSubImage2D", "10, 10, 16, 16") );
- DALI_TEST_CHECK( ! callStack.FindMethodAndParams("TexSubImage2D", "11, 11, 6, 6") );
-
- END_TEST;
-}
-
-
-
-
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <unistd.h>
-#include <dali-test-suite-utils.h>
-#include <dali/devel-api/threading/conditional-wait.h>
-#include <dali/devel-api/threading/thread.h>
-
-using Dali::ConditionalWait;
-using Dali::Thread;
-
-namespace // for local variables to avoid name clashes
-{
-volatile int gGlobalValue = 0;
-volatile bool gWorkerThreadWait = true;
-enum ThreadState { INIT, RUN, TERMINATE } volatile gWorkerThreadState = INIT;
-ConditionalWait* volatile gConditionalWait; // volatile pointer to a ConditionalWait object
-
-class WorkerThreadNotify : public Thread
-{
- virtual void Run()
- {
- gGlobalValue = -1;
- while( gWorkerThreadWait ) // wait till we can exit
- {
- gWorkerThreadState = RUN;
- usleep( 1 ); // 1 microseconds
- }
- usleep( 200 ); // give other thread time to get to Wait
- gGlobalValue = 1;
- gConditionalWait->Notify();
- gWorkerThreadState = TERMINATE;
- }
-};
-
-volatile int gNotifyCount = 0;
-class WorkerThreadNotifyN : public Thread
-{
- virtual void Run()
- {
- while( gNotifyCount > 0 )
- {
- gConditionalWait->Notify();
- usleep( 10 ); // 10 microseconds between each notify
- }
- }
-};
-
-class WorkerThreadWaitN : public Thread
-{
- virtual void Run()
- {
- gConditionalWait->Wait();
- }
-};
-
-}
-
-int UtcConditionalWait1P(void)
-{
- tet_infoline("Testing ConditionalWait - scenario: wait - notify with 2 threads");
-
- WorkerThreadNotify thread1;
- // initialize values
- gConditionalWait = new ConditionalWait();
- gWorkerThreadWait = true;
- DALI_TEST_EQUALS( INIT, gWorkerThreadState, TEST_LOCATION );
- DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
-
- thread1.Start();
- // wait till the thread is in run state
- while( RUN != gWorkerThreadState )
- {
- usleep( 1 ); // 1 microsecond
- }
- // let worker continue and finish
- gWorkerThreadWait = false;
- gConditionalWait->Wait();
- DALI_TEST_EQUALS( 1, gGlobalValue, TEST_LOCATION );
- DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
-
- // wait till the thread is terminated state
- while( TERMINATE != gWorkerThreadState )
- {
- usleep( 1 ); // 1 microsecond
- }
-
- thread1.Join();
-
- delete gConditionalWait;
- END_TEST;
-}
-
-int UtcConditionalWait2P(void)
-{
- tet_infoline("Testing ConditionalWait - scenario: notify without wait");
-
- ConditionalWait wait;
- DALI_TEST_EQUALS( 0u, wait.GetWaitCount(), TEST_LOCATION );
- wait.Notify();
- DALI_TEST_EQUALS( 0u, wait.GetWaitCount(), TEST_LOCATION );
-
- END_TEST;
-}
-
-
-int UtcConditionalWait3P(void)
-{
- tet_infoline("Testing ConditionalWait - scenario: wait - notify N times 2 threads");
-
- // initialize values
- gConditionalWait = new ConditionalWait();
- gNotifyCount = 100;
-
- WorkerThreadNotifyN thread1;
- thread1.Start();
-
- while( gNotifyCount > 0 )
- {
- gConditionalWait->Wait();
- --gNotifyCount;
- DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
- usleep( 10 ); // 10 microseconds between each notify
- }
- DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
-
- thread1.Join();
-
- delete gConditionalWait;
- END_TEST;
-}
-
-int UtcConditionalWait4P(void)
-{
- tet_infoline("Testing ConditionalWait - scenario: wait - notify N times from 3 threads");
-
- // initialize values
- gConditionalWait = new ConditionalWait();
- gNotifyCount = 100;
-
- WorkerThreadNotifyN thread1;
- thread1.Start();
- WorkerThreadNotifyN thread2;
- thread2.Start();
- WorkerThreadNotifyN thread3;
- thread3.Start();
-
- while( gNotifyCount > 0 )
- {
- gConditionalWait->Wait();
- --gNotifyCount;
- DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
- usleep( 10 ); // 10 microseconds between each notify
- }
-
- thread1.Join();
- thread2.Join();
- thread3.Join();
-
- delete gConditionalWait;
- END_TEST;
-}
-
-int UtcConditionalWait5P(void)
-{
- tet_infoline("Testing ConditionalWait - scenario: 4 threads wait - notify once from 1 thread");
-
- // initialize values
- gConditionalWait = new ConditionalWait();
-
- WorkerThreadWaitN thread1;
- thread1.Start();
- WorkerThreadWaitN thread2;
- thread2.Start();
- WorkerThreadWaitN thread3;
- thread3.Start();
- WorkerThreadWaitN thread4;
- thread4.Start();
- // wait till all child threads are waiting
- while( gConditionalWait->GetWaitCount() < 4 )
- { }
-
- // notify once, it will resume all threads
- gConditionalWait->Notify();
-
- thread1.Join();
- thread2.Join();
- thread3.Join();
- thread4.Join();
-
- DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
-
- delete gConditionalWait;
- END_TEST;
-}
-
-int UtcConditionalWait6P(void)
-{
- tet_infoline("Testing ConditionalWait - scenario: 4 threads wait - notify once from 1 thread");
-
- // initialize values
- gConditionalWait = new ConditionalWait();
-
- WorkerThreadWaitN thread1;
- thread1.Start();
- WorkerThreadWaitN thread2;
- thread2.Start();
- WorkerThreadWaitN thread3;
- thread3.Start();
- WorkerThreadWaitN thread4;
- thread4.Start();
- // wait till all child threads are waiting
- while( gConditionalWait->GetWaitCount() < 4 )
- { }
-
- // notify once but with a scoped lock, it will resume all threads
- {
- ConditionalWait::ScopedLock lock( *gConditionalWait );
- gConditionalWait->Notify( lock );
- }
-
- thread1.Join();
- thread2.Join();
- thread3.Join();
- thread4.Join();
-
- DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
-
- delete gConditionalWait;
- END_TEST;
-}
-
-int UtcConditionalWaitNonCopyable(void)
-{
- // we want to make sure that ConditionalWait is not copyable (its copy constructor is not defined)
- // this test will stop compiling if ConditionalWait has compiler generated copy constructor
- DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( ConditionalWait ) );
-
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/animation/path-constrainer.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-using namespace Dali::Internal;
-
-namespace
-{
-
-static void SetupPath( Dali::Path& path)
-{
- path.AddPoint(Vector3( 30.0, 80.0, 0.0));
- path.AddPoint(Vector3( 70.0, 120.0, 0.0));
- path.AddPoint(Vector3(100.0, 100.0, 0.0));
-
- //Control points for first segment
- path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
- path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
-
- //Control points for second segment
- path.AddControlPoint(Vector3( 78.0, 120.0, 0.0) );
- path.AddControlPoint(Vector3( 93.0, 104.0, 0.0) );
-}
-
-static void SetupPathConstrainer( Dali::PathConstrainer& PathConstrainer)
-{
- PathConstrainer.SetProperty( Dali::PathConstrainer::Property::FORWARD, Vector3(1.0f,0.0f,0.0f) );
-
- Dali::Property::Array points;
- points.Resize(3);
- points[0] = Vector3( 30.0, 80.0, 0.0);
- points[1] = Vector3( 70.0, 120.0, 0.0);
- points[2] = Vector3(100.0, 100.0, 0.0);
- PathConstrainer.SetProperty( Dali::PathConstrainer::Property::POINTS, points );
-
- points.Resize(4);
- points[0] = Vector3( 39.0, 90.0, 0.0);
- points[1] = Vector3( 56.0, 119.0, 0.0);
- points[2] = Vector3( 78.0, 120.0, 0.0);
- points[3] = Vector3( 93.0, 104.0, 0.0);
- PathConstrainer.SetProperty( Dali::PathConstrainer::Property::CONTROL_POINTS, points );
-}
-
-static void SetupLinearConstrainerUniformProgress( Dali::LinearConstrainer& linearConstrainer)
-{
- Dali::Property::Array points;
- points.Resize(3);
- points[0] = 0.0f;
- points[1] = 1.0f;
- points[2] = 0.0f;
- linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
-}
-
-static void SetupLinearConstrainerNonUniformProgress( Dali::LinearConstrainer& linearConstrainer)
-{
- Dali::Property::Array points;
- points.Resize(3);
- points[0] = 0.0f;
- points[1] = 1.0f;
- points[2] = 0.0f;
- linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
-
- points[0] = 0.0f;
- points[1] = 0.25f;
- points[2] = 1.0f;
- linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::PROGRESS, points );
-}
-
-} // anonymous namespace
-
-//PathConstrainer test cases
-int UtcPathConstrainerApply(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
-
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a Path
- Dali::Path path = Dali::Path::New();
- SetupPath(path);
-
- //Create a PathConstrainer
- Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
- SetupPathConstrainer( pathConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
-
- //Create an animation to animate the custom property
- float durationSeconds(1.0f);
- Dali::Animation animation = Dali::Animation::New(durationSeconds);
- animation.AnimateTo(Dali::Property(actor,index),1.0f);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
-
- Vector3 position, tangent;
- path.Sample(0.2f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
- path.Sample(0.4f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
- path.Sample(0.6f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
- path.Sample(0.8f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
- path.Sample(1.0f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* beyond the animation duration*/);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcPathConstrainerApplyRange(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a Path
- Dali::Path path = Dali::Path::New();
- SetupPath(path);
-
- //Create a PathConstrainer
- Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
- SetupPathConstrainer( pathConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 100.0f, 300.0f );
- pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
-
-
- //Create an animation to animate the custom property
- float durationSeconds(1.0f);
- Dali::Animation animation = Dali::Animation::New(durationSeconds);
- animation.AnimateTo(Dali::Property(actor,index),400.0f);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
-
- Vector3 position, tangent;
- float tValue;
- actor.GetProperty(index).Get(tValue);
- float currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- actor.GetProperty(index).Get(tValue);
- currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- path.Sample(0.5, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- actor.GetProperty(index).Get(tValue);
- currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- actor.GetProperty(index).Get(tValue);
- currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
- actor.GetProperty(index).Get(tValue);
- currentCursor = ( tValue - range.x ) / (range.y-range.x);
- path.Sample(currentCursor, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcPathConstrainerDestroy(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- {
- //Create a Path
- Dali::Path path = Dali::Path::New();
- SetupPath(path);
-
- //Create a PathConstrainer
- Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
- SetupPathConstrainer( pathConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
-
- //Test that the constraint is correctly applied
- actor.SetProperty(index,0.5f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- Vector3 position, tangent;
- path.Sample(0.5f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- }
-
- //PathConstrainer has been destroyed. Constraint in the actor should have been removed
- actor.SetProperty(index,0.75f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcPathConstrainerRemove(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a Path
- Dali::Path path = Dali::Path::New();
- SetupPath(path);
-
- //Create a PathConstrainer
- Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
- SetupPathConstrainer( pathConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
-
- //Test that the constraint is correctly applied
- actor.SetProperty(index,0.5f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- Vector3 position, tangent;
- path.Sample(0.5f, position, tangent );
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
-
- //Remove constraint
- pathConstrainer.Remove( actor );
- actor.SetProperty(index,0.75f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
-
- END_TEST;
-}
-
-//LinearConstrainer test cases
-int UtcLinearConstrainerDownCast(void)
-{
- TestApplication application;
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
-
- BaseHandle handle( linearConstrainer );
- Dali::LinearConstrainer linearConstrainer2 = Dali::LinearConstrainer::DownCast( handle );
- DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
-
- BaseHandle handle2;
- Dali:: LinearConstrainer linearConstrainer3 = Dali::LinearConstrainer::DownCast( handle2 );
- DALI_TEST_EQUALS( (bool)linearConstrainer3, false, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerCopyConstructor(void)
-{
- TestApplication application;
- Dali::LinearConstrainer linearConstrainer;
- DALI_TEST_EQUALS( (bool)linearConstrainer, false, TEST_LOCATION );
-
- linearConstrainer = Dali::LinearConstrainer::New();
- DALI_TEST_EQUALS( (bool)linearConstrainer, true, TEST_LOCATION );
-
- // call the copy constructor
- Dali::LinearConstrainer linearConstrainer2( linearConstrainer );
- DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerApply(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
-
- Dali::Stage::GetCurrent().Add(actor);
-
-
- //Create a LinearConstrainer without specifying progress for values
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
- SetupLinearConstrainerUniformProgress( linearConstrainer );
-
- //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
- //Create an animation to animate the custom property
- float durationSeconds(1.0f);
- Dali::Animation animation = Dali::Animation::New(durationSeconds);
- animation.AnimateTo(Dali::Property(actor,index),1.0f);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- //Setup a LinearConstrainer specifying the progress for each value
- linearConstrainer.Remove(actor);
- SetupLinearConstrainerNonUniformProgress( linearConstrainer );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
- actor.SetProperty(index,0.0f);
- animation.Play();
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 2.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerApplyRange(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 100.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a LinearConstrainer
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
- SetupLinearConstrainerUniformProgress( linearConstrainer );
-
- //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 100.0f, 300.0f );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
-
- //Create an animation to animate the custom property
- float durationSeconds(1.0f);
- Dali::Animation animation = Dali::Animation::New(durationSeconds);
- animation.AnimateTo(Dali::Property(actor,index),300.0f);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerDestroy(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- {
- //Create a LinearConstrainer
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
- SetupLinearConstrainerUniformProgress( linearConstrainer );
-
- //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
- //Test that the constraint is correctly applied
- actor.SetProperty(index,0.5f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- }
-
- //LinearConstrainer has been destroyed. Constraint in the actor should have been removed
- actor.SetProperty(index,0.75f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcLinearConstrainerRemove(void)
-{
- TestApplication application;
-
- Dali::Actor actor = Dali::Actor::New();
-
- // Register a float property
- Property::Index index = actor.RegisterProperty( "t", 0.0f );
- Dali::Stage::GetCurrent().Add(actor);
-
- //Create a LinearConstrainer
- Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
- SetupLinearConstrainerUniformProgress( linearConstrainer );
-
- //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
- Vector2 range( 0.0f, 1.0f );
- linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
-
- //Test that the constraint is correctly applied
- actor.SetProperty(index,0.5f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
-
- //Remove constraint
- linearConstrainer.Remove( actor );
- actor.SetProperty(index,0.75f);
- application.SendNotification();
- application.Render(static_cast<unsigned int>(1.0f));
-
- DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-
-namespace
-{
-// Size of the VertexAttributeArray enables
-// GLES specification states that there's a minimum of 8
-const unsigned int TEST_MAX_ATTRIBUTE_CACHE_SIZE = 8;
-
-enum TestAttribType
-{
- ATTRIB_UNKNOWN = -1,
- ATTRIB_POSITION,
- ATTRIB_NORMAL,
- ATTRIB_TEXCOORD,
- ATTRIB_COLOR,
- ATTRIB_BONE_WEIGHTS,
- ATTRIB_BONE_INDICES,
- ATTRIB_TYPE_LAST
-};
-
-// Create bitmap actor
-static Actor CreateBitmapActor()
-{
- BufferImage image = BufferImage::New(4,4,Pixel::RGBA8888);
- Actor actor = CreateRenderableActor( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetName("Test Image Rendering Actor");
- return actor;
-}
-
-} // anonymous namespace
-
-
-// Positive test case for a method
-int UtcDaliContextVertexAttribStartup(void)
-{
- tet_infoline("Testing vertex attrib initial state in context");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // check the locations
- for (unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++)
- {
- DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(i) == false);
- }
-
- tet_result(TET_PASS);
- END_TEST;
-}
-
-// Tests to make the attribs only get set once when continually rendering an image actor
-int UtcDaliContextVertexAttribImageRendering(void)
-{
- tet_infoline("Testing vertex attrib rendering state in context with images");
-
- TestApplication application;
-
- // start up
- application.SendNotification();
- application.Render();
- application.Render();
-
- // the vertex attribs get modified on startup to set them to disabled
- // clear the flag to say they've changed
- application.GetGlAbstraction().ClearVertexAttribArrayChanged();
-
-
- // create a test bitmap actor
- Actor actor(CreateBitmapActor());
- Stage::GetCurrent().Add(actor);
-
-
- application.SendNotification();
- application.Render();
- application.Render();
-
- // check to make sure the state has changed (the image renderer will enable some
- // locations).
- DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
-
- // Now check to make sure the state is cached, and isn't being set each frame.
- application.GetGlAbstraction().ClearVertexAttribArrayChanged();
-
- application.Render();
- application.Render();
- application.Render();
-
- // if it has changed then the caching has failed
- DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged() == false);
-
-
- tet_result(TET_PASS);
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <algorithm>
-
-#include <stdlib.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/images/distance-field.h>
-#include <dali-test-suite-utils.h>
-
-using std::max;
-using namespace Dali;
-
-namespace
-{
-
-static const float ROTATION_EPSILON = 0.0001f;
-
-static unsigned char sourceImage[] =
-{
- 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-
-} // anonymous namespace
-
-
-
-int UtcDaliGenerateDistanceField(void)
-{
- unsigned char distanceField[4*4];
-
- GenerateDistanceFieldMap(sourceImage, Size(8.0f, 8.0f), distanceField, Size(4.0f, 4.0f), 0, Size(4.0f, 4.0f));
-
- if(distanceField[0] <= distanceField[5] &&
- distanceField[5] <= distanceField[10] &&
- distanceField[10] <= distanceField[15])
- {
- tet_result(TET_PASS);
- }
- else
- {
- tet_result(TET_FAIL);
- }
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <string>
-#include <stdlib.h>
-#include <dali/devel-api/common/hash.h>
-#include <dali-test-suite-utils.h>
-
-void utc_dali_hash_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_hash_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliHash(void)
-{
- // To fully test the Hash distribution we need to use a tool like http://code.google.com/p/smhasher/
- // DALi currently uses the hash for variable length strings which come from:
- // shader vert+frag source, font family + style, image filename.
- TestApplication application;
-
- tet_infoline("UtcDaliHash");
-
- const std::string testString1( "highp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
- const std::string testString2( "lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
-
- DALI_TEST_CHECK( Dali::CalculateHash( testString1 ) != Dali::CalculateHash( testString2 ) );
- DALI_TEST_CHECK( Dali::CalculateHash( testString1, testString2 ) != Dali::CalculateHash( testString2, testString1 ) );
-
- END_TEST;
-}
-
-int UtcDaliHashNegative(void)
-{
- // negative test, check hash value == initial value
- const std::string emptyString;
-
- DALI_TEST_CHECK( Dali::CalculateHash( emptyString ) != 0 );
- DALI_TEST_CHECK( Dali::CalculateHash( emptyString, emptyString ) != 0 );
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/events/hit-test-algorithm.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-namespace
-{
-
-/**
- * The functor to be used in the hit-test algorithm to check whether the actor is hittable.
- */
-bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
-{
- bool hittable = false;
-
- switch (type)
- {
- case Dali::HitTestAlgorithm::CHECK_ACTOR:
- {
- // Check whether the actor is visible and not fully transparent.
- if( actor.IsVisible()
- && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
- {
- // Check whether the actor has the specific name "HittableActor"
- if(actor.GetName() == "HittableActor")
- {
- hittable = true;
- }
- }
- break;
- }
- case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
- {
- if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
- {
- hittable = true;
- }
- break;
- }
- default:
- {
- break;
- }
- }
-
- return hittable;
-};
-
-
-bool DefaultIsActorTouchableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::TraverseType type)
-{
- bool hittable = false;
-
- switch (type)
- {
- case Dali::HitTestAlgorithm::CHECK_ACTOR:
- {
- if( actor.IsVisible() &&
- actor.IsSensitive() &&
- actor.GetCurrentWorldColor().a > 0.01f)
- {
- hittable = true;
- }
- break;
- }
- case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
- {
- if( actor.IsVisible() && // Actor is visible, if not visible then none of its children are visible.
- actor.IsSensitive()) // Actor is sensitive, if insensitive none of its children should be hittable either.
- {
- hittable = true;
- }
- break;
- }
- default:
- {
- break;
- }
- }
-
- return hittable;
-};
-
-} // anonymous namespace
-
-
-// Positive test case for a method
-int UtcDaliHitTestAlgorithmWithFunctor(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm functor");
-
- Stage stage = Stage::GetCurrent();
-
- Actor actor = Actor::New();
- actor.SetSize(100.0f, 100.0f);
- actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- actor.SetName("NonHittableActor");
- stage.Add(actor);
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- Vector2 screenCoordinates( 10.0f, 10.0f );
- Vector2 localCoordinates;
- actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
-
- // Perform a hit-test at the given screen coordinates
- Dali::HitTestAlgorithm::Results results;
- Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor != actor );
-
- actor.SetName("HittableActor");
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
-
- // Perform a hit-test at the given screen coordinates
- Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor );
- DALI_TEST_EQUALS( localCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliHitTestAlgorithmWithFunctorOnRenderTask(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm functor, specific to a given render task");
-
- Stage stage = Stage::GetCurrent();
- Size stageSize = stage.GetSize();
- RenderTaskList taskList = stage.GetRenderTaskList();
-
- Actor actor[2];
-
- for( int i=0; i<2; i++ )
- {
- actor[i] = Actor::New();
- actor[i].SetSize(100.f, 100.f);
- actor[i].SetParentOrigin(ParentOrigin::TOP_LEFT);
- actor[i].SetAnchorPoint(AnchorPoint::TOP_LEFT);
- actor[i].SetName("HittableActor");
- stage.Add(actor[i]);
- }
- Vector2 position( 50.f, 40.f );
- actor[1].SetPosition( position.x, position.y );
-
- RenderTask renderTask[2];
- renderTask[0] = taskList.GetTask( 0u );
-
- FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width, stageSize.height, Pixel::A8, Image::NEVER);
- renderTask[1] = taskList.CreateTask();
- renderTask[1].SetSourceActor( actor[1] );
- renderTask[1].SetExclusive( true );
- renderTask[1].SetInputEnabled( true );
- renderTask[1].SetTargetFrameBuffer( frameBufferImage );
- renderTask[1].SetRefreshRate( RenderTask::REFRESH_ONCE );
- renderTask[1].SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
- application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
-
- // Render and notify
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- // Perform a hit-test at the given screen coordinates with different render tasks
-
- Dali::HitTestAlgorithm::Results results;
- Vector2 screenCoordinates( 25.f, 25.f );
-
- Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor[0] );
- DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( !results.actor );
- DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
- screenCoordinates.x = 80.f;
- screenCoordinates.y = 70.f;
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor[0] );
- DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor[1]);
- DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
- screenCoordinates.x = 120.f;
- screenCoordinates.y = 130.f;
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( !results.actor );
- DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
-
- results.actor = Actor();
- results.actorCoordinates = Vector2::ZERO;
- Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
- DALI_TEST_CHECK( results.actor == actor[1]);
- DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
- END_TEST;
-}
-
-
-int UtcDaliHitTestAlgorithmOrtho01(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm with parallel Ortho camera()");
-
- Stage stage = Stage::GetCurrent();
- RenderTaskList renderTaskList = stage.GetRenderTaskList();
- RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
- Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
-
- Vector2 stageSize ( stage.GetSize() );
- cameraActor.SetOrthographicProjection( stageSize );
- cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
-
- Vector2 actorSize( stageSize * 0.5f );
- // Create two actors with half the size of the stage and set them to be partially overlapping
- Actor blue = Actor::New();
- blue.SetName( "Blue" );
- blue.SetAnchorPoint( AnchorPoint::CENTER );
- blue.SetParentOrigin( Vector3(1.0f/3.0f, 1.0f/3.0f, 0.5f) );
- blue.SetSize( actorSize );
- blue.SetZ(30.0f);
-
- Actor green = Actor::New( );
- green.SetName( "Green" );
- green.SetAnchorPoint( AnchorPoint::CENTER );
- green.SetParentOrigin( Vector3(2.0f/3.0f, 2.0f/3.0f, 0.5f) );
- green.SetSize( actorSize );
-
- // Add the actors to the view
- stage.Add( blue );
- stage.Add( green );
-
- // Render and notify
- application.SendNotification();
- application.Render(0);
- application.Render(10);
-
- HitTestAlgorithm::Results results;
- HitTest(stage, stageSize / 2.0f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == green );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 1.0f/6.0f, TEST_LOCATION );
-
- HitTest(stage, stageSize / 3.0f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == blue );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
-
- HitTest(stage, stageSize * 2.0f / 3.0f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == green );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
- END_TEST;
-}
-
-
-int UtcDaliHitTestAlgorithmOrtho02(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm with offset Ortho camera()");
-
- Stage stage = Stage::GetCurrent();
- RenderTaskList renderTaskList = stage.GetRenderTaskList();
- RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
- Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
-
- Vector2 stageSize ( stage.GetSize() );
- cameraActor.SetOrthographicProjection(-stageSize.x * 0.3f, stageSize.x * 0.7f,
- stageSize.y * 0.3f, -stageSize.y * 0.7f,
- 800.0f, 4895.0f);
- cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
-
- Vector2 actorSize( stageSize * 0.5f );
- // Create two actors with half the size of the stage and set them to be partially overlapping
- Actor blue = Actor::New();
- blue.SetName( "Blue" );
- blue.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- blue.SetParentOrigin( Vector3(0.2f, 0.2f, 0.5f) );
- blue.SetSize( actorSize );
- blue.SetZ(30.0f);
-
- Actor green = Actor::New( );
- green.SetName( "Green" );
- green.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- green.SetParentOrigin( Vector3(0.4f, 0.4f, 0.5f) );
- green.SetSize( actorSize );
-
- // Add the actors to the view
- stage.Add( blue );
- stage.Add( green );
-
- // Render and notify
- application.SendNotification();
- application.Render(0);
- application.Render(10);
-
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == green );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.6f, 0.01f, TEST_LOCATION );
- }
-
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, Vector2( 0.001f, 0.001f ), results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == blue );
- DALI_TEST_EQUALS( results.actorCoordinates, Vector2( 0.001f, 0.001f ), 0.001f, TEST_LOCATION );
- }
-
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, stageSize, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( ! results.actor );
- DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION );
- }
-
- // Just inside green
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, stageSize*0.69f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == green );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.98f, 0.01f, TEST_LOCATION );
- }
-
- END_TEST;
-}
-
-int UtcDaliHitTestAlgorithmStencil(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm with a stencil");
-
- Stage stage = Stage::GetCurrent();
- Actor rootLayer = stage.GetRootLayer();
- rootLayer.SetName( "RootLayer" );
-
- // Create a layer
- Layer layer = Layer::New();
- layer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- layer.SetParentOrigin( ParentOrigin::TOP_LEFT );
- layer.SetName( "layer" );
- stage.Add( layer );
-
- // Create a stencil and add that to the layer
- Actor stencil = CreateRenderableActor(Dali::BufferImage::WHITE() );
- stencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- stencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
- stencil.SetSize( 50.0f, 50.0f );
- stencil.SetDrawMode( DrawMode::STENCIL );
- stencil.SetName( "stencil" );
- layer.Add( stencil );
-
- // Create a renderable actor and add that to the layer
- Actor layerHitActor = CreateRenderableActor( Dali::BufferImage::WHITE() );
- layerHitActor.SetSize( 100.0f, 100.0f );
- layerHitActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- layerHitActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- layerHitActor.SetName( "layerHitActor" );
- layer.Add( layerHitActor );
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- // Hit within stencil and actor
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, Vector2( 10.0f, 10.0f ), results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == layerHitActor );
- tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
- }
-
- // Hit within actor but outside of stencil, should hit the root-layer
- {
- HitTestAlgorithm::Results results;
- HitTest(stage, Vector2( 60.0f, 60.0f ), results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == rootLayer );
- tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
- }
- END_TEST;
-}
-
-int UtcDaliHitTestAlgorithmOverlay(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::HitTestAlgorithm with overlay actors");
-
- Stage stage = Stage::GetCurrent();
- RenderTaskList renderTaskList = stage.GetRenderTaskList();
- RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
- Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
-
- Vector2 stageSize ( stage.GetSize() );
- cameraActor.SetOrthographicProjection( stageSize );
- cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
-
- Vector2 actorSize( stageSize * 0.5f );
- // Create two actors with half the size of the stage and set them to be partially overlapping
- Actor blue = Actor::New();
- blue.SetDrawMode( DrawMode::OVERLAY_2D );
- blue.SetName( "Blue" );
- blue.SetAnchorPoint( AnchorPoint::CENTER );
- blue.SetParentOrigin( Vector3(1.0f/3.0f, 1.0f/3.0f, 0.5f) );
- blue.SetSize( actorSize );
- blue.SetZ(30.0f);
-
- Actor green = Actor::New( );
- green.SetName( "Green" );
- green.SetAnchorPoint( AnchorPoint::CENTER );
- green.SetParentOrigin( Vector3(2.0f/3.0f, 2.0f/3.0f, 0.5f) );
- green.SetSize( actorSize );
-
- // Add the actors to the view
- stage.Add( blue );
- stage.Add( green );
-
- // Render and notify
- application.SendNotification();
- application.Render(0);
- application.Render(10);
-
- HitTestAlgorithm::Results results;
-
- //Hit in the intersection. Should pick the blue actor since it is an overlay.
- HitTest(stage, stageSize / 2.0f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == blue );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 5.0f/6.0f, TEST_LOCATION );
-
- //Hit in the blue actor
- HitTest(stage, stageSize / 3.0f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == blue );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
-
- //Hit in the green actor
- HitTest(stage, stageSize * 2.0f / 3.0f, results, &DefaultIsActorTouchableFunction);
- DALI_TEST_CHECK( results.actor == green );
- DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <unistd.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/threading/mutex.h>
-#include <dali/devel-api/threading/thread.h>
-#include <dali-test-suite-utils.h>
-
-using Dali::Mutex;
-using Dali::Thread;
-
-int UtcDaliMutexSingleThread(void)
-{
- tet_infoline("Testing Dali::Mutex in a single thread");
-
- {
- Mutex mutex1;
- DALI_TEST_EQUALS( false, mutex1.IsLocked(), TEST_LOCATION );
- }
-
- {
- Mutex mutex2;
- Mutex::ScopedLock lock( mutex2 );
- DALI_TEST_EQUALS( true, mutex2.IsLocked(), TEST_LOCATION );
- }
-
- Mutex mutex3;
- {
- Mutex::ScopedLock lock( mutex3 );
- }
- DALI_TEST_EQUALS( false, mutex3.IsLocked(), TEST_LOCATION );
-
- END_TEST;
-}
-
-namespace // for local variables to avoid name clashes
-{
-// make all these volatile to pre-empt any optimization screwing up the logic
-volatile int gGlobalValue = 0;
-volatile bool gWorkerThreadWait = true;
-volatile enum ThreadState { INIT, RUN, LOCKING, TERMINATE } gWorkerThreadState = INIT;
-Mutex* volatile gGlobalValueMutex; // volatile pointer to a mutex object
-
-class TestThread : public Thread
-{
- virtual void Run()
- {
- gWorkerThreadState = RUN;
- {
- Mutex::ScopedLock lock( *gGlobalValueMutex );
- gWorkerThreadState = LOCKING;
- gGlobalValue = -1;
- while( gWorkerThreadWait ) // wait till we can exit
- {
- usleep( 1 ); // 1 microsecond
- }
- }
- gWorkerThreadState = TERMINATE;
- }
-};
-}
-
-int UtcDaliMutexMultiThread(void)
-{
- tet_infoline("Testing Dali::Mutex multithreaded");
-
- gGlobalValueMutex = new Dali::Mutex();
-
- TestThread thread1;
- // initialize values
- gGlobalValue = 0;
- gWorkerThreadWait = true;
- DALI_TEST_EQUALS( INIT, gWorkerThreadState, TEST_LOCATION );
- DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
- DALI_TEST_EQUALS( false, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
-
- // lock the mutex
- {
- Mutex::ScopedLock lock( *gGlobalValueMutex );
- DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
- thread1.Start();
- // wait till the thread is in run state
- while( RUN != gWorkerThreadState )
- {
- usleep( 1 ); // 1 microsecond
- }
- // now the thread is running and mutex is still locked by this thread so value is not changed
- DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
- DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
- // drop out of scope, releases our lock
- }
- // now child thread is allowed to change the value
- // wait till the thread is in locking state
- while( LOCKING != gWorkerThreadState )
- {
- usleep( 1 ); // 1 microsecond
- }
- // mutex is locked, but not by us, by the child thread
- DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
- // value is changed
- DALI_TEST_EQUALS( -1, gGlobalValue, TEST_LOCATION );
- // let worker finish
- gWorkerThreadWait = false;
- // wait till the thread is terminated state
- while( TERMINATE != gWorkerThreadState )
- {
- usleep( 1 ); // 1 microsecond
- }
- DALI_TEST_EQUALS( false, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
- thread1.Join();
-
- END_TEST;
-}
-
-int UtcDaliMutexNonCopyable(void)
-{
- // we want to make sure that mutex is not copyable (its copy constructor is not defined)
- // this test will stop compiling if Mutex has compiler generated copy constructor
- DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( Mutex ) );
-
- DALI_TEST_CHECK( true );
- END_TEST;
-}
-
-
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/scripting/scripting.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-using namespace Dali::Scripting;
-
-namespace
-{
-
-const StringEnum COLOR_MODE_VALUES[] =
-{
- { "USE_OWN_COLOR", USE_OWN_COLOR },
- { "USE_PARENT_COLOR", USE_PARENT_COLOR },
- { "USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR },
- { "USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA },
-};
-const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] );
-
-const StringEnum POSITION_INHERITANCE_MODE_VALUES[] =
-{
- { "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION },
- { "USE_PARENT_POSITION", USE_PARENT_POSITION },
- { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION },
- { "DONT_INHERIT_POSITION", DONT_INHERIT_POSITION },
-};
-const unsigned int POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_MODE_VALUES[0] );
-
-const StringEnum DRAW_MODE_VALUES[] =
-{
- { "NORMAL", DrawMode::NORMAL },
- { "OVERLAY_2D", DrawMode::OVERLAY_2D },
- { "STENCIL", DrawMode::STENCIL },
-};
-const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] );
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Helpers for string to enum comparisons for Image and Image loading parameters
-////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Template to check enumerations of type T, with a class of type X
- */
-template< typename T, typename X >
-void TestEnumStrings(
- Property::Map& map, // The map used to create instance of type X
- const char * const keyName, // the name of the key to iterate through
- const StringEnum* values, // An array of string values
- unsigned int num, // Number of items in the array
- T ( X::*method )() const, // The member method of X to call to get the enum
- X ( *creator ) ( const Property::Value& ) // The method which creates an instance of type X
-)
-{
- // get the key reference so we can change its value
- Property::Value* value = map.Find( keyName );
- for ( unsigned int i = 0; i < num; ++i )
- {
- *value = values[i].string;
- tet_printf("Checking: %s: %s\n", keyName, values[i].string );
- X instance = creator( map );
- DALI_TEST_EQUALS( values[i].value, (int)( instance.*method )(), TEST_LOCATION );
- }
-}
-
-/// Helper method to create ResourceImage using property
-ResourceImage NewResourceImage( const Property::Value& map )
-{
- ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
- return image;
-}
-
-/// Helper method to create ResourceImage using property
-BufferImage NewBufferImage( const Property::Value& map )
-{
- BufferImage image = BufferImage::DownCast( NewImage( map ) );
- return image;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Helpers for string to enum comparisons for Actor to Property::Map
-//////////////////////////////////////////////////////////////////////////////
-
-/**
- * Template to check enumerations of type T
- */
-template< typename T >
-void TestEnumStrings(
- const char * const keyName, // The name of the key to check
- TestApplication& application, // Reference to the application class
- const StringEnum* values, // An array of string values
- unsigned int num, // Number of items in the array
- void ( Actor::*method )( T ) // The Actor member method to set the enumeration
-)
-{
- for ( unsigned int i = 0; i < num; ++i )
- {
- tet_printf("Checking: %s: %s\n", keyName, values[i].string );
-
- Actor actor = Actor::New();
- (actor.*method)( ( T ) values[i].value );
-
- Stage::GetCurrent().Add( actor );
- application.SendNotification();
- application.Render();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
-
- DALI_TEST_CHECK( 0 < map.Count() );
- DALI_TEST_CHECK( NULL != map.Find( keyName ) );
- DALI_TEST_EQUALS( map.Find( keyName )->Get< std::string >(), values[i].string, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-
-} // anon namespace
-
-int UtcDaliScriptingNewImageNegative01(void)
-{
- // Invalid filename
- Property::Map map;
- map[ "filename" ] = Vector3::ZERO;
- // will give us an empty image handle
- Image image = NewImage( map );
- DALI_TEST_CHECK( !image );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative02(void)
-{
- TestApplication application; // Image needs application
- // Invalid load-policy value type
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "loadPolicy" ] = Vector3::ZERO;
- // will give us a valid image handle with default load policy
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetLoadPolicy(), ResourceImage::IMMEDIATE, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative03(void)
-{
- TestApplication application; // Image needs application
- // Invalid load-policy value
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "loadPolicy" ] = "INVALID";
- // will give us a valid image with default load policy
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetLoadPolicy(), ResourceImage::IMMEDIATE, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative04(void)
-{
- TestApplication application; // Image needs application
- // Invalid release-policy value type
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "releasePolicy" ] = Vector3::ZERO;
- // will give us a valid image with default release policy
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative05(void)
-{
- TestApplication application; // Image needs application
- // Invalid release-policy value
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "releasePolicy" ] = "INVALID";
- // will give us a valid image with default release policy
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative06(void)
-{
- TestApplication application; // Image needs application
- // Invalid width and height
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "width" ] = "Invalid";
- map[ "height" ] = 100;
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetWidth(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( resImage.GetHeight(), 100u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative07(void)
-{
- TestApplication application; // Image needs application
- // Invalid height
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "width" ] = 10;
- map[ "height" ] = "Invalid";
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- DALI_TEST_EQUALS( resImage.GetWidth(), 10u, TEST_LOCATION );
- DALI_TEST_EQUALS( resImage.GetHeight(), 0u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative08(void)
-{
- TestApplication application; // Image needs application
- // Invalid fitting-mode
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "fittingMode" ] = Vector3::ZERO;
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative09(void)
-{
- TestApplication application; // Image needs application
- // Invalid value
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "fittingMode" ] = "INVALID";
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative10(void)
-{
- TestApplication application; // Image needs application
- // Invalid scaling-mode
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "samplingMode" ] = Vector3::ZERO;
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative12(void)
-{
- TestApplication application; // Image needs application
- // Invalid orientation-correction
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "orientation" ] = Vector3::ZERO;
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative13(void)
-{
- TestApplication application; // Image needs application
- // Invalid type
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
- map[ "type" ] = Vector3::ZERO;
- // will give us a valid image
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- ResourceImage resImage = ResourceImage::DownCast( image );
- DALI_TEST_CHECK( resImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative14(void)
-{
- // Invalid value
- Property::Map map;
- map[ "type" ] = "INVALID";
- Image image = NewImage( map );
- DALI_TEST_CHECK( !image );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative15(void)
-{
- // Invalid pixel-format
- Property::Map map;
- map[ "pixelFormat" ] = Vector3::ZERO;
- Image image = NewImage( map );
- DALI_TEST_CHECK( !image );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImageNegative16(void)
-{
- // Invalid value
- Property::Map map;
- map[ "pixelFormat" ] = "INVALID";
- Image image = NewImage( map );
- DALI_TEST_CHECK( !image );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage01P(void)
-{
- TestApplication application; // Image needs application
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // Filename only
- ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
- DALI_TEST_EQUALS( "TEST_FILE", image.GetUrl(), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage02P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // load-policy
- map[ "loadPolicy" ] = "";
- const StringEnum values[] =
- {
- { "IMMEDIATE", ResourceImage::IMMEDIATE },
- { "ON_DEMAND", ResourceImage::ON_DEMAND }
- };
- TestEnumStrings< ResourceImage::LoadPolicy, ResourceImage >( map, "loadPolicy", values, ( sizeof( values ) / sizeof ( values[0] ) ), &ResourceImage::GetLoadPolicy, &NewResourceImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage03P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // release-policy
- map[ "releasePolicy" ] = "";
- const StringEnum values[] =
- {
- { "UNUSED", Image::UNUSED },
- { "NEVER", Image::NEVER }
- };
- TestEnumStrings< Image::ReleasePolicy, Image >( map, "releasePolicy", values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage04P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // float width and height
- map[ "width" ] = (float) 10.0f;
- map[ "height" ] = (float) 20.0f;
- Image image = NewImage( map );
- DALI_TEST_EQUALS( image.GetWidth(), 10u, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 20u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage05P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "filename" ] = "TEST_FILE";
-
- // width and height
- map[ "width"] = 50;
- map[ "height" ] = 70;
- Image image = NewImage( map );
- DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
- DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage06P(void)
-{
- TestApplication application;
-
- Property::Map map;
- // type FrameBufferImage
- map[ "type" ] = "FrameBufferImage";
- // width and height
- map[ "width"] = 50;
- map[ "height" ] = 70;
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage07P(void)
-{
- TestApplication application;
-
- Property::Map map;
- // type BufferImage
- map[ "type" ] = "BufferImage";
- // width and height
- map[ "width"] = 50;
- map[ "height" ] = 70;
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- DALI_TEST_CHECK( BufferImage::DownCast( image ) );
- DALI_TEST_EQUALS( (BufferImage::DownCast( image )).GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage08P(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "type" ] = "BufferImage";
- // width and height
- map[ "width"] = 66;
- map[ "height" ] = 99;
- // pixel-format
- map[ "pixelFormat" ] = "";
- const StringEnum values[] =
- {
- { "A8", Pixel::A8 },
- { "L8", Pixel::L8 },
- { "LA88", Pixel::LA88 },
- { "RGB565", Pixel::RGB565 },
- { "BGR565", Pixel::BGR565 },
- { "RGBA4444", Pixel::RGBA4444 },
- { "BGRA4444", Pixel::BGRA4444 },
- { "RGBA5551", Pixel::RGBA5551 },
- { "BGRA5551", Pixel::BGRA5551 },
- { "RGB888", Pixel::RGB888 },
- { "RGB8888", Pixel::RGB8888 },
- { "BGR8888", Pixel::BGR8888 },
- { "RGBA8888", Pixel::RGBA8888 },
- { "BGRA8888", Pixel::BGRA8888 },
- // BufferImage does not support compressed formats
- };
- TestEnumStrings< Pixel::Format, BufferImage >( map, "pixelFormat", values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
-
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage09P(void)
-{
- TestApplication application;
-
- Property::Map map;
- // type Image
- map[ "type" ] = "ResourceImage";
- map[ "filename" ] = "TEST_FILE";
-
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( ResourceImage::DownCast( image ) );
- DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
- DALI_TEST_CHECK( !BufferImage::DownCast( image ) );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingNewImage10P(void)
-{
- TestApplication application;
-
- Property::Map map;
- // type FrameBufferImage, empty size gives us stage size
- map[ "type" ] = "FrameBufferImage";
- Image image = NewImage( map );
- DALI_TEST_CHECK( image );
- END_TEST;
-}
-
-int UtcDaliScriptingNewActorNegative(void)
-{
- TestApplication application;
-
- // Empty map
- {
- Actor handle = NewActor( Property::Map() );
- DALI_TEST_CHECK( !handle );
- }
-
- // Map with only properties
- {
- Property::Map map;
- map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER;
- map[ "anchorPoint" ] = AnchorPoint::TOP_CENTER;
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( !handle );
- }
-
- // Add some signals to the map, we should have no signal connections as its not yet supported
- {
- Property::Map map;
- map[ "type" ] = "Actor";
- map[ "signals" ] = Property::MAP;
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
- DALI_TEST_CHECK( !handle.WheelEventSignal().GetConnectionCount() );
- DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() );
- DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() );
- DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingNewActorProperties(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "type" ] = "Actor";
- map[ "size" ] = Vector3::ONE;
- map[ "position" ] = Vector3::XAXIS;
- map[ "scale" ] = Vector3::ONE;
- map[ "visible" ] = false;
- map[ "color" ] = Color::MAGENTA;
- map[ "name" ] = "MyActor";
- map[ "colorMode" ] = "USE_PARENT_COLOR";
- map[ "sensitive" ] = false;
- map[ "leaveRequired" ] = true;
- map[ "positionInheritance" ] = "DONT_INHERIT_POSITION";
- map[ "drawMode" ] = "STENCIL";
- map[ "inheritOrientation" ] = false;
- map[ "inheritScale" ] = false;
-
- // Default properties
- {
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
-
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( handle.GetCurrentSize(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsVisible(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetName(), "MyActor", TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsSensitive(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetLeaveRequired(), true, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsOrientationInherited(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
- }
-
- // Check Anchor point and parent origin vector3s
- map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER;
- map[ "anchorPoint" ] = AnchorPoint::TOP_LEFT;
- {
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
-
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
- }
-
- // Check Anchor point and parent origin STRINGS
- map[ "parentOrigin" ] = "TOP_LEFT";
- map[ "anchorPoint" ] = "CENTER_LEFT";
- {
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
-
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingNewActorChildren(void)
-{
- TestApplication application;
-
- Property::Map map;
- map[ "type" ] = "Actor";
- map[ "position" ] = Vector3::XAXIS;
-
- Property::Map child1Map;
- child1Map[ "type" ] = "CameraActor";
- child1Map[ "position" ] = Vector3::YAXIS;
-
- Property::Array childArray;
- childArray.PushBack( child1Map );
- map[ "actors" ] = childArray;
-
- // Create
- Actor handle = NewActor( map );
- DALI_TEST_CHECK( handle );
-
- Stage::GetCurrent().Add( handle );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( handle.GetChildCount(), 1u, TEST_LOCATION );
-
- Actor child1 = handle.GetChildAt(0);
- DALI_TEST_CHECK( child1 );
- DALI_TEST_CHECK( CameraActor::DownCast( child1 ) );
- DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION );
- DALI_TEST_EQUALS( child1.GetChildCount(), 0u, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( handle );
- END_TEST;
-}
-
-
-int UtcDaliScriptingCreatePropertyMapActor(void)
-{
- TestApplication application;
-
- // Actor Type
- {
- Actor actor = Actor::New();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( !map.Empty() );
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type")->Get< std::string >(), "Actor", TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
-
- // Layer Type
- {
- Actor actor = Layer::New();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( !map.Empty() );
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
-
- // Default properties
- {
- Actor actor = Actor::New();
- actor.SetSize( Vector3::ONE );
- actor.SetPosition( Vector3::XAXIS );
- actor.SetScale( Vector3::ZAXIS );
- actor.SetVisible( false );
- actor.SetColor( Color::MAGENTA );
- actor.SetName( "MyActor" );
- actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
- actor.SetParentOrigin( ParentOrigin::TOP_RIGHT );
- actor.SetSensitive( false );
- actor.SetLeaveRequired( true );
- actor.SetInheritOrientation( false );
- actor.SetInheritScale( false );
- actor.SetSizeModeFactor( Vector3::ONE );
-
- Stage::GetCurrent().Add( actor );
- application.SendNotification();
- application.Render();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
-
- DALI_TEST_CHECK( !map.Empty() );
- DALI_TEST_CHECK( NULL != map.Find( "size" ) );
- DALI_TEST_EQUALS( map.Find( "size" )->Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "position" ) );
- DALI_TEST_EQUALS( map.Find( "position" )->Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "scale" ) );
- DALI_TEST_EQUALS( map.Find( "scale" )->Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "visible" ) );
- DALI_TEST_EQUALS( map.Find( "visible" )->Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "color" ) );
- DALI_TEST_EQUALS( map.Find( "color" )->Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "name" ) );
- DALI_TEST_EQUALS( map.Find( "name")->Get< std::string >(), "MyActor", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "anchorPoint" ) );
- DALI_TEST_EQUALS( map.Find( "anchorPoint" )->Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "parentOrigin" ) );
- DALI_TEST_EQUALS( map.Find( "parentOrigin" )->Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "sensitive" ) );
- DALI_TEST_EQUALS( map.Find( "sensitive" )->Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "leaveRequired" ) );
- DALI_TEST_EQUALS( map.Find( "leaveRequired" )->Get< bool >(), true, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "inheritOrientation" ) );
- DALI_TEST_EQUALS( map.Find( "inheritOrientation" )->Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "inheritScale" ) );
- DALI_TEST_EQUALS( map.Find( "inheritScale" )->Get< bool >(), false, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "sizeModeFactor" ) );
- DALI_TEST_EQUALS( map.Find( "sizeModeFactor" )->Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
-
- // ColorMode
- TestEnumStrings< ColorMode >( "colorMode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode );
-
- // PositionInheritanceMode
- TestEnumStrings< PositionInheritanceMode >( "positionInheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode );
-
- // DrawMode
- TestEnumStrings< DrawMode::Type >( "drawMode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode );
-
- // Children
- {
- Actor actor = Actor::New();
- Actor child = Layer::New();
- actor.Add( child );
-
- Stage::GetCurrent().Add( actor );
- application.SendNotification();
- application.Render();
-
- Property::Map map;
- CreatePropertyMap( actor, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Actor", TEST_LOCATION );
-
- DALI_TEST_CHECK( NULL != map.Find( "actors" ) );
- Property::Array children( map.Find( "actors")->Get< Property::Array >() );
- DALI_TEST_CHECK( !children.Empty() );
- Property::Map childMap( children[0].Get< Property::Map >() );
- DALI_TEST_CHECK( !childMap.Empty() );
- DALI_TEST_CHECK( childMap.Find( "type" ) );
- DALI_TEST_EQUALS( childMap.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
-
- Stage::GetCurrent().Remove( actor );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingCreatePropertyMapImage(void)
-{
- TestApplication application;
-
- // Empty
- {
- Image image;
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( map.Empty() );
- }
-
- // Default
- {
- Image image = ResourceImage::New( "MY_PATH" );
-
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
- DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "loadPolicy") );
- DALI_TEST_EQUALS( map.Find( "loadPolicy" )->Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "releasePolicy") );
- DALI_TEST_EQUALS( map.Find( "releasePolicy" )->Get< std::string >(), "NEVER", TEST_LOCATION );
- DALI_TEST_CHECK( NULL == map.Find( "width" ) );
- DALI_TEST_CHECK( NULL == map.Find( "height" ) );
- }
-
- // Change values
- {
- ResourceImage image = ResourceImage::New( "MY_PATH", ResourceImage::ON_DEMAND, Image::UNUSED, ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
-
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( !map.Empty() );
-
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
- DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "loadPolicy") );
- DALI_TEST_EQUALS( map.Find( "loadPolicy" )->Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "releasePolicy") );
- DALI_TEST_EQUALS( map.Find( "releasePolicy" )->Get< std::string >(), "UNUSED", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "width" ) );
- DALI_TEST_EQUALS( map.Find( "width" )->Get< int >(), 300, TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "height" ) );
- DALI_TEST_EQUALS( map.Find( "height" )->Get< int >(), 400, TEST_LOCATION );
- }
-
- // BufferImage
- {
- Image image = BufferImage::New( 200, 300, Pixel::A8 );
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "BufferImage", TEST_LOCATION );
- DALI_TEST_CHECK( NULL != map.Find( "pixelFormat") );
- DALI_TEST_EQUALS( map.Find( "pixelFormat" )->Get< std::string >(), "A8", TEST_LOCATION );
- }
-
- // FrameBufferImage
- {
- Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
- Property::Map map;
- CreatePropertyMap( image, map );
- DALI_TEST_CHECK( NULL != map.Find( "type" ) );
- DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliScriptingGetEnumerationTemplates(void)
-{
- const Scripting::StringEnum myTable[] =
- {
- { "ONE", 1 },
- { "TWO", 2 },
- { "THREE", 3 },
- { "FOUR", 4 },
- { "FIVE", 5 },
- };
- const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
-
- for ( unsigned int i = 0; i < myTableCount; ++i )
- {
- tet_printf("Checking: %s\n", myTable[ i ].string );
- int value;
- DALI_TEST_CHECK( GetEnumeration<int>( myTable[ i ].string, myTable, myTableCount, value ) );
- DALI_TEST_EQUALS( myTable[ i ].value, value, TEST_LOCATION );
- }
-
- for ( unsigned int i = 0; i < myTableCount; ++i )
- {
- tet_printf("Checking: %d\n", myTable[ i ].value );
- DALI_TEST_EQUALS( myTable[ i ].string, GetEnumerationName( myTable[ i ].value, myTable, myTableCount ), TEST_LOCATION );
- }
-
- END_TEST;
-}
-
-int UtcDaliScriptingGetEnumerationNameN(void)
-{
- const char* value = GetEnumerationName( 10, NULL, 0 );
- DALI_TEST_CHECK( NULL == value );
-
- value = GetEnumerationName( 10, NULL, 1 );
- DALI_TEST_CHECK( NULL == value );
-
- END_TEST;
-}
-
-int UtcDaliScriptingGetLinearEnumerationNameN(void)
-{
- const char* value = GetLinearEnumerationName( 10, NULL, 0 );
- DALI_TEST_CHECK( NULL == value );
-
- value = GetLinearEnumerationName( 10, NULL, 1 );
- DALI_TEST_CHECK( NULL == value );
-
- END_TEST;
-}
-
-int UtcDaliScriptingFindEnumIndexN(void)
-{
- const Scripting::StringEnum myTable[] =
- {
- { "ONE", (1<<1) },
- { "TWO", (1<<2) },
- { "THREE", (1<<3) },
- { "FOUR", (1<<4) },
- { "FIVE", (1<<5) },
- };
- const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
- DALI_TEST_EQUALS( myTableCount, FindEnumIndex( "Foo", myTable, myTableCount ), TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliScriptingEnumStringToIntegerP(void)
-{
- const Scripting::StringEnum myTable[] =
- {
- { "ONE", (1<<1) },
- { "TWO", (1<<2) },
- { "THREE", (1<<3) },
- { "FOUR", (1<<4) },
- { "FIVE", (1<<5) },
- };
- const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
-
- unsigned int integerEnum = 0;
- DALI_TEST_CHECK( EnumStringToInteger( "ONE", myTable, myTableCount, integerEnum ) );
-
- DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
-
- integerEnum = 0;
- DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO", myTable, myTableCount, integerEnum ) );
- DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION );
-
- DALI_TEST_CHECK( EnumStringToInteger( "ONE,,TWO", myTable, myTableCount, integerEnum ) );
- DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION );
-
- DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO,THREE", myTable, myTableCount, integerEnum ) );
- DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3), TEST_LOCATION );
-
- DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO,THREE,FOUR,FIVE", myTable, myTableCount, integerEnum ) );
- DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5), TEST_LOCATION );
-
- DALI_TEST_CHECK( EnumStringToInteger( "TWO,ONE", myTable, myTableCount, integerEnum ) );
- DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION );
-
- DALI_TEST_CHECK( EnumStringToInteger( "TWO,ONE,FOUR,THREE,FIVE", myTable, myTableCount, integerEnum ) );
- DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5), TEST_LOCATION );
-
- DALI_TEST_CHECK( EnumStringToInteger( "ONE,SEVEN", myTable, myTableCount, integerEnum ) );
- DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
-
- DALI_TEST_CHECK( EnumStringToInteger( "ONE,", myTable, myTableCount, integerEnum ) );
- DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
-
-
- END_TEST;
-}
-
-int UtcDaliScriptingEnumStringToIntegerN(void)
-{
- const Scripting::StringEnum myTable[] =
- {
- { "ONE", 1 },
- { "TWO", 2 },
- { "THREE", 3 },
- { "FOUR", 4 },
- { "FIVE", 5 },
- };
- const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
-
- unsigned int integerEnum = 0;
- DALI_TEST_CHECK( !EnumStringToInteger( "Foo", myTable, myTableCount, integerEnum ) );
-
- DALI_TEST_CHECK( !EnumStringToInteger( "", myTable, myTableCount, integerEnum ) );
-
- DALI_TEST_CHECK( !EnumStringToInteger( ",", myTable, myTableCount, integerEnum ) );
-
- DALI_TEST_CHECK( !EnumStringToInteger( ",ONE,SEVEN", myTable, myTableCount, integerEnum ) );
-
- DALI_TEST_CHECK( !EnumStringToInteger( ",", myTable, myTableCount, integerEnum ) );
-
- DALI_TEST_CHECK( !EnumStringToInteger( "ONE", myTable, 0, integerEnum ) );
-
- DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliScriptingEnumStringToIntegerInvalidEnumP(void)
-{
- const Scripting::StringEnum myTable[] =
- {
- { "", 1 },
- { "", 2 },
- { "", 3 },
- };
-
- const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
-
- unsigned int integerEnum = 0;
- DALI_TEST_CHECK( EnumStringToInteger( "", myTable, myTableCount, integerEnum ) );
- DALI_TEST_EQUALS( integerEnum, 1, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliScriptingEnumStringToIntegerInvalidEnumN(void)
-{
- const Scripting::StringEnum myTable[] =
- {
- { "", 1 },
- { "", 1 },
- { "", 1 },
- };
-
- const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
-
- unsigned int integerEnum = 0;
- DALI_TEST_CHECK( !EnumStringToInteger( NULL, NULL, 0, integerEnum ) );
-
- DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, 0, integerEnum ) );
-
- DALI_TEST_CHECK( !EnumStringToInteger( NULL, myTable, 0, integerEnum ) );
-
- DALI_TEST_CHECK( !EnumStringToInteger( NULL, myTable, myTableCount, integerEnum ) );
-
- DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, myTableCount, integerEnum ) );
-
- DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION );
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <iostream>
-#include <stdlib.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/signals/signal-delegate.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-
-void utc_dali_signal_delegate_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_signal_delegate_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-// Test infrastructure:
-
-static bool gSignalReceived = false;
-
-/**
- * This object allows us to test member function connection.
- */
-class SignalDelegateTestClass : public Dali::ConnectionTracker
-{
-public:
-
- SignalDelegateTestClass( Actor connectActor, std::string connectSignal )
- {
- mSignalDelegate = new SignalDelegate( connectActor, connectSignal );
- }
-
- void ConnectToInternalMember()
- {
- mSignalDelegate->Connect( this, &SignalDelegateTestClass::SignalHandlerMemberFunction );
- }
-
- bool IsConnected()
- {
- return mSignalDelegate->IsConnected();
- }
-
-private:
-
- void SignalHandlerMemberFunction()
- {
- tet_infoline( "Got signal in member function\n" );
- gSignalReceived = true;
- }
-
- SignalDelegate* mSignalDelegate;
-};
-
-/**
- * A connection tracker is required when connecting a signal delegate to a functor.
- */
-class TestConnectionTrackerObject : public ConnectionTracker
-{
-};
-
-/**
- * This functor is used to test the signal delegate's connect ( to functor ) method.
- */
-struct SignalDelegateTestFunctor
-{
- SignalDelegateTestFunctor()
- {
- }
-
- void operator()()
- {
- gSignalReceived = true;
- }
-};
-
-
-// Test cases:
-
-int UtcDaliSignalDelegateIsConnectedP(void)
-{
- TestApplication application;
- tet_infoline( " UtcDaliSignalDelegateIsConnectedP" );
-
- // Set up an actor with a signal to connect to.
- Actor connectActor = Actor::New();
- std::string connectSignal = "onStage";
-
- // Create the test class (this will create the delegate, but not connect to it yet.
- SignalDelegateTestClass testObject( connectActor, connectSignal );
-
- // Tell the test class to connect the delegate to it's internal member.
- // Note: It is at this point that the delegate internally makes the connection.
- testObject.ConnectToInternalMember();
-
- DALI_TEST_CHECK( testObject.IsConnected() );
-
- END_TEST;
-}
-
-int UtcDaliSignalDelegateIsConnectedN(void)
-{
- TestApplication application;
- tet_infoline( " UtcDaliSignalDelegateIsConnectedN" );
-
- // Set up an actor with a signal to connect to.
- Actor connectActor = Actor::New();
- std::string connectSignal = "onStage";
-
- // Create the test class (this will create the delegate, but not connect to it yet.
- SignalDelegateTestClass testObject( connectActor, connectSignal );
-
- DALI_TEST_CHECK( !testObject.IsConnected() );
-
- END_TEST;
-}
-
-int UtcDaliSignalDelegateConnectToMemberP(void)
-{
- TestApplication application;
- tet_infoline( " UtcDaliSignalDelegateConnectToMemberP" );
-
- // Set up an actor with a signal to connect to.
- Actor connectActor = Actor::New();
- std::string connectSignal = "onStage";
-
- gSignalReceived = false;
-
- // Create the test class (this will create the delegate, but not connect to it yet.
- SignalDelegateTestClass testObject( connectActor, connectSignal );
-
- // Tell the test class to connect the delegate to it's internal member.
- // Note: It is at this point that the delegate internally makes the connection.
- testObject.ConnectToInternalMember();
-
- // Add the actor to the stage to trigger it's "onStage" signal.
- // If the delegate connected correctly, this will call the member
- // function in the test object and set a global flag.
- Stage::GetCurrent().Add( connectActor );
-
- // Check the global flag to confirm the signal was received.
- DALI_TEST_CHECK( gSignalReceived );
-
- END_TEST;
-}
-
-int UtcDaliSignalDelegateConnectToMemberN(void)
-{
- TestApplication application;
- tet_infoline( " UtcDaliSignalDelegateConnectToMemberN" );
-
- // Set up an actor with a signal to connect to.
- Actor connectActor = Actor::New();
- std::string connectSignal = "onStage";
-
- gSignalReceived = false;
-
- // Create the test class (this will create the delegate, but not connect to it yet.
- SignalDelegateTestClass testObject( connectActor, connectSignal );
-
- // Tell the test class to connect the delegate to it's internal member.
- // Note: It is at this point that the delegate internally makes the connection.
- testObject.ConnectToInternalMember();
-
- // Check the global flag to confirm the signal was not received.
- DALI_TEST_CHECK( !gSignalReceived );
-
- END_TEST;
-}
-
-int UtcDaliSignalDelegateConnectToFunctorP(void)
-{
- TestApplication application;
- tet_infoline( " UtcDaliSignalDelegateConnectToFunctorP" );
-
- // Set up an actor with a signal to connect to.
- Actor connectActor = Actor::New();
- std::string connectSignal = "onStage";
-
- // Initialise the signal delegate with the actor to connect to and it's signal.
- SignalDelegate signalDelegate( connectActor, connectSignal );
-
- // We need a connection tracker object to associated with the connection.
- // This could normally be "this", but since we are not within a class, we pass
- // in an external one.
- TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
-
- // Check the signal delegate currently has no connection.
- DALI_TEST_CHECK( !signalDelegate.IsConnected() );
-
- // Tell the signal delegate to connect to the given functor (via a functor delegate).
- // Note: It is at this point that the delegate internally makes the connection.
- signalDelegate.Connect( testTracker, FunctorDelegate::New( SignalDelegateTestFunctor() ) );
-
- // Check the signal delegate has made the connection.
- DALI_TEST_CHECK( signalDelegate.IsConnected() );
-
- // Add the actor to the stage to trigger it's "onStage" signal.
- // If the delegate connected correctly, this will call the () operator of our
- // passed-in functor, the functor will in turn set a global flag.
- Stage::GetCurrent().Add( connectActor );
-
- // Check the global flag to confirm the signal was received.
- DALI_TEST_CHECK( gSignalReceived );
-
- END_TEST;
-}
-
-int UtcDaliSignalDelegateConnectToFunctorN(void)
-{
- TestApplication application;
- tet_infoline( " UtcDaliSignalDelegateConnectToFunctorN" );
-
- // Set up an actor with a signal to connect to.
- Actor connectActor = Actor::New();
- std::string connectSignal = "onStage";
-
- // Initialise the signal delegate with the actor to connect to and it's signal.
- SignalDelegate signalDelegate( connectActor, connectSignal );
-
- // We need a connection tracker object to associated with the connection.
- // This could normally be "this", but since we are not within a class, we pass
- // in an external one.
- TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
-
- // Check the signal delegate currently has no connection.
- DALI_TEST_CHECK( !signalDelegate.IsConnected() );
-
- // Tell the signal delegate to connect to the given functor (via a functor delegate).
- // Note: It is at this point that the delegate internally makes the connection.
- signalDelegate.Connect( testTracker, FunctorDelegate::New( SignalDelegateTestFunctor() ) );
-
- // Check the signal delegate has made the connection.
- DALI_TEST_CHECK( signalDelegate.IsConnected() );
-
- // Check the global flag to confirm the signal was received.
- DALI_TEST_CHECK( !gSignalReceived );
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <unistd.h>
-#include <dali-test-suite-utils.h>
-#include <dali/devel-api/threading/thread.h>
-
-using Dali::Thread;
-
-namespace
-{
-volatile bool gRunThreadEntryFunc = false;
-
-class TestThread : public Thread
-{
- virtual void Run()
- {
- gRunThreadEntryFunc = true;
- }
-};
-}
-
-int UtcDaliThreadP(void)
-{
- tet_infoline("Testing Dali::Thread");
-
- gRunThreadEntryFunc = false;
-
- TestThread thread;
-
- thread.Start();
- // wait till the thread is terminated
- while( !gRunThreadEntryFunc )
- {
- usleep( 1 ); // 1 microsecond
- }
- DALI_TEST_EQUALS( true, gRunThreadEntryFunc, TEST_LOCATION );
-
- thread.Join();
-
- // Restart the thread after joined
- gRunThreadEntryFunc = false;
- thread.Start();
- thread.Join();
- // wait till the thread is terminated
- while( !gRunThreadEntryFunc )
- {
- usleep( 1 ); // 1 microsecond
- }
- DALI_TEST_EQUALS( true, gRunThreadEntryFunc, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliThreadNonCopyable(void)
-{
- // we want to make sure that mutex is not copyable (its copy constructor is not defined)
- // this test will stop compiling if Mutex has compiler generated copy constructor
- DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( Thread ) );
-
- DALI_TEST_CHECK( true );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/object/weak-handle.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
-
-namespace
-{
-
-/*******************************************************************************
- *
- * Custom Actor
- *
- ******************************************************************************/
-namespace Impl
-{
-struct MyTestCustomActor : public CustomActorImpl
-{
- typedef Signal< void ()> SignalType;
- typedef Signal< void (float)> SignalTypeFloat;
-
- MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
- { }
-
- virtual ~MyTestCustomActor()
- { }
-
- void ResetCallStack()
- {
- }
-
- // From CustomActorImpl
- virtual void OnStageConnection( int depth )
- {
- }
- virtual void OnStageDisconnection()
- {
- }
- virtual void OnChildAdd(Actor& child)
- {
- }
- virtual void OnChildRemove(Actor& child)
- {
- }
- virtual void OnSizeSet(const Vector3& targetSize)
- {
- }
- virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
- {
- }
- virtual bool OnTouchEvent(const TouchEvent& event)
- {
- return true;
- }
- virtual bool OnHoverEvent(const HoverEvent& event)
- {
- return true;
- }
- virtual bool OnWheelEvent(const WheelEvent& event)
- {
- return true;
- }
- virtual bool OnKeyEvent(const KeyEvent& event)
- {
- return true;
- }
- virtual void OnKeyInputFocusGained()
- {
- }
- virtual void OnKeyInputFocusLost()
- {
- }
- virtual Vector3 GetNaturalSize()
- {
- return Vector3( 0.0f, 0.0f, 0.0f );
- }
-
- virtual float GetHeightForWidth( float width )
- {
- return 0.0f;
- }
-
- virtual float GetWidthForHeight( float height )
- {
- return 0.0f;
- }
-
- virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
- {
- }
-
- virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
- {
- }
-
- virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
- {
- }
-
- virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
- {
- return 0.0f;
- }
-
- virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
- {
- }
-
- virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
- {
- return false;
- }
-
-public:
-
- SignalType mSignal;
-};
-
-}; // namespace Impl
-
-class MyTestCustomActor : public CustomActor
-{
-public:
-
- typedef Signal< void ()> SignalType;
- typedef Signal< void (float)> SignalTypeFloat;
-
- MyTestCustomActor()
- {
- }
-
- static MyTestCustomActor New()
- {
- Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
- return MyTestCustomActor( *p ); // takes ownership
- }
-
- virtual ~MyTestCustomActor()
- {
- }
-
- static MyTestCustomActor DownCast( BaseHandle handle )
- {
- MyTestCustomActor result;
-
- CustomActor custom = Dali::CustomActor::DownCast( handle );
- if ( custom )
- {
- CustomActorImpl& customImpl = custom.GetImplementation();
-
- Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
-
- if (impl)
- {
- result = MyTestCustomActor(customImpl.GetOwner());
- }
- }
-
- return result;
- }
-
- SignalType& GetCustomSignal()
- {
- Dali::RefObject& obj = GetImplementation();
- return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
- }
-
- MyTestCustomActor(Internal::CustomActor* internal)
- : CustomActor(internal)
- {
- }
-
- MyTestCustomActor( Impl::MyTestCustomActor& impl )
- : CustomActor( impl )
- {
- }
-};
-
-}
-
-int UtcDaliWeakHandleBaseConstructorVoid(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::WeakHandleBase::WeakHandleBase()");
-
- WeakHandleBase object;
-
- DALI_TEST_CHECK(!object.GetBaseHandle());
-
- END_TEST;
-}
-
-int UtcDaliWeakHandleBaseConstructorWithHandle(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::WeakHandleBase::WeakHandleBase(Handle)");
-
- Handle emptyHandle;
- WeakHandleBase emptyObject(emptyHandle);
- DALI_TEST_CHECK(!emptyObject.GetBaseHandle());
-
- Actor actor = Actor::New();
- WeakHandleBase object(actor);
- DALI_TEST_CHECK(object.GetBaseHandle() == actor);
-
- END_TEST;
-}
-
-int UtcDaliWeakHandleBaseCopyConstructor(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::WeakHandleBase::WeakHandleBase(const WeakHandleBase&)");
-
- Actor actor = Actor::New();
- DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
-
- WeakHandleBase object(actor);
- DALI_TEST_CHECK(object.GetBaseHandle() == actor);
- DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
-
- WeakHandleBase copy(object);
- DALI_TEST_CHECK(copy.GetBaseHandle() == actor);
- DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
-
- END_TEST;
-}
-
-int UtcDaliWeakHandleBaseAssignmentOperator(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::WeakHandleBase::operator=");
-
- Actor actor = Actor::New();
- DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
-
- WeakHandleBase object(actor);
- DALI_TEST_CHECK(object.GetBaseHandle() == actor);
- DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
-
- WeakHandleBase copy = object;
- DALI_TEST_CHECK(copy.GetBaseHandle() == actor);
- DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
-
- END_TEST;
-}
-
-int UtcDaliWeakHandleBaseEqualityOperatorP(void)
-{
- TestApplication application;
- tet_infoline("Positive Test Dali::WeakHandleBase::operator==");
-
- WeakHandleBase object;
- WeakHandleBase theSameObject;
- DALI_TEST_CHECK(object == theSameObject);
-
- Actor actor = Actor::New();
-
- object = WeakHandleBase(actor);
- DALI_TEST_CHECK(object.GetBaseHandle() == actor);
-
- theSameObject = object;
- DALI_TEST_CHECK(theSameObject.GetBaseHandle() == actor);
- DALI_TEST_CHECK(object == theSameObject);
-
- END_TEST;
-}
-
-int UtcDaliWeakHandleBaseEqualityOperatorN(void)
-{
- TestApplication application;
- tet_infoline("Negative Test Dali::WeakHandleBase::operator==");
-
- Actor actor = Actor::New();
-
- WeakHandleBase object(actor);
- DALI_TEST_CHECK(object.GetBaseHandle() == actor);
-
- Actor differentActor = Actor::New();
- WeakHandleBase aDifferentWeakHandleBase(differentActor);
-
- DALI_TEST_CHECK(!(object == aDifferentWeakHandleBase));
-
- END_TEST;
-}
-
-int UtcDaliWeakHandleBaseInequalityOperatorP(void)
-{
- TestApplication application;
- tet_infoline("Positive Test Dali::WeakHandleBase::operator!=");
-
- Actor actor = Actor::New();
-
- WeakHandleBase object(actor);
- DALI_TEST_CHECK(object.GetBaseHandle() == actor);
-
- Actor differentActor = Actor::New();
- WeakHandleBase aDifferentWeakHandleBase(differentActor);
-
- DALI_TEST_CHECK(object != aDifferentWeakHandleBase);
- END_TEST;
-}
-
-int UtcDaliWeakHandleBaseInequalityOperatorN(void)
-{
- TestApplication application;
- tet_infoline("Negative Test Dali::WeakHandleBase::operator!=");
-
- Actor actor = Actor::New();
-
- WeakHandleBase object(actor);
- DALI_TEST_CHECK(object.GetBaseHandle() == actor);
-
- WeakHandleBase theSameWeakHandleBase = object;
-
- DALI_TEST_CHECK(!(object != theSameWeakHandleBase));
- END_TEST;
-}
-
-int UtcDaliWeakHandleBaseGetBaseHandle(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::WeakHandleBase::GetBaseHandle()");
-
- Handle emptyHandle;
- WeakHandleBase emptyObject(emptyHandle);
- DALI_TEST_CHECK(!emptyObject.GetBaseHandle());
-
- Actor actor = Actor::New();
- WeakHandleBase object(actor);
- DALI_TEST_CHECK(object.GetBaseHandle() == actor);
-
- WeakHandleBase theSameObject = WeakHandleBase(actor);
- DALI_TEST_CHECK(object.GetBaseHandle() == theSameObject.GetBaseHandle());
-
- Actor differentActor = Actor::New();
- WeakHandleBase aDifferentWeakHandleBase(differentActor);
- DALI_TEST_CHECK(object.GetBaseHandle() != aDifferentWeakHandleBase.GetBaseHandle());
-
- END_TEST;
-}
-
-int UtcDaliWeakHandleGetHandle(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::WeakHandle::GetHandle()");
-
- Actor actor = Actor::New();
- WeakHandle<Actor> object(actor);
- DALI_TEST_CHECK(object.GetHandle() == actor);
-
- MyTestCustomActor customActor = MyTestCustomActor::New();
- WeakHandle<MyTestCustomActor> customObject(customActor);
- DALI_TEST_CHECK(customObject.GetHandle() == customActor);
-
- DALI_TEST_CHECK(object.GetHandle() != customObject.GetHandle());
-
- END_TEST;
-}
-
-
-
utc-Dali-AngleAxis.cpp
utc-Dali-Animation.cpp
utc-Dali-Any.cpp
+ utc-Dali-Atlas.cpp
utc-Dali-BaseHandle.cpp
utc-Dali-BufferImage.cpp
utc-Dali-CameraActor.cpp
+ utc-Dali-ConditionalWait.cpp
+ utc-Dali-ConnectionTracker.cpp
+ utc-Dali-Constrainer.cpp
utc-Dali-Constraint.cpp
utc-Dali-ConstraintFunction.cpp
utc-Dali-Constraints.cpp
utc-Dali-ConstraintSource.cpp
- utc-Dali-ConnectionTracker.cpp
+ utc-Dali-Context.cpp
utc-Dali-CustomActor.cpp
utc-Dali-Degree.cpp
+ utc-Dali-DistanceField.cpp
utc-Dali-EncodedBufferImage.cpp
utc-Dali-FrameBuffer.cpp
utc-Dali-FrameBufferImage.cpp
utc-Dali-Gesture.cpp
utc-Dali-GestureDetector.cpp
utc-Dali-Handle.cpp
+ utc-Dali-Hash.cpp
+ utc-Dali-HitTestAlgorithm.cpp
utc-Dali-HoverProcessing.cpp
utc-Dali-Image.cpp
utc-Dali-IntrusivePtr.cpp
utc-Dali-Matrix.cpp
utc-Dali-Matrix3.cpp
utc-Dali-MeshMaterial.cpp
+ utc-Dali-Mutex.cpp
utc-Dali-NativeImage.cpp
utc-Dali-NinePatchImages.cpp
utc-Dali-ObjectRegistry.cpp
utc-Dali-RenderTaskList.cpp
utc-Dali-ResourceImage.cpp
utc-Dali-Sampler.cpp
+ utc-Dali-Scripting.cpp
utc-Dali-Shader.cpp
+ utc-Dali-SignalDelegate.cpp
utc-Dali-SignalTemplatesFunctors.cpp
utc-Dali-SignalTemplates.cpp
utc-Dali-Stage.cpp
utc-Dali-TapGestureDetector.cpp
utc-Dali-Texture.cpp
utc-Dali-TextureSet.cpp
+ utc-Dali-Thread.cpp
utc-Dali-TouchEventCombiner.cpp
utc-Dali-TouchProcessing.cpp
utc-Dali-TouchDataProcessing.cpp
utc-Dali-Vector2.cpp
utc-Dali-Vector3.cpp
utc-Dali-Vector4.cpp
+ utc-Dali-WeakHandle.cpp
utc-Dali-WheelEvent.cpp
- utc-Dali-Constrainer.cpp
)
LIST(APPEND TC_SOURCES
ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
TARGET_LINK_LIBRARIES(${EXEC_NAME}
${${CAPI_LIB}_LIBRARIES}
+ -lpthread
)
INSTALL(PROGRAMS ${EXEC_NAME}
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/hover-event-integ.h>
#include <dali-test-suite-utils.h>
+#include <mesh-builder.h>
//& set: DaliActor
END_TEST;
}
+
+int UtcDaliActorAddRendererP(void)
+{
+ tet_infoline("Testing Actor::AddRenderer");
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ actor.AddRenderer( renderer );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorAddRendererN(void)
+{
+ tet_infoline("Testing Actor::AddRenderer");
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Renderer renderer;
+
+ // try illegal Add
+ try
+ {
+ actor.AddRenderer( renderer );
+ tet_printf("Assertion test failed - no Exception\n" );
+ tet_result(TET_FAIL);
+ }
+ catch(Dali::DaliException& e)
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+ }
+ catch(...)
+ {
+ tet_printf("Assertion test failed - wrong Exception\n" );
+ tet_result(TET_FAIL);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliActorAddRendererOnStage(void)
+{
+ tet_infoline("Testing Actor::AddRenderer");
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ application.SendNotification();
+ application.Render(0);
+
+ try
+ {
+ actor.AddRenderer( renderer );
+ tet_result(TET_PASS);
+ }
+ catch(...)
+ {
+ tet_result(TET_FAIL);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliActorRemoveRendererP1(void)
+{
+ tet_infoline("Testing Actor::RemoveRenderer");
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ actor.AddRenderer( renderer );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
+
+ actor.RemoveRenderer(renderer);
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+
+ END_TEST;
+}
+
+int UtcDaliActorRemoveRendererP2(void)
+{
+ tet_infoline("Testing Actor::RemoveRenderer");
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ actor.AddRenderer( renderer );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
+
+ actor.RemoveRenderer(0);
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+
+ END_TEST;
+}
+
+
+int UtcDaliActorRemoveRendererN(void)
+{
+ tet_infoline("Testing Actor::RemoveRenderer");
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ actor.AddRenderer( renderer );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
+
+ actor.RemoveRenderer(10);
+ DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <algorithm>
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/bitmap.h>
+#include <dali/devel-api/images/atlas.h>
+#include <dali-test-suite-utils.h>
+#include <test-native-image.h>
+
+using namespace Dali;
+
+namespace
+{
+static const char* gTestImageFilename = "icon_wrt.png";
+
+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 );
+}
+
+PixelData CreatePixelData(unsigned int width, unsigned int height, Pixel::Format pixelFormat)
+{
+ unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( pixelFormat );
+ unsigned char* buffer = new unsigned char [ bufferSize ];
+
+ return PixelData::New( buffer, bufferSize, width, height, pixelFormat, PixelData::DELETE_ARRAY );
+}
+
+}
+
+void utc_dali_atlas_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_atlas_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliAtlasNew(void)
+{
+ TestApplication application;
+
+ // invoke default handle constructor
+ Atlas atlas;
+
+ DALI_TEST_CHECK( !atlas );
+
+ // initialise handle
+ atlas = Atlas::New( 16, 16 );
+
+ DALI_TEST_CHECK( atlas );
+ END_TEST;
+}
+
+int UtcDaliAtlasCopyConstructor(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 16, 16);
+ Atlas atlasCopy(atlas);
+
+
+ DALI_TEST_EQUALS( (bool)atlasCopy, true, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAtlasAssignmentOperator(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 16, 16);
+
+ Atlas atlas2;
+ DALI_TEST_EQUALS( (bool)atlas2, false, TEST_LOCATION );
+
+ atlas2 = atlas;
+ DALI_TEST_EQUALS( (bool)atlas2, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAtlasDownCast(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 16, 16);
+
+ BaseHandle handle(atlas);
+ Atlas atlasDowncast = Atlas::DownCast(handle);
+ DALI_TEST_EQUALS( (bool)atlasDowncast, true, TEST_LOCATION );
+
+ Handle handle2 = Handle::New(); // Create a custom object
+ Atlas atlas2 = Atlas::DownCast(handle2);
+ DALI_TEST_EQUALS( (bool)atlas2, false, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliAtlasClear(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 16, 32, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas );
+
+ atlas.Clear(Color::TRANSPARENT);
+
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+ callStack.Reset();
+ callStack.Enable(true);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ callStack.Enable(false);
+
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 32u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+
+ END_TEST;
+}
+
+
+// Upload resource image, buffer image & pixel data with same pixel format
+int UtcDaliAtlasUpload01P(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 16, 40, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas );
+
+ // Using same pixel format
+ PixelBuffer* buffer = new PixelBuffer[16 * 16 * 4];
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
+
+ PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 16 ) );
+
+ PixelData pixelData = CreatePixelData( 6,8,Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas.Upload( pixelData, 2, 32 ) );
+
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+ callStack.Reset();
+ callStack.Enable(true);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ callStack.Enable(false);
+
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 16u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 16u << ", " << 16u <<", "<< 16u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 2u << ", " << 32u << ", " << 6u <<", "<< 8u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+
+ END_TEST;
+}
+
+// Upload resource image, buffer image & pixel data with different pixel format
+int UtcDaliAtlasUpload02P(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 20, 20, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas );
+
+ // Using different pixel format
+ PixelBuffer* buffer = new PixelBuffer[16 * 16 * 3];
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGB888 );
+ DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
+
+ PrepareResourceImage( application, 12, 12, Pixel::A8 );
+ DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 6, 6 ) );
+
+ PixelData pixelData = CreatePixelData( 8,8,Pixel::LA88 );
+ DALI_TEST_CHECK( atlas.Upload( pixelData, 10, 10 ) );
+
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+ callStack.Reset();
+ callStack.Enable(true);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ callStack.Enable(false);
+
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 16u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 6u << ", " << 6u << ", " << 12u <<", "<< 12u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 10u << ", " << 10u << ", " << 8u <<", "<< 8u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+
+ END_TEST;
+}
+
+// Upload resource image, buffer image & pixel data which cannot fit into the atlas with given offset
+int UtcDaliAtlasUploadN(void)
+{
+ TestApplication application;
+
+ Atlas atlas = Atlas::New( 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( atlas );
+
+ // Using image cannot fit into atlas at the given offsets
+ PixelBuffer* buffer = new PixelBuffer[24 * 24 * 4];
+ BufferImage image = BufferImage::New( buffer, 24, 24, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( !atlas.Upload( image, 0, 0 ) );
+
+ PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
+ DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 10, 10 ) );
+
+ PixelData pixelData = CreatePixelData( 6,6,Pixel::RGBA8888 );
+ DALI_TEST_CHECK( !atlas.Upload( pixelData, 11, 11 ) );
+
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+ callStack.Reset();
+ callStack.Enable(true);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ callStack.Enable(false);
+
+ // none of these three upload() call sends texture to GPU
+ DALI_TEST_CHECK( ! callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 24, 24") );
+ DALI_TEST_CHECK( ! callStack.FindMethodAndParams("TexSubImage2D", "10, 10, 16, 16") );
+ DALI_TEST_CHECK( ! callStack.FindMethodAndParams("TexSubImage2D", "11, 11, 6, 6") );
+
+ END_TEST;
+}
+
+
+
+
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <unistd.h>
+#include <dali-test-suite-utils.h>
+#include <dali/devel-api/threading/conditional-wait.h>
+#include <dali/devel-api/threading/thread.h>
+
+using Dali::ConditionalWait;
+using Dali::Thread;
+
+namespace // for local variables to avoid name clashes
+{
+volatile int gGlobalValue = 0;
+volatile bool gWorkerThreadWait = true;
+enum ThreadState { INIT, RUN, TERMINATE } volatile gWorkerThreadState = INIT;
+ConditionalWait* volatile gConditionalWait; // volatile pointer to a ConditionalWait object
+
+class WorkerThreadNotify : public Thread
+{
+ virtual void Run()
+ {
+ gGlobalValue = -1;
+ while( gWorkerThreadWait ) // wait till we can exit
+ {
+ gWorkerThreadState = RUN;
+ usleep( 1 ); // 1 microseconds
+ }
+ usleep( 200 ); // give other thread time to get to Wait
+ gGlobalValue = 1;
+ gConditionalWait->Notify();
+ gWorkerThreadState = TERMINATE;
+ }
+};
+
+volatile int gNotifyCount = 0;
+class WorkerThreadNotifyN : public Thread
+{
+ virtual void Run()
+ {
+ while( gNotifyCount > 0 )
+ {
+ gConditionalWait->Notify();
+ usleep( 10 ); // 10 microseconds between each notify
+ }
+ }
+};
+
+class WorkerThreadWaitN : public Thread
+{
+ virtual void Run()
+ {
+ gConditionalWait->Wait();
+ }
+};
+
+}
+
+int UtcConditionalWait1P(void)
+{
+ tet_infoline("Testing ConditionalWait - scenario: wait - notify with 2 threads");
+
+ WorkerThreadNotify thread1;
+ // initialize values
+ gConditionalWait = new ConditionalWait();
+ gWorkerThreadWait = true;
+ DALI_TEST_EQUALS( INIT, gWorkerThreadState, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
+
+ thread1.Start();
+ // wait till the thread is in run state
+ while( RUN != gWorkerThreadState )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ // let worker continue and finish
+ gWorkerThreadWait = false;
+ gConditionalWait->Wait();
+ DALI_TEST_EQUALS( 1, gGlobalValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
+
+ // wait till the thread is terminated state
+ while( TERMINATE != gWorkerThreadState )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+
+ thread1.Join();
+
+ delete gConditionalWait;
+ END_TEST;
+}
+
+int UtcConditionalWait2P(void)
+{
+ tet_infoline("Testing ConditionalWait - scenario: notify without wait");
+
+ ConditionalWait wait;
+ DALI_TEST_EQUALS( 0u, wait.GetWaitCount(), TEST_LOCATION );
+ wait.Notify();
+ DALI_TEST_EQUALS( 0u, wait.GetWaitCount(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcConditionalWait3P(void)
+{
+ tet_infoline("Testing ConditionalWait - scenario: wait - notify N times 2 threads");
+
+ // initialize values
+ gConditionalWait = new ConditionalWait();
+ gNotifyCount = 100;
+
+ WorkerThreadNotifyN thread1;
+ thread1.Start();
+
+ while( gNotifyCount > 0 )
+ {
+ gConditionalWait->Wait();
+ --gNotifyCount;
+ DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
+ usleep( 10 ); // 10 microseconds between each notify
+ }
+ DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
+
+ thread1.Join();
+
+ delete gConditionalWait;
+ END_TEST;
+}
+
+int UtcConditionalWait4P(void)
+{
+ tet_infoline("Testing ConditionalWait - scenario: wait - notify N times from 3 threads");
+
+ // initialize values
+ gConditionalWait = new ConditionalWait();
+ gNotifyCount = 100;
+
+ WorkerThreadNotifyN thread1;
+ thread1.Start();
+ WorkerThreadNotifyN thread2;
+ thread2.Start();
+ WorkerThreadNotifyN thread3;
+ thread3.Start();
+
+ while( gNotifyCount > 0 )
+ {
+ gConditionalWait->Wait();
+ --gNotifyCount;
+ DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
+ usleep( 10 ); // 10 microseconds between each notify
+ }
+
+ thread1.Join();
+ thread2.Join();
+ thread3.Join();
+
+ delete gConditionalWait;
+ END_TEST;
+}
+
+int UtcConditionalWait5P(void)
+{
+ tet_infoline("Testing ConditionalWait - scenario: 4 threads wait - notify once from 1 thread");
+
+ // initialize values
+ gConditionalWait = new ConditionalWait();
+
+ WorkerThreadWaitN thread1;
+ thread1.Start();
+ WorkerThreadWaitN thread2;
+ thread2.Start();
+ WorkerThreadWaitN thread3;
+ thread3.Start();
+ WorkerThreadWaitN thread4;
+ thread4.Start();
+ // wait till all child threads are waiting
+ while( gConditionalWait->GetWaitCount() < 4 )
+ { }
+
+ // notify once, it will resume all threads
+ gConditionalWait->Notify();
+
+ thread1.Join();
+ thread2.Join();
+ thread3.Join();
+ thread4.Join();
+
+ DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
+
+ delete gConditionalWait;
+ END_TEST;
+}
+
+int UtcConditionalWait6P(void)
+{
+ tet_infoline("Testing ConditionalWait - scenario: 4 threads wait - notify once from 1 thread");
+
+ // initialize values
+ gConditionalWait = new ConditionalWait();
+
+ WorkerThreadWaitN thread1;
+ thread1.Start();
+ WorkerThreadWaitN thread2;
+ thread2.Start();
+ WorkerThreadWaitN thread3;
+ thread3.Start();
+ WorkerThreadWaitN thread4;
+ thread4.Start();
+ // wait till all child threads are waiting
+ while( gConditionalWait->GetWaitCount() < 4 )
+ { }
+
+ // notify once but with a scoped lock, it will resume all threads
+ {
+ ConditionalWait::ScopedLock lock( *gConditionalWait );
+ gConditionalWait->Notify( lock );
+ }
+
+ thread1.Join();
+ thread2.Join();
+ thread3.Join();
+ thread4.Join();
+
+ DALI_TEST_EQUALS( 0u, gConditionalWait->GetWaitCount(), TEST_LOCATION );
+
+ delete gConditionalWait;
+ END_TEST;
+}
+
+int UtcConditionalWaitNonCopyable(void)
+{
+ // we want to make sure that ConditionalWait is not copyable (its copy constructor is not defined)
+ // this test will stop compiling if ConditionalWait has compiler generated copy constructor
+ DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( ConditionalWait ) );
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+
namespace
{
+
+static void SetupPath( Dali::Path& path)
+{
+ path.AddPoint(Vector3( 30.0, 80.0, 0.0));
+ path.AddPoint(Vector3( 70.0, 120.0, 0.0));
+ path.AddPoint(Vector3(100.0, 100.0, 0.0));
+
+ //Control points for first segment
+ path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) );
+ path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) );
+
+ //Control points for second segment
+ path.AddControlPoint(Vector3( 78.0, 120.0, 0.0) );
+ path.AddControlPoint(Vector3( 93.0, 104.0, 0.0) );
+}
+
+static void SetupPathConstrainer( Dali::PathConstrainer& PathConstrainer)
+{
+ PathConstrainer.SetProperty( Dali::PathConstrainer::Property::FORWARD, Vector3(1.0f,0.0f,0.0f) );
+
+ Dali::Property::Array points;
+ points.Resize(3);
+ points[0] = Vector3( 30.0, 80.0, 0.0);
+ points[1] = Vector3( 70.0, 120.0, 0.0);
+ points[2] = Vector3(100.0, 100.0, 0.0);
+ PathConstrainer.SetProperty( Dali::PathConstrainer::Property::POINTS, points );
+
+ points.Resize(4);
+ points[0] = Vector3( 39.0, 90.0, 0.0);
+ points[1] = Vector3( 56.0, 119.0, 0.0);
+ points[2] = Vector3( 78.0, 120.0, 0.0);
+ points[3] = Vector3( 93.0, 104.0, 0.0);
+ PathConstrainer.SetProperty( Dali::PathConstrainer::Property::CONTROL_POINTS, points );
+}
+
static void SetupLinearConstrainerUniformProgress( Dali::LinearConstrainer& linearConstrainer)
{
Dali::Property::Array points;
} // anonymous namespace
+//PathConstrainer test cases
+int UtcPathConstrainerApply(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a Path
+ Dali::Path path = Dali::Path::New();
+ SetupPath(path);
+
+ //Create a PathConstrainer
+ Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
+ SetupPathConstrainer( pathConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
+
+ //Create an animation to animate the custom property
+ float durationSeconds(1.0f);
+ Dali::Animation animation = Dali::Animation::New(durationSeconds);
+ animation.AnimateTo(Dali::Property(actor,index),1.0f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+
+ Vector3 position, tangent;
+ path.Sample(0.2f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+ path.Sample(0.4f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+ path.Sample(0.6f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+ path.Sample(0.8f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
+ path.Sample(1.0f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* beyond the animation duration*/);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcPathConstrainerApplyRange(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a Path
+ Dali::Path path = Dali::Path::New();
+ SetupPath(path);
+
+ //Create a PathConstrainer
+ Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
+ SetupPathConstrainer( pathConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 100.0f, 300.0f );
+ pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
+
+
+ //Create an animation to animate the custom property
+ float durationSeconds(1.0f);
+ Dali::Animation animation = Dali::Animation::New(durationSeconds);
+ animation.AnimateTo(Dali::Property(actor,index),400.0f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+
+ Vector3 position, tangent;
+ float tValue;
+ actor.GetProperty(index).Get(tValue);
+ float currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ actor.GetProperty(index).Get(tValue);
+ currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ path.Sample(0.5, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ actor.GetProperty(index).Get(tValue);
+ currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
+ actor.GetProperty(index).Get(tValue);
+ currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
+ actor.GetProperty(index).Get(tValue);
+ currentCursor = ( tValue - range.x ) / (range.y-range.x);
+ path.Sample(currentCursor, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcPathConstrainerDestroy(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ {
+ //Create a Path
+ Dali::Path path = Dali::Path::New();
+ SetupPath(path);
+
+ //Create a PathConstrainer
+ Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
+ SetupPathConstrainer( pathConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
+
+ //Test that the constraint is correctly applied
+ actor.SetProperty(index,0.5f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ Vector3 position, tangent;
+ path.Sample(0.5f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ }
+
+ //PathConstrainer has been destroyed. Constraint in the actor should have been removed
+ actor.SetProperty(index,0.75f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcPathConstrainerRemove(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a Path
+ Dali::Path path = Dali::Path::New();
+ SetupPath(path);
+
+ //Create a PathConstrainer
+ Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New();
+ SetupPathConstrainer( pathConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range );
+
+ //Test that the constraint is correctly applied
+ actor.SetProperty(index,0.5f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ Vector3 position, tangent;
+ path.Sample(0.5f, position, tangent );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION );
+
+ //Remove constraint
+ pathConstrainer.Remove( actor );
+ actor.SetProperty(index,0.75f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+
+ END_TEST;
+}
+
+//LinearConstrainer test cases
+int UtcLinearConstrainerDownCast(void)
+{
+ TestApplication application;
+ Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+
+ BaseHandle handle( linearConstrainer );
+ Dali::LinearConstrainer linearConstrainer2 = Dali::LinearConstrainer::DownCast( handle );
+ DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
+
+ BaseHandle handle2;
+ Dali:: LinearConstrainer linearConstrainer3 = Dali::LinearConstrainer::DownCast( handle2 );
+ DALI_TEST_EQUALS( (bool)linearConstrainer3, false, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcLinearConstrainerCopyConstructor(void)
+{
+ TestApplication application;
+ Dali::LinearConstrainer linearConstrainer;
+ DALI_TEST_EQUALS( (bool)linearConstrainer, false, TEST_LOCATION );
+
+ linearConstrainer = Dali::LinearConstrainer::New();
+ DALI_TEST_EQUALS( (bool)linearConstrainer, true, TEST_LOCATION );
+
+ // call the copy constructor
+ Dali::LinearConstrainer linearConstrainer2( linearConstrainer );
+ DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcLinearConstrainerApply(void)
{
TestApplication application;
END_TEST;
}
+int UtcLinearConstrainerApplyRange(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 100.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a LinearConstrainer
+ Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+ SetupLinearConstrainerUniformProgress( linearConstrainer );
+
+ //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 100.0f, 300.0f );
+ linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+
+ //Create an animation to animate the custom property
+ float durationSeconds(1.0f);
+ Dali::Animation animation = Dali::Animation::New(durationSeconds);
+ animation.AnimateTo(Dali::Property(actor,index),300.0f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcLinearConstrainerDestroy(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ {
+ //Create a LinearConstrainer
+ Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+ SetupLinearConstrainerUniformProgress( linearConstrainer );
+
+ //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+ //Test that the constraint is correctly applied
+ actor.SetProperty(index,0.5f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+ }
+
+ //LinearConstrainer has been destroyed. Constraint in the actor should have been removed
+ actor.SetProperty(index,0.75f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcLinearConstrainerRemove(void)
+{
+ TestApplication application;
+
+ Dali::Actor actor = Dali::Actor::New();
+
+ // Register a float property
+ Property::Index index = actor.RegisterProperty( "t", 0.0f );
+ Dali::Stage::GetCurrent().Add(actor);
+
+ //Create a LinearConstrainer
+ Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+ SetupLinearConstrainerUniformProgress( linearConstrainer );
+
+ //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t"
+ Vector2 range( 0.0f, 1.0f );
+ linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+ //Test that the constraint is correctly applied
+ actor.SetProperty(index,0.5f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+ //Remove constraint
+ linearConstrainer.Remove( actor );
+ actor.SetProperty(index,0.75f);
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(1.0f));
+
+ DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+
+namespace
+{
+// Size of the VertexAttributeArray enables
+// GLES specification states that there's a minimum of 8
+const unsigned int TEST_MAX_ATTRIBUTE_CACHE_SIZE = 8;
+
+enum TestAttribType
+{
+ ATTRIB_UNKNOWN = -1,
+ ATTRIB_POSITION,
+ ATTRIB_NORMAL,
+ ATTRIB_TEXCOORD,
+ ATTRIB_COLOR,
+ ATTRIB_BONE_WEIGHTS,
+ ATTRIB_BONE_INDICES,
+ ATTRIB_TYPE_LAST
+};
+
+// Create bitmap actor
+static Actor CreateBitmapActor()
+{
+ BufferImage image = BufferImage::New(4,4,Pixel::RGBA8888);
+ Actor actor = CreateRenderableActor( image );
+ actor.SetSize( 100.0f, 100.0f );
+ actor.SetName("Test Image Rendering Actor");
+ return actor;
+}
+
+} // anonymous namespace
+
+
+// Positive test case for a method
+int UtcDaliContextVertexAttribStartup(void)
+{
+ tet_infoline("Testing vertex attrib initial state in context");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // check the locations
+ for (unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++)
+ {
+ DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(i) == false);
+ }
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+// Tests to make the attribs only get set once when continually rendering an image actor
+int UtcDaliContextVertexAttribImageRendering(void)
+{
+ tet_infoline("Testing vertex attrib rendering state in context with images");
+
+ TestApplication application;
+
+ // start up
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // the vertex attribs get modified on startup to set them to disabled
+ // clear the flag to say they've changed
+ application.GetGlAbstraction().ClearVertexAttribArrayChanged();
+
+
+ // create a test bitmap actor
+ Actor actor(CreateBitmapActor());
+ Stage::GetCurrent().Add(actor);
+
+
+ application.SendNotification();
+ application.Render();
+ application.Render();
+
+ // check to make sure the state has changed (the image renderer will enable some
+ // locations).
+ DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
+
+ // Now check to make sure the state is cached, and isn't being set each frame.
+ application.GetGlAbstraction().ClearVertexAttribArrayChanged();
+
+ application.Render();
+ application.Render();
+ application.Render();
+
+ // if it has changed then the caching has failed
+ DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged() == false);
+
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <algorithm>
+
+#include <stdlib.h>
+
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/images/distance-field.h>
+#include <dali-test-suite-utils.h>
+
+using std::max;
+using namespace Dali;
+
+namespace
+{
+
+static const float ROTATION_EPSILON = 0.0001f;
+
+static unsigned char sourceImage[] =
+{
+ 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+};
+
+} // anonymous namespace
+
+
+
+int UtcDaliGenerateDistanceField(void)
+{
+ unsigned char distanceField[4*4];
+
+ GenerateDistanceFieldMap(sourceImage, Size(8.0f, 8.0f), distanceField, Size(4.0f, 4.0f), 0, Size(4.0f, 4.0f));
+
+ if(distanceField[0] <= distanceField[5] &&
+ distanceField[5] <= distanceField[10] &&
+ distanceField[10] <= distanceField[15])
+ {
+ tet_result(TET_PASS);
+ }
+ else
+ {
+ tet_result(TET_FAIL);
+ }
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <string>
+#include <stdlib.h>
+#include <dali/devel-api/common/hash.h>
+#include <dali-test-suite-utils.h>
+
+void utc_dali_hash_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_hash_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+
+int UtcDaliHash(void)
+{
+ // To fully test the Hash distribution we need to use a tool like http://code.google.com/p/smhasher/
+ // DALi currently uses the hash for variable length strings which come from:
+ // shader vert+frag source, font family + style, image filename.
+ TestApplication application;
+
+ tet_infoline("UtcDaliHash");
+
+ const std::string testString1( "highp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
+ const std::string testString2( "lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a );");
+
+ DALI_TEST_CHECK( Dali::CalculateHash( testString1 ) != Dali::CalculateHash( testString2 ) );
+ DALI_TEST_CHECK( Dali::CalculateHash( testString1, testString2 ) != Dali::CalculateHash( testString2, testString1 ) );
+
+ END_TEST;
+}
+
+int UtcDaliHashNegative(void)
+{
+ // negative test, check hash value == initial value
+ const std::string emptyString;
+
+ DALI_TEST_CHECK( Dali::CalculateHash( emptyString ) != 0 );
+ DALI_TEST_CHECK( Dali::CalculateHash( emptyString, emptyString ) != 0 );
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/events/hit-test-algorithm.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+namespace
+{
+
+/**
+ * The functor to be used in the hit-test algorithm to check whether the actor is hittable.
+ */
+bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
+{
+ bool hittable = false;
+
+ switch (type)
+ {
+ case Dali::HitTestAlgorithm::CHECK_ACTOR:
+ {
+ // Check whether the actor is visible and not fully transparent.
+ if( actor.IsVisible()
+ && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
+ {
+ // Check whether the actor has the specific name "HittableActor"
+ if(actor.GetName() == "HittableActor")
+ {
+ hittable = true;
+ }
+ }
+ break;
+ }
+ case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
+ {
+ if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
+ {
+ hittable = true;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return hittable;
+};
+
+
+bool DefaultIsActorTouchableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::TraverseType type)
+{
+ bool hittable = false;
+
+ switch (type)
+ {
+ case Dali::HitTestAlgorithm::CHECK_ACTOR:
+ {
+ if( actor.IsVisible() &&
+ actor.IsSensitive() &&
+ actor.GetCurrentWorldColor().a > 0.01f)
+ {
+ hittable = true;
+ }
+ break;
+ }
+ case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
+ {
+ if( actor.IsVisible() && // Actor is visible, if not visible then none of its children are visible.
+ actor.IsSensitive()) // Actor is sensitive, if insensitive none of its children should be hittable either.
+ {
+ hittable = true;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return hittable;
+};
+
+} // anonymous namespace
+
+
+// Positive test case for a method
+int UtcDaliHitTestAlgorithmWithFunctor(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm functor");
+
+ Stage stage = Stage::GetCurrent();
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ actor.SetName("NonHittableActor");
+ stage.Add(actor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Vector2 screenCoordinates( 10.0f, 10.0f );
+ Vector2 localCoordinates;
+ actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
+
+ // Perform a hit-test at the given screen coordinates
+ Dali::HitTestAlgorithm::Results results;
+ Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor != actor );
+
+ actor.SetName("HittableActor");
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+
+ // Perform a hit-test at the given screen coordinates
+ Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor );
+ DALI_TEST_EQUALS( localCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliHitTestAlgorithmWithFunctorOnRenderTask(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm functor, specific to a given render task");
+
+ Stage stage = Stage::GetCurrent();
+ Size stageSize = stage.GetSize();
+ RenderTaskList taskList = stage.GetRenderTaskList();
+
+ Actor actor[2];
+
+ for( int i=0; i<2; i++ )
+ {
+ actor[i] = Actor::New();
+ actor[i].SetSize(100.f, 100.f);
+ actor[i].SetParentOrigin(ParentOrigin::TOP_LEFT);
+ actor[i].SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ actor[i].SetName("HittableActor");
+ stage.Add(actor[i]);
+ }
+ Vector2 position( 50.f, 40.f );
+ actor[1].SetPosition( position.x, position.y );
+
+ RenderTask renderTask[2];
+ renderTask[0] = taskList.GetTask( 0u );
+
+ FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width, stageSize.height, Pixel::A8, Image::NEVER);
+ renderTask[1] = taskList.CreateTask();
+ renderTask[1].SetSourceActor( actor[1] );
+ renderTask[1].SetExclusive( true );
+ renderTask[1].SetInputEnabled( true );
+ renderTask[1].SetTargetFrameBuffer( frameBufferImage );
+ renderTask[1].SetRefreshRate( RenderTask::REFRESH_ONCE );
+ renderTask[1].SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ // Perform a hit-test at the given screen coordinates with different render tasks
+
+ Dali::HitTestAlgorithm::Results results;
+ Vector2 screenCoordinates( 25.f, 25.f );
+
+ Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor[0] );
+ DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( !results.actor );
+ DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ screenCoordinates.x = 80.f;
+ screenCoordinates.y = 70.f;
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor[0] );
+ DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor[1]);
+ DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ screenCoordinates.x = 120.f;
+ screenCoordinates.y = 130.f;
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( !results.actor );
+ DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction );
+ DALI_TEST_CHECK( results.actor == actor[1]);
+ DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION );
+ END_TEST;
+}
+
+
+int UtcDaliHitTestAlgorithmOrtho01(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm with parallel Ortho camera()");
+
+ Stage stage = Stage::GetCurrent();
+ RenderTaskList renderTaskList = stage.GetRenderTaskList();
+ RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
+ Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
+
+ Vector2 stageSize ( stage.GetSize() );
+ cameraActor.SetOrthographicProjection( stageSize );
+ cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
+
+ Vector2 actorSize( stageSize * 0.5f );
+ // Create two actors with half the size of the stage and set them to be partially overlapping
+ Actor blue = Actor::New();
+ blue.SetName( "Blue" );
+ blue.SetAnchorPoint( AnchorPoint::CENTER );
+ blue.SetParentOrigin( Vector3(1.0f/3.0f, 1.0f/3.0f, 0.5f) );
+ blue.SetSize( actorSize );
+ blue.SetZ(30.0f);
+
+ Actor green = Actor::New( );
+ green.SetName( "Green" );
+ green.SetAnchorPoint( AnchorPoint::CENTER );
+ green.SetParentOrigin( Vector3(2.0f/3.0f, 2.0f/3.0f, 0.5f) );
+ green.SetSize( actorSize );
+
+ // Add the actors to the view
+ stage.Add( blue );
+ stage.Add( green );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(0);
+ application.Render(10);
+
+ HitTestAlgorithm::Results results;
+ HitTest(stage, stageSize / 2.0f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == green );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 1.0f/6.0f, TEST_LOCATION );
+
+ HitTest(stage, stageSize / 3.0f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == blue );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
+
+ HitTest(stage, stageSize * 2.0f / 3.0f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == green );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
+ END_TEST;
+}
+
+
+int UtcDaliHitTestAlgorithmOrtho02(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm with offset Ortho camera()");
+
+ Stage stage = Stage::GetCurrent();
+ RenderTaskList renderTaskList = stage.GetRenderTaskList();
+ RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
+ Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
+
+ Vector2 stageSize ( stage.GetSize() );
+ cameraActor.SetOrthographicProjection(-stageSize.x * 0.3f, stageSize.x * 0.7f,
+ stageSize.y * 0.3f, -stageSize.y * 0.7f,
+ 800.0f, 4895.0f);
+ cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
+
+ Vector2 actorSize( stageSize * 0.5f );
+ // Create two actors with half the size of the stage and set them to be partially overlapping
+ Actor blue = Actor::New();
+ blue.SetName( "Blue" );
+ blue.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ blue.SetParentOrigin( Vector3(0.2f, 0.2f, 0.5f) );
+ blue.SetSize( actorSize );
+ blue.SetZ(30.0f);
+
+ Actor green = Actor::New( );
+ green.SetName( "Green" );
+ green.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ green.SetParentOrigin( Vector3(0.4f, 0.4f, 0.5f) );
+ green.SetSize( actorSize );
+
+ // Add the actors to the view
+ stage.Add( blue );
+ stage.Add( green );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(0);
+ application.Render(10);
+
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == green );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.6f, 0.01f, TEST_LOCATION );
+ }
+
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, Vector2( 0.001f, 0.001f ), results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == blue );
+ DALI_TEST_EQUALS( results.actorCoordinates, Vector2( 0.001f, 0.001f ), 0.001f, TEST_LOCATION );
+ }
+
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, stageSize, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( ! results.actor );
+ DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION );
+ }
+
+ // Just inside green
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, stageSize*0.69f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == green );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.98f, 0.01f, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliHitTestAlgorithmStencil(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm with a stencil");
+
+ Stage stage = Stage::GetCurrent();
+ Actor rootLayer = stage.GetRootLayer();
+ rootLayer.SetName( "RootLayer" );
+
+ // Create a layer
+ Layer layer = Layer::New();
+ layer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ layer.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ layer.SetName( "layer" );
+ stage.Add( layer );
+
+ // Create a stencil and add that to the layer
+ Actor stencil = CreateRenderableActor(Dali::BufferImage::WHITE() );
+ stencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ stencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ stencil.SetSize( 50.0f, 50.0f );
+ stencil.SetDrawMode( DrawMode::STENCIL );
+ stencil.SetName( "stencil" );
+ layer.Add( stencil );
+
+ // Create a renderable actor and add that to the layer
+ Actor layerHitActor = CreateRenderableActor( Dali::BufferImage::WHITE() );
+ layerHitActor.SetSize( 100.0f, 100.0f );
+ layerHitActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ layerHitActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ layerHitActor.SetName( "layerHitActor" );
+ layer.Add( layerHitActor );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Hit within stencil and actor
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, Vector2( 10.0f, 10.0f ), results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == layerHitActor );
+ tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
+ }
+
+ // Hit within actor but outside of stencil, should hit the root-layer
+ {
+ HitTestAlgorithm::Results results;
+ HitTest(stage, Vector2( 60.0f, 60.0f ), results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == rootLayer );
+ tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
+ }
+ END_TEST;
+}
+
+int UtcDaliHitTestAlgorithmOverlay(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::HitTestAlgorithm with overlay actors");
+
+ Stage stage = Stage::GetCurrent();
+ RenderTaskList renderTaskList = stage.GetRenderTaskList();
+ RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
+ Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
+
+ Vector2 stageSize ( stage.GetSize() );
+ cameraActor.SetOrthographicProjection( stageSize );
+ cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
+
+ Vector2 actorSize( stageSize * 0.5f );
+ // Create two actors with half the size of the stage and set them to be partially overlapping
+ Actor blue = Actor::New();
+ blue.SetDrawMode( DrawMode::OVERLAY_2D );
+ blue.SetName( "Blue" );
+ blue.SetAnchorPoint( AnchorPoint::CENTER );
+ blue.SetParentOrigin( Vector3(1.0f/3.0f, 1.0f/3.0f, 0.5f) );
+ blue.SetSize( actorSize );
+ blue.SetZ(30.0f);
+
+ Actor green = Actor::New( );
+ green.SetName( "Green" );
+ green.SetAnchorPoint( AnchorPoint::CENTER );
+ green.SetParentOrigin( Vector3(2.0f/3.0f, 2.0f/3.0f, 0.5f) );
+ green.SetSize( actorSize );
+
+ // Add the actors to the view
+ stage.Add( blue );
+ stage.Add( green );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(0);
+ application.Render(10);
+
+ HitTestAlgorithm::Results results;
+
+ //Hit in the intersection. Should pick the blue actor since it is an overlay.
+ HitTest(stage, stageSize / 2.0f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == blue );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 5.0f/6.0f, TEST_LOCATION );
+
+ //Hit in the blue actor
+ HitTest(stage, stageSize / 3.0f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == blue );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
+
+ //Hit in the green actor
+ HitTest(stage, stageSize * 2.0f / 3.0f, results, &DefaultIsActorTouchableFunction);
+ DALI_TEST_CHECK( results.actor == green );
+ DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION );
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <unistd.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/threading/mutex.h>
+#include <dali/devel-api/threading/thread.h>
+#include <dali-test-suite-utils.h>
+
+using Dali::Mutex;
+using Dali::Thread;
+
+int UtcDaliMutexSingleThread(void)
+{
+ tet_infoline("Testing Dali::Mutex in a single thread");
+
+ {
+ Mutex mutex1;
+ DALI_TEST_EQUALS( false, mutex1.IsLocked(), TEST_LOCATION );
+ }
+
+ {
+ Mutex mutex2;
+ Mutex::ScopedLock lock( mutex2 );
+ DALI_TEST_EQUALS( true, mutex2.IsLocked(), TEST_LOCATION );
+ }
+
+ Mutex mutex3;
+ {
+ Mutex::ScopedLock lock( mutex3 );
+ }
+ DALI_TEST_EQUALS( false, mutex3.IsLocked(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+namespace // for local variables to avoid name clashes
+{
+// make all these volatile to pre-empt any optimization screwing up the logic
+volatile int gGlobalValue = 0;
+volatile bool gWorkerThreadWait = true;
+volatile enum ThreadState { INIT, RUN, LOCKING, TERMINATE } gWorkerThreadState = INIT;
+Mutex* volatile gGlobalValueMutex; // volatile pointer to a mutex object
+
+class TestThread : public Thread
+{
+ virtual void Run()
+ {
+ gWorkerThreadState = RUN;
+ {
+ Mutex::ScopedLock lock( *gGlobalValueMutex );
+ gWorkerThreadState = LOCKING;
+ gGlobalValue = -1;
+ while( gWorkerThreadWait ) // wait till we can exit
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ }
+ gWorkerThreadState = TERMINATE;
+ }
+};
+}
+
+int UtcDaliMutexMultiThread(void)
+{
+ tet_infoline("Testing Dali::Mutex multithreaded");
+
+ gGlobalValueMutex = new Dali::Mutex();
+
+ TestThread thread1;
+ // initialize values
+ gGlobalValue = 0;
+ gWorkerThreadWait = true;
+ DALI_TEST_EQUALS( INIT, gWorkerThreadState, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
+ DALI_TEST_EQUALS( false, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+
+ // lock the mutex
+ {
+ Mutex::ScopedLock lock( *gGlobalValueMutex );
+ DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+ thread1.Start();
+ // wait till the thread is in run state
+ while( RUN != gWorkerThreadState )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ // now the thread is running and mutex is still locked by this thread so value is not changed
+ DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 0, gGlobalValue, TEST_LOCATION );
+ // drop out of scope, releases our lock
+ }
+ // now child thread is allowed to change the value
+ // wait till the thread is in locking state
+ while( LOCKING != gWorkerThreadState )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ // mutex is locked, but not by us, by the child thread
+ DALI_TEST_EQUALS( true, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+ // value is changed
+ DALI_TEST_EQUALS( -1, gGlobalValue, TEST_LOCATION );
+ // let worker finish
+ gWorkerThreadWait = false;
+ // wait till the thread is terminated state
+ while( TERMINATE != gWorkerThreadState )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ DALI_TEST_EQUALS( false, gGlobalValueMutex->IsLocked(), TEST_LOCATION );
+ thread1.Join();
+
+ END_TEST;
+}
+
+int UtcDaliMutexNonCopyable(void)
+{
+ // we want to make sure that mutex is not copyable (its copy constructor is not defined)
+ // this test will stop compiling if Mutex has compiler generated copy constructor
+ DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( Mutex ) );
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/scripting/scripting.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+using namespace Dali::Scripting;
+
+namespace
+{
+
+const StringEnum COLOR_MODE_VALUES[] =
+{
+ { "USE_OWN_COLOR", USE_OWN_COLOR },
+ { "USE_PARENT_COLOR", USE_PARENT_COLOR },
+ { "USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR },
+ { "USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA },
+};
+const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] );
+
+const StringEnum POSITION_INHERITANCE_MODE_VALUES[] =
+{
+ { "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION },
+ { "USE_PARENT_POSITION", USE_PARENT_POSITION },
+ { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION },
+ { "DONT_INHERIT_POSITION", DONT_INHERIT_POSITION },
+};
+const unsigned int POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_MODE_VALUES[0] );
+
+const StringEnum DRAW_MODE_VALUES[] =
+{
+ { "NORMAL", DrawMode::NORMAL },
+ { "OVERLAY_2D", DrawMode::OVERLAY_2D },
+ { "STENCIL", DrawMode::STENCIL },
+};
+const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] );
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Helpers for string to enum comparisons for Image and Image loading parameters
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Template to check enumerations of type T, with a class of type X
+ */
+template< typename T, typename X >
+void TestEnumStrings(
+ Property::Map& map, // The map used to create instance of type X
+ const char * const keyName, // the name of the key to iterate through
+ const StringEnum* values, // An array of string values
+ unsigned int num, // Number of items in the array
+ T ( X::*method )() const, // The member method of X to call to get the enum
+ X ( *creator ) ( const Property::Value& ) // The method which creates an instance of type X
+)
+{
+ // get the key reference so we can change its value
+ Property::Value* value = map.Find( keyName );
+ for ( unsigned int i = 0; i < num; ++i )
+ {
+ *value = values[i].string;
+ tet_printf("Checking: %s: %s\n", keyName, values[i].string );
+ X instance = creator( map );
+ DALI_TEST_EQUALS( values[i].value, (int)( instance.*method )(), TEST_LOCATION );
+ }
+}
+
+/// Helper method to create ResourceImage using property
+ResourceImage NewResourceImage( const Property::Value& map )
+{
+ ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
+ return image;
+}
+
+/// Helper method to create ResourceImage using property
+BufferImage NewBufferImage( const Property::Value& map )
+{
+ BufferImage image = BufferImage::DownCast( NewImage( map ) );
+ return image;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Helpers for string to enum comparisons for Actor to Property::Map
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Template to check enumerations of type T
+ */
+template< typename T >
+void TestEnumStrings(
+ const char * const keyName, // The name of the key to check
+ TestApplication& application, // Reference to the application class
+ const StringEnum* values, // An array of string values
+ unsigned int num, // Number of items in the array
+ void ( Actor::*method )( T ) // The Actor member method to set the enumeration
+)
+{
+ for ( unsigned int i = 0; i < num; ++i )
+ {
+ tet_printf("Checking: %s: %s\n", keyName, values[i].string );
+
+ Actor actor = Actor::New();
+ (actor.*method)( ( T ) values[i].value );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+
+ DALI_TEST_CHECK( 0 < map.Count() );
+ DALI_TEST_CHECK( NULL != map.Find( keyName ) );
+ DALI_TEST_EQUALS( map.Find( keyName )->Get< std::string >(), values[i].string, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+
+} // anon namespace
+
+int UtcDaliScriptingNewImageNegative01(void)
+{
+ // Invalid filename
+ Property::Map map;
+ map[ "filename" ] = Vector3::ZERO;
+ // will give us an empty image handle
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( !image );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative02(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid load-policy value type
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "loadPolicy" ] = Vector3::ZERO;
+ // will give us a valid image handle with default load policy
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ DALI_TEST_EQUALS( resImage.GetLoadPolicy(), ResourceImage::IMMEDIATE, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative03(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid load-policy value
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "loadPolicy" ] = "INVALID";
+ // will give us a valid image with default load policy
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ DALI_TEST_EQUALS( resImage.GetLoadPolicy(), ResourceImage::IMMEDIATE, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative04(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid release-policy value type
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "releasePolicy" ] = Vector3::ZERO;
+ // will give us a valid image with default release policy
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ DALI_TEST_EQUALS( resImage.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative05(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid release-policy value
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "releasePolicy" ] = "INVALID";
+ // will give us a valid image with default release policy
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ DALI_TEST_EQUALS( resImage.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative06(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid width and height
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "width" ] = "Invalid";
+ map[ "height" ] = 100;
+ // will give us a valid image
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ DALI_TEST_EQUALS( resImage.GetWidth(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( resImage.GetHeight(), 100u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative07(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid height
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "width" ] = 10;
+ map[ "height" ] = "Invalid";
+ // will give us a valid image
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ DALI_TEST_EQUALS( resImage.GetWidth(), 10u, TEST_LOCATION );
+ DALI_TEST_EQUALS( resImage.GetHeight(), 0u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative08(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid fitting-mode
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "fittingMode" ] = Vector3::ZERO;
+ // will give us a valid image
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative09(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid value
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "fittingMode" ] = "INVALID";
+ // will give us a valid image
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative10(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid scaling-mode
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "samplingMode" ] = Vector3::ZERO;
+ // will give us a valid image
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative12(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid orientation-correction
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "orientation" ] = Vector3::ZERO;
+ // will give us a valid image
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative13(void)
+{
+ TestApplication application; // Image needs application
+ // Invalid type
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+ map[ "type" ] = Vector3::ZERO;
+ // will give us a valid image
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ ResourceImage resImage = ResourceImage::DownCast( image );
+ DALI_TEST_CHECK( resImage );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative14(void)
+{
+ // Invalid value
+ Property::Map map;
+ map[ "type" ] = "INVALID";
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( !image );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative15(void)
+{
+ // Invalid pixel-format
+ Property::Map map;
+ map[ "pixelFormat" ] = Vector3::ZERO;
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( !image );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImageNegative16(void)
+{
+ // Invalid value
+ Property::Map map;
+ map[ "pixelFormat" ] = "INVALID";
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( !image );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage01P(void)
+{
+ TestApplication application; // Image needs application
+
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+
+ // Filename only
+ ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
+ DALI_TEST_EQUALS( "TEST_FILE", image.GetUrl(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage02P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+
+ // load-policy
+ map[ "loadPolicy" ] = "";
+ const StringEnum values[] =
+ {
+ { "IMMEDIATE", ResourceImage::IMMEDIATE },
+ { "ON_DEMAND", ResourceImage::ON_DEMAND }
+ };
+ TestEnumStrings< ResourceImage::LoadPolicy, ResourceImage >( map, "loadPolicy", values, ( sizeof( values ) / sizeof ( values[0] ) ), &ResourceImage::GetLoadPolicy, &NewResourceImage );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage03P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+
+ // release-policy
+ map[ "releasePolicy" ] = "";
+ const StringEnum values[] =
+ {
+ { "UNUSED", Image::UNUSED },
+ { "NEVER", Image::NEVER }
+ };
+ TestEnumStrings< Image::ReleasePolicy, Image >( map, "releasePolicy", values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage04P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+
+ // float width and height
+ map[ "width" ] = (float) 10.0f;
+ map[ "height" ] = (float) 20.0f;
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( image.GetWidth(), 10u, TEST_LOCATION );
+ DALI_TEST_EQUALS( image.GetHeight(), 20u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage05P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "filename" ] = "TEST_FILE";
+
+ // width and height
+ map[ "width"] = 50;
+ map[ "height" ] = 70;
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
+ DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage06P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ // type FrameBufferImage
+ map[ "type" ] = "FrameBufferImage";
+ // width and height
+ map[ "width"] = 50;
+ map[ "height" ] = 70;
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage07P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ // type BufferImage
+ map[ "type" ] = "BufferImage";
+ // width and height
+ map[ "width"] = 50;
+ map[ "height" ] = 70;
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ DALI_TEST_CHECK( BufferImage::DownCast( image ) );
+ DALI_TEST_EQUALS( (BufferImage::DownCast( image )).GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage08P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "type" ] = "BufferImage";
+ // width and height
+ map[ "width"] = 66;
+ map[ "height" ] = 99;
+ // pixel-format
+ map[ "pixelFormat" ] = "";
+ const StringEnum values[] =
+ {
+ { "A8", Pixel::A8 },
+ { "L8", Pixel::L8 },
+ { "LA88", Pixel::LA88 },
+ { "RGB565", Pixel::RGB565 },
+ { "BGR565", Pixel::BGR565 },
+ { "RGBA4444", Pixel::RGBA4444 },
+ { "BGRA4444", Pixel::BGRA4444 },
+ { "RGBA5551", Pixel::RGBA5551 },
+ { "BGRA5551", Pixel::BGRA5551 },
+ { "RGB888", Pixel::RGB888 },
+ { "RGB8888", Pixel::RGB8888 },
+ { "BGR8888", Pixel::BGR8888 },
+ { "RGBA8888", Pixel::RGBA8888 },
+ { "BGRA8888", Pixel::BGRA8888 },
+ // BufferImage does not support compressed formats
+ };
+ TestEnumStrings< Pixel::Format, BufferImage >( map, "pixelFormat", values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
+
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage09P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ // type Image
+ map[ "type" ] = "ResourceImage";
+ map[ "filename" ] = "TEST_FILE";
+
+ {
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( ResourceImage::DownCast( image ) );
+ DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
+ DALI_TEST_CHECK( !BufferImage::DownCast( image ) );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingNewImage10P(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ // type FrameBufferImage, empty size gives us stage size
+ map[ "type" ] = "FrameBufferImage";
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( image );
+ END_TEST;
+}
+
+int UtcDaliScriptingNewActorNegative(void)
+{
+ TestApplication application;
+
+ // Empty map
+ {
+ Actor handle = NewActor( Property::Map() );
+ DALI_TEST_CHECK( !handle );
+ }
+
+ // Map with only properties
+ {
+ Property::Map map;
+ map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER;
+ map[ "anchorPoint" ] = AnchorPoint::TOP_CENTER;
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( !handle );
+ }
+
+ // Add some signals to the map, we should have no signal connections as its not yet supported
+ {
+ Property::Map map;
+ map[ "type" ] = "Actor";
+ map[ "signals" ] = Property::MAP;
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+ DALI_TEST_CHECK( !handle.WheelEventSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingNewActorProperties(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "type" ] = "Actor";
+ map[ "size" ] = Vector3::ONE;
+ map[ "position" ] = Vector3::XAXIS;
+ map[ "scale" ] = Vector3::ONE;
+ map[ "visible" ] = false;
+ map[ "color" ] = Color::MAGENTA;
+ map[ "name" ] = "MyActor";
+ map[ "colorMode" ] = "USE_PARENT_COLOR";
+ map[ "sensitive" ] = false;
+ map[ "leaveRequired" ] = true;
+ map[ "positionInheritance" ] = "DONT_INHERIT_POSITION";
+ map[ "drawMode" ] = "STENCIL";
+ map[ "inheritOrientation" ] = false;
+ map[ "inheritScale" ] = false;
+
+ // Default properties
+ {
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentSize(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsVisible(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetName(), "MyActor", TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsSensitive(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetLeaveRequired(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsOrientationInherited(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ }
+
+ // Check Anchor point and parent origin vector3s
+ map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER;
+ map[ "anchorPoint" ] = AnchorPoint::TOP_LEFT;
+ {
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ }
+
+ // Check Anchor point and parent origin STRINGS
+ map[ "parentOrigin" ] = "TOP_LEFT";
+ map[ "anchorPoint" ] = "CENTER_LEFT";
+ {
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingNewActorChildren(void)
+{
+ TestApplication application;
+
+ Property::Map map;
+ map[ "type" ] = "Actor";
+ map[ "position" ] = Vector3::XAXIS;
+
+ Property::Map child1Map;
+ child1Map[ "type" ] = "CameraActor";
+ child1Map[ "position" ] = Vector3::YAXIS;
+
+ Property::Array childArray;
+ childArray.PushBack( child1Map );
+ map[ "actors" ] = childArray;
+
+ // Create
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetChildCount(), 1u, TEST_LOCATION );
+
+ Actor child1 = handle.GetChildAt(0);
+ DALI_TEST_CHECK( child1 );
+ DALI_TEST_CHECK( CameraActor::DownCast( child1 ) );
+ DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( child1.GetChildCount(), 0u, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ END_TEST;
+}
+
+
+int UtcDaliScriptingCreatePropertyMapActor(void)
+{
+ TestApplication application;
+
+ // Actor Type
+ {
+ Actor actor = Actor::New();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+ DALI_TEST_CHECK( !map.Empty() );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type")->Get< std::string >(), "Actor", TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+
+ // Layer Type
+ {
+ Actor actor = Layer::New();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+ DALI_TEST_CHECK( !map.Empty() );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+
+ // Default properties
+ {
+ Actor actor = Actor::New();
+ actor.SetSize( Vector3::ONE );
+ actor.SetPosition( Vector3::XAXIS );
+ actor.SetScale( Vector3::ZAXIS );
+ actor.SetVisible( false );
+ actor.SetColor( Color::MAGENTA );
+ actor.SetName( "MyActor" );
+ actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ actor.SetParentOrigin( ParentOrigin::TOP_RIGHT );
+ actor.SetSensitive( false );
+ actor.SetLeaveRequired( true );
+ actor.SetInheritOrientation( false );
+ actor.SetInheritScale( false );
+ actor.SetSizeModeFactor( Vector3::ONE );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+
+ DALI_TEST_CHECK( !map.Empty() );
+ DALI_TEST_CHECK( NULL != map.Find( "size" ) );
+ DALI_TEST_EQUALS( map.Find( "size" )->Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "position" ) );
+ DALI_TEST_EQUALS( map.Find( "position" )->Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "scale" ) );
+ DALI_TEST_EQUALS( map.Find( "scale" )->Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "visible" ) );
+ DALI_TEST_EQUALS( map.Find( "visible" )->Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "color" ) );
+ DALI_TEST_EQUALS( map.Find( "color" )->Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "name" ) );
+ DALI_TEST_EQUALS( map.Find( "name")->Get< std::string >(), "MyActor", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "anchorPoint" ) );
+ DALI_TEST_EQUALS( map.Find( "anchorPoint" )->Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "parentOrigin" ) );
+ DALI_TEST_EQUALS( map.Find( "parentOrigin" )->Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "sensitive" ) );
+ DALI_TEST_EQUALS( map.Find( "sensitive" )->Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "leaveRequired" ) );
+ DALI_TEST_EQUALS( map.Find( "leaveRequired" )->Get< bool >(), true, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "inheritOrientation" ) );
+ DALI_TEST_EQUALS( map.Find( "inheritOrientation" )->Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "inheritScale" ) );
+ DALI_TEST_EQUALS( map.Find( "inheritScale" )->Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "sizeModeFactor" ) );
+ DALI_TEST_EQUALS( map.Find( "sizeModeFactor" )->Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+
+ // ColorMode
+ TestEnumStrings< ColorMode >( "colorMode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode );
+
+ // PositionInheritanceMode
+ TestEnumStrings< PositionInheritanceMode >( "positionInheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode );
+
+ // DrawMode
+ TestEnumStrings< DrawMode::Type >( "drawMode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode );
+
+ // Children
+ {
+ Actor actor = Actor::New();
+ Actor child = Layer::New();
+ actor.Add( child );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+ DALI_TEST_CHECK( !map.Empty() );
+
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Actor", TEST_LOCATION );
+
+ DALI_TEST_CHECK( NULL != map.Find( "actors" ) );
+ Property::Array children( map.Find( "actors")->Get< Property::Array >() );
+ DALI_TEST_CHECK( !children.Empty() );
+ Property::Map childMap( children[0].Get< Property::Map >() );
+ DALI_TEST_CHECK( !childMap.Empty() );
+ DALI_TEST_CHECK( childMap.Find( "type" ) );
+ DALI_TEST_EQUALS( childMap.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingCreatePropertyMapImage(void)
+{
+ TestApplication application;
+
+ // Empty
+ {
+ Image image;
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( map.Empty() );
+ }
+
+ // Default
+ {
+ Image image = ResourceImage::New( "MY_PATH" );
+
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( !map.Empty() );
+
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
+ DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "loadPolicy") );
+ DALI_TEST_EQUALS( map.Find( "loadPolicy" )->Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "releasePolicy") );
+ DALI_TEST_EQUALS( map.Find( "releasePolicy" )->Get< std::string >(), "NEVER", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL == map.Find( "width" ) );
+ DALI_TEST_CHECK( NULL == map.Find( "height" ) );
+ }
+
+ // Change values
+ {
+ ResourceImage image = ResourceImage::New( "MY_PATH", ResourceImage::ON_DEMAND, Image::UNUSED, ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
+
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( !map.Empty() );
+
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
+ DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "loadPolicy") );
+ DALI_TEST_EQUALS( map.Find( "loadPolicy" )->Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "releasePolicy") );
+ DALI_TEST_EQUALS( map.Find( "releasePolicy" )->Get< std::string >(), "UNUSED", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "width" ) );
+ DALI_TEST_EQUALS( map.Find( "width" )->Get< int >(), 300, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "height" ) );
+ DALI_TEST_EQUALS( map.Find( "height" )->Get< int >(), 400, TEST_LOCATION );
+ }
+
+ // BufferImage
+ {
+ Image image = BufferImage::New( 200, 300, Pixel::A8 );
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "BufferImage", TEST_LOCATION );
+ DALI_TEST_CHECK( NULL != map.Find( "pixelFormat") );
+ DALI_TEST_EQUALS( map.Find( "pixelFormat" )->Get< std::string >(), "A8", TEST_LOCATION );
+ }
+
+ // FrameBufferImage
+ {
+ Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( NULL != map.Find( "type" ) );
+ DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
+int UtcDaliScriptingGetEnumerationTemplates(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ { "ONE", 1 },
+ { "TWO", 2 },
+ { "THREE", 3 },
+ { "FOUR", 4 },
+ { "FIVE", 5 },
+ };
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+
+ for ( unsigned int i = 0; i < myTableCount; ++i )
+ {
+ tet_printf("Checking: %s\n", myTable[ i ].string );
+ int value;
+ DALI_TEST_CHECK( GetEnumeration<int>( myTable[ i ].string, myTable, myTableCount, value ) );
+ DALI_TEST_EQUALS( myTable[ i ].value, value, TEST_LOCATION );
+ }
+
+ for ( unsigned int i = 0; i < myTableCount; ++i )
+ {
+ tet_printf("Checking: %d\n", myTable[ i ].value );
+ DALI_TEST_EQUALS( myTable[ i ].string, GetEnumerationName( myTable[ i ].value, myTable, myTableCount ), TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliScriptingGetEnumerationNameN(void)
+{
+ const char* value = GetEnumerationName( 10, NULL, 0 );
+ DALI_TEST_CHECK( NULL == value );
+
+ value = GetEnumerationName( 10, NULL, 1 );
+ DALI_TEST_CHECK( NULL == value );
+
+ END_TEST;
+}
+
+int UtcDaliScriptingGetLinearEnumerationNameN(void)
+{
+ const char* value = GetLinearEnumerationName( 10, NULL, 0 );
+ DALI_TEST_CHECK( NULL == value );
+
+ value = GetLinearEnumerationName( 10, NULL, 1 );
+ DALI_TEST_CHECK( NULL == value );
+
+ END_TEST;
+}
+
+int UtcDaliScriptingFindEnumIndexN(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ { "ONE", (1<<1) },
+ { "TWO", (1<<2) },
+ { "THREE", (1<<3) },
+ { "FOUR", (1<<4) },
+ { "FIVE", (1<<5) },
+ };
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+ DALI_TEST_EQUALS( myTableCount, FindEnumIndex( "Foo", myTable, myTableCount ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliScriptingEnumStringToIntegerP(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ { "ONE", (1<<1) },
+ { "TWO", (1<<2) },
+ { "THREE", (1<<3) },
+ { "FOUR", (1<<4) },
+ { "FIVE", (1<<5) },
+ };
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+
+ unsigned int integerEnum = 0;
+ DALI_TEST_CHECK( EnumStringToInteger( "ONE", myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
+
+ integerEnum = 0;
+ DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION );
+
+ DALI_TEST_CHECK( EnumStringToInteger( "ONE,,TWO", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION );
+
+ DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO,THREE", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3), TEST_LOCATION );
+
+ DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO,THREE,FOUR,FIVE", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5), TEST_LOCATION );
+
+ DALI_TEST_CHECK( EnumStringToInteger( "TWO,ONE", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION );
+
+ DALI_TEST_CHECK( EnumStringToInteger( "TWO,ONE,FOUR,THREE,FIVE", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5), TEST_LOCATION );
+
+ DALI_TEST_CHECK( EnumStringToInteger( "ONE,SEVEN", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
+
+ DALI_TEST_CHECK( EnumStringToInteger( "ONE,", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
+
+
+ END_TEST;
+}
+
+int UtcDaliScriptingEnumStringToIntegerN(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ { "ONE", 1 },
+ { "TWO", 2 },
+ { "THREE", 3 },
+ { "FOUR", 4 },
+ { "FIVE", 5 },
+ };
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+
+ unsigned int integerEnum = 0;
+ DALI_TEST_CHECK( !EnumStringToInteger( "Foo", myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( "", myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( ",", myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( ",ONE,SEVEN", myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( ",", myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( "ONE", myTable, 0, integerEnum ) );
+
+ DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliScriptingEnumStringToIntegerInvalidEnumP(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ { "", 1 },
+ { "", 2 },
+ { "", 3 },
+ };
+
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+
+ unsigned int integerEnum = 0;
+ DALI_TEST_CHECK( EnumStringToInteger( "", myTable, myTableCount, integerEnum ) );
+ DALI_TEST_EQUALS( integerEnum, 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliScriptingEnumStringToIntegerInvalidEnumN(void)
+{
+ const Scripting::StringEnum myTable[] =
+ {
+ { "", 1 },
+ { "", 1 },
+ { "", 1 },
+ };
+
+ const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
+
+ unsigned int integerEnum = 0;
+ DALI_TEST_CHECK( !EnumStringToInteger( NULL, NULL, 0, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, 0, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( NULL, myTable, 0, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( NULL, myTable, myTableCount, integerEnum ) );
+
+ DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, myTableCount, integerEnum ) );
+
+ DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION );
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <iostream>
+#include <stdlib.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/signals/signal-delegate.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+
+void utc_dali_signal_delegate_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_signal_delegate_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+// Test infrastructure:
+
+static bool gSignalReceived = false;
+
+/**
+ * This object allows us to test member function connection.
+ */
+class SignalDelegateTestClass : public Dali::ConnectionTracker
+{
+public:
+
+ SignalDelegateTestClass( Actor connectActor, std::string connectSignal )
+ {
+ mSignalDelegate = new SignalDelegate( connectActor, connectSignal );
+ }
+
+ void ConnectToInternalMember()
+ {
+ mSignalDelegate->Connect( this, &SignalDelegateTestClass::SignalHandlerMemberFunction );
+ }
+
+ bool IsConnected()
+ {
+ return mSignalDelegate->IsConnected();
+ }
+
+private:
+
+ void SignalHandlerMemberFunction()
+ {
+ tet_infoline( "Got signal in member function\n" );
+ gSignalReceived = true;
+ }
+
+ SignalDelegate* mSignalDelegate;
+};
+
+/**
+ * A connection tracker is required when connecting a signal delegate to a functor.
+ */
+class TestConnectionTrackerObject : public ConnectionTracker
+{
+};
+
+/**
+ * This functor is used to test the signal delegate's connect ( to functor ) method.
+ */
+struct SignalDelegateTestFunctor
+{
+ SignalDelegateTestFunctor()
+ {
+ }
+
+ void operator()()
+ {
+ gSignalReceived = true;
+ }
+};
+
+
+// Test cases:
+
+int UtcDaliSignalDelegateIsConnectedP(void)
+{
+ TestApplication application;
+ tet_infoline( " UtcDaliSignalDelegateIsConnectedP" );
+
+ // Set up an actor with a signal to connect to.
+ Actor connectActor = Actor::New();
+ std::string connectSignal = "onStage";
+
+ // Create the test class (this will create the delegate, but not connect to it yet.
+ SignalDelegateTestClass testObject( connectActor, connectSignal );
+
+ // Tell the test class to connect the delegate to it's internal member.
+ // Note: It is at this point that the delegate internally makes the connection.
+ testObject.ConnectToInternalMember();
+
+ DALI_TEST_CHECK( testObject.IsConnected() );
+
+ END_TEST;
+}
+
+int UtcDaliSignalDelegateIsConnectedN(void)
+{
+ TestApplication application;
+ tet_infoline( " UtcDaliSignalDelegateIsConnectedN" );
+
+ // Set up an actor with a signal to connect to.
+ Actor connectActor = Actor::New();
+ std::string connectSignal = "onStage";
+
+ // Create the test class (this will create the delegate, but not connect to it yet.
+ SignalDelegateTestClass testObject( connectActor, connectSignal );
+
+ DALI_TEST_CHECK( !testObject.IsConnected() );
+
+ END_TEST;
+}
+
+int UtcDaliSignalDelegateConnectToMemberP(void)
+{
+ TestApplication application;
+ tet_infoline( " UtcDaliSignalDelegateConnectToMemberP" );
+
+ // Set up an actor with a signal to connect to.
+ Actor connectActor = Actor::New();
+ std::string connectSignal = "onStage";
+
+ gSignalReceived = false;
+
+ // Create the test class (this will create the delegate, but not connect to it yet.
+ SignalDelegateTestClass testObject( connectActor, connectSignal );
+
+ // Tell the test class to connect the delegate to it's internal member.
+ // Note: It is at this point that the delegate internally makes the connection.
+ testObject.ConnectToInternalMember();
+
+ // Add the actor to the stage to trigger it's "onStage" signal.
+ // If the delegate connected correctly, this will call the member
+ // function in the test object and set a global flag.
+ Stage::GetCurrent().Add( connectActor );
+
+ // Check the global flag to confirm the signal was received.
+ DALI_TEST_CHECK( gSignalReceived );
+
+ END_TEST;
+}
+
+int UtcDaliSignalDelegateConnectToMemberN(void)
+{
+ TestApplication application;
+ tet_infoline( " UtcDaliSignalDelegateConnectToMemberN" );
+
+ // Set up an actor with a signal to connect to.
+ Actor connectActor = Actor::New();
+ std::string connectSignal = "onStage";
+
+ gSignalReceived = false;
+
+ // Create the test class (this will create the delegate, but not connect to it yet.
+ SignalDelegateTestClass testObject( connectActor, connectSignal );
+
+ // Tell the test class to connect the delegate to it's internal member.
+ // Note: It is at this point that the delegate internally makes the connection.
+ testObject.ConnectToInternalMember();
+
+ // Check the global flag to confirm the signal was not received.
+ DALI_TEST_CHECK( !gSignalReceived );
+
+ END_TEST;
+}
+
+int UtcDaliSignalDelegateConnectToFunctorP(void)
+{
+ TestApplication application;
+ tet_infoline( " UtcDaliSignalDelegateConnectToFunctorP" );
+
+ // Set up an actor with a signal to connect to.
+ Actor connectActor = Actor::New();
+ std::string connectSignal = "onStage";
+
+ // Initialise the signal delegate with the actor to connect to and it's signal.
+ SignalDelegate signalDelegate( connectActor, connectSignal );
+
+ // We need a connection tracker object to associated with the connection.
+ // This could normally be "this", but since we are not within a class, we pass
+ // in an external one.
+ TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
+
+ // Check the signal delegate currently has no connection.
+ DALI_TEST_CHECK( !signalDelegate.IsConnected() );
+
+ // Tell the signal delegate to connect to the given functor (via a functor delegate).
+ // Note: It is at this point that the delegate internally makes the connection.
+ signalDelegate.Connect( testTracker, FunctorDelegate::New( SignalDelegateTestFunctor() ) );
+
+ // Check the signal delegate has made the connection.
+ DALI_TEST_CHECK( signalDelegate.IsConnected() );
+
+ // Add the actor to the stage to trigger it's "onStage" signal.
+ // If the delegate connected correctly, this will call the () operator of our
+ // passed-in functor, the functor will in turn set a global flag.
+ Stage::GetCurrent().Add( connectActor );
+
+ // Check the global flag to confirm the signal was received.
+ DALI_TEST_CHECK( gSignalReceived );
+
+ END_TEST;
+}
+
+int UtcDaliSignalDelegateConnectToFunctorN(void)
+{
+ TestApplication application;
+ tet_infoline( " UtcDaliSignalDelegateConnectToFunctorN" );
+
+ // Set up an actor with a signal to connect to.
+ Actor connectActor = Actor::New();
+ std::string connectSignal = "onStage";
+
+ // Initialise the signal delegate with the actor to connect to and it's signal.
+ SignalDelegate signalDelegate( connectActor, connectSignal );
+
+ // We need a connection tracker object to associated with the connection.
+ // This could normally be "this", but since we are not within a class, we pass
+ // in an external one.
+ TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
+
+ // Check the signal delegate currently has no connection.
+ DALI_TEST_CHECK( !signalDelegate.IsConnected() );
+
+ // Tell the signal delegate to connect to the given functor (via a functor delegate).
+ // Note: It is at this point that the delegate internally makes the connection.
+ signalDelegate.Connect( testTracker, FunctorDelegate::New( SignalDelegateTestFunctor() ) );
+
+ // Check the signal delegate has made the connection.
+ DALI_TEST_CHECK( signalDelegate.IsConnected() );
+
+ // Check the global flag to confirm the signal was received.
+ DALI_TEST_CHECK( !gSignalReceived );
+
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <unistd.h>
+#include <dali-test-suite-utils.h>
+#include <dali/devel-api/threading/thread.h>
+
+using Dali::Thread;
+
+namespace
+{
+volatile bool gRunThreadEntryFunc = false;
+
+class TestThread : public Thread
+{
+ virtual void Run()
+ {
+ gRunThreadEntryFunc = true;
+ }
+};
+}
+
+int UtcDaliThreadP(void)
+{
+ tet_infoline("Testing Dali::Thread");
+
+ gRunThreadEntryFunc = false;
+
+ TestThread thread;
+
+ thread.Start();
+ // wait till the thread is terminated
+ while( !gRunThreadEntryFunc )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ DALI_TEST_EQUALS( true, gRunThreadEntryFunc, TEST_LOCATION );
+
+ thread.Join();
+
+ // Restart the thread after joined
+ gRunThreadEntryFunc = false;
+ thread.Start();
+ thread.Join();
+ // wait till the thread is terminated
+ while( !gRunThreadEntryFunc )
+ {
+ usleep( 1 ); // 1 microsecond
+ }
+ DALI_TEST_EQUALS( true, gRunThreadEntryFunc, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliThreadNonCopyable(void)
+{
+ // we want to make sure that mutex is not copyable (its copy constructor is not defined)
+ // this test will stop compiling if Mutex has compiler generated copy constructor
+ DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( Thread ) );
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/object/weak-handle.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+namespace
+{
+
+/*******************************************************************************
+ *
+ * Custom Actor
+ *
+ ******************************************************************************/
+namespace Impl
+{
+struct MyTestCustomActor : public CustomActorImpl
+{
+ typedef Signal< void ()> SignalType;
+ typedef Signal< void (float)> SignalTypeFloat;
+
+ MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
+ { }
+
+ virtual ~MyTestCustomActor()
+ { }
+
+ void ResetCallStack()
+ {
+ }
+
+ // From CustomActorImpl
+ virtual void OnStageConnection( int depth )
+ {
+ }
+ virtual void OnStageDisconnection()
+ {
+ }
+ virtual void OnChildAdd(Actor& child)
+ {
+ }
+ virtual void OnChildRemove(Actor& child)
+ {
+ }
+ virtual void OnSizeSet(const Vector3& targetSize)
+ {
+ }
+ virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
+ {
+ }
+ virtual bool OnTouchEvent(const TouchEvent& event)
+ {
+ return true;
+ }
+ virtual bool OnHoverEvent(const HoverEvent& event)
+ {
+ return true;
+ }
+ virtual bool OnWheelEvent(const WheelEvent& event)
+ {
+ return true;
+ }
+ virtual bool OnKeyEvent(const KeyEvent& event)
+ {
+ return true;
+ }
+ virtual void OnKeyInputFocusGained()
+ {
+ }
+ virtual void OnKeyInputFocusLost()
+ {
+ }
+ virtual Vector3 GetNaturalSize()
+ {
+ return Vector3( 0.0f, 0.0f, 0.0f );
+ }
+
+ virtual float GetHeightForWidth( float width )
+ {
+ return 0.0f;
+ }
+
+ virtual float GetWidthForHeight( float height )
+ {
+ return 0.0f;
+ }
+
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
+ {
+ }
+
+ virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
+ {
+ }
+
+ virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
+ {
+ }
+
+ virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
+ {
+ return 0.0f;
+ }
+
+ virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
+ {
+ }
+
+ virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
+ {
+ return false;
+ }
+
+public:
+
+ SignalType mSignal;
+};
+
+}; // namespace Impl
+
+class MyTestCustomActor : public CustomActor
+{
+public:
+
+ typedef Signal< void ()> SignalType;
+ typedef Signal< void (float)> SignalTypeFloat;
+
+ MyTestCustomActor()
+ {
+ }
+
+ static MyTestCustomActor New()
+ {
+ Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor;
+ return MyTestCustomActor( *p ); // takes ownership
+ }
+
+ virtual ~MyTestCustomActor()
+ {
+ }
+
+ static MyTestCustomActor DownCast( BaseHandle handle )
+ {
+ MyTestCustomActor result;
+
+ CustomActor custom = Dali::CustomActor::DownCast( handle );
+ if ( custom )
+ {
+ CustomActorImpl& customImpl = custom.GetImplementation();
+
+ Impl::MyTestCustomActor* impl = dynamic_cast<Impl::MyTestCustomActor*>(&customImpl);
+
+ if (impl)
+ {
+ result = MyTestCustomActor(customImpl.GetOwner());
+ }
+ }
+
+ return result;
+ }
+
+ SignalType& GetCustomSignal()
+ {
+ Dali::RefObject& obj = GetImplementation();
+ return static_cast<Impl::MyTestCustomActor&>( obj ).mSignal;
+ }
+
+ MyTestCustomActor(Internal::CustomActor* internal)
+ : CustomActor(internal)
+ {
+ }
+
+ MyTestCustomActor( Impl::MyTestCustomActor& impl )
+ : CustomActor( impl )
+ {
+ }
+};
+
+}
+
+int UtcDaliWeakHandleBaseConstructorVoid(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::WeakHandleBase::WeakHandleBase()");
+
+ WeakHandleBase object;
+
+ DALI_TEST_CHECK(!object.GetBaseHandle());
+
+ END_TEST;
+}
+
+int UtcDaliWeakHandleBaseConstructorWithHandle(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::WeakHandleBase::WeakHandleBase(Handle)");
+
+ Handle emptyHandle;
+ WeakHandleBase emptyObject(emptyHandle);
+ DALI_TEST_CHECK(!emptyObject.GetBaseHandle());
+
+ Actor actor = Actor::New();
+ WeakHandleBase object(actor);
+ DALI_TEST_CHECK(object.GetBaseHandle() == actor);
+
+ END_TEST;
+}
+
+int UtcDaliWeakHandleBaseCopyConstructor(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::WeakHandleBase::WeakHandleBase(const WeakHandleBase&)");
+
+ Actor actor = Actor::New();
+ DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
+
+ WeakHandleBase object(actor);
+ DALI_TEST_CHECK(object.GetBaseHandle() == actor);
+ DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
+
+ WeakHandleBase copy(object);
+ DALI_TEST_CHECK(copy.GetBaseHandle() == actor);
+ DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
+
+ END_TEST;
+}
+
+int UtcDaliWeakHandleBaseAssignmentOperator(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::WeakHandleBase::operator=");
+
+ Actor actor = Actor::New();
+ DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
+
+ WeakHandleBase object(actor);
+ DALI_TEST_CHECK(object.GetBaseHandle() == actor);
+ DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
+
+ WeakHandleBase copy = object;
+ DALI_TEST_CHECK(copy.GetBaseHandle() == actor);
+ DALI_TEST_EQUALS(1, actor.GetBaseObject().ReferenceCount(), TEST_LOCATION); // reference count of the actor is not increased
+
+ END_TEST;
+}
+
+int UtcDaliWeakHandleBaseEqualityOperatorP(void)
+{
+ TestApplication application;
+ tet_infoline("Positive Test Dali::WeakHandleBase::operator==");
+
+ WeakHandleBase object;
+ WeakHandleBase theSameObject;
+ DALI_TEST_CHECK(object == theSameObject);
+
+ Actor actor = Actor::New();
+
+ object = WeakHandleBase(actor);
+ DALI_TEST_CHECK(object.GetBaseHandle() == actor);
+
+ theSameObject = object;
+ DALI_TEST_CHECK(theSameObject.GetBaseHandle() == actor);
+ DALI_TEST_CHECK(object == theSameObject);
+
+ END_TEST;
+}
+
+int UtcDaliWeakHandleBaseEqualityOperatorN(void)
+{
+ TestApplication application;
+ tet_infoline("Negative Test Dali::WeakHandleBase::operator==");
+
+ Actor actor = Actor::New();
+
+ WeakHandleBase object(actor);
+ DALI_TEST_CHECK(object.GetBaseHandle() == actor);
+
+ Actor differentActor = Actor::New();
+ WeakHandleBase aDifferentWeakHandleBase(differentActor);
+
+ DALI_TEST_CHECK(!(object == aDifferentWeakHandleBase));
+
+ END_TEST;
+}
+
+int UtcDaliWeakHandleBaseInequalityOperatorP(void)
+{
+ TestApplication application;
+ tet_infoline("Positive Test Dali::WeakHandleBase::operator!=");
+
+ Actor actor = Actor::New();
+
+ WeakHandleBase object(actor);
+ DALI_TEST_CHECK(object.GetBaseHandle() == actor);
+
+ Actor differentActor = Actor::New();
+ WeakHandleBase aDifferentWeakHandleBase(differentActor);
+
+ DALI_TEST_CHECK(object != aDifferentWeakHandleBase);
+ END_TEST;
+}
+
+int UtcDaliWeakHandleBaseInequalityOperatorN(void)
+{
+ TestApplication application;
+ tet_infoline("Negative Test Dali::WeakHandleBase::operator!=");
+
+ Actor actor = Actor::New();
+
+ WeakHandleBase object(actor);
+ DALI_TEST_CHECK(object.GetBaseHandle() == actor);
+
+ WeakHandleBase theSameWeakHandleBase = object;
+
+ DALI_TEST_CHECK(!(object != theSameWeakHandleBase));
+ END_TEST;
+}
+
+int UtcDaliWeakHandleBaseGetBaseHandle(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::WeakHandleBase::GetBaseHandle()");
+
+ Handle emptyHandle;
+ WeakHandleBase emptyObject(emptyHandle);
+ DALI_TEST_CHECK(!emptyObject.GetBaseHandle());
+
+ Actor actor = Actor::New();
+ WeakHandleBase object(actor);
+ DALI_TEST_CHECK(object.GetBaseHandle() == actor);
+
+ WeakHandleBase theSameObject = WeakHandleBase(actor);
+ DALI_TEST_CHECK(object.GetBaseHandle() == theSameObject.GetBaseHandle());
+
+ Actor differentActor = Actor::New();
+ WeakHandleBase aDifferentWeakHandleBase(differentActor);
+ DALI_TEST_CHECK(object.GetBaseHandle() != aDifferentWeakHandleBase.GetBaseHandle());
+
+ END_TEST;
+}
+
+int UtcDaliWeakHandleGetHandle(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::WeakHandle::GetHandle()");
+
+ Actor actor = Actor::New();
+ WeakHandle<Actor> object(actor);
+ DALI_TEST_CHECK(object.GetHandle() == actor);
+
+ MyTestCustomActor customActor = MyTestCustomActor::New();
+ WeakHandle<MyTestCustomActor> customObject(customActor);
+ DALI_TEST_CHECK(customObject.GetHandle() == customActor);
+
+ DALI_TEST_CHECK(object.GetHandle() != customObject.GetHandle());
+
+ END_TEST;
+}
+
+
+