2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/mouse-wheel-event-integ.h>
27 #include <dali/integration-api/events/long-press-gesture-event.h>
28 #include <dali/integration-api/events/pinch-gesture-event.h>
29 #include <dali/integration-api/events/pan-gesture-event.h>
30 #include <dali/integration-api/events/tap-gesture-event.h>
31 #include <dali/integration-api/events/touch-event-integ.h>
33 #include <dali-toolkit-test-suite-utils.h>
35 #include "dummy-control.h"
38 using namespace Dali::Toolkit;
40 static void Startup();
41 static void Cleanup();
44 void (*tet_startup)() = Startup;
45 void (*tet_cleanup)() = Cleanup;
49 POSITIVE_TC_IDX = 0x01,
53 #define MAX_NUMBER_OF_TESTS 10000
55 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
58 // Add test functionality for all APIs in the class (Positive and Negative)
59 TEST_FUNCTION( UtcDaliControlImplNew, POSITIVE_TC_IDX );
60 TEST_FUNCTION( UtcDaliControlImplTypeRegistry, POSITIVE_TC_IDX );
61 TEST_FUNCTION( UtcDaliControlImplEnableGestureDetector, POSITIVE_TC_IDX );
62 TEST_FUNCTION( UtcDaliControlImplDisableGestureDetector, POSITIVE_TC_IDX );
63 TEST_FUNCTION( UtcDaliControlImplOnGestureMethods, POSITIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliControlImplChildAddAndRemove, POSITIVE_TC_IDX );
65 TEST_FUNCTION( UtcDaliControlImplStageConnection, POSITIVE_TC_IDX );
66 TEST_FUNCTION( UtcDaliControlImplSizeSet, POSITIVE_TC_IDX );
67 TEST_FUNCTION( UtcDaliControlImplSizeAnimation, POSITIVE_TC_IDX );
68 TEST_FUNCTION( UtcDaliControlImplTouchEvent, POSITIVE_TC_IDX );
69 TEST_FUNCTION( UtcDaliControlImplMouseWheelEvent, POSITIVE_TC_IDX );
70 TEST_FUNCTION( UtcDaliControlImplKeyEvent, POSITIVE_TC_IDX );
71 TEST_FUNCTION( UtcDaliControlImplStyleChange, POSITIVE_TC_IDX );
72 TEST_FUNCTION( UtcDaliControlImplKeyInputFocusGained, POSITIVE_TC_IDX );
73 TEST_FUNCTION( UtcDaliControlImplKeyInputFocusLost, POSITIVE_TC_IDX );
75 // Called only once before first test is run.
80 // Called only once after last test is run
85 static void UtcDaliControlImplNew()
87 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
91 DALI_TEST_CHECK( !Control::DownCast(control) );
93 control = ControlImpl::New();
95 DALI_TEST_CHECK( Control::DownCast(control) );
98 static void UtcDaliControlImplTypeRegistry()
100 ToolkitTestApplication application;
104 type = TypeRegistry::Get().GetTypeInfo( "Control" );
105 DALI_TEST_CHECK( type );
106 BaseHandle handle = type.CreateInstance();
107 DALI_TEST_CHECK( handle );
109 // Check if it's a control
110 DALI_TEST_CHECK( Control::DownCast(handle) );
113 static void UtcDaliControlImplEnableGestureDetector()
115 ToolkitTestApplication application;
117 // Enable individually
119 DummyControl dummy = DummyControl::New();
120 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
122 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
123 dummyImpl.EnableGestureDetection(Gesture::Pinch);
124 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
126 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
127 dummyImpl.EnableGestureDetection(Gesture::Pan);
128 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
130 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
131 dummyImpl.EnableGestureDetection(Gesture::Tap);
132 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
134 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
135 dummyImpl.EnableGestureDetection(Gesture::LongPress);
136 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
141 DummyControl dummy = DummyControl::New();
142 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
144 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
145 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
146 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
147 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
149 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
151 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
152 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
153 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
154 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
156 // Enable when already enabled
158 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
160 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
161 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
162 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
163 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
167 static void UtcDaliControlImplDisableGestureDetector()
169 ToolkitTestApplication application;
171 // Disable individually
173 DummyControl dummy = DummyControl::New();
174 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
176 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
178 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
179 dummyImpl.DisableGestureDetection(Gesture::Pinch);
180 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
182 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
183 dummyImpl.DisableGestureDetection(Gesture::Pan);
184 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
186 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
187 dummyImpl.DisableGestureDetection(Gesture::Tap);
188 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
190 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
191 dummyImpl.DisableGestureDetection(Gesture::LongPress);
192 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
197 DummyControl dummy = DummyControl::New();
198 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
200 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
202 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
203 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
204 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
205 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
207 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
209 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
210 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
211 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
212 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
215 // Disable When not enabled
217 DummyControl dummy = DummyControl::New();
218 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
220 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
221 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
222 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
223 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
225 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
227 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
228 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
229 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
230 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
233 // Ensure control is detached if gesture detector is not deleted
235 DummyControl dummy = DummyControl::New();
236 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
238 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
240 PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
241 PanGestureDetector pan = dummyImpl.GetPanGestureDetector();
242 TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
243 LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
245 DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), false, TEST_LOCATION );
246 DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), false, TEST_LOCATION );
247 DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), false, TEST_LOCATION );
248 DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), false, TEST_LOCATION );
250 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
252 DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), true, TEST_LOCATION );
253 DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), true, TEST_LOCATION );
254 DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), true, TEST_LOCATION );
255 DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), true, TEST_LOCATION );
259 static void UtcDaliControlImplOnGestureMethods()
261 ToolkitTestApplication application;
263 // Check gesture actually happens
265 DummyControl dummy = DummyControl::New(true);
266 dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
268 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
269 Stage::GetCurrent().Add(dummy);
271 // Render and notify a couple of times
272 application.SendNotification();
273 application.Render();
274 application.SendNotification();
275 application.Render();
277 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
278 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
280 DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
281 Integration::PinchGestureEvent pinch(Gesture::Started);
284 pinch.centerPoint = Vector2(20.0f, 20.0f);
285 application.GetCore().SendEvent(pinch);
286 DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
288 DALI_TEST_CHECK( dummyImpl.panCalled == false );
289 Integration::PanGestureEvent pan(Gesture::Possible);
290 pan.previousPosition = Vector2(10.0f, 20.0f);
291 pan.currentPosition = Vector2(20.0f, 20.0f);
293 pan.numberOfTouches = 1u;
294 application.GetCore().SendEvent(pan);
295 pan.state = Gesture::Started;
296 application.GetCore().SendEvent(pan);
297 DALI_TEST_CHECK( dummyImpl.panCalled == true );
299 DALI_TEST_CHECK( dummyImpl.tapCalled == false );
300 Integration::TapGestureEvent tap(Gesture::Possible);
301 tap.numberOfTaps = 1u;
302 tap.numberOfTouches = 1u;
303 tap.point = Vector2(50.0f, 50.0f);
304 application.GetCore().SendEvent(tap);
305 tap.state = Gesture::Started;
306 application.GetCore().SendEvent(tap);
307 DALI_TEST_CHECK( dummyImpl.tapCalled == true );
309 DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
310 Integration::LongPressGestureEvent longPress(Gesture::Possible);
311 longPress.numberOfTouches = 1u;
312 longPress.point = Vector2(50.0f, 50.0f);
313 application.GetCore().SendEvent(longPress);
314 longPress.state = Gesture::Started;
315 application.GetCore().SendEvent(longPress);
316 DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
317 longPress.state = Gesture::Finished;
318 application.GetCore().SendEvent(longPress);
320 Stage::GetCurrent().Remove(dummy);
323 // Ensure full code coverage
325 DummyControl dummy = DummyControl::New();
326 dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
328 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
329 Stage::GetCurrent().Add(dummy);
331 // Render and notify a couple of times
332 application.SendNotification();
333 application.Render();
334 application.SendNotification();
335 application.Render();
337 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
338 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
340 DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
341 Integration::PinchGestureEvent pinch(Gesture::Started);
344 pinch.centerPoint = Vector2(20.0f, 20.0f);
345 application.GetCore().SendEvent(pinch);
347 // Render and notify a couple of times
348 application.SendNotification();
349 application.Render();
350 application.SendNotification();
351 application.Render();
352 DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
354 Integration::PanGestureEvent pan(Gesture::Possible);
355 pan.previousPosition = Vector2(10.0f, 20.0f);
356 pan.currentPosition = Vector2(20.0f, 20.0f);
358 pan.numberOfTouches = 1u;
359 application.GetCore().SendEvent(pan);
360 pan.state = Gesture::Started;
361 application.GetCore().SendEvent(pan);
363 Integration::TapGestureEvent tap(Gesture::Possible);
364 tap.numberOfTaps = 1u;
365 tap.numberOfTouches = 1u;
366 tap.point = Vector2(50.0f, 50.0f);
367 application.GetCore().SendEvent(tap);
368 tap.state = Gesture::Started;
369 application.GetCore().SendEvent(tap);
371 Integration::LongPressGestureEvent longPress(Gesture::Possible);
372 longPress.numberOfTouches = 1u;
373 longPress.point = Vector2(50.0f, 50.0f);
374 application.GetCore().SendEvent(longPress);
375 longPress.state = Gesture::Started;
376 application.GetCore().SendEvent(longPress);
377 longPress.state = Gesture::Finished;
378 application.GetCore().SendEvent(longPress);
380 Stage::GetCurrent().Remove(dummy);
384 static void UtcDaliControlImplChildAddAndRemove()
386 ToolkitTestApplication application;
389 DummyControl dummy = DummyControl::New( true );
390 Stage::GetCurrent().Add(dummy);
391 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
393 application.Render();
394 application.SendNotification();
396 DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
397 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
398 Actor actor = RenderableActor::New();
400 DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
401 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
403 application.Render();
404 application.SendNotification();
406 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
407 dummy.Remove( actor );
408 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
409 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
411 application.Render();
412 application.SendNotification();
414 Stage::GetCurrent().Remove(dummy);
417 // Ensure full code coverage
419 DummyControl dummy = DummyControl::New();
420 Stage::GetCurrent().Add(dummy);
422 application.Render();
423 application.SendNotification();
425 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
426 Actor actor = RenderableActor::New();
428 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
430 application.Render();
431 application.SendNotification();
433 dummy.Remove( actor );
434 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
436 application.Render();
437 application.SendNotification();
439 Stage::GetCurrent().Remove(dummy);
443 static void UtcDaliControlImplStageConnection()
445 ToolkitTestApplication application;
448 DummyControl dummy = DummyControl::New( true );
449 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
451 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
452 Stage::GetCurrent().Add(dummy);
453 application.Render();
454 application.SendNotification();
455 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
457 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
458 Stage::GetCurrent().Remove(dummy);
459 application.Render();
460 application.SendNotification();
461 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
464 // Ensure full code coverage
466 unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
467 DummyControl dummy = DummyControl::New();
469 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
470 Stage::GetCurrent().Add(dummy);
471 application.Render();
472 application.SendNotification();
473 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
475 Stage::GetCurrent().Remove(dummy);
476 application.Render();
477 application.SendNotification();
478 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
482 static void UtcDaliControlImplSizeSet()
484 ToolkitTestApplication application;
487 DummyControl dummy = DummyControl::New( true );
488 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
490 Stage::GetCurrent().Add(dummy);
491 application.Render();
492 application.SendNotification();
494 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION );
495 Vector3 size(100.0f, 200.0f, 0.0f);
498 application.Render();
499 application.SendNotification();
500 application.Render();
501 application.SendNotification();
503 DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
504 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
506 Stage::GetCurrent().Remove(dummy);
509 // Ensure full code coverage
511 DummyControl dummy = DummyControl::New();
512 Stage::GetCurrent().Add(dummy);
514 Vector3 size(100.0f, 200.0f, 0.0f);
515 DALI_TEST_CHECK( size != dummy.GetCurrentSize() );
517 application.Render();
518 application.SendNotification();
522 application.Render();
523 application.SendNotification();
524 application.Render();
525 application.SendNotification();
527 DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
529 Stage::GetCurrent().Remove(dummy);
533 static void UtcDaliControlImplSizeAnimation()
535 ToolkitTestApplication application;
538 DummyControl dummy = DummyControl::New( true );
539 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
541 Stage::GetCurrent().Add(dummy);
543 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
544 Animation animation = Animation::New(1.0f);
545 animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
548 application.Render();
549 application.SendNotification();
550 application.Render();
551 application.SendNotification();
553 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
555 Stage::GetCurrent().Remove(dummy);
558 // Ensure full code coverage
560 DummyControl dummy = DummyControl::New();
562 Stage::GetCurrent().Add(dummy);
564 Animation animation = Animation::New(1.0f);
565 animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
568 application.Render();
569 application.SendNotification();
570 application.Render();
571 application.SendNotification();
573 Stage::GetCurrent().Remove(dummy);
577 ///////////////////////////////////////////////////////////////////////////////////////////////////
579 static void UtcDaliControlImplTouchEvent()
581 ToolkitTestApplication application;
584 DummyControl dummy = DummyControl::New( true );
585 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
587 dummy.SetSize(100.0f, 100.0f);
588 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
589 Stage::GetCurrent().Add(dummy);
591 application.Render();
592 application.SendNotification();
593 application.Render();
594 application.SendNotification();
596 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
597 Integration::TouchEvent touchEvent(1);
598 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
599 touchEvent.AddPoint(point);
600 application.GetCore().SendEvent(touchEvent);
601 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
603 Stage::GetCurrent().Remove(dummy);
606 // Ensure full code coverage
608 DummyControl dummy = DummyControl::New();
610 dummy.SetSize(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 Integration::TouchEvent touchEvent(1);
620 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
621 touchEvent.AddPoint(point);
622 application.GetCore().SendEvent(touchEvent);
624 Stage::GetCurrent().Remove(dummy);
628 ///////////////////////////////////////////////////////////////////////////////////////////////////
630 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
635 static void UtcDaliControlImplMouseWheelEvent()
637 ToolkitTestApplication application;
640 DummyControl dummy = DummyControl::New( true );
641 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
643 dummy.SetSize(100.0f, 100.0f);
644 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
645 Stage::GetCurrent().Add(dummy);
647 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
649 application.Render();
650 application.SendNotification();
651 application.Render();
652 application.SendNotification();
654 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
656 // simulate a mouse wheel event
657 Vector2 screenCoordinates( 10.0f, 10.0f );
658 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
659 application.GetCore().SendEvent(event);
660 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
662 Stage::GetCurrent().Remove(dummy);
665 // Ensure full code coverage
667 DummyControl dummy = DummyControl::New();
669 dummy.SetSize(100.0f, 100.0f);
670 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
671 Stage::GetCurrent().Add(dummy);
673 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
675 application.Render();
676 application.SendNotification();
677 application.Render();
678 application.SendNotification();
680 // simulate a mouse wheel event
681 Vector2 screenCoordinates( 20.0f, 20.0f );
682 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
683 application.GetCore().SendEvent(event);
685 Stage::GetCurrent().Remove(dummy);
689 ///////////////////////////////////////////////////////////////////////////////////////////////////
691 static void UtcDaliControlImplKeyEvent()
693 ToolkitTestApplication application;
696 DummyControl dummy = DummyControl::New( true );
697 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
699 Stage::GetCurrent().Add(dummy);
700 dummy.SetKeyInputFocus();
702 application.Render();
703 application.SendNotification();
704 application.Render();
705 application.SendNotification();
707 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
708 Integration::KeyEvent keyEvent;
709 application.GetCore().SendEvent(keyEvent);
710 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
712 Stage::GetCurrent().Remove(dummy);
715 // Ensure full code coverage
717 DummyControl dummy = DummyControl::New();
719 Stage::GetCurrent().Add(dummy);
720 dummy.SetKeyInputFocus();
722 application.Render();
723 application.SendNotification();
724 application.Render();
725 application.SendNotification();
727 Integration::KeyEvent keyEvent;
728 application.GetCore().SendEvent(keyEvent);
730 Stage::GetCurrent().Remove(dummy);
734 static void UtcDaliControlImplStyleChange()
736 ToolkitTestApplication application;
738 DummyControl dummy = DummyControl::New( true );
739 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
741 Stage::GetCurrent().Add(dummy);
743 application.Render();
744 application.SendNotification();
745 application.Render();
746 application.SendNotification();
748 // Add a Control and normal Actor as children
749 DummyControl dummyChild = DummyControl::New();
750 dummy.Add(dummyChild);
752 Actor actor = Actor::New();
755 DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, false, TEST_LOCATION );
756 StyleChange styleChange;
757 styleChange.defaultFontChange = true;
758 application.GetAdaptor().GetToolkitStyleMonitor().EmitSignalStyleChange(styleChange);
759 DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, true, TEST_LOCATION );
761 Stage::GetCurrent().Remove(dummy);
764 static void UtcDaliControlImplKeyInputFocusGained()
766 ToolkitTestApplication application;
769 DummyControl dummy = DummyControl::New( true );
770 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
772 Stage::GetCurrent().Add(dummy);
774 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
776 dummy.SetKeyInputFocus();
778 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
780 Stage::GetCurrent().Remove(dummy);
783 // Ensure full code coverage
785 DummyControl dummy = DummyControl::New();
787 Stage::GetCurrent().Add(dummy);
788 dummy.SetKeyInputFocus();
789 Stage::GetCurrent().Remove(dummy);
793 static void UtcDaliControlImplKeyInputFocusLost()
795 ToolkitTestApplication application;
798 DummyControl dummy = DummyControl::New( true );
799 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
801 Stage::GetCurrent().Add(dummy);
803 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
805 dummy.SetKeyInputFocus();
806 dummy.ClearKeyInputFocus();
808 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
810 Stage::GetCurrent().Remove(dummy);
813 // Ensure full code coverage
815 DummyControl dummy = DummyControl::New();
817 Stage::GetCurrent().Add(dummy);
818 dummy.SetKeyInputFocus();
819 dummy.ClearKeyInputFocus();
821 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
823 dummyImpl.OnAccessibilityValueChange( true );
824 dummyImpl.IsKeyboardNavigationSupported();
825 dummyImpl.IsKeyboardFocusGroup();
827 Stage::GetCurrent().Remove(dummy);