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.
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>
36 #include "dummy-control.h"
39 using namespace Dali::Toolkit;
41 void utc_dali_toolkit_control_impl_startup(void)
43 test_return_value = TET_UNDEF;
46 void utc_dali_toolkit_control_impl_cleanup(void)
48 test_return_value = TET_PASS;
51 int UtcDaliControlImplNew(void)
53 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
57 DALI_TEST_CHECK( !Control::DownCast(control) );
59 control = Toolkit::Internal::Control::New();
61 DALI_TEST_CHECK( Control::DownCast(control) );
66 int UtcDaliControlImplEnableGestureDetector(void)
68 ToolkitTestApplication application;
70 // Enable individually
72 DummyControl dummy = DummyControl::New();
73 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
75 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
76 dummyImpl.EnableGestureDetection(Gesture::Pinch);
77 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
79 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
80 dummyImpl.EnableGestureDetection(Gesture::Pan);
81 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
83 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
84 dummyImpl.EnableGestureDetection(Gesture::Tap);
85 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
87 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
88 dummyImpl.EnableGestureDetection(Gesture::LongPress);
89 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
94 DummyControl dummy = DummyControl::New();
95 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
97 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
98 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
99 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
100 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
102 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
104 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
105 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
106 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
107 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
109 // Enable when already enabled
111 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
113 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
114 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
115 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
116 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
121 int UtcDaliControlImplDisableGestureDetector(void)
123 ToolkitTestApplication application;
125 // Disable individually
127 DummyControl dummy = DummyControl::New();
128 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
130 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
132 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
133 dummyImpl.DisableGestureDetection(Gesture::Pinch);
134 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
136 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
137 dummyImpl.DisableGestureDetection(Gesture::Pan);
138 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
140 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
141 dummyImpl.DisableGestureDetection(Gesture::Tap);
142 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
144 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
145 dummyImpl.DisableGestureDetection(Gesture::LongPress);
146 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
151 DummyControl dummy = DummyControl::New();
152 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
154 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
156 DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
157 DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
158 DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
159 DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
161 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
163 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
164 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
165 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
166 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
169 // Disable When not enabled
171 DummyControl dummy = DummyControl::New();
172 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
174 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
175 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
176 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
177 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
179 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
181 DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
182 DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
183 DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
184 DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
187 // Ensure control is detached if gesture detector is not deleted
189 DummyControl dummy = DummyControl::New();
190 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
192 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
194 PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
195 PanGestureDetector pan = dummyImpl.GetPanGestureDetector();
196 TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
197 LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
199 DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), false, TEST_LOCATION );
200 DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), false, TEST_LOCATION );
201 DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), false, TEST_LOCATION );
202 DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), false, TEST_LOCATION );
204 dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
206 DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), true, TEST_LOCATION );
207 DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), true, TEST_LOCATION );
208 DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), true, TEST_LOCATION );
209 DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), true, TEST_LOCATION );
214 int UtcDaliControlImplOnGestureMethods(void)
216 ToolkitTestApplication application;
218 // Check gesture actually happens
220 DummyControl dummy = DummyControl::New(true);
221 dummy.SetRelayoutEnabled( true );
222 dummy.SetPreferredSize( 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.SetRelayoutEnabled( true );
283 dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
285 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
286 Stage::GetCurrent().Add(dummy);
288 // Render and notify a couple of times
289 application.SendNotification();
290 application.Render();
291 application.SendNotification();
292 application.Render();
294 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
295 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
297 DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
298 Integration::PinchGestureEvent pinch(Gesture::Started);
301 pinch.centerPoint = Vector2(20.0f, 20.0f);
302 application.ProcessEvent(pinch);
304 // Render and notify a couple of times
305 application.SendNotification();
306 application.Render();
307 application.SendNotification();
308 application.Render();
309 DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
311 Integration::PanGestureEvent pan(Gesture::Possible);
312 pan.previousPosition = Vector2(10.0f, 20.0f);
313 pan.currentPosition = Vector2(20.0f, 20.0f);
315 pan.numberOfTouches = 1u;
316 application.ProcessEvent(pan);
317 pan.state = Gesture::Started;
318 application.ProcessEvent(pan);
320 Integration::TapGestureEvent tap(Gesture::Possible);
321 tap.numberOfTaps = 1u;
322 tap.numberOfTouches = 1u;
323 tap.point = Vector2(50.0f, 50.0f);
324 application.ProcessEvent(tap);
325 tap.state = Gesture::Started;
326 application.ProcessEvent(tap);
328 Integration::LongPressGestureEvent longPress(Gesture::Possible);
329 longPress.numberOfTouches = 1u;
330 longPress.point = Vector2(50.0f, 50.0f);
331 application.ProcessEvent(longPress);
332 longPress.state = Gesture::Started;
333 application.ProcessEvent(longPress);
334 longPress.state = Gesture::Finished;
335 application.ProcessEvent(longPress);
337 Stage::GetCurrent().Remove(dummy);
342 int UtcDaliControlImplChildAddAndRemove(void)
344 ToolkitTestApplication application;
347 DummyControl dummy = DummyControl::New( true );
348 Stage::GetCurrent().Add(dummy);
349 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
351 application.Render();
352 application.SendNotification();
354 DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
355 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
356 Actor actor = RenderableActor::New();
358 DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
359 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
361 application.Render();
362 application.SendNotification();
364 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
365 dummy.Remove( actor );
366 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
367 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
369 application.Render();
370 application.SendNotification();
372 Stage::GetCurrent().Remove(dummy);
375 // Ensure full code coverage
377 DummyControl dummy = DummyControl::New();
378 Stage::GetCurrent().Add(dummy);
380 application.Render();
381 application.SendNotification();
383 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
384 Actor actor = RenderableActor::New();
386 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
388 application.Render();
389 application.SendNotification();
391 dummy.Remove( actor );
392 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
394 application.Render();
395 application.SendNotification();
397 Stage::GetCurrent().Remove(dummy);
402 int UtcDaliControlImplStageConnection(void)
404 ToolkitTestApplication application;
407 DummyControl dummy = DummyControl::New( true );
408 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
410 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
411 Stage::GetCurrent().Add(dummy);
412 application.Render();
413 application.SendNotification();
414 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
416 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
417 Stage::GetCurrent().Remove(dummy);
418 application.Render();
419 application.SendNotification();
420 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
423 // Ensure full code coverage
425 unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
426 DummyControl dummy = DummyControl::New();
428 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
429 Stage::GetCurrent().Add(dummy);
430 application.Render();
431 application.SendNotification();
432 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
434 Stage::GetCurrent().Remove(dummy);
435 application.Render();
436 application.SendNotification();
437 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
442 int UtcDaliControlImplSizeSet(void)
444 ToolkitTestApplication application;
447 DummyControl dummy = DummyControl::New( true );
448 dummy.SetRelayoutEnabled( 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, true, TEST_LOCATION ); // Called from size negotiation
456 Vector2 size(100.0f, 200.0f);
457 dummy.SetPreferredSize(size);
459 application.Render();
460 application.SendNotification();
461 application.Render();
462 application.SendNotification();
464 DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
465 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
467 Stage::GetCurrent().Remove(dummy);
470 // Ensure full code coverage
472 DummyControl dummy = DummyControl::New();
473 dummy.SetRelayoutEnabled( true );
474 Stage::GetCurrent().Add(dummy);
476 Vector2 size(100.0f, 200.0f);
477 DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
479 application.Render();
480 application.SendNotification();
482 dummy.SetPreferredSize(size);
484 application.Render();
485 application.SendNotification();
486 application.Render();
487 application.SendNotification();
489 DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
491 Stage::GetCurrent().Remove(dummy);
496 int UtcDaliControlImplSizeAnimation(void)
498 ToolkitTestApplication application;
501 DummyControl dummy = DummyControl::New( true );
502 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
504 Stage::GetCurrent().Add(dummy);
506 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
507 Animation animation = Animation::New(1.0f);
508 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
511 application.Render();
512 application.SendNotification();
513 application.Render();
514 application.SendNotification();
516 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
518 Stage::GetCurrent().Remove(dummy);
521 // Ensure full code coverage
523 DummyControl dummy = DummyControl::New();
525 Stage::GetCurrent().Add(dummy);
527 Animation animation = Animation::New(1.0f);
528 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
531 application.Render();
532 application.SendNotification();
533 application.Render();
534 application.SendNotification();
536 Stage::GetCurrent().Remove(dummy);
541 ///////////////////////////////////////////////////////////////////////////////////////////////////
543 int UtcDaliControlImplTouchEvent(void)
545 ToolkitTestApplication application;
548 DummyControl dummy = DummyControl::New( true );
549 dummy.SetRelayoutEnabled( true );
550 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
552 dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
553 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
554 Stage::GetCurrent().Add(dummy);
556 application.Render();
557 application.SendNotification();
558 application.Render();
559 application.SendNotification();
561 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
562 Integration::TouchEvent touchEvent(1);
563 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
564 touchEvent.AddPoint(point);
565 application.ProcessEvent(touchEvent);
566 DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
568 Stage::GetCurrent().Remove(dummy);
571 // Ensure full code coverage
573 DummyControl dummy = DummyControl::New();
574 dummy.SetRelayoutEnabled( true );
576 dummy.SetPreferredSize( 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 ///////////////////////////////////////////////////////////////////////////////////////////////////
598 int UtcDaliControlImplKeyEvent(void)
600 ToolkitTestApplication application;
603 DummyControl dummy = DummyControl::New( true );
604 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
606 Stage::GetCurrent().Add(dummy);
607 dummy.SetKeyInputFocus();
609 application.Render();
610 application.SendNotification();
611 application.Render();
612 application.SendNotification();
614 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
615 Integration::KeyEvent keyEvent;
616 application.ProcessEvent(keyEvent);
617 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
619 Stage::GetCurrent().Remove(dummy);
622 // Ensure full code coverage
624 DummyControl dummy = DummyControl::New();
626 Stage::GetCurrent().Add(dummy);
627 dummy.SetKeyInputFocus();
629 application.Render();
630 application.SendNotification();
631 application.Render();
632 application.SendNotification();
634 Integration::KeyEvent keyEvent;
635 application.ProcessEvent(keyEvent);
637 Stage::GetCurrent().Remove(dummy);
642 int UtcDaliControlImplStyleChange(void)
644 ToolkitTestApplication application;
646 DummyControl dummy = DummyControl::New( true );
647 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
649 Stage::GetCurrent().Add(dummy);
651 application.Render();
652 application.SendNotification();
653 application.Render();
654 application.SendNotification();
656 // Add a Control and normal Actor as children
657 DummyControl dummyChild = DummyControl::New();
658 dummy.Add(dummyChild);
660 Actor actor = Actor::New();
663 DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, false, TEST_LOCATION );
664 StyleChange styleChange;
665 styleChange.defaultFontChange = true;
666 Dali::StyleMonitor styleMonitor = StyleMonitor::Get();
667 styleMonitor.EmitStyleChangeSignal(styleChange);
669 DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, true, TEST_LOCATION );
671 Stage::GetCurrent().Remove(dummy);
675 int UtcDaliControlImplKeyInputFocusGained(void)
677 ToolkitTestApplication application;
680 DummyControl dummy = DummyControl::New( true );
681 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
683 Stage::GetCurrent().Add(dummy);
685 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
687 dummy.SetKeyInputFocus();
689 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
691 Stage::GetCurrent().Remove(dummy);
694 // Ensure full code coverage
696 DummyControl dummy = DummyControl::New();
698 Stage::GetCurrent().Add(dummy);
699 dummy.SetKeyInputFocus();
700 Stage::GetCurrent().Remove(dummy);
705 int UtcDaliControlImplKeyInputFocusLost(void)
707 ToolkitTestApplication application;
710 DummyControl dummy = DummyControl::New( true );
711 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
713 Stage::GetCurrent().Add(dummy);
715 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
717 dummy.SetKeyInputFocus();
718 dummy.ClearKeyInputFocus();
720 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
722 Stage::GetCurrent().Remove(dummy);
725 // Ensure full code coverage
727 DummyControl dummy = DummyControl::New();
729 Stage::GetCurrent().Add(dummy);
730 dummy.SetKeyInputFocus();
731 dummy.ClearKeyInputFocus();
733 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
735 dummyImpl.OnAccessibilityValueChange( true );
736 dummyImpl.IsKeyboardNavigationSupported();
737 dummyImpl.IsKeyboardFocusGroup();
739 Stage::GetCurrent().Remove(dummy);
744 int UtcDaliControlImplTypeRegistry(void)
746 ToolkitTestApplication application;
750 type = TypeRegistry::Get().GetTypeInfo( "Control" );
751 DALI_TEST_CHECK( type );
752 BaseHandle handle = type.CreateInstance();
753 DALI_TEST_CHECK( handle );
755 // Check if it's a control
756 DALI_TEST_CHECK( Control::DownCast(handle) );
761 ///////////////////////////////////////////////////////////////////////////////////////////////////
764 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
770 int UtcDaliControlImplMouseWheelEvent(void)
772 ToolkitTestApplication application;
775 DummyControl dummy = DummyControl::New( true );
776 dummy.SetRelayoutEnabled( true );
777 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
779 dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
780 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
781 Stage::GetCurrent().Add(dummy);
783 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
785 application.Render();
786 application.SendNotification();
787 application.Render();
788 application.SendNotification();
790 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
792 // simulate a mouse wheel event
793 Vector2 screenCoordinates( 10.0f, 10.0f );
794 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
795 application.ProcessEvent(event);
796 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
798 Stage::GetCurrent().Remove(dummy);
801 // Ensure full code coverage
803 DummyControl dummy = DummyControl::New();
804 dummy.SetRelayoutEnabled( true );
806 dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
807 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
808 Stage::GetCurrent().Add(dummy);
810 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
812 application.Render();
813 application.SendNotification();
814 application.Render();
815 application.SendNotification();
817 // simulate a mouse wheel event
818 Vector2 screenCoordinates( 20.0f, 20.0f );
819 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
820 application.ProcessEvent(event);
822 Stage::GetCurrent().Remove(dummy);