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=d1f6925edf444fbdff2b0ddf801ffaa509e804af;hp=6965f358da2206eba0a5b865ec6f440726ca25c7;hb=a78bb823aebc305823855ac35b3413aaff7bc684;hpb=af70c4c72ccbf2f680bd43f67888224f97a361eb diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index 6965f35..d1f6925 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) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,12 +26,15 @@ #include #include #include -#include +#include #include #include #include #include #include +#include + +#include #include "dummy-control.h" @@ -218,7 +221,7 @@ int UtcDaliControlImplOnGestureMethods(void) // Check gesture actually happens { DummyControl dummy = DummyControl::New(true); - dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) ); + dummy.SetSize( Vector2(100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); @@ -278,7 +281,7 @@ int UtcDaliControlImplOnGestureMethods(void) // Ensure full code coverage { DummyControl dummy = DummyControl::New(); - dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) ); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); @@ -437,7 +440,7 @@ int UtcDaliControlImplStageConnection(void) END_TEST; } -int UtcDaliControlImplSizeSet(void) +int UtcDaliControlImplSizeSetP(void) { ToolkitTestApplication application; @@ -449,46 +452,51 @@ int UtcDaliControlImplSizeSet(void) application.Render(); application.SendNotification(); - DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); - Vector3 size(100.0f, 200.0f, 0.0f); - dummy.SetSize(size); + DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size not set, no onSizeSet called + Vector2 size(100.0f, 200.0f); + dummy.SetSize( size ); + + DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size is going to get negotiated, no onSizeSet called - application.Render(); application.SendNotification(); application.Render(); - application.SendNotification(); - DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION); + DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION ); Stage::GetCurrent().Remove(dummy); } - // Ensure full code coverage + END_TEST; +} + +int UtcDaliControlImplSizeSet2P(void) +{ + ToolkitTestApplication application; + { DummyControl dummy = DummyControl::New(); Stage::GetCurrent().Add(dummy); - Vector3 size(100.0f, 200.0f, 0.0f); - DALI_TEST_CHECK( size != dummy.GetCurrentSize() ); + Vector2 size(100.0f, 200.0f); + DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() ); - application.Render(); application.SendNotification(); + application.Render(); dummy.SetSize(size); - application.Render(); application.SendNotification(); application.Render(); - application.SendNotification(); - DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION); + DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION); Stage::GetCurrent().Remove(dummy); } END_TEST; } + int UtcDaliControlImplSizeAnimation(void) { ToolkitTestApplication application; @@ -501,7 +509,7 @@ int UtcDaliControlImplSizeAnimation(void) DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION ); Animation animation = Animation::New(1.0f); - animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f)); + animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) ); animation.Play(); application.Render(); @@ -521,7 +529,7 @@ int UtcDaliControlImplSizeAnimation(void) Stage::GetCurrent().Add(dummy); Animation animation = Animation::New(1.0f); - animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f)); + animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) ); animation.Play(); application.Render(); @@ -544,7 +552,7 @@ int UtcDaliControlImplTouchEvent(void) DummyControl dummy = DummyControl::New( true ); DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); - dummy.SetSize(100.0f, 100.0f); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); @@ -567,7 +575,7 @@ int UtcDaliControlImplTouchEvent(void) { DummyControl dummy = DummyControl::New(); - dummy.SetSize(100.0f, 100.0f); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); @@ -586,10 +594,7 @@ int UtcDaliControlImplTouchEvent(void) END_TEST; } -/////////////////////////////////////////////////////////////////////////////////////////////////// - - -int UtcDaliControlImplKeyEvent(void) +int UtcDaliControlImplHoverEvent(void) { ToolkitTestApplication application; @@ -597,18 +602,21 @@ int UtcDaliControlImplKeyEvent(void) DummyControl dummy = DummyControl::New( true ); DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); + dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); - dummy.SetKeyInputFocus(); application.Render(); application.SendNotification(); application.Render(); application.SendNotification(); - DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION ); - Integration::KeyEvent keyEvent; - application.ProcessEvent(keyEvent); - DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, false, TEST_LOCATION ); + Integration::HoverEvent event(1); + TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f ); + event.AddPoint( point ); + application.ProcessEvent( event ); + DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, true, TEST_LOCATION ); Stage::GetCurrent().Remove(dummy); } @@ -617,52 +625,69 @@ int UtcDaliControlImplKeyEvent(void) { DummyControl dummy = DummyControl::New(); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); + dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); - dummy.SetKeyInputFocus(); application.Render(); application.SendNotification(); application.Render(); application.SendNotification(); - Integration::KeyEvent keyEvent; - application.ProcessEvent(keyEvent); + Integration::HoverEvent event(1); + TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f ); + event.AddPoint( point ); + application.ProcessEvent( event ); Stage::GetCurrent().Remove(dummy); } END_TEST; } -int UtcDaliControlImplStyleChange(void) +/////////////////////////////////////////////////////////////////////////////////////////////////// + + +int UtcDaliControlImplKeyEvent(void) { ToolkitTestApplication application; - DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); + { + DummyControl dummy = DummyControl::New( true ); + DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); - Stage::GetCurrent().Add(dummy); + Stage::GetCurrent().Add(dummy); + dummy.SetKeyInputFocus(); - application.Render(); - application.SendNotification(); - application.Render(); - application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); - // Add a Control and normal Actor as children - DummyControl dummyChild = DummyControl::New(); - dummy.Add(dummyChild); + DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION ); + Integration::KeyEvent keyEvent; + application.ProcessEvent(keyEvent); + DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION ); - Actor actor = Actor::New(); - dummy.Add(actor); + Stage::GetCurrent().Remove(dummy); + } - DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, false, TEST_LOCATION ); - StyleChange styleChange; - styleChange.defaultFontChange = true; - Dali::StyleMonitor styleMonitor = StyleMonitor::Get(); - styleMonitor.EmitStyleChangeSignal(styleChange); + // Ensure full code coverage + { + DummyControl dummy = DummyControl::New(); + + Stage::GetCurrent().Add(dummy); + dummy.SetKeyInputFocus(); + + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); - DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, true, TEST_LOCATION ); + Integration::KeyEvent keyEvent; + application.ProcessEvent(keyEvent); - Stage::GetCurrent().Remove(dummy); + Stage::GetCurrent().Remove(dummy); + } END_TEST; } @@ -755,13 +780,13 @@ int UtcDaliControlImplTypeRegistry(void) /////////////////////////////////////////////////////////////////////////////////////////////////// namespace { -static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event) +static bool WheelEventCallback(Actor actor, const WheelEvent& event) { return false; } } -int UtcDaliControlImplMouseWheelEvent(void) +int UtcDaliControlImplWheelEvent(void) { ToolkitTestApplication application; @@ -769,24 +794,24 @@ int UtcDaliControlImplMouseWheelEvent(void) DummyControl dummy = DummyControl::New( true ); DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); - dummy.SetSize(100.0f, 100.0f); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); - dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback); + dummy.WheelEventSignal().Connect(&WheelEventCallback); application.Render(); application.SendNotification(); application.Render(); application.SendNotification(); - DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, false, TEST_LOCATION ); - // simulate a mouse wheel event + // simulate a wheel event Vector2 screenCoordinates( 10.0f, 10.0f ); - Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u); - application.ProcessEvent(event); - DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION ); + Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u ); + application.ProcessEvent( event ); + DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, true, TEST_LOCATION ); Stage::GetCurrent().Remove(dummy); } @@ -795,23 +820,127 @@ int UtcDaliControlImplMouseWheelEvent(void) { DummyControl dummy = DummyControl::New(); - dummy.SetSize(100.0f, 100.0f); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); - dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback); + dummy.WheelEventSignal().Connect(&WheelEventCallback); application.Render(); application.SendNotification(); application.Render(); application.SendNotification(); - // simulate a mouse wheel event + // simulate a wheel event Vector2 screenCoordinates( 20.0f, 20.0f ); - Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u); - application.ProcessEvent(event); + Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u ); + application.ProcessEvent( event ); Stage::GetCurrent().Remove(dummy); } END_TEST; } + +int UtcDaliControlImplSetStyleName(void) +{ + ToolkitTestApplication application; + + { + DummyControl dummy = DummyControl::New( true ); + + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); + dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(dummy); + + dummy.SetStyleName("TestStyle"); + + DALI_TEST_CHECK( dummy.GetStyleName() == "TestStyle" ); + + Stage::GetCurrent().Remove(dummy); + } + END_TEST; +} + +int UtcDaliControlImplOnStyleChangeN(void) +{ + ToolkitTestApplication application; + Control dummy = Control::New(); + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy ); + + // test that style manager is being used, passing an empty handle throws exception + try + { + Dali::Toolkit::StyleManager styleManager; + controlImpl.OnStyleChange( styleManager, StyleChange::THEME_CHANGE ); + tet_result(TET_FAIL); + } + catch (DaliException &exception) + { + tet_result(TET_PASS); + } + + END_TEST; +} + + +int UtcDaliControlImplOnAccessibilityPanP(void) +{ + ToolkitTestApplication application; + Control dummy = Control::New(); + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy ); + + PanGesture pan; + DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityPan( pan ), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliControlImplOnAccessibilityTouchP(void) +{ + ToolkitTestApplication application; + Control dummy = Control::New(); + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy ); + TouchEvent touch; + DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityTouch( touch ), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliControlImplOnAccessibilityActivatedP(void) +{ + ToolkitTestApplication application; + + Control dummy = Control::New(); + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy ); + DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityActivated(), TEST_LOCATION ); + + // Invoke the control's activate action + TypeInfo type = TypeRegistry::Get().GetTypeInfo( "Control" ); + DALI_TEST_CHECK( type ); + + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); + + std::vector attributes; + DALI_TEST_EQUALS( false, handle.DoAction("control-activated", attributes), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliControlImplGetNextKeyboardFocusableActorP(void) +{ + ToolkitTestApplication application; + Control dummy = Control::New(); + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy ); + + Actor currentFocusedActor; + Actor result = controlImpl.GetNextKeyboardFocusableActor( currentFocusedActor, Control::KeyboardFocus::LEFT, false ); + + DALI_TEST_EQUALS( result, currentFocusedActor, TEST_LOCATION ); + + END_TEST; +} + + + +