2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/mouse-wheel-event-integ.h>
25 #include <dali/integration-api/events/long-press-gesture-event.h>
26 #include <dali/integration-api/events/pinch-gesture-event.h>
27 #include <dali/integration-api/events/pan-gesture-event.h>
28 #include <dali/integration-api/events/tap-gesture-event.h>
29 #include <dali/integration-api/events/touch-event-integ.h>
31 #include "dummy-control.h"
34 using namespace Dali::Toolkit;
37 void control_impl_startup(void)
39 test_return_value = TET_UNDEF;
42 void control_impl_cleanup(void)
44 test_return_value = TET_PASS;
48 int UtcDaliControlImplTypeRegistry(void)
50 ToolkitTestApplication application;
54 type = TypeRegistry::Get().GetTypeInfo( "Control" );
55 DALI_TEST_CHECK( type );
56 BaseHandle handle = type.CreateInstance();
57 DALI_TEST_CHECK( handle );
59 // Check if it's a control
60 DALI_TEST_CHECK( Control::DownCast(handle) );
65 ///////////////////////////////////////////////////////////////////////////////////////////////////
68 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
74 int UtcDaliControlImplMouseWheelEvent(void)
76 ToolkitTestApplication application;
79 DummyControl dummy = DummyControl::New( true );
80 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
82 dummy.SetSize(100.0f, 100.0f);
83 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
84 Stage::GetCurrent().Add(dummy);
86 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
89 application.SendNotification();
91 application.SendNotification();
93 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
95 // simulate a mouse wheel event
96 Vector2 screenCoordinates( 10.0f, 10.0f );
97 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
98 application.ProcessEvent(event);
99 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
101 Stage::GetCurrent().Remove(dummy);
104 // Ensure full code coverage
106 DummyControl dummy = DummyControl::New();
108 dummy.SetSize(100.0f, 100.0f);
109 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
110 Stage::GetCurrent().Add(dummy);
112 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
114 application.Render();
115 application.SendNotification();
116 application.Render();
117 application.SendNotification();
119 // simulate a mouse wheel event
120 Vector2 screenCoordinates( 20.0f, 20.0f );
121 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
122 application.ProcessEvent(event);
124 Stage::GetCurrent().Remove(dummy);