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/mouse-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>
37 #include "dummy-control.h"
40 using namespace Dali::Toolkit;
42 void utc_dali_toolkit_control_impl_startup(void)
44 test_return_value = TET_UNDEF;
47 void utc_dali_toolkit_control_impl_cleanup(void)
49 test_return_value = TET_PASS;
52 int UtcDaliControlImplNew(void)
54 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
58 DALI_TEST_CHECK( !Control::DownCast(control) );
60 control = Toolkit::Internal::Control::New();
62 DALI_TEST_CHECK( Control::DownCast(control) );
67 int UtcDaliControlImplEnableGestureDetector(void)
69 ToolkitTestApplication application;
71 // Enable individually
73 DummyControl dummy = DummyControl::New();
74 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
76 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
77 dummyImpl.EnableGestureDetection(Gesture::Pinch);
78 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
80 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
81 dummyImpl.EnableGestureDetection(Gesture::Pan);
82 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
84 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
85 dummyImpl.EnableGestureDetection(Gesture::Tap);
86 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
88 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
89 dummyImpl.EnableGestureDetection(Gesture::LongPress);
90 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
95 DummyControl dummy = DummyControl::New();
96 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
98 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
99 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
100 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
101 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
103 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
105 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
106 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
107 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
108 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
110 // Enable when already enabled
112 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
114 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
115 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
116 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
117 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
122 int UtcDaliControlImplDisableGestureDetector(void)
124 ToolkitTestApplication application;
126 // Disable individually
128 DummyControl dummy = DummyControl::New();
129 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
131 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
133 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
134 dummyImpl.DisableGestureDetection(Gesture::Pinch);
135 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
137 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
138 dummyImpl.DisableGestureDetection(Gesture::Pan);
139 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
141 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
142 dummyImpl.DisableGestureDetection(Gesture::Tap);
143 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
145 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
146 dummyImpl.DisableGestureDetection(Gesture::LongPress);
147 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
152 DummyControl dummy = DummyControl::New();
153 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
155 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
157 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
158 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
159 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
160 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
162 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
164 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
165 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
166 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
167 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
170 // Disable When not enabled
172 DummyControl dummy = DummyControl::New();
173 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
175 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
176 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
177 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
178 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
180 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
182 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
183 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
184 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
185 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
188 // Ensure control is detached if gesture detector is not deleted
190 DummyControl dummy = DummyControl::New();
191 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
193 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
195 PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
196 PanGestureDetector pan = dummyImpl.GetPanGestureDetector();
197 TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
198 LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
200 DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), false, TEST_LOCATION );
201 DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), false, TEST_LOCATION );
202 DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), false, TEST_LOCATION );
203 DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), false, TEST_LOCATION );
205 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
207 DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), true, TEST_LOCATION );
208 DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), true, TEST_LOCATION );
209 DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), true, TEST_LOCATION );
210 DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), true, TEST_LOCATION );
215 int UtcDaliControlImplOnGestureMethods(void)
217 ToolkitTestApplication application;
219 // Check gesture actually happens
221 DummyControl dummy = DummyControl::New(true);
222 dummy.SetSize( Vector2(100.0f, 100.0f ) );
224 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
225 Stage::GetCurrent().Add(dummy);
227 // Render and notify a couple of times
228 application.SendNotification();
229 application.Render();
230 application.SendNotification();
231 application.Render();
233 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
234 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
236 DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
237 Integration::PinchGestureEvent pinch(Gesture::Started);
240 pinch.centerPoint = Vector2(20.0f, 20.0f);
241 application.ProcessEvent(pinch);
242 DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
244 DALI_TEST_CHECK( dummyImpl.panCalled == false );
245 Integration::PanGestureEvent pan(Gesture::Possible);
246 pan.previousPosition = Vector2(10.0f, 20.0f);
247 pan.currentPosition = Vector2(20.0f, 20.0f);
249 pan.numberOfTouches = 1u;
250 application.ProcessEvent(pan);
251 pan.state = Gesture::Started;
252 application.ProcessEvent(pan);
253 DALI_TEST_CHECK( dummyImpl.panCalled == true );
255 DALI_TEST_CHECK( dummyImpl.tapCalled == false );
256 Integration::TapGestureEvent tap(Gesture::Possible);
257 tap.numberOfTaps = 1u;
258 tap.numberOfTouches = 1u;
259 tap.point = Vector2(50.0f, 50.0f);
260 application.ProcessEvent(tap);
261 tap.state = Gesture::Started;
262 application.ProcessEvent(tap);
263 DALI_TEST_CHECK( dummyImpl.tapCalled == true );
265 DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
266 Integration::LongPressGestureEvent longPress(Gesture::Possible);
267 longPress.numberOfTouches = 1u;
268 longPress.point = Vector2(50.0f, 50.0f);
269 application.ProcessEvent(longPress);
270 longPress.state = Gesture::Started;
271 application.ProcessEvent(longPress);
272 DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
273 longPress.state = Gesture::Finished;
274 application.ProcessEvent(longPress);
276 Stage::GetCurrent().Remove(dummy);
279 // Ensure full code coverage
281 DummyControl dummy = DummyControl::New();
282 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
284 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
285 Stage::GetCurrent().Add(dummy);
287 // Render and notify a couple of times
288 application.SendNotification();
289 application.Render();
290 application.SendNotification();
291 application.Render();
293 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
294 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
296 DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
297 Integration::PinchGestureEvent pinch(Gesture::Started);
300 pinch.centerPoint = Vector2(20.0f, 20.0f);
301 application.ProcessEvent(pinch);
303 // Render and notify a couple of times
304 application.SendNotification();
305 application.Render();
306 application.SendNotification();
307 application.Render();
308 DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
310 Integration::PanGestureEvent pan(Gesture::Possible);
311 pan.previousPosition = Vector2(10.0f, 20.0f);
312 pan.currentPosition = Vector2(20.0f, 20.0f);
314 pan.numberOfTouches = 1u;
315 application.ProcessEvent(pan);
316 pan.state = Gesture::Started;
317 application.ProcessEvent(pan);
319 Integration::TapGestureEvent tap(Gesture::Possible);
320 tap.numberOfTaps = 1u;
321 tap.numberOfTouches = 1u;
322 tap.point = Vector2(50.0f, 50.0f);
323 application.ProcessEvent(tap);
324 tap.state = Gesture::Started;
325 application.ProcessEvent(tap);
327 Integration::LongPressGestureEvent longPress(Gesture::Possible);
328 longPress.numberOfTouches = 1u;
329 longPress.point = Vector2(50.0f, 50.0f);
330 application.ProcessEvent(longPress);
331 longPress.state = Gesture::Started;
332 application.ProcessEvent(longPress);
333 longPress.state = Gesture::Finished;
334 application.ProcessEvent(longPress);
336 Stage::GetCurrent().Remove(dummy);
341 int UtcDaliControlImplChildAddAndRemove(void)
343 ToolkitTestApplication application;
346 DummyControl dummy = DummyControl::New( true );
347 Stage::GetCurrent().Add(dummy);
348 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
350 application.Render();
351 application.SendNotification();
353 DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
354 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
355 Actor actor = RenderableActor::New();
357 DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
358 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
360 application.Render();
361 application.SendNotification();
363 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
364 dummy.Remove( actor );
365 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
366 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
368 application.Render();
369 application.SendNotification();
371 Stage::GetCurrent().Remove(dummy);
374 // Ensure full code coverage
376 DummyControl dummy = DummyControl::New();
377 Stage::GetCurrent().Add(dummy);
379 application.Render();
380 application.SendNotification();
382 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
383 Actor actor = RenderableActor::New();
385 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
387 application.Render();
388 application.SendNotification();
390 dummy.Remove( actor );
391 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
393 application.Render();
394 application.SendNotification();
396 Stage::GetCurrent().Remove(dummy);
401 int UtcDaliControlImplStageConnection(void)
403 ToolkitTestApplication application;
406 DummyControl dummy = DummyControl::New( true );
407 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
409 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
410 Stage::GetCurrent().Add(dummy);
411 application.Render();
412 application.SendNotification();
413 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
415 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
416 Stage::GetCurrent().Remove(dummy);
417 application.Render();
418 application.SendNotification();
419 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
422 // Ensure full code coverage
424 unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
425 DummyControl dummy = DummyControl::New();
427 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
428 Stage::GetCurrent().Add(dummy);
429 application.Render();
430 application.SendNotification();
431 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
433 Stage::GetCurrent().Remove(dummy);
434 application.Render();
435 application.SendNotification();
436 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
441 int UtcDaliControlImplSizeSetP(void)
443 ToolkitTestApplication application;
446 DummyControl dummy = DummyControl::New( true );
447 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
449 Stage::GetCurrent().Add(dummy);
450 application.Render();
451 application.SendNotification();
453 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size not set, no onSizeSet called
454 Vector2 size(100.0f, 200.0f);
455 dummy.SetSize( size );
457 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size is going to get negotiated, no onSizeSet called
459 application.SendNotification();
460 application.Render();
462 DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
463 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
465 Stage::GetCurrent().Remove(dummy);
471 int UtcDaliControlImplSizeSet2P(void)
473 ToolkitTestApplication application;
476 DummyControl dummy = DummyControl::New();
477 Stage::GetCurrent().Add(dummy);
479 Vector2 size(100.0f, 200.0f);
480 DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
482 application.SendNotification();
483 application.Render();
487 application.SendNotification();
488 application.Render();
490 DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
492 Stage::GetCurrent().Remove(dummy);
498 int UtcDaliControlImplSizeAnimation(void)
500 ToolkitTestApplication application;
503 DummyControl dummy = DummyControl::New( true );
504 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
506 Stage::GetCurrent().Add(dummy);
508 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
509 Animation animation = Animation::New(1.0f);
510 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
513 application.Render();
514 application.SendNotification();
515 application.Render();
516 application.SendNotification();
518 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
520 Stage::GetCurrent().Remove(dummy);
523 // Ensure full code coverage
525 DummyControl dummy = DummyControl::New();
527 Stage::GetCurrent().Add(dummy);
529 Animation animation = Animation::New(1.0f);
530 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
533 application.Render();
534 application.SendNotification();
535 application.Render();
536 application.SendNotification();
538 Stage::GetCurrent().Remove(dummy);
543 ///////////////////////////////////////////////////////////////////////////////////////////////////
545 int UtcDaliControlImplTouchEvent(void)
547 ToolkitTestApplication application;
550 DummyControl dummy = DummyControl::New( true );
551 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
553 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
554 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
555 Stage::GetCurrent().Add(dummy);
557 application.Render();
558 application.SendNotification();
559 application.Render();
560 application.SendNotification();
562 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
563 Integration::TouchEvent touchEvent(1);
564 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
565 touchEvent.AddPoint(point);
566 application.ProcessEvent(touchEvent);
567 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
569 Stage::GetCurrent().Remove(dummy);
572 // Ensure full code coverage
574 DummyControl dummy = DummyControl::New();
576 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
577 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
578 Stage::GetCurrent().Add(dummy);
580 application.Render();
581 application.SendNotification();
582 application.Render();
583 application.SendNotification();
585 Integration::TouchEvent touchEvent(1);
586 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
587 touchEvent.AddPoint(point);
588 application.ProcessEvent(touchEvent);
590 Stage::GetCurrent().Remove(dummy);
595 int UtcDaliControlImplHoverEvent(void)
597 ToolkitTestApplication application;
600 DummyControl dummy = DummyControl::New( true );
601 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
603 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
604 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
605 Stage::GetCurrent().Add(dummy);
607 application.Render();
608 application.SendNotification();
609 application.Render();
610 application.SendNotification();
612 DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, false, TEST_LOCATION );
613 Integration::HoverEvent event(1);
614 TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f );
615 event.AddPoint( point );
616 application.ProcessEvent( event );
617 DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, true, TEST_LOCATION );
619 Stage::GetCurrent().Remove(dummy);
622 // Ensure full code coverage
624 DummyControl dummy = DummyControl::New();
626 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
627 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
628 Stage::GetCurrent().Add(dummy);
630 application.Render();
631 application.SendNotification();
632 application.Render();
633 application.SendNotification();
635 Integration::HoverEvent event(1);
636 TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f );
637 event.AddPoint( point );
638 application.ProcessEvent( event );
640 Stage::GetCurrent().Remove(dummy);
645 ///////////////////////////////////////////////////////////////////////////////////////////////////
648 int UtcDaliControlImplKeyEvent(void)
650 ToolkitTestApplication application;
653 DummyControl dummy = DummyControl::New( true );
654 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
656 Stage::GetCurrent().Add(dummy);
657 dummy.SetKeyInputFocus();
659 application.Render();
660 application.SendNotification();
661 application.Render();
662 application.SendNotification();
664 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
665 Integration::KeyEvent keyEvent;
666 application.ProcessEvent(keyEvent);
667 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
669 Stage::GetCurrent().Remove(dummy);
672 // Ensure full code coverage
674 DummyControl dummy = DummyControl::New();
676 Stage::GetCurrent().Add(dummy);
677 dummy.SetKeyInputFocus();
679 application.Render();
680 application.SendNotification();
681 application.Render();
682 application.SendNotification();
684 Integration::KeyEvent keyEvent;
685 application.ProcessEvent(keyEvent);
687 Stage::GetCurrent().Remove(dummy);
692 int UtcDaliControlImplKeyInputFocusGained(void)
694 ToolkitTestApplication application;
697 DummyControl dummy = DummyControl::New( true );
698 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
700 Stage::GetCurrent().Add(dummy);
702 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
704 dummy.SetKeyInputFocus();
706 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
708 Stage::GetCurrent().Remove(dummy);
711 // Ensure full code coverage
713 DummyControl dummy = DummyControl::New();
715 Stage::GetCurrent().Add(dummy);
716 dummy.SetKeyInputFocus();
717 Stage::GetCurrent().Remove(dummy);
722 int UtcDaliControlImplKeyInputFocusLost(void)
724 ToolkitTestApplication application;
727 DummyControl dummy = DummyControl::New( true );
728 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
730 Stage::GetCurrent().Add(dummy);
732 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
734 dummy.SetKeyInputFocus();
735 dummy.ClearKeyInputFocus();
737 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
739 Stage::GetCurrent().Remove(dummy);
742 // Ensure full code coverage
744 DummyControl dummy = DummyControl::New();
746 Stage::GetCurrent().Add(dummy);
747 dummy.SetKeyInputFocus();
748 dummy.ClearKeyInputFocus();
750 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
752 dummyImpl.OnAccessibilityValueChange( true );
753 dummyImpl.IsKeyboardNavigationSupported();
754 dummyImpl.IsKeyboardFocusGroup();
756 Stage::GetCurrent().Remove(dummy);
761 int UtcDaliControlImplTypeRegistry(void)
763 ToolkitTestApplication application;
767 type = TypeRegistry::Get().GetTypeInfo( "Control" );
768 DALI_TEST_CHECK( type );
769 BaseHandle handle = type.CreateInstance();
770 DALI_TEST_CHECK( handle );
772 // Check if it's a control
773 DALI_TEST_CHECK( Control::DownCast(handle) );
778 ///////////////////////////////////////////////////////////////////////////////////////////////////
781 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
787 int UtcDaliControlImplMouseWheelEvent(void)
789 ToolkitTestApplication application;
792 DummyControl dummy = DummyControl::New( true );
793 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
795 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
796 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
797 Stage::GetCurrent().Add(dummy);
799 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
801 application.Render();
802 application.SendNotification();
803 application.Render();
804 application.SendNotification();
806 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
808 // simulate a mouse wheel event
809 Vector2 screenCoordinates( 10.0f, 10.0f );
810 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
811 application.ProcessEvent(event);
812 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
814 Stage::GetCurrent().Remove(dummy);
817 // Ensure full code coverage
819 DummyControl dummy = DummyControl::New();
821 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
822 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
823 Stage::GetCurrent().Add(dummy);
825 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
827 application.Render();
828 application.SendNotification();
829 application.Render();
830 application.SendNotification();
832 // simulate a mouse wheel event
833 Vector2 screenCoordinates( 20.0f, 20.0f );
834 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
835 application.ProcessEvent(event);
837 Stage::GetCurrent().Remove(dummy);
842 int UtcDaliControlImplSetStyleName(void)
844 ToolkitTestApplication application;
847 DummyControl dummy = DummyControl::New( true );
848 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
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);