From: Adeel Kazmi Date: Thu, 14 Jul 2016 14:54:49 +0000 (+0100) Subject: Removed dead code from Actor & fixed minor bugs in GestureDetector X-Git-Tag: dali_1.1.43~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F20%2F80120%2F2;p=platform%2Fcore%2Fuifw%2Fdali-core.git Removed dead code from Actor & fixed minor bugs in GestureDetector Change-Id: I7c4a1ccfc909ecd9e82824e2d132e3561e7bf15d --- diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index a913208..2386eeb 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -603,6 +603,42 @@ int UtcDaliActorSetParentOrigin(void) END_TEST; } +int UtcDaliActorSetParentOriginIndividual(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.7f, 0.8f, 0.9f); + DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin()); + + actor.SetProperty( Actor::Property::PARENT_ORIGIN_X, vector.x ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.x, actor.GetCurrentParentOrigin().x, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::PARENT_ORIGIN_Y, vector.y ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.y, actor.GetCurrentParentOrigin().y, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::PARENT_ORIGIN_Z, vector.z ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.z, actor.GetCurrentParentOrigin().z, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliActorGetCurrentParentOrigin(void) { TestApplication application; @@ -652,6 +688,42 @@ int UtcDaliActorSetAnchorPoint(void) END_TEST; } +int UtcDaliActorSetAnchorPointIndividual(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.7f, 0.8f, 0.9f); + DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint()); + + actor.SetProperty( Actor::Property::ANCHOR_POINT_X, vector.x ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.x, actor.GetCurrentAnchorPoint().x, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::ANCHOR_POINT_Y, vector.y ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.y, actor.GetCurrentAnchorPoint().y, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::ANCHOR_POINT_Z, vector.z ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.z, actor.GetCurrentAnchorPoint().z, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliActorGetCurrentAnchorPoint(void) { TestApplication application; @@ -761,6 +833,43 @@ int UtcDaliActorSetSize04(void) END_TEST; } +int UtcDaliActorSetSizeIndividual(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.7f, 0.8f, 0.9f); + DALI_TEST_CHECK(vector != actor.GetCurrentSize()); + + actor.SetProperty( Actor::Property::SIZE_WIDTH, vector.width ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.width, actor.GetCurrentSize().width, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::SIZE_HEIGHT, vector.height ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.height, actor.GetCurrentSize().height, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::SIZE_DEPTH, vector.depth ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.depth, actor.GetCurrentSize().depth, TEST_LOCATION ); + + END_TEST; +} + + int UtcDaliActorGetCurrentSize(void) { TestApplication application; @@ -987,6 +1096,42 @@ int UtcDaliActorSetZ(void) END_TEST; } +int UtcDaliActorSetPositionProperties(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.7f, 0.8f, 0.9f); + DALI_TEST_CHECK(vector != actor.GetCurrentPosition()); + + actor.SetProperty( Actor::Property::POSITION_X, vector.x ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.x, actor.GetCurrentPosition().x, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::POSITION_Y, vector.y ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.y, actor.GetCurrentPosition().y, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::POSITION_Z, vector.z ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.z, actor.GetCurrentPosition().z, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliActorTranslateBy(void) { TestApplication application; @@ -1226,6 +1371,24 @@ int UtcDaliActorSetOrientation02(void) END_TEST; } +// SetOrientation(float angleRadians, Vector3 axis) +int UtcDaliActorSetOrientationProperty(void) +{ + TestApplication application; + + Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f)); + Actor actor = Actor::New(); + + actor.SetProperty( Actor::Property::ORIENTATION, rotation ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION); + END_TEST; +} + // RotateBy(float angleRadians, Vector3 axis) int UtcDaliActorRotateBy01(void) { @@ -1408,6 +1571,42 @@ int UtcDaliActorSetScale03(void) END_TEST; } +int UtcDaliActorSetScaleIndividual(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.7f, 0.8f, 0.9f); + DALI_TEST_CHECK(vector != actor.GetCurrentScale()); + + actor.SetProperty( Actor::Property::SCALE_X, vector.x ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.x, actor.GetCurrentScale().x, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::SCALE_Y, vector.y ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.y, actor.GetCurrentScale().y, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::SCALE_Z, vector.z ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.z, actor.GetCurrentScale().z, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliActorScaleBy(void) { TestApplication application; @@ -1672,6 +1871,51 @@ int UtcDaliActorSetColor(void) END_TEST; } +int UtcDaliActorSetColorIndividual(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector4 vector(0.7f, 0.8f, 0.9f, 0.6f); + DALI_TEST_CHECK(vector != actor.GetCurrentColor()); + + actor.SetProperty( Actor::Property::COLOR_RED, vector.r ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.r, actor.GetCurrentColor().r, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::COLOR_GREEN, vector.g ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.g, actor.GetCurrentColor().g, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::COLOR_BLUE, vector.b ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.b, actor.GetCurrentColor().b, TEST_LOCATION ); + + actor.SetProperty( Actor::Property::COLOR_ALPHA, vector.a ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( vector.a, actor.GetCurrentColor().a, TEST_LOCATION ); + + END_TEST; +} + + int UtcDaliActorGetCurrentColor(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-GestureDetector.cpp b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp index 12a41c4..911eabb 100644 --- a/automated-tests/src/dali/utc-Dali-GestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp @@ -437,3 +437,31 @@ int UtcDaliGestureDetectorGetAttachedActors(void) DALI_TEST_EQUALS(0u, detector.GetAttachedActorCount(), TEST_LOCATION); END_TEST; } + +int UtcDaliGestureDetectorProperties(void) +{ + TestApplication application; + + // Use pinch gesture as that doen't currently have any properties. Will need to change it if default properties are added. + GestureDetector detector = PinchGestureDetector::New(); + + DALI_TEST_EQUALS( detector.GetPropertyCount(), 0u, TEST_LOCATION ); + + Property::IndexContainer indices; + detector.GetPropertyIndices( indices ); + DALI_TEST_EQUALS( indices.Size(), 0u, TEST_LOCATION ); + + DALI_TEST_EQUALS( detector.IsPropertyWritable( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( detector.IsPropertyAnimatable( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( detector.IsPropertyAConstraintInput( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( detector.GetPropertyType( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ), Property::NONE, TEST_LOCATION ); + DALI_TEST_EQUALS( detector.GetPropertyIndex( "InvalidIndex" ), Property::INVALID_INDEX, TEST_LOCATION ); + + Property::Value propValue = detector.GetProperty( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ); + DALI_TEST_EQUALS( propValue.GetType(), Property::NONE, TEST_LOCATION ); + + // For coverage only, not testable + detector.SetProperty( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX, true ); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp index 43f5d95..d305917 100644 --- a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp @@ -131,7 +131,8 @@ struct TouchEventFunctor struct ConstraintData { ConstraintData() - : called(false) + : panning( false ), + called( false ) { } @@ -141,11 +142,13 @@ struct ConstraintData Vector2 localPosition; Vector2 localDisplacement; Vector2 localVelocity; + bool panning; bool called; void Reset() { screenPosition = screenDisplacement = screenVelocity = localPosition = localDisplacement = localVelocity = Vector2::ZERO; + panning = false; called = false; } }; @@ -163,6 +166,7 @@ struct PanConstraint constraintData.localPosition = inputs[3]->GetVector2(); constraintData.localDisplacement = inputs[4]->GetVector2(); constraintData.localVelocity = inputs[5]->GetVector2(); + constraintData.panning = inputs[6]->GetBoolean(); constraintData.called = true; current = Vector3::ZERO; } @@ -2142,6 +2146,7 @@ int UtcDaliPanGestureNoPredictionNoSmoothing(void) constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) ); + constraint.AddSource( Source( detector, PanGestureDetector::Property::PANNING ) ); constraint.Apply(); // Render and notify @@ -2188,6 +2193,7 @@ int UtcDaliPanGestureNoPredictionSmoothing(void) constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) ); + constraint.AddSource( Source( detector, PanGestureDetector::Property::PANNING ) ); constraint.Apply(); // Render and notify @@ -2236,6 +2242,7 @@ int UtcDaliPanGesturePredictionNoSmoothing(void) constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) ); + constraint.AddSource( Source( detector, PanGestureDetector::Property::PANNING ) ); constraint.Apply(); // Render and notify @@ -2283,6 +2290,7 @@ int UtcDaliPanGesturePredictionSmoothing(void) constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) ); + constraint.AddSource( Source( detector, PanGestureDetector::Property::PANNING ) ); constraint.Apply(); // Render and notify @@ -2322,6 +2330,7 @@ int UtcDaliPanGestureSetProperties(void) detector.DetectedSignal().Connect( &application, functor ); Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO ); + Property::Index animatableGestureProperty = detector.RegisterProperty( "Dummy Property", Vector3::ZERO ); // For code coverage ConstraintData constraintData; Constraint constraint = Constraint::New( actor, property, PanConstraint( constraintData ) ); @@ -2331,6 +2340,8 @@ int UtcDaliPanGestureSetProperties(void) constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) ); + constraint.AddSource( Source( detector, PanGestureDetector::Property::PANNING ) ); + constraint.AddSource( Source( detector, animatableGestureProperty ) ); constraint.Apply(); // Render and notify @@ -2392,6 +2403,7 @@ int UtcDaliPanGestureSetPropertiesAlreadyPanning(void) constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_DISPLACEMENT ) ); constraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_VELOCITY ) ); + constraint.AddSource( Source( detector, PanGestureDetector::Property::PANNING ) ); constraint.Apply(); // Render and notify @@ -2432,6 +2444,107 @@ int UtcDaliPanGesturePropertyIndices(void) END_TEST; } +namespace +{ +struct PropertyStringIndex +{ + const char * const name; + const Property::Index index; + const Property::Type type; + const Property::Value value; +}; + +const PropertyStringIndex PROPERTY_TABLE[] = +{ + { "screenPosition", PanGestureDetector::Property::SCREEN_POSITION, Property::VECTOR2, Vector2::ZERO }, + { "screenDisplacement", PanGestureDetector::Property::SCREEN_DISPLACEMENT, Property::VECTOR2, Vector2::ZERO }, + { "screenVelocity", PanGestureDetector::Property::SCREEN_VELOCITY, Property::VECTOR2, Vector2::ZERO }, + { "localPosition", PanGestureDetector::Property::LOCAL_POSITION, Property::VECTOR2, Vector2::ZERO }, + { "localDisplacement", PanGestureDetector::Property::LOCAL_DISPLACEMENT, Property::VECTOR2, Vector2::ZERO }, + { "localVelocity", PanGestureDetector::Property::LOCAL_VELOCITY, Property::VECTOR2, Vector2::ZERO }, + { "panning", PanGestureDetector::Property::PANNING, Property::BOOLEAN, false }, +}; +const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] ); +} // unnamed namespace + + +int UtcDaliPanGestureProperties(void) +{ + TestApplication application; + PanGestureDetector detector = PanGestureDetector::New(); + + for( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i ) + { + DALI_TEST_EQUALS( detector.GetPropertyName( PROPERTY_TABLE[ i ].index ), std::string( PROPERTY_TABLE[ i ].name ), TEST_LOCATION ); + DALI_TEST_EQUALS( detector.GetPropertyIndex( PROPERTY_TABLE[ i ].name ), PROPERTY_TABLE[ i ].index, TEST_LOCATION ); + DALI_TEST_EQUALS( detector.GetPropertyType( PROPERTY_TABLE[ i ].index ), PROPERTY_TABLE[ i ].type, TEST_LOCATION ); + DALI_TEST_EQUALS( detector.IsPropertyWritable( PROPERTY_TABLE[ i ].index ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( detector.IsPropertyAnimatable( PROPERTY_TABLE[ i ].index ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( detector.IsPropertyAConstraintInput( PROPERTY_TABLE[ i ].index ), true, TEST_LOCATION ); + detector.SetProperty( PROPERTY_TABLE[ i ].index, Property::Value() ); // Just for Coverage + } + + END_TEST; +} + +int UtcDaliPanGestureGetProperty(void) +{ + TestApplication application; + PanGestureDetector detector = PanGestureDetector::New(); + + for( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i ) + { + if( PROPERTY_TABLE[ i ].type == Property::VECTOR2 ) + { + bool value = detector.GetProperty( PROPERTY_TABLE[ i ].index ).Get< bool >(); + DALI_TEST_EQUALS( PROPERTY_TABLE[ i ].value.Get< bool >(), value, TEST_LOCATION ); + } + else if( PROPERTY_TABLE[ i ].type == Property::BOOLEAN ) + { + Vector2 value = detector.GetProperty( PROPERTY_TABLE[ i ].index ).Get< Vector2 >(); + DALI_TEST_EQUALS( PROPERTY_TABLE[ i ].value.Get< Vector2 >(), value, TEST_LOCATION ); + } + } + + END_TEST; +} + +int UtcDaliPanGestureGetPropertyWithSceneObject(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Add a pan detector + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach( actor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + for( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i ) + { + detector.SetProperty( PROPERTY_TABLE[ i ].index, Property::Value() ); // Just for Coverage + + if( PROPERTY_TABLE[ i ].type == Property::VECTOR2 ) + { + bool value = detector.GetProperty( PROPERTY_TABLE[ i ].index ).Get< bool >(); + DALI_TEST_EQUALS( PROPERTY_TABLE[ i ].value.Get< bool >(), value, TEST_LOCATION ); + } + else if( PROPERTY_TABLE[ i ].type == Property::BOOLEAN ) + { + Vector2 value = detector.GetProperty( PROPERTY_TABLE[ i ].index ).Get< Vector2 >(); + DALI_TEST_EQUALS( PROPERTY_TABLE[ i ].value.Get< Vector2 >(), value, TEST_LOCATION ); + } + } + + END_TEST; +} + int UtcDaliPanGestureLayerConsumesTouch(void) { TestApplication application; diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index acc916c..f441277 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -1495,15 +1495,6 @@ void Actor::RemoveRenderer( unsigned int index ) } } -void Actor::SetOverlay( bool enable ) -{ - // Setting STENCIL will override OVERLAY_2D - if( DrawMode::STENCIL != mDrawMode ) - { - SetDrawMode( enable ? DrawMode::OVERLAY_2D : DrawMode::NORMAL ); - } -} - bool Actor::IsOverlay() const { return ( DrawMode::OVERLAY_2D == mDrawMode ); diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 920cc1f..d38493b 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -681,11 +681,6 @@ public: DrawMode::Type GetDrawMode() const; /** - * @copydoc Dali::Actor::SetOverlay - */ - void SetOverlay( bool enable ); - - /** * @copydoc Dali::Actor::IsOverlay */ bool IsOverlay() const; diff --git a/dali/internal/event/events/gesture-detector-impl.cpp b/dali/internal/event/events/gesture-detector-impl.cpp index 58e4816..3280b44 100644 --- a/dali/internal/event/events/gesture-detector-impl.cpp +++ b/dali/internal/event/events/gesture-detector-impl.cpp @@ -212,7 +212,7 @@ const char* GestureDetector::GetDefaultPropertyName( Property::Index index ) con Property::Index GestureDetector::GetDefaultPropertyIndex(const std::string& name) const { - return 0; + return Property::INVALID_INDEX; } bool GestureDetector::IsDefaultPropertyWritable(Property::Index index) const diff --git a/dali/internal/event/events/pan-gesture-detector-impl.cpp b/dali/internal/event/events/pan-gesture-detector-impl.cpp index 229ffad..0531670 100644 --- a/dali/internal/event/events/pan-gesture-detector-impl.cpp +++ b/dali/internal/event/events/pan-gesture-detector-impl.cpp @@ -363,7 +363,7 @@ Property::Index PanGestureDetector::GetDefaultPropertyIndex(const std::string& n const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string { - index = i; + index = DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX + i; break; } }