(AutomatedTests) Merged managed and unmanaged tests
[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.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
222
223     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
224     Stage::GetCurrent().Add(dummy);
225
226     // Render and notify a couple of times
227     application.SendNotification();
228     application.Render();
229     application.SendNotification();
230     application.Render();
231
232     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
233     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
234
235     DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
236     Integration::PinchGestureEvent pinch(Gesture::Started);
237     pinch.scale = 10.0f;
238     pinch.speed = 50.0f;
239     pinch.centerPoint = Vector2(20.0f, 20.0f);
240     application.ProcessEvent(pinch);
241     DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
242
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);
247     pan.timeDelta = 10;
248     pan.numberOfTouches = 1u;
249     application.ProcessEvent(pan);
250     pan.state = Gesture::Started;
251     application.ProcessEvent(pan);
252     DALI_TEST_CHECK( dummyImpl.panCalled == true );
253
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 );
263
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);
274
275     Stage::GetCurrent().Remove(dummy);
276   }
277
278   // Ensure full code coverage
279   {
280     DummyControl dummy = DummyControl::New();
281     dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
282
283     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
284     Stage::GetCurrent().Add(dummy);
285
286     // Render and notify a couple of times
287     application.SendNotification();
288     application.Render();
289     application.SendNotification();
290     application.Render();
291
292     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
293     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
294
295     DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
296     Integration::PinchGestureEvent pinch(Gesture::Started);
297     pinch.scale = 10.0f;
298     pinch.speed = 50.0f;
299     pinch.centerPoint = Vector2(20.0f, 20.0f);
300     application.ProcessEvent(pinch);
301
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 );
308
309     Integration::PanGestureEvent pan(Gesture::Possible);
310     pan.previousPosition = Vector2(10.0f, 20.0f);
311     pan.currentPosition = Vector2(20.0f, 20.0f);
312     pan.timeDelta = 10;
313     pan.numberOfTouches = 1u;
314     application.ProcessEvent(pan);
315     pan.state = Gesture::Started;
316     application.ProcessEvent(pan);
317
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);
325
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);
334
335     Stage::GetCurrent().Remove(dummy);
336   }
337   END_TEST;
338 }
339
340 int UtcDaliControlImplChildAddAndRemove(void)
341 {
342   ToolkitTestApplication application;
343
344   {
345     DummyControl dummy = DummyControl::New( true );
346     Stage::GetCurrent().Add(dummy);
347     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
348
349     application.Render();
350     application.SendNotification();
351
352     DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
353     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
354     Actor actor = RenderableActor::New();
355     dummy.Add(actor);
356     DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
357     DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
358
359     application.Render();
360     application.SendNotification();
361
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 );
366
367     application.Render();
368     application.SendNotification();
369
370     Stage::GetCurrent().Remove(dummy);
371   }
372
373   // Ensure full code coverage
374   {
375     DummyControl dummy = DummyControl::New();
376     Stage::GetCurrent().Add(dummy);
377
378     application.Render();
379     application.SendNotification();
380
381     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
382     Actor actor = RenderableActor::New();
383     dummy.Add(actor);
384     DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
385
386     application.Render();
387     application.SendNotification();
388
389     dummy.Remove( actor );
390     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
391
392     application.Render();
393     application.SendNotification();
394
395     Stage::GetCurrent().Remove(dummy);
396   }
397   END_TEST;
398 }
399
400 int UtcDaliControlImplStageConnection(void)
401 {
402   ToolkitTestApplication application;
403
404   {
405     DummyControl dummy = DummyControl::New( true );
406     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
407
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 );
413
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 );
419   }
420
421   // Ensure full code coverage
422   {
423     unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
424     DummyControl dummy = DummyControl::New();
425
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 );
431
432     Stage::GetCurrent().Remove(dummy);
433     application.Render();
434     application.SendNotification();
435     DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
436   }
437   END_TEST;
438 }
439
440 int UtcDaliControlImplSizeSet(void)
441 {
442   ToolkitTestApplication application;
443
444   {
445     DummyControl dummy = DummyControl::New( true );
446     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
447
448     Stage::GetCurrent().Add(dummy);
449     application.Render();
450     application.SendNotification();
451
452     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION );
453     Vector3 size(100.0f, 200.0f, 0.0f);
454     dummy.SetSize(size);
455
456     application.Render();
457     application.SendNotification();
458     application.Render();
459     application.SendNotification();
460
461     DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
462     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
463
464     Stage::GetCurrent().Remove(dummy);
465   }
466
467   // Ensure full code coverage
468   {
469     DummyControl dummy = DummyControl::New();
470     Stage::GetCurrent().Add(dummy);
471
472     Vector3 size(100.0f, 200.0f, 0.0f);
473     DALI_TEST_CHECK( size != dummy.GetCurrentSize() );
474
475     application.Render();
476     application.SendNotification();
477
478     dummy.SetSize(size);
479
480     application.Render();
481     application.SendNotification();
482     application.Render();
483     application.SendNotification();
484
485     DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
486
487     Stage::GetCurrent().Remove(dummy);
488   }
489   END_TEST;
490 }
491
492 int UtcDaliControlImplSizeAnimation(void)
493 {
494   ToolkitTestApplication application;
495
496   {
497     DummyControl dummy = DummyControl::New( true );
498     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
499
500     Stage::GetCurrent().Add(dummy);
501
502     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
503     Animation animation = Animation::New(1.0f);
504     animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
505     animation.Play();
506
507     application.Render();
508     application.SendNotification();
509     application.Render();
510     application.SendNotification();
511
512     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
513
514     Stage::GetCurrent().Remove(dummy);
515   }
516
517   // Ensure full code coverage
518   {
519     DummyControl dummy = DummyControl::New();
520
521     Stage::GetCurrent().Add(dummy);
522
523     Animation animation = Animation::New(1.0f);
524     animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
525     animation.Play();
526
527     application.Render();
528     application.SendNotification();
529     application.Render();
530     application.SendNotification();
531
532     Stage::GetCurrent().Remove(dummy);
533   }
534   END_TEST;
535 }
536
537 ///////////////////////////////////////////////////////////////////////////////////////////////////
538
539 int UtcDaliControlImplTouchEvent(void)
540 {
541   ToolkitTestApplication application;
542
543   {
544     DummyControl dummy = DummyControl::New( true );
545     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
546
547     dummy.SetSize(100.0f, 100.0f);
548     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
549     Stage::GetCurrent().Add(dummy);
550
551     application.Render();
552     application.SendNotification();
553     application.Render();
554     application.SendNotification();
555
556     DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
557     Integration::TouchEvent touchEvent(1);
558     TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
559     touchEvent.AddPoint(point);
560     application.ProcessEvent(touchEvent);
561     DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
562
563     Stage::GetCurrent().Remove(dummy);
564   }
565
566   // Ensure full code coverage
567   {
568     DummyControl dummy = DummyControl::New();
569
570     dummy.SetSize(100.0f, 100.0f);
571     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
572     Stage::GetCurrent().Add(dummy);
573
574     application.Render();
575     application.SendNotification();
576     application.Render();
577     application.SendNotification();
578
579     Integration::TouchEvent touchEvent(1);
580     TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
581     touchEvent.AddPoint(point);
582     application.ProcessEvent(touchEvent);
583
584     Stage::GetCurrent().Remove(dummy);
585   }
586   END_TEST;
587 }
588
589 ///////////////////////////////////////////////////////////////////////////////////////////////////
590
591
592 int UtcDaliControlImplKeyEvent(void)
593 {
594   ToolkitTestApplication application;
595
596   {
597     DummyControl dummy = DummyControl::New( true );
598     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
599
600     Stage::GetCurrent().Add(dummy);
601     dummy.SetKeyInputFocus();
602
603     application.Render();
604     application.SendNotification();
605     application.Render();
606     application.SendNotification();
607
608     DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
609     Integration::KeyEvent keyEvent;
610     application.ProcessEvent(keyEvent);
611     DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
612
613     Stage::GetCurrent().Remove(dummy);
614   }
615
616   // Ensure full code coverage
617   {
618     DummyControl dummy = DummyControl::New();
619
620     Stage::GetCurrent().Add(dummy);
621     dummy.SetKeyInputFocus();
622
623     application.Render();
624     application.SendNotification();
625     application.Render();
626     application.SendNotification();
627
628     Integration::KeyEvent keyEvent;
629     application.ProcessEvent(keyEvent);
630
631     Stage::GetCurrent().Remove(dummy);
632   }
633   END_TEST;
634 }
635
636 int UtcDaliControlImplStyleChange(void)
637 {
638   ToolkitTestApplication application;
639
640   DummyControl dummy = DummyControl::New( true );
641   DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
642
643   Stage::GetCurrent().Add(dummy);
644
645   application.Render();
646   application.SendNotification();
647   application.Render();
648   application.SendNotification();
649
650   // Add a Control and normal Actor as children
651   DummyControl dummyChild = DummyControl::New();
652   dummy.Add(dummyChild);
653
654   Actor actor = Actor::New();
655   dummy.Add(actor);
656
657   DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, false, TEST_LOCATION );
658   StyleChange styleChange;
659   styleChange.defaultFontChange = true;
660   Dali::StyleMonitor styleMonitor = StyleMonitor::Get();
661   styleMonitor.EmitStyleChangeSignal(styleChange);
662
663   DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, true, TEST_LOCATION );
664
665   Stage::GetCurrent().Remove(dummy);
666   END_TEST;
667 }
668
669 int UtcDaliControlImplKeyInputFocusGained(void)
670 {
671   ToolkitTestApplication application;
672
673   {
674     DummyControl dummy = DummyControl::New( true );
675     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
676
677     Stage::GetCurrent().Add(dummy);
678
679     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
680
681     dummy.SetKeyInputFocus();
682
683     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
684
685     Stage::GetCurrent().Remove(dummy);
686   }
687
688   // Ensure full code coverage
689   {
690     DummyControl dummy = DummyControl::New();
691
692     Stage::GetCurrent().Add(dummy);
693     dummy.SetKeyInputFocus();
694     Stage::GetCurrent().Remove(dummy);
695   }
696   END_TEST;
697 }
698
699 int UtcDaliControlImplKeyInputFocusLost(void)
700 {
701   ToolkitTestApplication application;
702
703   {
704     DummyControl dummy = DummyControl::New( true );
705     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
706
707     Stage::GetCurrent().Add(dummy);
708
709     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
710
711     dummy.SetKeyInputFocus();
712     dummy.ClearKeyInputFocus();
713
714     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
715
716     Stage::GetCurrent().Remove(dummy);
717   }
718
719   // Ensure full code coverage
720   {
721     DummyControl dummy = DummyControl::New();
722
723     Stage::GetCurrent().Add(dummy);
724     dummy.SetKeyInputFocus();
725     dummy.ClearKeyInputFocus();
726
727     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
728
729     dummyImpl.OnAccessibilityValueChange( true );
730     dummyImpl.IsKeyboardNavigationSupported();
731     dummyImpl.IsKeyboardFocusGroup();
732
733     Stage::GetCurrent().Remove(dummy);
734   }
735   END_TEST;
736 }
737
738 int UtcDaliControlImplTypeRegistry(void)
739 {
740   ToolkitTestApplication application;
741
742   // Register Type
743   TypeInfo type;
744   type = TypeRegistry::Get().GetTypeInfo( "Control" );
745   DALI_TEST_CHECK( type );
746   BaseHandle handle = type.CreateInstance();
747   DALI_TEST_CHECK( handle );
748
749   // Check if it's a control
750   DALI_TEST_CHECK( Control::DownCast(handle) );
751   END_TEST;
752 }
753
754
755 ///////////////////////////////////////////////////////////////////////////////////////////////////
756 namespace
757 {
758 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
759 {
760   return false;
761 }
762 }
763
764 int UtcDaliControlImplMouseWheelEvent(void)
765 {
766   ToolkitTestApplication application;
767
768   {
769     DummyControl dummy = DummyControl::New( true );
770     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
771
772     dummy.SetSize(100.0f, 100.0f);
773     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
774     Stage::GetCurrent().Add(dummy);
775
776     dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
777
778     application.Render();
779     application.SendNotification();
780     application.Render();
781     application.SendNotification();
782
783     DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
784
785     // simulate a mouse wheel event
786     Vector2 screenCoordinates( 10.0f, 10.0f );
787     Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
788     application.ProcessEvent(event);
789     DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
790
791     Stage::GetCurrent().Remove(dummy);
792   }
793
794   // Ensure full code coverage
795   {
796     DummyControl dummy = DummyControl::New();
797
798     dummy.SetSize(100.0f, 100.0f);
799     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
800     Stage::GetCurrent().Add(dummy);
801
802     dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
803
804     application.Render();
805     application.SendNotification();
806     application.Render();
807     application.SendNotification();
808
809     // simulate a mouse wheel event
810     Vector2 screenCoordinates( 20.0f, 20.0f );
811     Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
812     application.ProcessEvent(event);
813
814     Stage::GetCurrent().Remove(dummy);
815   }
816   END_TEST;
817 }