Merge "Use new animatable registered properties in ScrollView" into tizen
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ControlImpl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20
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"
25
26 #include <dali.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>
35
36 #include "dummy-control.h"
37
38 using namespace Dali;
39 using namespace Dali::Toolkit;
40
41 void utc_dali_toolkit_control_impl_startup(void)
42 {
43   test_return_value = TET_UNDEF;
44 }
45
46 void utc_dali_toolkit_control_impl_cleanup(void)
47 {
48   test_return_value = TET_PASS;
49 }
50
51 int UtcDaliControlImplNew(void)
52 {
53   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
54
55   Control control;
56
57   DALI_TEST_CHECK( !Control::DownCast(control) );
58
59   control = Toolkit::Internal::Control::New();
60
61   DALI_TEST_CHECK( Control::DownCast(control) );
62   END_TEST;
63 }
64
65
66 int UtcDaliControlImplEnableGestureDetector(void)
67 {
68   ToolkitTestApplication application;
69
70   // Enable individually
71   {
72     DummyControl dummy = DummyControl::New();
73     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
74
75     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
76     dummyImpl.EnableGestureDetection(Gesture::Pinch);
77     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
78
79     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
80     dummyImpl.EnableGestureDetection(Gesture::Pan);
81     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
82
83     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
84     dummyImpl.EnableGestureDetection(Gesture::Tap);
85     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
86
87     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
88     dummyImpl.EnableGestureDetection(Gesture::LongPress);
89     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
90   }
91
92   // Enable All
93   {
94     DummyControl dummy = DummyControl::New();
95     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
96
97     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
98     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
99     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
100     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
101
102     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
103
104     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
105     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
106     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
107     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
108
109     // Enable when already enabled
110
111     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
112
113     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
114     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
115     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
116     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
117   }
118   END_TEST;
119 }
120
121 int UtcDaliControlImplDisableGestureDetector(void)
122 {
123   ToolkitTestApplication application;
124
125   // Disable individually
126   {
127     DummyControl dummy = DummyControl::New();
128     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
129
130     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
131
132     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
133     dummyImpl.DisableGestureDetection(Gesture::Pinch);
134     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
135
136     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
137     dummyImpl.DisableGestureDetection(Gesture::Pan);
138     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
139
140     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
141     dummyImpl.DisableGestureDetection(Gesture::Tap);
142     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
143
144     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
145     dummyImpl.DisableGestureDetection(Gesture::LongPress);
146     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
147   }
148
149   // Disable All
150   {
151     DummyControl dummy = DummyControl::New();
152     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
153
154     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
155
156     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
157     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
158     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
159     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
160
161     dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
162
163     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
164     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
165     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
166     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
167   }
168
169   // Disable When not enabled
170   {
171     DummyControl dummy = DummyControl::New();
172     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
173
174     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
175     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
176     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
177     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
178
179     dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
180
181     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
182     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
183     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
184     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
185   }
186
187   // Ensure control is detached if gesture detector is not deleted
188   {
189     DummyControl dummy = DummyControl::New();
190     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
191
192     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
193
194     PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
195     PanGestureDetector pan   = dummyImpl.GetPanGestureDetector();
196     TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
197     LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
198
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 );
203
204     dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
205
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 );
210   }
211   END_TEST;
212 }
213
214 int UtcDaliControlImplOnGestureMethods(void)
215 {
216   ToolkitTestApplication application;
217
218   // Check gesture actually happens
219   {
220     DummyControl dummy = DummyControl::New(true);
221     dummy.SetRelayoutEnabled( true );
222     dummy.SetPreferredSize( Vector2(100.0f, 100.0f ) );
223
224     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
225     Stage::GetCurrent().Add(dummy);
226
227     // Render and notify a couple of times
228     application.SendNotification();
229     application.Render();
230     application.SendNotification();
231     application.Render();
232
233     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
234     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
235
236     DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
237     Integration::PinchGestureEvent pinch(Gesture::Started);
238     pinch.scale = 10.0f;
239     pinch.speed = 50.0f;
240     pinch.centerPoint = Vector2(20.0f, 20.0f);
241     application.ProcessEvent(pinch);
242     DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
243
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);
248     pan.timeDelta = 10;
249     pan.numberOfTouches = 1u;
250     application.ProcessEvent(pan);
251     pan.state = Gesture::Started;
252     application.ProcessEvent(pan);
253     DALI_TEST_CHECK( dummyImpl.panCalled == true );
254
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 );
264
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);
275
276     Stage::GetCurrent().Remove(dummy);
277   }
278
279   // Ensure full code coverage
280   {
281     DummyControl dummy = DummyControl::New();
282     dummy.SetRelayoutEnabled( true );
283     dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
284
285     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
286     Stage::GetCurrent().Add(dummy);
287
288     // Render and notify a couple of times
289     application.SendNotification();
290     application.Render();
291     application.SendNotification();
292     application.Render();
293
294     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
295     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
296
297     DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
298     Integration::PinchGestureEvent pinch(Gesture::Started);
299     pinch.scale = 10.0f;
300     pinch.speed = 50.0f;
301     pinch.centerPoint = Vector2(20.0f, 20.0f);
302     application.ProcessEvent(pinch);
303
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 );
310
311     Integration::PanGestureEvent pan(Gesture::Possible);
312     pan.previousPosition = Vector2(10.0f, 20.0f);
313     pan.currentPosition = Vector2(20.0f, 20.0f);
314     pan.timeDelta = 10;
315     pan.numberOfTouches = 1u;
316     application.ProcessEvent(pan);
317     pan.state = Gesture::Started;
318     application.ProcessEvent(pan);
319
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);
327
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);
336
337     Stage::GetCurrent().Remove(dummy);
338   }
339   END_TEST;
340 }
341
342 int UtcDaliControlImplChildAddAndRemove(void)
343 {
344   ToolkitTestApplication application;
345
346   {
347     DummyControl dummy = DummyControl::New( true );
348     Stage::GetCurrent().Add(dummy);
349     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
350
351     application.Render();
352     application.SendNotification();
353
354     DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
355     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
356     Actor actor = RenderableActor::New();
357     dummy.Add(actor);
358     DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
359     DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
360
361     application.Render();
362     application.SendNotification();
363
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 );
368
369     application.Render();
370     application.SendNotification();
371
372     Stage::GetCurrent().Remove(dummy);
373   }
374
375   // Ensure full code coverage
376   {
377     DummyControl dummy = DummyControl::New();
378     Stage::GetCurrent().Add(dummy);
379
380     application.Render();
381     application.SendNotification();
382
383     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
384     Actor actor = RenderableActor::New();
385     dummy.Add(actor);
386     DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
387
388     application.Render();
389     application.SendNotification();
390
391     dummy.Remove( actor );
392     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
393
394     application.Render();
395     application.SendNotification();
396
397     Stage::GetCurrent().Remove(dummy);
398   }
399   END_TEST;
400 }
401
402 int UtcDaliControlImplStageConnection(void)
403 {
404   ToolkitTestApplication application;
405
406   {
407     DummyControl dummy = DummyControl::New( true );
408     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
409
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 );
415
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 );
421   }
422
423   // Ensure full code coverage
424   {
425     unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
426     DummyControl dummy = DummyControl::New();
427
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 );
433
434     Stage::GetCurrent().Remove(dummy);
435     application.Render();
436     application.SendNotification();
437     DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
438   }
439   END_TEST;
440 }
441
442 int UtcDaliControlImplSizeSet(void)
443 {
444   ToolkitTestApplication application;
445
446   {
447     DummyControl dummy = DummyControl::New( true );
448     dummy.SetRelayoutEnabled( true );
449     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
450
451     Stage::GetCurrent().Add(dummy);
452     application.Render();
453     application.SendNotification();
454
455     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION ); // Called from size negotiation
456     Vector2 size(100.0f, 200.0f);
457     dummy.SetPreferredSize(size);
458
459     application.Render();
460     application.SendNotification();
461     application.Render();
462     application.SendNotification();
463
464     DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
465     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
466
467     Stage::GetCurrent().Remove(dummy);
468   }
469
470   // Ensure full code coverage
471   {
472     DummyControl dummy = DummyControl::New();
473     dummy.SetRelayoutEnabled( true );
474     Stage::GetCurrent().Add(dummy);
475
476     Vector2 size(100.0f, 200.0f);
477     DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
478
479     application.Render();
480     application.SendNotification();
481
482     dummy.SetPreferredSize(size);
483
484     application.Render();
485     application.SendNotification();
486     application.Render();
487     application.SendNotification();
488
489     DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
490
491     Stage::GetCurrent().Remove(dummy);
492   }
493   END_TEST;
494 }
495
496 int UtcDaliControlImplSizeAnimation(void)
497 {
498   ToolkitTestApplication application;
499
500   {
501     DummyControl dummy = DummyControl::New( true );
502     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
503
504     Stage::GetCurrent().Add(dummy);
505
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 ) );
509     animation.Play();
510
511     application.Render();
512     application.SendNotification();
513     application.Render();
514     application.SendNotification();
515
516     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
517
518     Stage::GetCurrent().Remove(dummy);
519   }
520
521   // Ensure full code coverage
522   {
523     DummyControl dummy = DummyControl::New();
524
525     Stage::GetCurrent().Add(dummy);
526
527     Animation animation = Animation::New(1.0f);
528     animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
529     animation.Play();
530
531     application.Render();
532     application.SendNotification();
533     application.Render();
534     application.SendNotification();
535
536     Stage::GetCurrent().Remove(dummy);
537   }
538   END_TEST;
539 }
540
541 ///////////////////////////////////////////////////////////////////////////////////////////////////
542
543 int UtcDaliControlImplTouchEvent(void)
544 {
545   ToolkitTestApplication application;
546
547   {
548     DummyControl dummy = DummyControl::New( true );
549     dummy.SetRelayoutEnabled( true );
550     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
551
552     dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
553     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
554     Stage::GetCurrent().Add(dummy);
555
556     application.Render();
557     application.SendNotification();
558     application.Render();
559     application.SendNotification();
560
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 );
567
568     Stage::GetCurrent().Remove(dummy);
569   }
570
571   // Ensure full code coverage
572   {
573     DummyControl dummy = DummyControl::New();
574     dummy.SetRelayoutEnabled( true );
575
576     dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
577     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
578     Stage::GetCurrent().Add(dummy);
579
580     application.Render();
581     application.SendNotification();
582     application.Render();
583     application.SendNotification();
584
585     Integration::TouchEvent touchEvent(1);
586     TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
587     touchEvent.AddPoint(point);
588     application.ProcessEvent(touchEvent);
589
590     Stage::GetCurrent().Remove(dummy);
591   }
592   END_TEST;
593 }
594
595 ///////////////////////////////////////////////////////////////////////////////////////////////////
596
597
598 int UtcDaliControlImplKeyEvent(void)
599 {
600   ToolkitTestApplication application;
601
602   {
603     DummyControl dummy = DummyControl::New( true );
604     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
605
606     Stage::GetCurrent().Add(dummy);
607     dummy.SetKeyInputFocus();
608
609     application.Render();
610     application.SendNotification();
611     application.Render();
612     application.SendNotification();
613
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 );
618
619     Stage::GetCurrent().Remove(dummy);
620   }
621
622   // Ensure full code coverage
623   {
624     DummyControl dummy = DummyControl::New();
625
626     Stage::GetCurrent().Add(dummy);
627     dummy.SetKeyInputFocus();
628
629     application.Render();
630     application.SendNotification();
631     application.Render();
632     application.SendNotification();
633
634     Integration::KeyEvent keyEvent;
635     application.ProcessEvent(keyEvent);
636
637     Stage::GetCurrent().Remove(dummy);
638   }
639   END_TEST;
640 }
641
642 int UtcDaliControlImplStyleChange(void)
643 {
644   ToolkitTestApplication application;
645
646   DummyControl dummy = DummyControl::New( true );
647   DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
648
649   Stage::GetCurrent().Add(dummy);
650
651   application.Render();
652   application.SendNotification();
653   application.Render();
654   application.SendNotification();
655
656   // Add a Control and normal Actor as children
657   DummyControl dummyChild = DummyControl::New();
658   dummy.Add(dummyChild);
659
660   Actor actor = Actor::New();
661   dummy.Add(actor);
662
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);
668
669   DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, true, TEST_LOCATION );
670
671   Stage::GetCurrent().Remove(dummy);
672   END_TEST;
673 }
674
675 int UtcDaliControlImplKeyInputFocusGained(void)
676 {
677   ToolkitTestApplication application;
678
679   {
680     DummyControl dummy = DummyControl::New( true );
681     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
682
683     Stage::GetCurrent().Add(dummy);
684
685     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
686
687     dummy.SetKeyInputFocus();
688
689     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
690
691     Stage::GetCurrent().Remove(dummy);
692   }
693
694   // Ensure full code coverage
695   {
696     DummyControl dummy = DummyControl::New();
697
698     Stage::GetCurrent().Add(dummy);
699     dummy.SetKeyInputFocus();
700     Stage::GetCurrent().Remove(dummy);
701   }
702   END_TEST;
703 }
704
705 int UtcDaliControlImplKeyInputFocusLost(void)
706 {
707   ToolkitTestApplication application;
708
709   {
710     DummyControl dummy = DummyControl::New( true );
711     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
712
713     Stage::GetCurrent().Add(dummy);
714
715     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
716
717     dummy.SetKeyInputFocus();
718     dummy.ClearKeyInputFocus();
719
720     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
721
722     Stage::GetCurrent().Remove(dummy);
723   }
724
725   // Ensure full code coverage
726   {
727     DummyControl dummy = DummyControl::New();
728
729     Stage::GetCurrent().Add(dummy);
730     dummy.SetKeyInputFocus();
731     dummy.ClearKeyInputFocus();
732
733     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
734
735     dummyImpl.OnAccessibilityValueChange( true );
736     dummyImpl.IsKeyboardNavigationSupported();
737     dummyImpl.IsKeyboardFocusGroup();
738
739     Stage::GetCurrent().Remove(dummy);
740   }
741   END_TEST;
742 }
743
744 int UtcDaliControlImplTypeRegistry(void)
745 {
746   ToolkitTestApplication application;
747
748   // Register Type
749   TypeInfo type;
750   type = TypeRegistry::Get().GetTypeInfo( "Control" );
751   DALI_TEST_CHECK( type );
752   BaseHandle handle = type.CreateInstance();
753   DALI_TEST_CHECK( handle );
754
755   // Check if it's a control
756   DALI_TEST_CHECK( Control::DownCast(handle) );
757   END_TEST;
758 }
759
760
761 ///////////////////////////////////////////////////////////////////////////////////////////////////
762 namespace
763 {
764 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
765 {
766   return false;
767 }
768 }
769
770 int UtcDaliControlImplMouseWheelEvent(void)
771 {
772   ToolkitTestApplication application;
773
774   {
775     DummyControl dummy = DummyControl::New( true );
776     dummy.SetRelayoutEnabled( true );
777     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
778
779     dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
780     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
781     Stage::GetCurrent().Add(dummy);
782
783     dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
784
785     application.Render();
786     application.SendNotification();
787     application.Render();
788     application.SendNotification();
789
790     DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
791
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 );
797
798     Stage::GetCurrent().Remove(dummy);
799   }
800
801   // Ensure full code coverage
802   {
803     DummyControl dummy = DummyControl::New();
804     dummy.SetRelayoutEnabled( true );
805
806     dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
807     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
808     Stage::GetCurrent().Add(dummy);
809
810     dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
811
812     application.Render();
813     application.SendNotification();
814     application.Render();
815     application.SendNotification();
816
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);
821
822     Stage::GetCurrent().Remove(dummy);
823   }
824   END_TEST;
825 }