2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/mouse-wheel-event-integ.h>
26 #include <dali/integration-api/events/long-press-gesture-event.h>
27 #include <dali/integration-api/events/pinch-gesture-event.h>
28 #include <dali/integration-api/events/pan-gesture-event.h>
29 #include <dali/integration-api/events/tap-gesture-event.h>
30 #include <dali/integration-api/events/touch-event-integ.h>
32 #include "dummy-control.h"
35 using namespace Dali::Toolkit;
38 void control_impl_startup(void)
40 test_return_value = TET_UNDEF;
43 void control_impl_cleanup(void)
45 test_return_value = TET_PASS;
49 int UtcDaliControlImplTypeRegistry(void)
51 ToolkitTestApplication application;
55 type = TypeRegistry::Get().GetTypeInfo( "Control" );
56 DALI_TEST_CHECK( type );
57 BaseHandle handle = type.CreateInstance();
58 DALI_TEST_CHECK( handle );
60 // Check if it's a control
61 DALI_TEST_CHECK( Control::DownCast(handle) );
66 ///////////////////////////////////////////////////////////////////////////////////////////////////
69 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
75 int UtcDaliControlImplMouseWheelEvent(void)
77 ToolkitTestApplication application;
80 DummyControl dummy = DummyControl::New( true );
81 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
83 dummy.SetSize(100.0f, 100.0f);
84 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
85 Stage::GetCurrent().Add(dummy);
87 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
90 application.SendNotification();
92 application.SendNotification();
94 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
96 // simulate a mouse wheel event
97 Vector2 screenCoordinates( 10.0f, 10.0f );
98 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
99 application.ProcessEvent(event);
100 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
102 Stage::GetCurrent().Remove(dummy);
105 // Ensure full code coverage
107 DummyControl dummy = DummyControl::New();
109 dummy.SetSize(100.0f, 100.0f);
110 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
111 Stage::GetCurrent().Add(dummy);
113 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
115 application.Render();
116 application.SendNotification();
117 application.Render();
118 application.SendNotification();
120 // simulate a mouse wheel event
121 Vector2 screenCoordinates( 20.0f, 20.0f );
122 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
123 application.ProcessEvent(event);
125 Stage::GetCurrent().Remove(dummy);