2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24 #include "toolkit-style-monitor.h"
27 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali/integration-api/events/key-event-integ.h>
29 #include <dali/integration-api/events/mouse-wheel-event-integ.h>
30 #include <dali/integration-api/events/long-press-gesture-event.h>
31 #include <dali/integration-api/events/pinch-gesture-event.h>
32 #include <dali/integration-api/events/pan-gesture-event.h>
33 #include <dali/integration-api/events/tap-gesture-event.h>
34 #include <dali/integration-api/events/touch-event-integ.h>
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.SetSize( Vector2(100.0f, 100.0f ) );
223 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
224 Stage::GetCurrent().Add(dummy);
226 // Render and notify a couple of times
227 application.SendNotification();
228 application.Render();
229 application.SendNotification();
230 application.Render();
232 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
233 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
235 DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
236 Integration::PinchGestureEvent pinch(Gesture::Started);
239 pinch.centerPoint = Vector2(20.0f, 20.0f);
240 application.ProcessEvent(pinch);
241 DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
243 DALI_TEST_CHECK( dummyImpl.panCalled == false );
244 Integration::PanGestureEvent pan(Gesture::Possible);
245 pan.previousPosition = Vector2(10.0f, 20.0f);
246 pan.currentPosition = Vector2(20.0f, 20.0f);
248 pan.numberOfTouches = 1u;
249 application.ProcessEvent(pan);
250 pan.state = Gesture::Started;
251 application.ProcessEvent(pan);
252 DALI_TEST_CHECK( dummyImpl.panCalled == true );
254 DALI_TEST_CHECK( dummyImpl.tapCalled == false );
255 Integration::TapGestureEvent tap(Gesture::Possible);
256 tap.numberOfTaps = 1u;
257 tap.numberOfTouches = 1u;
258 tap.point = Vector2(50.0f, 50.0f);
259 application.ProcessEvent(tap);
260 tap.state = Gesture::Started;
261 application.ProcessEvent(tap);
262 DALI_TEST_CHECK( dummyImpl.tapCalled == true );
264 DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
265 Integration::LongPressGestureEvent longPress(Gesture::Possible);
266 longPress.numberOfTouches = 1u;
267 longPress.point = Vector2(50.0f, 50.0f);
268 application.ProcessEvent(longPress);
269 longPress.state = Gesture::Started;
270 application.ProcessEvent(longPress);
271 DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
272 longPress.state = Gesture::Finished;
273 application.ProcessEvent(longPress);
275 Stage::GetCurrent().Remove(dummy);
278 // Ensure full code coverage
280 DummyControl dummy = DummyControl::New();
281 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
283 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
284 Stage::GetCurrent().Add(dummy);
286 // Render and notify a couple of times
287 application.SendNotification();
288 application.Render();
289 application.SendNotification();
290 application.Render();
292 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
293 dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
295 DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
296 Integration::PinchGestureEvent pinch(Gesture::Started);
299 pinch.centerPoint = Vector2(20.0f, 20.0f);
300 application.ProcessEvent(pinch);
302 // Render and notify a couple of times
303 application.SendNotification();
304 application.Render();
305 application.SendNotification();
306 application.Render();
307 DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
309 Integration::PanGestureEvent pan(Gesture::Possible);
310 pan.previousPosition = Vector2(10.0f, 20.0f);
311 pan.currentPosition = Vector2(20.0f, 20.0f);
313 pan.numberOfTouches = 1u;
314 application.ProcessEvent(pan);
315 pan.state = Gesture::Started;
316 application.ProcessEvent(pan);
318 Integration::TapGestureEvent tap(Gesture::Possible);
319 tap.numberOfTaps = 1u;
320 tap.numberOfTouches = 1u;
321 tap.point = Vector2(50.0f, 50.0f);
322 application.ProcessEvent(tap);
323 tap.state = Gesture::Started;
324 application.ProcessEvent(tap);
326 Integration::LongPressGestureEvent longPress(Gesture::Possible);
327 longPress.numberOfTouches = 1u;
328 longPress.point = Vector2(50.0f, 50.0f);
329 application.ProcessEvent(longPress);
330 longPress.state = Gesture::Started;
331 application.ProcessEvent(longPress);
332 longPress.state = Gesture::Finished;
333 application.ProcessEvent(longPress);
335 Stage::GetCurrent().Remove(dummy);
340 int UtcDaliControlImplChildAddAndRemove(void)
342 ToolkitTestApplication application;
345 DummyControl dummy = DummyControl::New( true );
346 Stage::GetCurrent().Add(dummy);
347 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
349 application.Render();
350 application.SendNotification();
352 DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
353 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
354 Actor actor = RenderableActor::New();
356 DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
357 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
359 application.Render();
360 application.SendNotification();
362 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
363 dummy.Remove( actor );
364 DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
365 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
367 application.Render();
368 application.SendNotification();
370 Stage::GetCurrent().Remove(dummy);
373 // Ensure full code coverage
375 DummyControl dummy = DummyControl::New();
376 Stage::GetCurrent().Add(dummy);
378 application.Render();
379 application.SendNotification();
381 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
382 Actor actor = RenderableActor::New();
384 DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
386 application.Render();
387 application.SendNotification();
389 dummy.Remove( actor );
390 DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
392 application.Render();
393 application.SendNotification();
395 Stage::GetCurrent().Remove(dummy);
400 int UtcDaliControlImplStageConnection(void)
402 ToolkitTestApplication application;
405 DummyControl dummy = DummyControl::New( true );
406 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
408 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
409 Stage::GetCurrent().Add(dummy);
410 application.Render();
411 application.SendNotification();
412 DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
414 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
415 Stage::GetCurrent().Remove(dummy);
416 application.Render();
417 application.SendNotification();
418 DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
421 // Ensure full code coverage
423 unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
424 DummyControl dummy = DummyControl::New();
426 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
427 Stage::GetCurrent().Add(dummy);
428 application.Render();
429 application.SendNotification();
430 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
432 Stage::GetCurrent().Remove(dummy);
433 application.Render();
434 application.SendNotification();
435 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
440 int UtcDaliControlImplSizeSetP(void)
442 ToolkitTestApplication application;
445 DummyControl dummy = DummyControl::New( true );
446 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
448 Stage::GetCurrent().Add(dummy);
449 application.Render();
450 application.SendNotification();
452 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size not set, no onSizeSet called
453 Vector2 size(100.0f, 200.0f);
454 dummy.SetSize( size );
456 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size is going to get negotiated, no onSizeSet called
458 application.SendNotification();
459 application.Render();
461 DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
462 DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
464 Stage::GetCurrent().Remove(dummy);
470 int UtcDaliControlImplSizeSet2P(void)
472 ToolkitTestApplication application;
475 DummyControl dummy = DummyControl::New();
476 Stage::GetCurrent().Add(dummy);
478 Vector2 size(100.0f, 200.0f);
479 DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
481 application.SendNotification();
482 application.Render();
486 application.SendNotification();
487 application.Render();
489 DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
491 Stage::GetCurrent().Remove(dummy);
497 int UtcDaliControlImplSizeAnimation(void)
499 ToolkitTestApplication application;
502 DummyControl dummy = DummyControl::New( true );
503 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
505 Stage::GetCurrent().Add(dummy);
507 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
508 Animation animation = Animation::New(1.0f);
509 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
512 application.Render();
513 application.SendNotification();
514 application.Render();
515 application.SendNotification();
517 DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
519 Stage::GetCurrent().Remove(dummy);
522 // Ensure full code coverage
524 DummyControl dummy = DummyControl::New();
526 Stage::GetCurrent().Add(dummy);
528 Animation animation = Animation::New(1.0f);
529 animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
532 application.Render();
533 application.SendNotification();
534 application.Render();
535 application.SendNotification();
537 Stage::GetCurrent().Remove(dummy);
542 ///////////////////////////////////////////////////////////////////////////////////////////////////
544 int UtcDaliControlImplTouchEvent(void)
546 ToolkitTestApplication application;
549 DummyControl dummy = DummyControl::New( true );
550 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
552 dummy.SetSize( 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();
575 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
576 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
577 Stage::GetCurrent().Add(dummy);
579 application.Render();
580 application.SendNotification();
581 application.Render();
582 application.SendNotification();
584 Integration::TouchEvent touchEvent(1);
585 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
586 touchEvent.AddPoint(point);
587 application.ProcessEvent(touchEvent);
589 Stage::GetCurrent().Remove(dummy);
594 ///////////////////////////////////////////////////////////////////////////////////////////////////
597 int UtcDaliControlImplKeyEvent(void)
599 ToolkitTestApplication application;
602 DummyControl dummy = DummyControl::New( true );
603 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
605 Stage::GetCurrent().Add(dummy);
606 dummy.SetKeyInputFocus();
608 application.Render();
609 application.SendNotification();
610 application.Render();
611 application.SendNotification();
613 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
614 Integration::KeyEvent keyEvent;
615 application.ProcessEvent(keyEvent);
616 DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
618 Stage::GetCurrent().Remove(dummy);
621 // Ensure full code coverage
623 DummyControl dummy = DummyControl::New();
625 Stage::GetCurrent().Add(dummy);
626 dummy.SetKeyInputFocus();
628 application.Render();
629 application.SendNotification();
630 application.Render();
631 application.SendNotification();
633 Integration::KeyEvent keyEvent;
634 application.ProcessEvent(keyEvent);
636 Stage::GetCurrent().Remove(dummy);
641 int UtcDaliControlImplKeyInputFocusGained(void)
643 ToolkitTestApplication application;
646 DummyControl dummy = DummyControl::New( true );
647 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
649 Stage::GetCurrent().Add(dummy);
651 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
653 dummy.SetKeyInputFocus();
655 DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
657 Stage::GetCurrent().Remove(dummy);
660 // Ensure full code coverage
662 DummyControl dummy = DummyControl::New();
664 Stage::GetCurrent().Add(dummy);
665 dummy.SetKeyInputFocus();
666 Stage::GetCurrent().Remove(dummy);
671 int UtcDaliControlImplKeyInputFocusLost(void)
673 ToolkitTestApplication application;
676 DummyControl dummy = DummyControl::New( true );
677 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
679 Stage::GetCurrent().Add(dummy);
681 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
683 dummy.SetKeyInputFocus();
684 dummy.ClearKeyInputFocus();
686 DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
688 Stage::GetCurrent().Remove(dummy);
691 // Ensure full code coverage
693 DummyControl dummy = DummyControl::New();
695 Stage::GetCurrent().Add(dummy);
696 dummy.SetKeyInputFocus();
697 dummy.ClearKeyInputFocus();
699 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
701 dummyImpl.OnAccessibilityValueChange( true );
702 dummyImpl.IsKeyboardNavigationSupported();
703 dummyImpl.IsKeyboardFocusGroup();
705 Stage::GetCurrent().Remove(dummy);
710 int UtcDaliControlImplTypeRegistry(void)
712 ToolkitTestApplication application;
716 type = TypeRegistry::Get().GetTypeInfo( "Control" );
717 DALI_TEST_CHECK( type );
718 BaseHandle handle = type.CreateInstance();
719 DALI_TEST_CHECK( handle );
721 // Check if it's a control
722 DALI_TEST_CHECK( Control::DownCast(handle) );
727 ///////////////////////////////////////////////////////////////////////////////////////////////////
730 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
736 int UtcDaliControlImplMouseWheelEvent(void)
738 ToolkitTestApplication application;
741 DummyControl dummy = DummyControl::New( true );
742 DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
744 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
745 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
746 Stage::GetCurrent().Add(dummy);
748 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
750 application.Render();
751 application.SendNotification();
752 application.Render();
753 application.SendNotification();
755 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
757 // simulate a mouse wheel event
758 Vector2 screenCoordinates( 10.0f, 10.0f );
759 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
760 application.ProcessEvent(event);
761 DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
763 Stage::GetCurrent().Remove(dummy);
766 // Ensure full code coverage
768 DummyControl dummy = DummyControl::New();
770 dummy.SetSize( Vector2( 100.0f, 100.0f ) );
771 dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
772 Stage::GetCurrent().Add(dummy);
774 dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
776 application.Render();
777 application.SendNotification();
778 application.Render();
779 application.SendNotification();
781 // simulate a mouse wheel event
782 Vector2 screenCoordinates( 20.0f, 20.0f );
783 Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
784 application.ProcessEvent(event);
786 Stage::GetCurrent().Remove(dummy);