X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ControlImpl.cpp;h=8f363af5bff08f6295a01ba833a1af9a8437bea1;hb=030e7c680a6eb0e8d87bfdb8ec359a0267ef7db2;hp=f704531facf081eae6b0afb9830749d52c82eaeb;hpb=cf229fa2e4f00e5fe727eab2d215868bf79ac524;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 f704531..8f363af 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -1,18 +1,19 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #include #include @@ -20,6 +21,7 @@ // Need to override adaptor classes for toolkit test harness, so include // test harness headers before dali headers. #include +#include "toolkit-style-monitor.h" #include #include @@ -216,7 +218,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); @@ -276,7 +278,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); @@ -447,8 +449,8 @@ int UtcDaliControlImplSizeSet(void) application.Render(); application.SendNotification(); - DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); - Vector3 size(100.0f, 200.0f, 0.0f); + DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION ); // Called from size negotiation + Vector2 size(100.0f, 200.0f); dummy.SetSize(size); application.Render(); @@ -456,7 +458,7 @@ int UtcDaliControlImplSizeSet(void) 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); @@ -467,8 +469,8 @@ int UtcDaliControlImplSizeSet(void) 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(); @@ -480,7 +482,7 @@ int UtcDaliControlImplSizeSet(void) 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); } @@ -499,7 +501,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(); @@ -519,7 +521,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(); @@ -542,7 +544,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); @@ -565,7 +567,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); @@ -631,39 +633,6 @@ int UtcDaliControlImplKeyEvent(void) END_TEST; } -int UtcDaliControlImplStyleChange(void) -{ - ToolkitTestApplication application; - - DummyControl dummy = DummyControl::New( true ); - DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); - - Stage::GetCurrent().Add(dummy); - - application.Render(); - application.SendNotification(); - application.Render(); - application.SendNotification(); - - // Add a Control and normal Actor as children - DummyControl dummyChild = DummyControl::New(); - dummy.Add(dummyChild); - - Actor actor = Actor::New(); - dummy.Add(actor); - - DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, false, TEST_LOCATION ); - StyleChange styleChange; - styleChange.defaultFontChange = true; - Dali::StyleMonitor styleMonitor = application.GetAdaptor().GetToolkitStyleMonitor(); - styleMonitor.EmitStyleChangeSignal(styleChange); - - DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, true, TEST_LOCATION ); - - Stage::GetCurrent().Remove(dummy); - END_TEST; -} - int UtcDaliControlImplKeyInputFocusGained(void) { ToolkitTestApplication application; @@ -732,3 +701,84 @@ int UtcDaliControlImplKeyInputFocusLost(void) } END_TEST; } + +int UtcDaliControlImplTypeRegistry(void) +{ + ToolkitTestApplication application; + + // Register Type + TypeInfo type; + type = TypeRegistry::Get().GetTypeInfo( "Control" ); + DALI_TEST_CHECK( type ); + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); + + // Check if it's a control + DALI_TEST_CHECK( Control::DownCast(handle) ); + END_TEST; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +namespace +{ +static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event) +{ + return false; +} +} + +int UtcDaliControlImplMouseWheelEvent(void) +{ + ToolkitTestApplication application; + + { + 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.MouseWheelEventSignal().Connect(&MouseWheelEventCallback); + + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION ); + + // simulate a mouse 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 ); + + Stage::GetCurrent().Remove(dummy); + } + + // Ensure full code coverage + { + DummyControl dummy = DummyControl::New(); + + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); + dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(dummy); + + dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback); + + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + // simulate a mouse wheel event + Vector2 screenCoordinates( 20.0f, 20.0f ); + Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u); + application.ProcessEvent(event); + + Stage::GetCurrent().Remove(dummy); + } + END_TEST; +}