X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ControlImpl.cpp;h=31f309436374bca21bd515bfcd8b1bab956e0183;hp=4a29efce8bf598d6ed67d251ac09631892013803;hb=b514a4671789bee2f03b0177393b9a21f62ac2c3;hpb=574ce69b5c6abe40f245aa2dc7e36e55ca873995 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index 4a29efc..31f3094 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 @@ -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 ); + TestGenerateMiniPan(application); - 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); - - 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(); @@ -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,7 +471,7 @@ 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); @@ -606,7 +527,7 @@ 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); @@ -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,7 +724,7 @@ 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); @@ -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; +}