X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-PinchGestureDetector.cpp;h=9cdf967a1ca0aa510512aa710fab7ba09cd77e3c;hb=e97ce3673ceda34d252bb13a320a7947a552c1ac;hp=5fb8b27e0d67f2f01b1b3ca613ef613e3aaec92e;hpb=0495953dba33e35e17d01887f4bf01dc96f7eb4b;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp index 5fb8b27..9cdf967 100644 --- a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -20,8 +20,7 @@ #include #include #include -#include -#include +#include #include #include @@ -121,22 +120,6 @@ struct TouchEventFunctor } }; -// Generate a PinchGestureEvent to send to Core -Integration::PinchGestureEvent GeneratePinch( - Gesture::State state, - float scale, - float speed, - Vector2 centerpoint) -{ - Integration::PinchGestureEvent pinch(state); - - pinch.scale = scale; - pinch.speed = speed; - pinch.centerPoint = centerpoint; - - return pinch; -} - } // anon namespace /////////////////////////////////////////////////////////////////////////////// @@ -186,7 +169,7 @@ int UtcDaliPinchGestureDetectorNew(void) // Attach an actor and emit a touch event on the actor to ensure complete line coverage Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Render and notify @@ -196,11 +179,17 @@ int UtcDaliPinchGestureDetectorNew(void) detector.Attach(actor); Integration::TouchEvent touchEvent(1); - TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f); + Integration::Point point; + point.SetDeviceId( 1 ); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); touchEvent.AddPoint(point); application.ProcessEvent(touchEvent); - TouchPoint point2(1, TouchPoint::Down, 20.0f, 20.0f, 20.0f, 20.0f); + Integration::Point point2; + point.SetDeviceId( 1 ); + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); touchEvent.AddPoint(point2); application.ProcessEvent(touchEvent); END_TEST; @@ -241,7 +230,7 @@ int UtcDaliPinchGestureSignalReceptionNegative(void) Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Render and notify @@ -256,17 +245,23 @@ int UtcDaliPinchGestureSignalReceptionNegative(void) detector.DetectedSignal().Connect(&application, functor); // Do a pinch outside actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 45.0f, Vector2(112.0f, 112.0f))); + TestStartPinch( application, Vector2( 112.0f, 62.0f ), Vector2( 112.0f, 162.0f ), + Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ), 100 ); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); // Continue pinch into actor's area - we should still not receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 4.5f, 95.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ), + Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 ); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); // Stop pinching - we should still not receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(12.0f, 12.0f))); + TestEndPinch( application, Vector2( 6.0f, 6.0f ), Vector2( 18.0f, 18.0f ), + Vector2( 10.0f, 8.0f ), Vector2( 14.0f, 16.0f ), 300 ); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -277,7 +272,7 @@ int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void) Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Render and notify @@ -292,38 +287,42 @@ int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void) detector.DetectedSignal().Connect(&application, functor); // Start pan within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + TestStartPinch( application, Vector2( 5.0f, 20.0f ), Vector2( 35.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.666f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(66.666f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); // Continue the pan within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 90.0f, Vector2(21.0f, 20.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(90.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.2666f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(80.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); // Pan Gesture leaves actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 15.5f, Vector2(320.0f, 10.0f))); + TestContinuePinch( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(15.5f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(1.333f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(213.333f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); // Gesture ends - we would receive a finished state data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 15.2f, 12.1f, Vector2(310.0f, 10.0f))); + TestEndPinch( application, Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), + Vector2( 305.0f, 10.0f ), Vector2( 315.0f, 10.0f ), 1500); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(15.2f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(12.1f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.333f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(600.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); END_TEST; } @@ -334,7 +333,7 @@ int UtcDaliPinchGestureSignalReceptionDownMotionUp(void) Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Render and notify @@ -349,80 +348,43 @@ int UtcDaliPinchGestureSignalReceptionDownMotionUp(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.555f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(106.667f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.277f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(66.666f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); // Gesture ends within actor's area - we would receive a finished state data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); END_TEST; } -int UtcDaliPinchGestureSignalReceptionCancelled(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); - - // Render and notify - application.SendNotification(); - application.Render(); - - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect(&application, functor); - - // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); - - - // Continue the pinch within the actor's area - we should still receive the signal - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); - - // The gesture is cancelled - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Cancelled, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION); - END_TEST; -} - int UtcDaliPinchGestureSignalReceptionDetach(void) { TestApplication application; Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Render and notify @@ -437,20 +399,23 @@ int UtcDaliPinchGestureSignalReceptionDetach(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); // Gesture ends within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); @@ -459,9 +424,7 @@ int UtcDaliPinchGestureSignalReceptionDetach(void) // Ensure we are no longer signalled data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestGeneratePinch( application ); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -472,7 +435,7 @@ int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void) Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Render and notify @@ -487,13 +450,15 @@ int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); @@ -502,7 +467,8 @@ int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void) // Gesture ends within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -521,7 +487,7 @@ int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) // is destroyed. Actor tempActor = Actor::New(); tempActor.SetSize(100.0f, 100.0f); - tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); + tempActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT); Stage::GetCurrent().Add(tempActor); detector.Attach(tempActor); @@ -529,7 +495,7 @@ int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) { Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Render and notify @@ -539,13 +505,15 @@ int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) detector.Attach(actor); // Start pinch within the actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); // Continue the pinch within the actor's area - we should still receive the signal data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); @@ -561,7 +529,8 @@ int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) // Gesture ends within the area where the actor used to be data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -572,7 +541,7 @@ int UtcDaliPinchGestureSignalReceptionRotatedActor(void) Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS); + actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) ); Stage::GetCurrent().Add(actor); // Render and notify a couple of times @@ -587,41 +556,47 @@ int UtcDaliPinchGestureSignalReceptionRotatedActor(void) detector.DetectedSignal().Connect(&application, functor); // Do an entire pinch, only check finished value - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); // Rotate actor again and render and notify - actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS); + actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) ); application.SendNotification(); application.Render(); // Do an entire pinch, only check finished value - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 ); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); // Rotate actor again and render and notify - actor.SetOrientation(Dali::Degree(270.0f), Vector3::ZAXIS); + actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS) ); application.SendNotification(); application.Render(); // Do an entire pinch, only check finished value - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 4100 ); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 5000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); END_TEST; } @@ -631,7 +606,7 @@ int UtcDaliPinchGestureSignalReceptionChildHit(void) Actor parent = Actor::New(); parent.SetSize(100.0f, 100.0f); - parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); + parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(parent); // Set child to completely cover parent. @@ -639,9 +614,9 @@ int UtcDaliPinchGestureSignalReceptionChildHit(void) // conversion of the parent actor is correct. Actor child = Actor::New(); child.SetSize(100.0f, 100.0f); - child.SetAnchorPoint(AnchorPoint::CENTER); - child.SetParentOrigin(ParentOrigin::CENTER); - child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS); + child.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER); + child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); + child.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) ); parent.Add(child); TouchEventFunctor touchFunctor; @@ -659,14 +634,16 @@ int UtcDaliPinchGestureSignalReceptionChildHit(void) detector.DetectedSignal().Connect(&application, functor); // Do an entire pan, only check finished value - hits child area but parent should still receive it - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); // Attach child and generate same touch points to yield same results // (Also proves that you can detach and then re-attach another actor) @@ -674,14 +651,16 @@ int UtcDaliPinchGestureSignalReceptionChildHit(void) detector.Detach(parent); // Do an entire pan, only check finished value - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 ); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION); - DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); END_TEST; } @@ -691,13 +670,13 @@ int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void) Actor first = Actor::New(); first.SetSize(100.0f, 100.0f); - first.SetAnchorPoint(AnchorPoint::TOP_LEFT); + first.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(first); Actor second = Actor::New(); second.SetSize(100.0f, 100.0f); second.SetX(100.0f); - second.SetAnchorPoint(AnchorPoint::TOP_LEFT); + second.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(second); // Render and notify @@ -713,13 +692,15 @@ int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch within second actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(120.0f, 10.0f))); + TestStartPinch( application, Vector2( 102.0f, 20.0f ), Vector2( 138.0f, 20.0f ), + Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION); // Pinch moves into first actor's area - second actor should receive the pinch data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestContinuePinch( application, Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION); @@ -728,7 +709,8 @@ int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void) // Gesture ends within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(120.0f, 10.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 119.0f, 20.0f ), Vector2( 121.0f, 20.0f ), 3000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -739,7 +721,7 @@ int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void) Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Render and notify @@ -754,16 +736,18 @@ int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void) detector.DetectedSignal().Connect(&application, functor); // Start pinch in actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); // Pan continues within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); // Actor become invisible - actor should not receive the next pinch - actor.SetVisible(false); + actor.SetProperty( Actor::Property::VISIBLE,false); // Render and notify application.SendNotification(); @@ -771,7 +755,8 @@ int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void) // Gesture ends within actor's area data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } @@ -782,12 +767,12 @@ int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void) Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); Actor actor2 = Actor::New(); actor2.SetSize(100.0f, 100.0f); - actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); + actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT); Stage::GetCurrent().Add(actor2); // Render and notify @@ -814,14 +799,16 @@ int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void) secondDetector.Attach(actor2); // Pinch in actor's area - both detector's functors should be called - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); // Pinch continues in actor's area - both detector's functors should be called firstData.Reset(); secondData.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); @@ -829,14 +816,16 @@ int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void) firstDetector.Detach(actor); firstData.Reset(); secondData.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); // New pinch on actor, only secondDetector has actor attached firstData.Reset(); secondData.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 ); DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); @@ -844,76 +833,20 @@ int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void) secondDetector.Detach(actor); firstData.Reset(); secondData.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 ); DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION); END_TEST; } -int UtcDaliPinchGestureSignalReceptionMultipleStarted(void) -{ - // Should handle two started events gracefully. - - TestApplication application; - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); - - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect(&application, functor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Start pan in actor's area - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - - // Send another start in actor's area - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - - // Add a child actor to overlap actor and send another start in actor's area - Actor child = Actor::New(); - child.SetSize(100.0f, 100.0f); - child.SetAnchorPoint(AnchorPoint::CENTER); - child.SetParentOrigin(ParentOrigin::CENTER); - actor.Add(child); - - TouchEventFunctor touchFunctor; - child.TouchedSignal().Connect(&application, touchFunctor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Send another start in actor's area - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - - // Send another start in actor's area - data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - END_TEST; -} - int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void) { TestApplication application; Actor actor1 = Actor::New(); actor1.SetSize(100.0f, 100.0f); - actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor1); SignalData data1; GestureReceivedFunctor functor1(data1); @@ -923,8 +856,8 @@ int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void) Actor actor2 = Actor::New(); actor2.SetSize(100.0f, 100.0f); - actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); - actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT); + actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT); + actor2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::BOTTOM_RIGHT); Stage::GetCurrent().Add(actor2); SignalData data2; GestureReceivedFunctor functor2(data2); @@ -937,85 +870,20 @@ int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void) application.Render(); // Start pan in actor1's area, only data1 should be set - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION); END_TEST; } -int UtcDaliPinchGestureEmitIncorrectStateClear(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Attach actor to detector - SignalData data; - GestureReceivedFunctor functor( data ); - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect( &application, functor ); - - // Try a Clear state - try - { - application.ProcessEvent(GeneratePinch(Gesture::Clear, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - tet_result(TET_FAIL); - } - catch ( Dali::DaliException& e ) - { - DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); - } - END_TEST; -} - -int UtcDaliPinchGestureEmitIncorrectStatePossible(void) -{ - TestApplication application; - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(actor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Attach actor to detector - SignalData data; - GestureReceivedFunctor functor( data ); - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect( &application, functor ); - - // Try a Possible state - try - { - application.ProcessEvent(GeneratePinch(Gesture::Possible, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); - tet_result(TET_FAIL); - } - catch ( Dali::DaliException& e ) - { - DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); - } - END_TEST; -} - int UtcDaliPinchGestureActorUnstaged(void) { TestApplication application; Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Render and notify @@ -1033,10 +901,12 @@ int UtcDaliPinchGestureActorUnstaged(void) detector.DetectedSignal().Connect( &application, functor ); // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1055,13 +925,16 @@ int UtcDaliPinchGestureActorUnstaged(void) stateToUnstage = Gesture::Continuing; // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1080,13 +953,16 @@ int UtcDaliPinchGestureActorUnstaged(void) stateToUnstage = Gesture::Finished; // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully. END_TEST; @@ -1098,14 +974,14 @@ int UtcDaliPinchGestureActorStagedAndDestroyed(void) Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Create and add a second actor so that GestureDetector destruction does not come into play. Actor dummyActor( Actor::New() ); dummyActor.SetSize( 100.0f, 100.0f ); dummyActor.SetPosition( 100.0f, 100.0f ); - dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + dummyActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummyActor); // Render and notify @@ -1128,7 +1004,8 @@ int UtcDaliPinchGestureActorStagedAndDestroyed(void) // position, we should still not be signalled. // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1144,17 +1021,20 @@ int UtcDaliPinchGestureActorStagedAndDestroyed(void) application.Render(); // Continue signal emission - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 ); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); // Here we delete an actor in started, we should not receive any subsequent signalling. // Emit signals - application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 ); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1170,168 +1050,23 @@ int UtcDaliPinchGestureActorStagedAndDestroyed(void) application.Render(); // Continue signal emission - application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 ); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); - application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); END_TEST; } -int UtcDaliPinchGestureSystemOverlay(void) -{ - TestApplication application; - Dali::Integration::Core& core = application.GetCore(); - Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); - systemOverlay.GetOverlayRenderTasks().CreateTask(); - - Actor actor = Actor::New(); - actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - systemOverlay.Add(actor); - - // Render and notify - application.SendNotification(); - application.Render(); - - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(actor); - detector.DetectedSignal().Connect(&application, functor); - - Vector2 screenCoords( 50.0f, 50.0f ); - float scale ( 10.0f ); - float speed ( 50.0f ); - - // Start pan within the actor's area - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliPinchGestureBehindTouchableSystemOverlay(void) -{ - TestApplication application; - Dali::Integration::Core& core = application.GetCore(); - Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); - systemOverlay.GetOverlayRenderTasks().CreateTask(); - - // SystemOverlay actor - Actor systemOverlayActor = Actor::New(); - systemOverlayActor.SetSize(100.0f, 100.0f); - systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - systemOverlay.Add(systemOverlayActor); - - // Stage actor - Actor stageActor = Actor::New(); - stageActor.SetSize(100.0f, 100.0f); - stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(stageActor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Set system-overlay actor to touchable - TouchEventData touchData; - TouchEventDataFunctor touchFunctor( touchData ); - systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor); - - // Set stage actor to receive the gesture - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(stageActor); - detector.DetectedSignal().Connect(&application, functor); - - Vector2 screenCoords( 50.0f, 50.0f ); - float scale ( 10.0f ); - float speed ( 50.0f ); - - // Start pinch within the two actors' area - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION ); - - data.Reset(); - touchData.Reset(); - - // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliPinchGestureTouchBehindGesturedSystemOverlay(void) -{ - TestApplication application; - Dali::Integration::Core& core = application.GetCore(); - Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); - systemOverlay.GetOverlayRenderTasks().CreateTask(); - - // SystemOverlay actor - Actor systemOverlayActor = Actor::New(); - systemOverlayActor.SetSize(100.0f, 100.0f); - systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - systemOverlay.Add(systemOverlayActor); - - // Stage actor - Actor stageActor = Actor::New(); - stageActor.SetSize(100.0f, 100.0f); - stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(stageActor); - - // Render and notify - application.SendNotification(); - application.Render(); - - // Set stage actor to touchable - TouchEventData touchData; - TouchEventDataFunctor touchFunctor( touchData ); - stageActor.TouchedSignal().Connect(&application, touchFunctor); - - // Set system-overlay actor to have the gesture - SignalData data; - GestureReceivedFunctor functor(data); - - PinchGestureDetector detector = PinchGestureDetector::New(); - detector.Attach(systemOverlayActor); - detector.DetectedSignal().Connect(&application, functor); - - Vector2 screenCoords( 50.0f, 50.0f ); - float scale ( 10.0f ); - float speed ( 50.0f ); - - // Start pinch within the two actors' area - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) ); - DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION ); - - data.Reset(); - touchData.Reset(); - - // Do touch in the same area - application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) ); - DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); - DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION ); - - END_TEST; -} - int UtcDaliPinchGestureLayerConsumesTouch(void) { TestApplication application; Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); - actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(actor); // Add a detector @@ -1344,7 +1079,7 @@ int UtcDaliPinchGestureLayerConsumesTouch(void) // Add a layer to overlap the actor Layer layer = Layer::New(); layer.SetSize(100.0f, 100.0f); - layer.SetAnchorPoint(AnchorPoint::TOP_LEFT); + layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add( layer ); layer.RaiseToTop(); @@ -1352,13 +1087,11 @@ int UtcDaliPinchGestureLayerConsumesTouch(void) application.SendNotification(); application.Render(); - Vector2 screenCoords( 50.0f, 50.0f ); - float scale ( 10.0f ); - float speed ( 50.0f ); - // Emit signals, should receive - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) ); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 ); + TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); data.Reset(); @@ -1370,8 +1103,10 @@ int UtcDaliPinchGestureLayerConsumesTouch(void) application.Render(); // Emit the same signals again, should not receive - application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); - application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) ); + TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ), + Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 ); + TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), + Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 2000); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset();