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 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
566 touchEvent.AddPoint(point);
567 application.ProcessEvent(touchEvent);
568 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
570 Stage::GetCurrent().Remove(dummy);
573 // Ensure full code coverage
575 DummyControl dummy = DummyControl::New();
577 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
578 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
579 Stage::GetCurrent().Add(dummy);
581 application.Render();
582 application.SendNotification();
583 application.Render();
584 application.SendNotification();
586 Integration::TouchEvent touchEvent(1);
587 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
588 touchEvent.AddPoint(point);
589 application.ProcessEvent(touchEvent);
591 Stage::GetCurrent().Remove(dummy);
596 int UtcDaliControlImplHoverEvent(void)
598 ToolkitTestApplication application;
601 DummyControl dummy = DummyControl::New( true );
602 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
604 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
605 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
606 Stage::GetCurrent().Add(dummy);
608 application.Render();
609 application.SendNotification();
610 application.Render();
611 application.SendNotification();
613 DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, false, TEST_LOCATION );
614 Integration::HoverEvent event(1);
615 TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f );
616 event.AddPoint( point );
617 application.ProcessEvent( event );
618 DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, true, TEST_LOCATION );
620 Stage::GetCurrent().Remove(dummy);
623 // Ensure full code coverage
625 DummyControl dummy = DummyControl::New();
627 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
628 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
629 Stage::GetCurrent().Add(dummy);
631 application.Render();
632 application.SendNotification();
633 application.Render();
634 application.SendNotification();
636 Integration::HoverEvent event(1);
637 TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f );
638 event.AddPoint( point );
639 application.ProcessEvent( event );
641 Stage::GetCurrent().Remove(dummy);
646 ///////////////////////////////////////////////////////////////////////////////////////////////////
649 int UtcDaliControlImplKeyEvent(void)
651 ToolkitTestApplication application;
654 DummyControl dummy = DummyControl::New( true );
655 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
657 Stage::GetCurrent().Add(dummy);
658 dummy.SetKeyInputFocus();
660 application.Render();
661 application.SendNotification();
662 application.Render();
663 application.SendNotification();
665 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
666 Integration::KeyEvent keyEvent;
667 application.ProcessEvent(keyEvent);
668 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
670 Stage::GetCurrent().Remove(dummy);
673 // Ensure full code coverage
675 DummyControl dummy = DummyControl::New();
677 Stage::GetCurrent().Add(dummy);
678 dummy.SetKeyInputFocus();
680 application.Render();
681 application.SendNotification();
682 application.Render();
683 application.SendNotification();
685 Integration::KeyEvent keyEvent;
686 application.ProcessEvent(keyEvent);
688 Stage::GetCurrent().Remove(dummy);
693 int UtcDaliControlImplKeyInputFocusGained(void)
695 ToolkitTestApplication application;
698 DummyControl dummy = DummyControl::New( true );
699 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
701 Stage::GetCurrent().Add(dummy);
703 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
705 dummy.SetKeyInputFocus();
707 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
709 Stage::GetCurrent().Remove(dummy);
712 // Ensure full code coverage
714 DummyControl dummy = DummyControl::New();
716 Stage::GetCurrent().Add(dummy);
717 dummy.SetKeyInputFocus();
718 Stage::GetCurrent().Remove(dummy);
723 int UtcDaliControlImplKeyInputFocusLost(void)
725 ToolkitTestApplication application;
728 DummyControl dummy = DummyControl::New( true );
729 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
731 Stage::GetCurrent().Add(dummy);
733 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
735 dummy.SetKeyInputFocus();
736 dummy.ClearKeyInputFocus();
738 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
740 Stage::GetCurrent().Remove(dummy);
743 // Ensure full code coverage
745 DummyControl dummy = DummyControl::New();
747 Stage::GetCurrent().Add(dummy);
748 dummy.SetKeyInputFocus();
749 dummy.ClearKeyInputFocus();
751 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
753 dummyImpl.OnAccessibilityValueChange( true );
754 dummyImpl.IsKeyboardNavigationSupported();
755 dummyImpl.IsKeyboardFocusGroup();
757 Stage::GetCurrent().Remove(dummy);
762 int UtcDaliControlImplTypeRegistry(void)
764 ToolkitTestApplication application;
768 type = TypeRegistry::Get().GetTypeInfo( "Control" );
769 DALI_TEST_CHECK( type );
770 BaseHandle handle = type.CreateInstance();
771 DALI_TEST_CHECK( handle );
773 // Check if it's a control
774 DALI_TEST_CHECK( Control::DownCast(handle) );
779 ///////////////////////////////////////////////////////////////////////////////////////////////////
782 static bool WheelEventCallback(Actor actor, const WheelEvent& event)
788 int UtcDaliControlImplWheelEvent(void)
790 ToolkitTestApplication application;
793 DummyControl dummy = DummyControl::New( true );
794 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
796 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
797 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
798 Stage::GetCurrent().Add(dummy);
800 dummy.WheelEventSignal().Connect(&WheelEventCallback);
802 application.Render();
803 application.SendNotification();
804 application.Render();
805 application.SendNotification();
807 DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, false, TEST_LOCATION );
809 // simulate a wheel event
810 Vector2 screenCoordinates( 10.0f, 10.0f );
811 Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
812 application.ProcessEvent( event );
813 DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, true, TEST_LOCATION );
815 Stage::GetCurrent().Remove(dummy);
818 // Ensure full code coverage
820 DummyControl dummy = DummyControl::New();
822 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
823 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
824 Stage::GetCurrent().Add(dummy);
826 dummy.WheelEventSignal().Connect(&WheelEventCallback);
828 application.Render();
829 application.SendNotification();
830 application.Render();
831 application.SendNotification();
833 // simulate a wheel event
834 Vector2 screenCoordinates( 20.0f, 20.0f );
835 Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
836 application.ProcessEvent( event );
838 Stage::GetCurrent().Remove(dummy);
843 int UtcDaliControlImplSetStyleName(void)
845 ToolkitTestApplication application;
848 DummyControl dummy = DummyControl::New( true );
850 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
851 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
852 Stage::GetCurrent().Add(dummy);
854 dummy.SetStyleName("TestStyle");
856 DALI_TEST_CHECK( dummy.GetStyleName() == "TestStyle" );
858 Stage::GetCurrent().Remove(dummy);
863 int UtcDaliControlImplOnStyleChangeN(void)
865 ToolkitTestApplication application;
866 Control dummy = Control::New();
867 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
869 // test that style manager is being used, passing an empty handle does nothing but does not crash either
870 Dali::Toolkit::StyleManager styleManager;
871 controlImpl.OnStyleChange( styleManager, StyleChange::THEME_CHANGE );
872 // no crash so test passes
873 tet_result(TET_PASS);
879 int UtcDaliControlImplOnAccessibilityPanP(void)
881 ToolkitTestApplication application;
882 Control dummy = Control::New();
883 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
886 DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityPan( pan ), TEST_LOCATION );
891 int UtcDaliControlImplOnAccessibilityTouchP(void)
893 ToolkitTestApplication application;
894 Control dummy = Control::New();
895 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
897 DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityTouch( touch ), TEST_LOCATION );
902 int UtcDaliControlImplOnAccessibilityActivatedP(void)
904 ToolkitTestApplication application;
906 Control dummy = Control::New();
907 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
908 DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityActivated(), TEST_LOCATION );
910 // Invoke the control's activate action
911 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "Control" );
912 DALI_TEST_CHECK( type );
914 BaseHandle handle = type.CreateInstance();
915 DALI_TEST_CHECK( handle );
917 Property::Map attributes;
918 DALI_TEST_EQUALS( false, handle.DoAction("accessibilityActivated", attributes), TEST_LOCATION );
923 int UtcDaliControlImplGetNextKeyboardFocusableActorP(void)
925 ToolkitTestApplication application;
926 Control dummy = Control::New();
927 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
929 Actor currentFocusedActor;
930 Actor result = controlImpl.GetNextKeyboardFocusableActor( currentFocusedActor, Control::KeyboardFocus::LEFT, false );
932 DALI_TEST_EQUALS( result, currentFocusedActor, TEST_LOCATION );