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>
37 #include <dali-toolkit/devel-api/styling/style-manager.h>
39 #include "dummy-control.h"
42 using namespace Dali::Toolkit;
44 void utc_dali_toolkit_control_impl_startup(void)
46 test_return_value = TET_UNDEF;
49 void utc_dali_toolkit_control_impl_cleanup(void)
51 test_return_value = TET_PASS;
54 int UtcDaliControlImplNew(void)
56 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
60 DALI_TEST_CHECK( !Control::DownCast(control) );
62 control = Toolkit::Internal::Control::New();
64 DALI_TEST_CHECK( Control::DownCast(control) );
69 int UtcDaliControlImplEnableGestureDetector(void)
71 ToolkitTestApplication application;
73 // Enable individually
75 DummyControl dummy = DummyControl::New();
76 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
78 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
79 dummyImpl.EnableGestureDetection(Gesture::Pinch);
80 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
82 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
83 dummyImpl.EnableGestureDetection(Gesture::Pan);
84 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
86 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
87 dummyImpl.EnableGestureDetection(Gesture::Tap);
88 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
90 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
91 dummyImpl.EnableGestureDetection(Gesture::LongPress);
92 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
97 DummyControl dummy = DummyControl::New();
98 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
100 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
101 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
102 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
103 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
105 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
107 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
108 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
109 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
110 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
112 // Enable when already enabled
114 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
116 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
117 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
118 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
119 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
124 int UtcDaliControlImplDisableGestureDetector(void)
126 ToolkitTestApplication application;
128 // Disable individually
130 DummyControl dummy = DummyControl::New();
131 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
133 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
135 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
136 dummyImpl.DisableGestureDetection(Gesture::Pinch);
137 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
139 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
140 dummyImpl.DisableGestureDetection(Gesture::Pan);
141 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
143 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
144 dummyImpl.DisableGestureDetection(Gesture::Tap);
145 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
147 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
148 dummyImpl.DisableGestureDetection(Gesture::LongPress);
149 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
154 DummyControl dummy = DummyControl::New();
155 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
157 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
159 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
160 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
161 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
162 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
164 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
166 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
167 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
168 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
169 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
172 // Disable When not enabled
174 DummyControl dummy = DummyControl::New();
175 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
177 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
178 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
179 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
180 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
182 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
184 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
185 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
186 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
187 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
190 // Ensure control is detached if gesture detector is not deleted
192 DummyControl dummy = DummyControl::New();
193 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
195 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
197 PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
198 PanGestureDetector pan = dummyImpl.GetPanGestureDetector();
199 TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
200 LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
202 DALI_TEST_EQUALS( 0 == pinch.GetAttachedActorCount(), false, TEST_LOCATION );
203 DALI_TEST_EQUALS( 0 == pan.GetAttachedActorCount(), false, TEST_LOCATION );
204 DALI_TEST_EQUALS( 0 == tap.GetAttachedActorCount(), false, TEST_LOCATION );
205 DALI_TEST_EQUALS( 0 == longPress.GetAttachedActorCount(), false, TEST_LOCATION );
207 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
209 DALI_TEST_EQUALS( 0 == pinch.GetAttachedActorCount(), true, TEST_LOCATION );
210 DALI_TEST_EQUALS( 0 == pan.GetAttachedActorCount(), true, TEST_LOCATION );
211 DALI_TEST_EQUALS( 0 == tap.GetAttachedActorCount(), true, TEST_LOCATION );
212 DALI_TEST_EQUALS( 0 == longPress.GetAttachedActorCount(), true, TEST_LOCATION );
217 int UtcDaliControlImplOnGestureMethods(void)
219 ToolkitTestApplication application;
221 // Check gesture actually happens
223 DummyControl dummy = DummyControl::New(true);
224 dummy.SetSize( Vector2(100.0f, 100.0f ) );
226 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
227 Stage::GetCurrent().Add(dummy);
229 // Render and notify a couple of times
230 application.SendNotification();
231 application.Render();
232 application.SendNotification();
233 application.Render();
235 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
236 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
238 DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
239 Integration::PinchGestureEvent pinch(Gesture::Started);
242 pinch.centerPoint = Vector2(20.0f, 20.0f);
243 application.ProcessEvent(pinch);
244 DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
246 DALI_TEST_CHECK( dummyImpl.panCalled == false );
247 Integration::PanGestureEvent pan(Gesture::Possible);
248 pan.previousPosition = Vector2(10.0f, 20.0f);
249 pan.currentPosition = Vector2(20.0f, 20.0f);
251 pan.numberOfTouches = 1u;
252 application.ProcessEvent(pan);
253 pan.state = Gesture::Started;
254 application.ProcessEvent(pan);
255 DALI_TEST_CHECK( dummyImpl.panCalled == true );
257 DALI_TEST_CHECK( dummyImpl.tapCalled == false );
258 Integration::TapGestureEvent tap(Gesture::Possible);
259 tap.numberOfTaps = 1u;
260 tap.numberOfTouches = 1u;
261 tap.point = Vector2(50.0f, 50.0f);
262 application.ProcessEvent(tap);
263 tap.state = Gesture::Started;
264 application.ProcessEvent(tap);
265 DALI_TEST_CHECK( dummyImpl.tapCalled == true );
267 DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
268 Integration::LongPressGestureEvent longPress(Gesture::Possible);
269 longPress.numberOfTouches = 1u;
270 longPress.point = Vector2(50.0f, 50.0f);
271 application.ProcessEvent(longPress);
272 longPress.state = Gesture::Started;
273 application.ProcessEvent(longPress);
274 DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
275 longPress.state = Gesture::Finished;
276 application.ProcessEvent(longPress);
278 Stage::GetCurrent().Remove(dummy);
281 // Ensure full code coverage
283 DummyControl dummy = DummyControl::New();
284 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
286 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
287 Stage::GetCurrent().Add(dummy);
289 // Render and notify a couple of times
290 application.SendNotification();
291 application.Render();
292 application.SendNotification();
293 application.Render();
295 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
296 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
298 DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
299 Integration::PinchGestureEvent pinch(Gesture::Started);
302 pinch.centerPoint = Vector2(20.0f, 20.0f);
303 application.ProcessEvent(pinch);
305 // Render and notify a couple of times
306 application.SendNotification();
307 application.Render();
308 application.SendNotification();
309 application.Render();
310 DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
312 Integration::PanGestureEvent pan(Gesture::Possible);
313 pan.previousPosition = Vector2(10.0f, 20.0f);
314 pan.currentPosition = Vector2(20.0f, 20.0f);
316 pan.numberOfTouches = 1u;
317 application.ProcessEvent(pan);
318 pan.state = Gesture::Started;
319 application.ProcessEvent(pan);
321 Integration::TapGestureEvent tap(Gesture::Possible);
322 tap.numberOfTaps = 1u;
323 tap.numberOfTouches = 1u;
324 tap.point = Vector2(50.0f, 50.0f);
325 application.ProcessEvent(tap);
326 tap.state = Gesture::Started;
327 application.ProcessEvent(tap);
329 Integration::LongPressGestureEvent longPress(Gesture::Possible);
330 longPress.numberOfTouches = 1u;
331 longPress.point = Vector2(50.0f, 50.0f);
332 application.ProcessEvent(longPress);
333 longPress.state = Gesture::Started;
334 application.ProcessEvent(longPress);
335 longPress.state = Gesture::Finished;
336 application.ProcessEvent(longPress);
338 Stage::GetCurrent().Remove(dummy);
343 int UtcDaliControlImplChildAddAndRemove(void)
345 ToolkitTestApplication application;
348 DummyControl dummy = DummyControl::New( true );
349 Stage::GetCurrent().Add(dummy);
350 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
352 application.Render();
353 application.SendNotification();
355 DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
356 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
357 Actor actor = RenderableActor::New();
359 DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
360 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
362 application.Render();
363 application.SendNotification();
365 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
366 dummy.Remove( actor );
367 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
368 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
370 application.Render();
371 application.SendNotification();
373 Stage::GetCurrent().Remove(dummy);
376 // Ensure full code coverage
378 DummyControl dummy = DummyControl::New();
379 Stage::GetCurrent().Add(dummy);
381 application.Render();
382 application.SendNotification();
384 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
385 Actor actor = RenderableActor::New();
387 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
389 application.Render();
390 application.SendNotification();
392 dummy.Remove( actor );
393 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
395 application.Render();
396 application.SendNotification();
398 Stage::GetCurrent().Remove(dummy);
403 int UtcDaliControlImplStageConnection(void)
405 ToolkitTestApplication application;
408 DummyControl dummy = DummyControl::New( true );
409 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
411 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
412 Stage::GetCurrent().Add(dummy);
413 application.Render();
414 application.SendNotification();
415 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
417 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
418 Stage::GetCurrent().Remove(dummy);
419 application.Render();
420 application.SendNotification();
421 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
424 // Ensure full code coverage
426 unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
427 DummyControl dummy = DummyControl::New();
429 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
430 Stage::GetCurrent().Add(dummy);
431 application.Render();
432 application.SendNotification();
433 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
435 Stage::GetCurrent().Remove(dummy);
436 application.Render();
437 application.SendNotification();
438 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
443 int UtcDaliControlImplSizeSetP(void)
445 ToolkitTestApplication application;
448 DummyControl dummy = DummyControl::New( true );
449 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
451 Stage::GetCurrent().Add(dummy);
452 application.Render();
453 application.SendNotification();
455 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size not set, no onSizeSet called
456 Vector2 size(100.0f, 200.0f);
457 dummy.SetSize( size );
459 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size is going to get negotiated, no onSizeSet called
461 application.SendNotification();
462 application.Render();
464 DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
465 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
467 Stage::GetCurrent().Remove(dummy);
473 int UtcDaliControlImplSizeSet2P(void)
475 ToolkitTestApplication application;
478 DummyControl dummy = DummyControl::New();
479 Stage::GetCurrent().Add(dummy);
481 Vector2 size(100.0f, 200.0f);
482 DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
484 application.SendNotification();
485 application.Render();
489 application.SendNotification();
490 application.Render();
492 DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
494 Stage::GetCurrent().Remove(dummy);
500 int UtcDaliControlImplSizeAnimation(void)
502 ToolkitTestApplication application;
505 DummyControl dummy = DummyControl::New( true );
506 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
508 Stage::GetCurrent().Add(dummy);
510 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
511 Animation animation = Animation::New(1.0f);
512 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
515 application.Render();
516 application.SendNotification();
517 application.Render();
518 application.SendNotification();
520 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
522 Stage::GetCurrent().Remove(dummy);
525 // Ensure full code coverage
527 DummyControl dummy = DummyControl::New();
529 Stage::GetCurrent().Add(dummy);
531 Animation animation = Animation::New(1.0f);
532 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
535 application.Render();
536 application.SendNotification();
537 application.Render();
538 application.SendNotification();
540 Stage::GetCurrent().Remove(dummy);
545 ///////////////////////////////////////////////////////////////////////////////////////////////////
547 int UtcDaliControlImplTouchEvent(void)
549 ToolkitTestApplication application;
552 DummyControl dummy = DummyControl::New( true );
553 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
555 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
556 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
557 Stage::GetCurrent().Add(dummy);
559 application.Render();
560 application.SendNotification();
561 application.Render();
562 application.SendNotification();
564 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
565 Integration::TouchEvent touchEvent(1);
566 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
567 touchEvent.AddPoint(point);
568 application.ProcessEvent(touchEvent);
569 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
571 Stage::GetCurrent().Remove(dummy);
574 // Ensure full code coverage
576 DummyControl dummy = DummyControl::New();
578 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
579 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
580 Stage::GetCurrent().Add(dummy);
582 application.Render();
583 application.SendNotification();
584 application.Render();
585 application.SendNotification();
587 Integration::TouchEvent touchEvent(1);
588 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
589 touchEvent.AddPoint(point);
590 application.ProcessEvent(touchEvent);
592 Stage::GetCurrent().Remove(dummy);
597 int UtcDaliControlImplHoverEvent(void)
599 ToolkitTestApplication application;
602 DummyControl dummy = DummyControl::New( true );
603 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
605 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
606 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
607 Stage::GetCurrent().Add(dummy);
609 application.Render();
610 application.SendNotification();
611 application.Render();
612 application.SendNotification();
614 DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, false, TEST_LOCATION );
615 Integration::HoverEvent event(1);
616 TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f );
617 event.AddPoint( point );
618 application.ProcessEvent( event );
619 DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, true, TEST_LOCATION );
621 Stage::GetCurrent().Remove(dummy);
624 // Ensure full code coverage
626 DummyControl dummy = DummyControl::New();
628 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
629 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
630 Stage::GetCurrent().Add(dummy);
632 application.Render();
633 application.SendNotification();
634 application.Render();
635 application.SendNotification();
637 Integration::HoverEvent event(1);
638 TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f );
639 event.AddPoint( point );
640 application.ProcessEvent( event );
642 Stage::GetCurrent().Remove(dummy);
647 ///////////////////////////////////////////////////////////////////////////////////////////////////
650 int UtcDaliControlImplKeyEvent(void)
652 ToolkitTestApplication application;
655 DummyControl dummy = DummyControl::New( true );
656 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
658 Stage::GetCurrent().Add(dummy);
659 dummy.SetKeyInputFocus();
661 application.Render();
662 application.SendNotification();
663 application.Render();
664 application.SendNotification();
666 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
667 Integration::KeyEvent keyEvent;
668 application.ProcessEvent(keyEvent);
669 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
671 Stage::GetCurrent().Remove(dummy);
674 // Ensure full code coverage
676 DummyControl dummy = DummyControl::New();
678 Stage::GetCurrent().Add(dummy);
679 dummy.SetKeyInputFocus();
681 application.Render();
682 application.SendNotification();
683 application.Render();
684 application.SendNotification();
686 Integration::KeyEvent keyEvent;
687 application.ProcessEvent(keyEvent);
689 Stage::GetCurrent().Remove(dummy);
694 int UtcDaliControlImplKeyInputFocusGained(void)
696 ToolkitTestApplication application;
699 DummyControl dummy = DummyControl::New( true );
700 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
702 Stage::GetCurrent().Add(dummy);
704 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
706 dummy.SetKeyInputFocus();
708 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
710 Stage::GetCurrent().Remove(dummy);
713 // Ensure full code coverage
715 DummyControl dummy = DummyControl::New();
717 Stage::GetCurrent().Add(dummy);
718 dummy.SetKeyInputFocus();
719 Stage::GetCurrent().Remove(dummy);
724 int UtcDaliControlImplKeyInputFocusLost(void)
726 ToolkitTestApplication application;
729 DummyControl dummy = DummyControl::New( true );
730 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
732 Stage::GetCurrent().Add(dummy);
734 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
736 dummy.SetKeyInputFocus();
737 dummy.ClearKeyInputFocus();
739 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
741 Stage::GetCurrent().Remove(dummy);
744 // Ensure full code coverage
746 DummyControl dummy = DummyControl::New();
748 Stage::GetCurrent().Add(dummy);
749 dummy.SetKeyInputFocus();
750 dummy.ClearKeyInputFocus();
752 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
754 dummyImpl.OnAccessibilityValueChange( true );
755 dummyImpl.IsKeyboardNavigationSupported();
756 dummyImpl.IsKeyboardFocusGroup();
758 Stage::GetCurrent().Remove(dummy);
763 int UtcDaliControlImplTypeRegistry(void)
765 ToolkitTestApplication application;
769 type = TypeRegistry::Get().GetTypeInfo( "Control" );
770 DALI_TEST_CHECK( type );
771 BaseHandle handle = type.CreateInstance();
772 DALI_TEST_CHECK( handle );
774 // Check if it's a control
775 DALI_TEST_CHECK( Control::DownCast(handle) );
780 ///////////////////////////////////////////////////////////////////////////////////////////////////
783 static bool WheelEventCallback(Actor actor, const WheelEvent& event)
789 int UtcDaliControlImplWheelEvent(void)
791 ToolkitTestApplication application;
794 DummyControl dummy = DummyControl::New( true );
795 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
797 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
798 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
799 Stage::GetCurrent().Add(dummy);
801 dummy.WheelEventSignal().Connect(&WheelEventCallback);
803 application.Render();
804 application.SendNotification();
805 application.Render();
806 application.SendNotification();
808 DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, false, TEST_LOCATION );
810 // simulate a wheel event
811 Vector2 screenCoordinates( 10.0f, 10.0f );
812 Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
813 application.ProcessEvent( event );
814 DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, true, TEST_LOCATION );
816 Stage::GetCurrent().Remove(dummy);
819 // Ensure full code coverage
821 DummyControl dummy = DummyControl::New();
823 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
824 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
825 Stage::GetCurrent().Add(dummy);
827 dummy.WheelEventSignal().Connect(&WheelEventCallback);
829 application.Render();
830 application.SendNotification();
831 application.Render();
832 application.SendNotification();
834 // simulate a wheel event
835 Vector2 screenCoordinates( 20.0f, 20.0f );
836 Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
837 application.ProcessEvent( event );
839 Stage::GetCurrent().Remove(dummy);
844 int UtcDaliControlImplSetStyleName(void)
846 ToolkitTestApplication application;
849 DummyControl dummy = DummyControl::New( true );
851 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
852 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
853 Stage::GetCurrent().Add(dummy);
855 dummy.SetStyleName("TestStyle");
857 DALI_TEST_CHECK( dummy.GetStyleName() == "TestStyle" );
859 Stage::GetCurrent().Remove(dummy);
864 int UtcDaliControlImplOnStyleChangeN(void)
866 ToolkitTestApplication application;
867 Control dummy = Control::New();
868 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
870 // test that style manager is being used, passing an empty handle throws exception
873 Dali::Toolkit::StyleManager styleManager;
874 controlImpl.OnStyleChange( styleManager, StyleChange::THEME_CHANGE );
875 tet_result(TET_FAIL);
877 catch (DaliException &exception)
879 tet_result(TET_PASS);
886 int UtcDaliControlImplOnAccessibilityPanP(void)
888 ToolkitTestApplication application;
889 Control dummy = Control::New();
890 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
893 DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityPan( pan ), TEST_LOCATION );
898 int UtcDaliControlImplOnAccessibilityTouchP(void)
900 ToolkitTestApplication application;
901 Control dummy = Control::New();
902 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
904 DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityTouch( touch ), TEST_LOCATION );
909 int UtcDaliControlImplOnAccessibilityActivatedP(void)
911 ToolkitTestApplication application;
913 Control dummy = Control::New();
914 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
915 DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityActivated(), TEST_LOCATION );
917 // Invoke the control's activate action
918 TypeInfo type = TypeRegistry::Get().GetTypeInfo( "Control" );
919 DALI_TEST_CHECK( type );
921 BaseHandle handle = type.CreateInstance();
922 DALI_TEST_CHECK( handle );
924 Property::Map attributes;
925 DALI_TEST_EQUALS( false, handle.DoAction("control-activated", attributes), TEST_LOCATION );
930 int UtcDaliControlImplGetNextKeyboardFocusableActorP(void)
932 ToolkitTestApplication application;
933 Control dummy = Control::New();
934 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
936 Actor currentFocusedActor;
937 Actor result = controlImpl.GetNextKeyboardFocusableActor( currentFocusedActor, Control::KeyboardFocus::LEFT, false );
939 DALI_TEST_EQUALS( result, currentFocusedActor, TEST_LOCATION );