2 * Copyright (c) 2015 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 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24 #include "toolkit-style-monitor.h"
27 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali/integration-api/events/key-event-integ.h>
29 #include <dali/integration-api/events/wheel-event-integ.h>
30 #include <dali/integration-api/events/long-press-gesture-event.h>
31 #include <dali/integration-api/events/pinch-gesture-event.h>
32 #include <dali/integration-api/events/pan-gesture-event.h>
33 #include <dali/integration-api/events/tap-gesture-event.h>
34 #include <dali/integration-api/events/touch-event-integ.h>
35 #include <dali/integration-api/events/hover-event-integ.h>
38 #include "dummy-control.h"
41 using namespace Dali::Toolkit;
43 void utc_dali_toolkit_control_impl_startup(void)
45 test_return_value = TET_UNDEF;
48 void utc_dali_toolkit_control_impl_cleanup(void)
50 test_return_value = TET_PASS;
53 int UtcDaliControlImplNew(void)
55 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
59 DALI_TEST_CHECK( !Control::DownCast(control) );
61 control = Toolkit::Internal::Control::New();
63 DALI_TEST_CHECK( Control::DownCast(control) );
68 int UtcDaliControlImplEnableGestureDetector(void)
70 ToolkitTestApplication application;
72 // Enable individually
74 DummyControl dummy = DummyControl::New();
75 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
77 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
78 dummyImpl.EnableGestureDetection(Gesture::Pinch);
79 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
81 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
82 dummyImpl.EnableGestureDetection(Gesture::Pan);
83 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
85 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
86 dummyImpl.EnableGestureDetection(Gesture::Tap);
87 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
89 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
90 dummyImpl.EnableGestureDetection(Gesture::LongPress);
91 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
96 DummyControl dummy = DummyControl::New();
97 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
99 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
100 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
101 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
102 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
104 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
106 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
107 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
108 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
109 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
111 // Enable when already enabled
113 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
115 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
116 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
117 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
118 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
123 int UtcDaliControlImplDisableGestureDetector(void)
125 ToolkitTestApplication application;
127 // Disable individually
129 DummyControl dummy = DummyControl::New();
130 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
132 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
134 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
135 dummyImpl.DisableGestureDetection(Gesture::Pinch);
136 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
138 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
139 dummyImpl.DisableGestureDetection(Gesture::Pan);
140 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
142 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
143 dummyImpl.DisableGestureDetection(Gesture::Tap);
144 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
146 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
147 dummyImpl.DisableGestureDetection(Gesture::LongPress);
148 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
153 DummyControl dummy = DummyControl::New();
154 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
156 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
158 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
159 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
160 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
161 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
163 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
165 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
166 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
167 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
168 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
171 // Disable When not enabled
173 DummyControl dummy = DummyControl::New();
174 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
176 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
177 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
178 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
179 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
181 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
183 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
184 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
185 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
186 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
189 // Ensure control is detached if gesture detector is not deleted
191 DummyControl dummy = DummyControl::New();
192 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
194 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
196 PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
197 PanGestureDetector pan = dummyImpl.GetPanGestureDetector();
198 TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
199 LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
201 DALI_TEST_EQUALS( 0 == pinch.GetAttachedActorCount(), false, TEST_LOCATION );
202 DALI_TEST_EQUALS( 0 == pan.GetAttachedActorCount(), false, TEST_LOCATION );
203 DALI_TEST_EQUALS( 0 == tap.GetAttachedActorCount(), false, TEST_LOCATION );
204 DALI_TEST_EQUALS( 0 == longPress.GetAttachedActorCount(), false, TEST_LOCATION );
206 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
208 DALI_TEST_EQUALS( 0 == pinch.GetAttachedActorCount(), true, TEST_LOCATION );
209 DALI_TEST_EQUALS( 0 == pan.GetAttachedActorCount(), true, TEST_LOCATION );
210 DALI_TEST_EQUALS( 0 == tap.GetAttachedActorCount(), true, TEST_LOCATION );
211 DALI_TEST_EQUALS( 0 == longPress.GetAttachedActorCount(), true, TEST_LOCATION );
216 int UtcDaliControlImplOnGestureMethods(void)
218 ToolkitTestApplication application;
220 // Check gesture actually happens
222 DummyControl dummy = DummyControl::New(true);
223 dummy.SetSize( Vector2(100.0f, 100.0f ) );
225 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
226 Stage::GetCurrent().Add(dummy);
228 // Render and notify a couple of times
229 application.SendNotification();
230 application.Render();
231 application.SendNotification();
232 application.Render();
234 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
235 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
237 DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
238 Integration::PinchGestureEvent pinch(Gesture::Started);
241 pinch.centerPoint = Vector2(20.0f, 20.0f);
242 application.ProcessEvent(pinch);
243 DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
245 DALI_TEST_CHECK( dummyImpl.panCalled == false );
246 Integration::PanGestureEvent pan(Gesture::Possible);
247 pan.previousPosition = Vector2(10.0f, 20.0f);
248 pan.currentPosition = Vector2(20.0f, 20.0f);
250 pan.numberOfTouches = 1u;
251 application.ProcessEvent(pan);
252 pan.state = Gesture::Started;
253 application.ProcessEvent(pan);
254 DALI_TEST_CHECK( dummyImpl.panCalled == true );
256 DALI_TEST_CHECK( dummyImpl.tapCalled == false );
257 Integration::TapGestureEvent tap(Gesture::Possible);
258 tap.numberOfTaps = 1u;
259 tap.numberOfTouches = 1u;
260 tap.point = Vector2(50.0f, 50.0f);
261 application.ProcessEvent(tap);
262 tap.state = Gesture::Started;
263 application.ProcessEvent(tap);
264 DALI_TEST_CHECK( dummyImpl.tapCalled == true );
266 DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
267 Integration::LongPressGestureEvent longPress(Gesture::Possible);
268 longPress.numberOfTouches = 1u;
269 longPress.point = Vector2(50.0f, 50.0f);
270 application.ProcessEvent(longPress);
271 longPress.state = Gesture::Started;
272 application.ProcessEvent(longPress);
273 DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
274 longPress.state = Gesture::Finished;
275 application.ProcessEvent(longPress);
277 Stage::GetCurrent().Remove(dummy);
280 // Ensure full code coverage
282 DummyControl dummy = DummyControl::New();
283 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
285 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
286 Stage::GetCurrent().Add(dummy);
288 // Render and notify a couple of times
289 application.SendNotification();
290 application.Render();
291 application.SendNotification();
292 application.Render();
294 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
295 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
297 DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
298 Integration::PinchGestureEvent pinch(Gesture::Started);
301 pinch.centerPoint = Vector2(20.0f, 20.0f);
302 application.ProcessEvent(pinch);
304 // Render and notify a couple of times
305 application.SendNotification();
306 application.Render();
307 application.SendNotification();
308 application.Render();
309 DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
311 Integration::PanGestureEvent pan(Gesture::Possible);
312 pan.previousPosition = Vector2(10.0f, 20.0f);
313 pan.currentPosition = Vector2(20.0f, 20.0f);
315 pan.numberOfTouches = 1u;
316 application.ProcessEvent(pan);
317 pan.state = Gesture::Started;
318 application.ProcessEvent(pan);
320 Integration::TapGestureEvent tap(Gesture::Possible);
321 tap.numberOfTaps = 1u;
322 tap.numberOfTouches = 1u;
323 tap.point = Vector2(50.0f, 50.0f);
324 application.ProcessEvent(tap);
325 tap.state = Gesture::Started;
326 application.ProcessEvent(tap);
328 Integration::LongPressGestureEvent longPress(Gesture::Possible);
329 longPress.numberOfTouches = 1u;
330 longPress.point = Vector2(50.0f, 50.0f);
331 application.ProcessEvent(longPress);
332 longPress.state = Gesture::Started;
333 application.ProcessEvent(longPress);
334 longPress.state = Gesture::Finished;
335 application.ProcessEvent(longPress);
337 Stage::GetCurrent().Remove(dummy);
342 int UtcDaliControlImplChildAddAndRemove(void)
344 ToolkitTestApplication application;
347 DummyControl dummy = DummyControl::New( true );
348 Stage::GetCurrent().Add(dummy);
349 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
351 application.Render();
352 application.SendNotification();
354 DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
355 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
356 Actor actor = Actor::New();
358 DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
359 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
361 application.Render();
362 application.SendNotification();
364 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
365 dummy.Remove( actor );
366 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
367 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
369 application.Render();
370 application.SendNotification();
372 Stage::GetCurrent().Remove(dummy);
375 // Ensure full code coverage
377 DummyControl dummy = DummyControl::New();
378 Stage::GetCurrent().Add(dummy);
380 application.Render();
381 application.SendNotification();
383 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
384 Actor actor = Actor::New();
386 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
388 application.Render();
389 application.SendNotification();
391 dummy.Remove( actor );
392 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
394 application.Render();
395 application.SendNotification();
397 Stage::GetCurrent().Remove(dummy);
402 int UtcDaliControlImplStageConnection(void)
404 ToolkitTestApplication application;
407 DummyControl dummy = DummyControl::New( true );
408 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
410 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
411 Stage::GetCurrent().Add(dummy);
412 application.Render();
413 application.SendNotification();
414 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
416 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
417 Stage::GetCurrent().Remove(dummy);
418 application.Render();
419 application.SendNotification();
420 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
423 // Ensure full code coverage
425 unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
426 DummyControl dummy = DummyControl::New();
428 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
429 Stage::GetCurrent().Add(dummy);
430 application.Render();
431 application.SendNotification();
432 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
434 Stage::GetCurrent().Remove(dummy);
435 application.Render();
436 application.SendNotification();
437 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
442 int UtcDaliControlImplSizeSetP(void)
444 ToolkitTestApplication application;
447 DummyControl dummy = DummyControl::New( true );
448 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
450 Stage::GetCurrent().Add(dummy);
451 application.Render();
452 application.SendNotification();
454 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size not set, no onSizeSet called
455 Vector2 size(100.0f, 200.0f);
456 dummy.SetSize( size );
458 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size is going to get negotiated, no onSizeSet called
460 application.SendNotification();
461 application.Render();
463 DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
464 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
466 Stage::GetCurrent().Remove(dummy);
472 int UtcDaliControlImplSizeSet2P(void)
474 ToolkitTestApplication application;
477 DummyControl dummy = DummyControl::New();
478 Stage::GetCurrent().Add(dummy);
480 Vector2 size(100.0f, 200.0f);
481 DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
483 application.SendNotification();
484 application.Render();
488 application.SendNotification();
489 application.Render();
491 DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
493 Stage::GetCurrent().Remove(dummy);
499 int UtcDaliControlImplSizeAnimation(void)
501 ToolkitTestApplication application;
504 DummyControl dummy = DummyControl::New( true );
505 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
507 Stage::GetCurrent().Add(dummy);
509 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
510 Animation animation = Animation::New(1.0f);
511 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
514 application.Render();
515 application.SendNotification();
516 application.Render();
517 application.SendNotification();
519 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
521 Stage::GetCurrent().Remove(dummy);
524 // Ensure full code coverage
526 DummyControl dummy = DummyControl::New();
528 Stage::GetCurrent().Add(dummy);
530 Animation animation = Animation::New(1.0f);
531 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
534 application.Render();
535 application.SendNotification();
536 application.Render();
537 application.SendNotification();
539 Stage::GetCurrent().Remove(dummy);
544 ///////////////////////////////////////////////////////////////////////////////////////////////////
546 int UtcDaliControlImplTouchEvent(void)
548 ToolkitTestApplication application;
551 DummyControl dummy = DummyControl::New( true );
552 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
554 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
555 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
556 Stage::GetCurrent().Add(dummy);
558 application.Render();
559 application.SendNotification();
560 application.Render();
561 application.SendNotification();
563 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
564 Integration::TouchEvent touchEvent(1);
565 Integration::Point point;
566 point.SetDeviceId( 1 );
567 point.SetState( PointState::DOWN );
568 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
569 touchEvent.AddPoint(point);
570 application.ProcessEvent(touchEvent);
571 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
573 Stage::GetCurrent().Remove(dummy);
576 // Ensure full code coverage
578 DummyControl dummy = DummyControl::New();
580 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
581 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
582 Stage::GetCurrent().Add(dummy);
584 application.Render();
585 application.SendNotification();
586 application.Render();
587 application.SendNotification();
589 Integration::TouchEvent touchEvent(1);
590 Integration::Point point;
591 point.SetDeviceId( 1 );
592 point.SetState( PointState::DOWN );
593 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
594 touchEvent.AddPoint(point);
595 application.ProcessEvent(touchEvent);
597 Stage::GetCurrent().Remove(dummy);
602 int UtcDaliControlImplHoverEvent(void)
604 ToolkitTestApplication application;
607 DummyControl dummy = DummyControl::New( true );
608 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
610 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
611 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
612 Stage::GetCurrent().Add(dummy);
614 application.Render();
615 application.SendNotification();
616 application.Render();
617 application.SendNotification();
619 DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, false, TEST_LOCATION );
620 Integration::HoverEvent event(1);
621 Integration::Point point;
622 point.SetDeviceId( 1 );
623 point.SetState( PointState::MOTION );
624 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
625 event.AddPoint(point);
626 application.ProcessEvent( event );
627 DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, true, TEST_LOCATION );
629 Stage::GetCurrent().Remove(dummy);
632 // Ensure full code coverage
634 DummyControl dummy = DummyControl::New();
636 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
637 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
638 Stage::GetCurrent().Add(dummy);
640 application.Render();
641 application.SendNotification();
642 application.Render();
643 application.SendNotification();
645 Integration::HoverEvent event(1);
646 Integration::Point point;
647 point.SetDeviceId( 1 );
648 point.SetState( PointState::MOTION );
649 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
650 event.AddPoint(point);
651 application.ProcessEvent( event );
653 Stage::GetCurrent().Remove(dummy);
658 ///////////////////////////////////////////////////////////////////////////////////////////////////
661 int UtcDaliControlImplKeyEvent(void)
663 ToolkitTestApplication application;
666 DummyControl dummy = DummyControl::New( true );
667 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
669 Stage::GetCurrent().Add(dummy);
670 dummy.SetKeyInputFocus();
672 application.Render();
673 application.SendNotification();
674 application.Render();
675 application.SendNotification();
677 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
678 Integration::KeyEvent keyEvent;
679 application.ProcessEvent(keyEvent);
680 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
682 Stage::GetCurrent().Remove(dummy);
685 // Ensure full code coverage
687 DummyControl dummy = DummyControl::New();
689 Stage::GetCurrent().Add(dummy);
690 dummy.SetKeyInputFocus();
692 application.Render();
693 application.SendNotification();
694 application.Render();
695 application.SendNotification();
697 Integration::KeyEvent keyEvent;
698 application.ProcessEvent(keyEvent);
700 Stage::GetCurrent().Remove(dummy);
705 int UtcDaliControlImplKeyInputFocusGained(void)
707 ToolkitTestApplication application;
710 DummyControl dummy = DummyControl::New( true );
711 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
713 Stage::GetCurrent().Add(dummy);
715 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
717 dummy.SetKeyInputFocus();
719 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
721 Stage::GetCurrent().Remove(dummy);
724 // Ensure full code coverage
726 DummyControl dummy = DummyControl::New();
728 Stage::GetCurrent().Add(dummy);
729 dummy.SetKeyInputFocus();
730 Stage::GetCurrent().Remove(dummy);
735 int UtcDaliControlImplKeyInputFocusLost(void)
737 ToolkitTestApplication application;
740 DummyControl dummy = DummyControl::New( true );
741 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
743 Stage::GetCurrent().Add(dummy);
745 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
747 dummy.SetKeyInputFocus();
748 dummy.ClearKeyInputFocus();
750 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
752 Stage::GetCurrent().Remove(dummy);
755 // Ensure full code coverage
757 DummyControl dummy = DummyControl::New();
759 Stage::GetCurrent().Add(dummy);
760 dummy.SetKeyInputFocus();
761 dummy.ClearKeyInputFocus();
763 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
765 dummyImpl.OnAccessibilityValueChange( true );
766 dummyImpl.IsKeyboardNavigationSupported();
767 dummyImpl.IsKeyboardFocusGroup();
769 Stage::GetCurrent().Remove(dummy);
774 int UtcDaliControlImplTypeRegistry(void)
776 ToolkitTestApplication application;
780 type = TypeRegistry::Get().GetTypeInfo( "Control" );
781 DALI_TEST_CHECK( type );
782 BaseHandle handle = type.CreateInstance();
783 DALI_TEST_CHECK( handle );
785 // Check if it's a control
786 DALI_TEST_CHECK( Control::DownCast(handle) );
791 ///////////////////////////////////////////////////////////////////////////////////////////////////
794 static bool WheelEventCallback(Actor actor, const WheelEvent& event)
800 int UtcDaliControlImplWheelEvent(void)
802 ToolkitTestApplication application;
805 DummyControl dummy = DummyControl::New( true );
806 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
808 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
809 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
810 Stage::GetCurrent().Add(dummy);
812 dummy.WheelEventSignal().Connect(&WheelEventCallback);
814 application.Render();
815 application.SendNotification();
816 application.Render();
817 application.SendNotification();
819 DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, false, TEST_LOCATION );
821 // simulate a wheel event
822 Vector2 screenCoordinates( 10.0f, 10.0f );
823 Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
824 application.ProcessEvent( event );
825 DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, true, TEST_LOCATION );
827 Stage::GetCurrent().Remove(dummy);
830 // Ensure full code coverage
832 DummyControl dummy = DummyControl::New();
834 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
835 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
836 Stage::GetCurrent().Add(dummy);
838 dummy.WheelEventSignal().Connect(&WheelEventCallback);
840 application.Render();
841 application.SendNotification();
842 application.Render();
843 application.SendNotification();
845 // simulate a wheel event
846 Vector2 screenCoordinates( 20.0f, 20.0f );
847 Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
848 application.ProcessEvent( event );
850 Stage::GetCurrent().Remove(dummy);
855 int UtcDaliControlImplSetStyleName(void)
857 ToolkitTestApplication application;
860 DummyControl dummy = DummyControl::New( true );
862 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
863 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
864 Stage::GetCurrent().Add(dummy);
866 dummy.SetStyleName("TestStyle");
868 DALI_TEST_CHECK( dummy.GetStyleName() == "TestStyle" );
870 Stage::GetCurrent().Remove(dummy);
875 int UtcDaliControlImplOnStyleChangeN(void)
877 ToolkitTestApplication application;
878 Control dummy = Control::New();
879 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
881 // test that style manager is being used, passing an empty handle does nothing but does not crash either
882 Dali::Toolkit::StyleManager styleManager;
883 controlImpl.OnStyleChange( styleManager, StyleChange::THEME_CHANGE );
884 // no crash so test passes
885 tet_result(TET_PASS);
891 int UtcDaliControlImplOnAccessibilityPanP(void)
893 ToolkitTestApplication application;
894 Control dummy = Control::New();
895 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
898 DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityPan( pan ), TEST_LOCATION );
903 int UtcDaliControlImplOnAccessibilityTouchP(void)
905 ToolkitTestApplication application;
906 Control dummy = Control::New();
907 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
909 DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityTouch( touch ), TEST_LOCATION );
914 int UtcDaliControlImplOnAccessibilityActivatedP(void)
916 ToolkitTestApplication application;
918 Control dummy = Control::New();
919 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
920 DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityActivated(), TEST_LOCATION );
922 // Invoke the control's activate action
923 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "Control" );
924 DALI_TEST_CHECK( type );
926 BaseHandle handle = type.CreateInstance();
927 DALI_TEST_CHECK( handle );
929 Property::Map attributes;
930 DALI_TEST_EQUALS( false, handle.DoAction("accessibilityActivated", attributes), TEST_LOCATION );
935 int UtcDaliControlImplGetNextKeyboardFocusableActorP(void)
937 ToolkitTestApplication application;
938 Control dummy = Control::New();
939 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
941 Actor currentFocusedActor;
942 Actor result = controlImpl.GetNextKeyboardFocusableActor( currentFocusedActor, Control::KeyboardFocus::LEFT, false );
944 DALI_TEST_EQUALS( result, currentFocusedActor, TEST_LOCATION );