X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ControlImpl.cpp;h=60fd218a276c7bc0b7de554dffe8a21638fe15cc;hb=cbda2de83c5025276c35d69044934ab1258b4998;hp=4a29efce8bf598d6ed67d251ac09631892013803;hpb=ca96219e908001c5701e71c997965b11b85f05ed;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index 4a29efc..60fd218 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 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. @@ -28,10 +28,6 @@ #include #include #include -#include -#include -#include -#include #include #include @@ -221,9 +217,9 @@ int UtcDaliControlImplOnGestureMethods(void) // Check gesture actually happens { DummyControl dummy = DummyControl::New(true); - dummy.SetSize( Vector2(100.0f, 100.0f ) ); + dummy.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f ) ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); // Render and notify a couple of times @@ -232,111 +228,36 @@ int UtcDaliControlImplOnGestureMethods(void) application.SendNotification(); application.Render(); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) ); DALI_TEST_CHECK( dummyImpl.pinchCalled == false ); - Integration::PinchGestureEvent pinch(Gesture::Started); - pinch.scale = 10.0f; - pinch.speed = 50.0f; - pinch.centerPoint = Vector2(20.0f, 20.0f); - application.ProcessEvent(pinch); + + TestGeneratePinch(application); + DALI_TEST_CHECK( dummyImpl.pinchCalled == true ); DALI_TEST_CHECK( dummyImpl.panCalled == false ); - Integration::PanGestureEvent pan(Gesture::Possible); - pan.previousPosition = Vector2(10.0f, 20.0f); - pan.currentPosition = Vector2(20.0f, 20.0f); - pan.timeDelta = 10; - pan.numberOfTouches = 1u; - application.ProcessEvent(pan); - pan.state = Gesture::Started; - application.ProcessEvent(pan); - DALI_TEST_CHECK( dummyImpl.panCalled == true ); - - DALI_TEST_CHECK( dummyImpl.tapCalled == false ); - Integration::TapGestureEvent tap(Gesture::Possible); - tap.numberOfTaps = 1u; - tap.numberOfTouches = 1u; - tap.point = Vector2(50.0f, 50.0f); - application.ProcessEvent(tap); - tap.state = Gesture::Started; - application.ProcessEvent(tap); - DALI_TEST_CHECK( dummyImpl.tapCalled == true ); - DALI_TEST_CHECK( dummyImpl.longPressCalled == false ); - Integration::LongPressGestureEvent longPress(Gesture::Possible); - longPress.numberOfTouches = 1u; - longPress.point = Vector2(50.0f, 50.0f); - application.ProcessEvent(longPress); - longPress.state = Gesture::Started; - application.ProcessEvent(longPress); - DALI_TEST_CHECK( dummyImpl.longPressCalled == true ); - longPress.state = Gesture::Finished; - application.ProcessEvent(longPress); + TestGenerateMiniPan(application); - Stage::GetCurrent().Remove(dummy); - } + DALI_TEST_CHECK( dummyImpl.panCalled == true ); - // Ensure full code coverage - { - DummyControl dummy = DummyControl::New(); - dummy.SetSize( Vector2( 100.0f, 100.0f ) ); + DALI_TEST_CHECK( dummyImpl.tapCalled == false ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(dummy); + TestGenerateTap(application); - // Render and notify a couple of times - application.SendNotification(); - application.Render(); - application.SendNotification(); - application.Render(); + DALI_TEST_CHECK( dummyImpl.tapCalled == true ); - DummyControlImpl& dummyImpl = static_cast(dummy.GetImplementation()); - dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) ); + DALI_TEST_CHECK( dummyImpl.longPressCalled == false ); - DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f ); - Integration::PinchGestureEvent pinch(Gesture::Started); - pinch.scale = 10.0f; - pinch.speed = 50.0f; - pinch.centerPoint = Vector2(20.0f, 20.0f); - application.ProcessEvent(pinch); + TestGenerateLongPress(application); - // Render and notify a couple of times - application.SendNotification(); - application.Render(); - application.SendNotification(); - application.Render(); - DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f ); - - Integration::PanGestureEvent pan(Gesture::Possible); - pan.previousPosition = Vector2(10.0f, 20.0f); - pan.currentPosition = Vector2(20.0f, 20.0f); - pan.timeDelta = 10; - pan.numberOfTouches = 1u; - application.ProcessEvent(pan); - pan.state = Gesture::Started; - application.ProcessEvent(pan); - - Integration::TapGestureEvent tap(Gesture::Possible); - tap.numberOfTaps = 1u; - tap.numberOfTouches = 1u; - tap.point = Vector2(50.0f, 50.0f); - application.ProcessEvent(tap); - tap.state = Gesture::Started; - application.ProcessEvent(tap); - - Integration::LongPressGestureEvent longPress(Gesture::Possible); - longPress.numberOfTouches = 1u; - longPress.point = Vector2(50.0f, 50.0f); - application.ProcessEvent(longPress); - longPress.state = Gesture::Started; - application.ProcessEvent(longPress); - longPress.state = Gesture::Finished; - application.ProcessEvent(longPress); + DALI_TEST_CHECK( dummyImpl.longPressCalled == true ); Stage::GetCurrent().Remove(dummy); } + END_TEST; } @@ -347,7 +268,7 @@ int UtcDaliControlImplChildAddAndRemove(void) { DummyControl dummy = DummyControl::New( true ); Stage::GetCurrent().Add(dummy); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); application.Render(); application.SendNotification(); @@ -406,7 +327,7 @@ int UtcDaliControlImplStageConnection(void) { DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION ); Stage::GetCurrent().Add(dummy); @@ -446,7 +367,7 @@ int UtcDaliControlImplSizeSetP(void) { DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); Stage::GetCurrent().Add(dummy); application.Render(); @@ -454,14 +375,14 @@ int UtcDaliControlImplSizeSetP(void) DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size not set, no onSizeSet called Vector2 size(100.0f, 200.0f); - dummy.SetSize( size ); + dummy.SetProperty( Actor::Property::SIZE, size ); DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size is going to get negotiated, no onSizeSet called application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); + DALI_TEST_EQUALS( size, dummy.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).GetVectorXY(), TEST_LOCATION ); DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION ); Stage::GetCurrent().Remove(dummy); @@ -479,17 +400,17 @@ int UtcDaliControlImplSizeSet2P(void) Stage::GetCurrent().Add(dummy); Vector2 size(100.0f, 200.0f); - DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() ); + DALI_TEST_CHECK( size != dummy.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).GetVectorXY() ); application.SendNotification(); application.Render(); - dummy.SetSize(size); + dummy.SetProperty( Actor::Property::SIZE, size); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION); + DALI_TEST_EQUALS(size, dummy.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).GetVectorXY(), TEST_LOCATION); Stage::GetCurrent().Remove(dummy); } @@ -503,7 +424,7 @@ int UtcDaliControlImplSizeAnimation(void) { DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); Stage::GetCurrent().Add(dummy); @@ -550,10 +471,10 @@ int UtcDaliControlImplTouchEvent(void) { DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); - dummy.SetSize( Vector2( 100.0f, 100.0f ) ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); + dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); application.Render(); @@ -578,8 +499,8 @@ int UtcDaliControlImplTouchEvent(void) { DummyControl dummy = DummyControl::New(); - dummy.SetSize( Vector2( 100.0f, 100.0f ) ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); + dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); application.Render(); @@ -606,10 +527,10 @@ int UtcDaliControlImplHoverEvent(void) { DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); - dummy.SetSize( Vector2( 100.0f, 100.0f ) ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); + dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); application.Render(); @@ -634,8 +555,8 @@ int UtcDaliControlImplHoverEvent(void) { DummyControl dummy = DummyControl::New(); - dummy.SetSize( Vector2( 100.0f, 100.0f ) ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); + dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); application.Render(); @@ -665,7 +586,7 @@ int UtcDaliControlImplKeyEvent(void) { DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); Stage::GetCurrent().Add(dummy); dummy.SetKeyInputFocus(); @@ -709,7 +630,7 @@ int UtcDaliControlImplKeyInputFocusGained(void) { DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); Stage::GetCurrent().Add(dummy); @@ -739,7 +660,7 @@ int UtcDaliControlImplKeyInputFocusLost(void) { DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); Stage::GetCurrent().Add(dummy); @@ -761,7 +682,7 @@ int UtcDaliControlImplKeyInputFocusLost(void) dummy.SetKeyInputFocus(); dummy.ClearKeyInputFocus(); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); dummyImpl.IsKeyboardNavigationSupported(); dummyImpl.IsKeyboardFocusGroup(); @@ -803,10 +724,10 @@ int UtcDaliControlImplWheelEvent(void) { DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); - dummy.SetSize( Vector2( 100.0f, 100.0f ) ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); + dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); dummy.WheelEventSignal().Connect(&WheelEventCallback); @@ -831,8 +752,8 @@ int UtcDaliControlImplWheelEvent(void) { DummyControl dummy = DummyControl::New(); - dummy.SetSize( Vector2( 100.0f, 100.0f ) ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); + dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); dummy.WheelEventSignal().Connect(&WheelEventCallback); @@ -859,8 +780,8 @@ int UtcDaliControlImplSetStyleName(void) { DummyControl dummy = DummyControl::New( true ); - dummy.SetSize( Vector2( 100.0f, 100.0f ) ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); + dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); dummy.SetStyleName("TestStyle"); @@ -1350,4 +1271,69 @@ int UtcDaliControlImplRegisterTwoVisualsAndEnableOnlyOne(void) END_TEST; } +int UtcDaliControlImplAutoClippingWithVisuals(void) +{ + ToolkitTestApplication application; + + tet_infoline( "Test to ensure a renderer does NOT get added when we've already registered a visual which we haven't enabled" ); + DummyControl control = DummyControl::New(); + DummyControlImpl& controlImpl = static_cast( control.GetImplementation() ); + + Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get(); + Toolkit::Visual::Base visual; + Property::Map map; + map[Visual::Property::TYPE] = Visual::COLOR; + map[ColorVisual::Property::MIX_COLOR] = Color::RED; + visual = visualFactory.CreateVisual( map ); + DALI_TEST_CHECK(visual); + controlImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual, false ); + + DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION ); + + control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + + Stage::GetCurrent().Add( control ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliControlImplAutoClippingWithVisualsAlreadyOnStage(void) +{ + ToolkitTestApplication application; + + tet_infoline( "Test to ensure a renderer does NOT get added when we've already registered a visual which we haven't enabled and we're already on the stage" ); + + DummyControl control = DummyControl::New(); + DummyControlImpl& controlImpl = static_cast( control.GetImplementation() ); + + Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get(); + Toolkit::Visual::Base visual; + Property::Map map; + map[Visual::Property::TYPE] = Visual::COLOR; + map[ColorVisual::Property::MIX_COLOR] = Color::RED; + visual = visualFactory.CreateVisual( map ); + DALI_TEST_CHECK(visual); + controlImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual, false ); + + DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION ); + + Stage::GetCurrent().Add( control ); + + application.SendNotification(); + application.Render(); + + control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION ); + + END_TEST; +}