2 * Copyright (c) 2014 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.
23 #include <dali/public-api/dali-core.h>
24 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali/integration-api/events/key-event-integ.h>
27 #include <dali/integration-api/events/mouse-wheel-event-integ.h>
28 #include <dali/integration-api/events/long-press-gesture-event.h>
29 #include <dali/integration-api/events/pinch-gesture-event.h>
30 #include <dali/integration-api/events/pan-gesture-event.h>
31 #include <dali/integration-api/events/tap-gesture-event.h>
32 #include <dali/integration-api/events/touch-event-integ.h>
34 #include <dali-toolkit-test-suite-utils.h>
36 #include "dummy-control.h"
39 using namespace Dali::Toolkit;
41 static void Startup();
42 static void Cleanup();
45 void (*tet_startup)() = Startup;
46 void (*tet_cleanup)() = Cleanup;
50 POSITIVE_TC_IDX = 0x01,
54 #define MAX_NUMBER_OF_TESTS 10000
56 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
59 // Add test functionality for all APIs in the class (Positive and Negative)
60 TEST_FUNCTION( UtcDaliControlImplNew, POSITIVE_TC_IDX );
61 TEST_FUNCTION( UtcDaliControlImplTypeRegistry, POSITIVE_TC_IDX );
62 TEST_FUNCTION( UtcDaliControlImplEnableGestureDetector, POSITIVE_TC_IDX );
63 TEST_FUNCTION( UtcDaliControlImplDisableGestureDetector, POSITIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliControlImplOnGestureMethods, POSITIVE_TC_IDX );
65 TEST_FUNCTION( UtcDaliControlImplChildAddAndRemove, POSITIVE_TC_IDX );
66 TEST_FUNCTION( UtcDaliControlImplStageConnection, POSITIVE_TC_IDX );
67 TEST_FUNCTION( UtcDaliControlImplSizeSet, POSITIVE_TC_IDX );
68 TEST_FUNCTION( UtcDaliControlImplSizeAnimation, POSITIVE_TC_IDX );
69 TEST_FUNCTION( UtcDaliControlImplTouchEvent, POSITIVE_TC_IDX );
70 TEST_FUNCTION( UtcDaliControlImplMouseWheelEvent, POSITIVE_TC_IDX );
71 TEST_FUNCTION( UtcDaliControlImplKeyEvent, POSITIVE_TC_IDX );
72 TEST_FUNCTION( UtcDaliControlImplStyleChange, POSITIVE_TC_IDX );
73 TEST_FUNCTION( UtcDaliControlImplKeyInputFocusGained, POSITIVE_TC_IDX );
74 TEST_FUNCTION( UtcDaliControlImplKeyInputFocusLost, POSITIVE_TC_IDX );
76 // Called only once before first test is run.
81 // Called only once after last test is run
86 static void UtcDaliControlImplNew()
88 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
92 DALI_TEST_CHECK( !Control::DownCast(control) );
94 control = ControlImpl::New();
96 DALI_TEST_CHECK( Control::DownCast(control) );
99 static void UtcDaliControlImplTypeRegistry()
101 ToolkitTestApplication application;
105 type = TypeRegistry::Get().GetTypeInfo( "Control" );
106 DALI_TEST_CHECK( type );
107 BaseHandle handle = type.CreateInstance();
108 DALI_TEST_CHECK( handle );
110 // Check if it's a control
111 DALI_TEST_CHECK( Control::DownCast(handle) );
114 static void UtcDaliControlImplEnableGestureDetector()
116 ToolkitTestApplication application;
118 // Enable individually
120 DummyControl dummy = DummyControl::New();
121 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
123 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
124 dummyImpl.EnableGestureDetection(Gesture::Pinch);
125 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
127 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
128 dummyImpl.EnableGestureDetection(Gesture::Pan);
129 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
131 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
132 dummyImpl.EnableGestureDetection(Gesture::Tap);
133 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
135 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
136 dummyImpl.EnableGestureDetection(Gesture::LongPress);
137 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
142 DummyControl dummy = DummyControl::New();
143 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
145 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
146 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
147 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
148 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
150 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
152 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
153 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
154 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
155 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
157 // Enable when already enabled
159 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
161 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
162 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
163 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
164 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
168 static void UtcDaliControlImplDisableGestureDetector()
170 ToolkitTestApplication application;
172 // Disable individually
174 DummyControl dummy = DummyControl::New();
175 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
177 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
179 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
180 dummyImpl.DisableGestureDetection(Gesture::Pinch);
181 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
183 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
184 dummyImpl.DisableGestureDetection(Gesture::Pan);
185 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
187 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
188 dummyImpl.DisableGestureDetection(Gesture::Tap);
189 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
191 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
192 dummyImpl.DisableGestureDetection(Gesture::LongPress);
193 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
198 DummyControl dummy = DummyControl::New();
199 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
201 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
203 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
204 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
205 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
206 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
208 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
210 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
211 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
212 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
213 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
216 // Disable When not enabled
218 DummyControl dummy = DummyControl::New();
219 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
221 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
222 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
223 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
224 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
226 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
228 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
229 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
230 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
231 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
234 // Ensure control is detached if gesture detector is not deleted
236 DummyControl dummy = DummyControl::New();
237 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
239 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
241 PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
242 PanGestureDetector pan = dummyImpl.GetPanGestureDetector();
243 TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
244 LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
246 DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), false, TEST_LOCATION );
247 DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), false, TEST_LOCATION );
248 DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), false, TEST_LOCATION );
249 DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), false, TEST_LOCATION );
251 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
253 DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), true, TEST_LOCATION );
254 DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), true, TEST_LOCATION );
255 DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), true, TEST_LOCATION );
256 DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), true, TEST_LOCATION );
260 static void UtcDaliControlImplOnGestureMethods()
262 ToolkitTestApplication application;
264 // Check gesture actually happens
266 DummyControl dummy = DummyControl::New(true);
267 dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
269 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
270 Stage::GetCurrent().Add(dummy);
272 // Render and notify a couple of times
273 application.SendNotification();
274 application.Render();
275 application.SendNotification();
276 application.Render();
278 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
279 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
281 DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
282 Integration::PinchGestureEvent pinch(Gesture::Started);
285 pinch.centerPoint = Vector2(20.0f, 20.0f);
286 application.ProcessEvent(pinch);
287 DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
289 DALI_TEST_CHECK( dummyImpl.panCalled == false );
290 Integration::PanGestureEvent pan(Gesture::Possible);
291 pan.previousPosition = Vector2(10.0f, 20.0f);
292 pan.currentPosition = Vector2(20.0f, 20.0f);
294 pan.numberOfTouches = 1u;
295 application.ProcessEvent(pan);
296 pan.state = Gesture::Started;
297 application.ProcessEvent(pan);
298 DALI_TEST_CHECK( dummyImpl.panCalled == true );
300 DALI_TEST_CHECK( dummyImpl.tapCalled == false );
301 Integration::TapGestureEvent tap(Gesture::Possible);
302 tap.numberOfTaps = 1u;
303 tap.numberOfTouches = 1u;
304 tap.point = Vector2(50.0f, 50.0f);
305 application.ProcessEvent(tap);
306 tap.state = Gesture::Started;
307 application.ProcessEvent(tap);
308 DALI_TEST_CHECK( dummyImpl.tapCalled == true );
310 DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
311 Integration::LongPressGestureEvent longPress(Gesture::Possible);
312 longPress.numberOfTouches = 1u;
313 longPress.point = Vector2(50.0f, 50.0f);
314 application.ProcessEvent(longPress);
315 longPress.state = Gesture::Started;
316 application.ProcessEvent(longPress);
317 DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
318 longPress.state = Gesture::Finished;
319 application.ProcessEvent(longPress);
321 Stage::GetCurrent().Remove(dummy);
324 // Ensure full code coverage
326 DummyControl dummy = DummyControl::New();
327 dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
329 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
330 Stage::GetCurrent().Add(dummy);
332 // Render and notify a couple of times
333 application.SendNotification();
334 application.Render();
335 application.SendNotification();
336 application.Render();
338 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
339 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
341 DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
342 Integration::PinchGestureEvent pinch(Gesture::Started);
345 pinch.centerPoint = Vector2(20.0f, 20.0f);
346 application.ProcessEvent(pinch);
348 // Render and notify a couple of times
349 application.SendNotification();
350 application.Render();
351 application.SendNotification();
352 application.Render();
353 DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
355 Integration::PanGestureEvent pan(Gesture::Possible);
356 pan.previousPosition = Vector2(10.0f, 20.0f);
357 pan.currentPosition = Vector2(20.0f, 20.0f);
359 pan.numberOfTouches = 1u;
360 application.ProcessEvent(pan);
361 pan.state = Gesture::Started;
362 application.ProcessEvent(pan);
364 Integration::TapGestureEvent tap(Gesture::Possible);
365 tap.numberOfTaps = 1u;
366 tap.numberOfTouches = 1u;
367 tap.point = Vector2(50.0f, 50.0f);
368 application.ProcessEvent(tap);
369 tap.state = Gesture::Started;
370 application.ProcessEvent(tap);
372 Integration::LongPressGestureEvent longPress(Gesture::Possible);
373 longPress.numberOfTouches = 1u;
374 longPress.point = Vector2(50.0f, 50.0f);
375 application.ProcessEvent(longPress);
376 longPress.state = Gesture::Started;
377 application.ProcessEvent(longPress);
378 longPress.state = Gesture::Finished;
379 application.ProcessEvent(longPress);
381 Stage::GetCurrent().Remove(dummy);
385 static void UtcDaliControlImplChildAddAndRemove()
387 ToolkitTestApplication application;
390 DummyControl dummy = DummyControl::New( true );
391 Stage::GetCurrent().Add(dummy);
392 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
394 application.Render();
395 application.SendNotification();
397 DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
398 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
399 Actor actor = RenderableActor::New();
401 DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
402 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
404 application.Render();
405 application.SendNotification();
407 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
408 dummy.Remove( actor );
409 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
410 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
412 application.Render();
413 application.SendNotification();
415 Stage::GetCurrent().Remove(dummy);
418 // Ensure full code coverage
420 DummyControl dummy = DummyControl::New();
421 Stage::GetCurrent().Add(dummy);
423 application.Render();
424 application.SendNotification();
426 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
427 Actor actor = RenderableActor::New();
429 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
431 application.Render();
432 application.SendNotification();
434 dummy.Remove( actor );
435 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
437 application.Render();
438 application.SendNotification();
440 Stage::GetCurrent().Remove(dummy);
444 static void UtcDaliControlImplStageConnection()
446 ToolkitTestApplication application;
449 DummyControl dummy = DummyControl::New( true );
450 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
452 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
453 Stage::GetCurrent().Add(dummy);
454 application.Render();
455 application.SendNotification();
456 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
458 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
459 Stage::GetCurrent().Remove(dummy);
460 application.Render();
461 application.SendNotification();
462 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
465 // Ensure full code coverage
467 unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
468 DummyControl dummy = DummyControl::New();
470 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
471 Stage::GetCurrent().Add(dummy);
472 application.Render();
473 application.SendNotification();
474 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
476 Stage::GetCurrent().Remove(dummy);
477 application.Render();
478 application.SendNotification();
479 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
483 static void UtcDaliControlImplSizeSet()
485 ToolkitTestApplication application;
488 DummyControl dummy = DummyControl::New( true );
489 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
491 Stage::GetCurrent().Add(dummy);
492 application.Render();
493 application.SendNotification();
495 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION );
496 Vector3 size(100.0f, 200.0f, 0.0f);
499 application.Render();
500 application.SendNotification();
501 application.Render();
502 application.SendNotification();
504 DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
505 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
507 Stage::GetCurrent().Remove(dummy);
510 // Ensure full code coverage
512 DummyControl dummy = DummyControl::New();
513 Stage::GetCurrent().Add(dummy);
515 Vector3 size(100.0f, 200.0f, 0.0f);
516 DALI_TEST_CHECK( size != dummy.GetCurrentSize() );
518 application.Render();
519 application.SendNotification();
523 application.Render();
524 application.SendNotification();
525 application.Render();
526 application.SendNotification();
528 DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
530 Stage::GetCurrent().Remove(dummy);
534 static void UtcDaliControlImplSizeAnimation()
536 ToolkitTestApplication application;
539 DummyControl dummy = DummyControl::New( true );
540 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
542 Stage::GetCurrent().Add(dummy);
544 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
545 Animation animation = Animation::New(1.0f);
546 animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
549 application.Render();
550 application.SendNotification();
551 application.Render();
552 application.SendNotification();
554 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
556 Stage::GetCurrent().Remove(dummy);
559 // Ensure full code coverage
561 DummyControl dummy = DummyControl::New();
563 Stage::GetCurrent().Add(dummy);
565 Animation animation = Animation::New(1.0f);
566 animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
569 application.Render();
570 application.SendNotification();
571 application.Render();
572 application.SendNotification();
574 Stage::GetCurrent().Remove(dummy);
578 ///////////////////////////////////////////////////////////////////////////////////////////////////
580 static void UtcDaliControlImplTouchEvent()
582 ToolkitTestApplication application;
585 DummyControl dummy = DummyControl::New( true );
586 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
588 dummy.SetSize(100.0f, 100.0f);
589 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
590 Stage::GetCurrent().Add(dummy);
592 application.Render();
593 application.SendNotification();
594 application.Render();
595 application.SendNotification();
597 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
598 Integration::TouchEvent touchEvent(1);
599 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
600 touchEvent.AddPoint(point);
601 application.ProcessEvent(touchEvent);
602 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
604 Stage::GetCurrent().Remove(dummy);
607 // Ensure full code coverage
609 DummyControl dummy = DummyControl::New();
611 dummy.SetSize(100.0f, 100.0f);
612 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
613 Stage::GetCurrent().Add(dummy);
615 application.Render();
616 application.SendNotification();
617 application.Render();
618 application.SendNotification();
620 Integration::TouchEvent touchEvent(1);
621 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
622 touchEvent.AddPoint(point);
623 application.ProcessEvent(touchEvent);
625 Stage::GetCurrent().Remove(dummy);
629 ///////////////////////////////////////////////////////////////////////////////////////////////////
631 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
636 static void UtcDaliControlImplMouseWheelEvent()
638 ToolkitTestApplication application;
641 DummyControl dummy = DummyControl::New( true );
642 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
644 dummy.SetSize(100.0f, 100.0f);
645 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
646 Stage::GetCurrent().Add(dummy);
648 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
650 application.Render();
651 application.SendNotification();
652 application.Render();
653 application.SendNotification();
655 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
657 // simulate a mouse wheel event
658 Vector2 screenCoordinates( 10.0f, 10.0f );
659 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
660 application.ProcessEvent(event);
661 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
663 Stage::GetCurrent().Remove(dummy);
666 // Ensure full code coverage
668 DummyControl dummy = DummyControl::New();
670 dummy.SetSize(100.0f, 100.0f);
671 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
672 Stage::GetCurrent().Add(dummy);
674 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
676 application.Render();
677 application.SendNotification();
678 application.Render();
679 application.SendNotification();
681 // simulate a mouse wheel event
682 Vector2 screenCoordinates( 20.0f, 20.0f );
683 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
684 application.ProcessEvent(event);
686 Stage::GetCurrent().Remove(dummy);
690 ///////////////////////////////////////////////////////////////////////////////////////////////////
692 static void UtcDaliControlImplKeyEvent()
694 ToolkitTestApplication application;
697 DummyControl dummy = DummyControl::New( true );
698 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
700 Stage::GetCurrent().Add(dummy);
701 dummy.SetKeyInputFocus();
703 application.Render();
704 application.SendNotification();
705 application.Render();
706 application.SendNotification();
708 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
709 Integration::KeyEvent keyEvent;
710 application.ProcessEvent(keyEvent);
711 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
713 Stage::GetCurrent().Remove(dummy);
716 // Ensure full code coverage
718 DummyControl dummy = DummyControl::New();
720 Stage::GetCurrent().Add(dummy);
721 dummy.SetKeyInputFocus();
723 application.Render();
724 application.SendNotification();
725 application.Render();
726 application.SendNotification();
728 Integration::KeyEvent keyEvent;
729 application.ProcessEvent(keyEvent);
731 Stage::GetCurrent().Remove(dummy);
735 static void UtcDaliControlImplStyleChange()
737 ToolkitTestApplication application;
739 DummyControl dummy = DummyControl::New( true );
740 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
742 Stage::GetCurrent().Add(dummy);
744 application.Render();
745 application.SendNotification();
746 application.Render();
747 application.SendNotification();
749 // Add a Control and normal Actor as children
750 DummyControl dummyChild = DummyControl::New();
751 dummy.Add(dummyChild);
753 Actor actor = Actor::New();
756 DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, false, TEST_LOCATION );
757 StyleChange styleChange;
758 styleChange.defaultFontChange = true;
759 application.GetAdaptor().GetToolkitStyleMonitor().EmitSignalStyleChange(styleChange);
760 DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, true, TEST_LOCATION );
762 Stage::GetCurrent().Remove(dummy);
765 static void UtcDaliControlImplKeyInputFocusGained()
767 ToolkitTestApplication application;
770 DummyControl dummy = DummyControl::New( true );
771 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
773 Stage::GetCurrent().Add(dummy);
775 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
777 dummy.SetKeyInputFocus();
779 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
781 Stage::GetCurrent().Remove(dummy);
784 // Ensure full code coverage
786 DummyControl dummy = DummyControl::New();
788 Stage::GetCurrent().Add(dummy);
789 dummy.SetKeyInputFocus();
790 Stage::GetCurrent().Remove(dummy);
794 static void UtcDaliControlImplKeyInputFocusLost()
796 ToolkitTestApplication application;
799 DummyControl dummy = DummyControl::New( true );
800 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
802 Stage::GetCurrent().Add(dummy);
804 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
806 dummy.SetKeyInputFocus();
807 dummy.ClearKeyInputFocus();
809 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
811 Stage::GetCurrent().Remove(dummy);
814 // Ensure full code coverage
816 DummyControl dummy = DummyControl::New();
818 Stage::GetCurrent().Add(dummy);
819 dummy.SetKeyInputFocus();
820 dummy.ClearKeyInputFocus();
822 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
824 dummyImpl.OnAccessibilityValueChange( true );
825 dummyImpl.IsKeyboardNavigationSupported();
826 dummyImpl.IsKeyboardFocusGroup();
828 Stage::GetCurrent().Remove(dummy);