License conversion from Flora to Apache 2.0
[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
25 #include <dali.h>
26 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali/integration-api/events/key-event-integ.h>
28 #include <dali/integration-api/events/mouse-wheel-event-integ.h>
29 #include <dali/integration-api/events/long-press-gesture-event.h>
30 #include <dali/integration-api/events/pinch-gesture-event.h>
31 #include <dali/integration-api/events/pan-gesture-event.h>
32 #include <dali/integration-api/events/tap-gesture-event.h>
33 #include <dali/integration-api/events/touch-event-integ.h>
34
35 #include "dummy-control.h"
36
37 using namespace Dali;
38 using namespace Dali::Toolkit;
39
40 void utc_dali_toolkit_control_impl_startup(void)
41 {
42   test_return_value = TET_UNDEF;
43 }
44
45 void utc_dali_toolkit_control_impl_cleanup(void)
46 {
47   test_return_value = TET_PASS;
48 }
49
50 int UtcDaliControlImplNew(void)
51 {
52   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
53
54   Control control;
55
56   DALI_TEST_CHECK( !Control::DownCast(control) );
57
58   control = ControlImpl::New();
59
60   DALI_TEST_CHECK( Control::DownCast(control) );
61   END_TEST;
62 }
63
64
65 int UtcDaliControlImplEnableGestureDetector(void)
66 {
67   ToolkitTestApplication application;
68
69   // Enable individually
70   {
71     DummyControl dummy = DummyControl::New();
72     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
73
74     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
75     dummyImpl.EnableGestureDetection(Gesture::Pinch);
76     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
77
78     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
79     dummyImpl.EnableGestureDetection(Gesture::Pan);
80     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
81
82     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
83     dummyImpl.EnableGestureDetection(Gesture::Tap);
84     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
85
86     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
87     dummyImpl.EnableGestureDetection(Gesture::LongPress);
88     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
89   }
90
91   // Enable All
92   {
93     DummyControl dummy = DummyControl::New();
94     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
95
96     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
97     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
98     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
99     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
100
101     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
102
103     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
104     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
105     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
106     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
107
108     // Enable when already enabled
109
110     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
111
112     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
113     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
114     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
115     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
116   }
117   END_TEST;
118 }
119
120 int UtcDaliControlImplDisableGestureDetector(void)
121 {
122   ToolkitTestApplication application;
123
124   // Disable individually
125   {
126     DummyControl dummy = DummyControl::New();
127     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
128
129     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
130
131     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
132     dummyImpl.DisableGestureDetection(Gesture::Pinch);
133     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
134
135     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
136     dummyImpl.DisableGestureDetection(Gesture::Pan);
137     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
138
139     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
140     dummyImpl.DisableGestureDetection(Gesture::Tap);
141     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
142
143     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
144     dummyImpl.DisableGestureDetection(Gesture::LongPress);
145     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
146   }
147
148   // Disable All
149   {
150     DummyControl dummy = DummyControl::New();
151     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
152
153     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
154
155     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
156     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
157     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
158     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
159
160     dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
161
162     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
163     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
164     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
165     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
166   }
167
168   // Disable When not enabled
169   {
170     DummyControl dummy = DummyControl::New();
171     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
172
173     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
174     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
175     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
176     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
177
178     dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
179
180     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
181     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
182     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
183     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
184   }
185
186   // Ensure control is detached if gesture detector is not deleted
187   {
188     DummyControl dummy = DummyControl::New();
189     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
190
191     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
192
193     PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
194     PanGestureDetector pan   = dummyImpl.GetPanGestureDetector();
195     TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
196     LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
197
198     DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), false, TEST_LOCATION );
199     DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), false, TEST_LOCATION );
200     DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), false, TEST_LOCATION );
201     DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), false, TEST_LOCATION );
202
203     dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
204
205     DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), true, TEST_LOCATION );
206     DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), true, TEST_LOCATION );
207     DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), true, TEST_LOCATION );
208     DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), true, TEST_LOCATION );
209   }
210   END_TEST;
211 }
212
213 int UtcDaliControlImplOnGestureMethods(void)
214 {
215   ToolkitTestApplication application;
216
217   // Check gesture actually happens
218   {
219     DummyControl dummy = DummyControl::New(true);
220     dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
221
222     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
223     Stage::GetCurrent().Add(dummy);
224
225     // Render and notify a couple of times
226     application.SendNotification();
227     application.Render();
228     application.SendNotification();
229     application.Render();
230
231     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
232     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
233
234     DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
235     Integration::PinchGestureEvent pinch(Gesture::Started);
236     pinch.scale = 10.0f;
237     pinch.speed = 50.0f;
238     pinch.centerPoint = Vector2(20.0f, 20.0f);
239     application.ProcessEvent(pinch);
240     DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
241
242     DALI_TEST_CHECK( dummyImpl.panCalled == false );
243     Integration::PanGestureEvent pan(Gesture::Possible);
244     pan.previousPosition = Vector2(10.0f, 20.0f);
245     pan.currentPosition = Vector2(20.0f, 20.0f);
246     pan.timeDelta = 10;
247     pan.numberOfTouches = 1u;
248     application.ProcessEvent(pan);
249     pan.state = Gesture::Started;
250     application.ProcessEvent(pan);
251     DALI_TEST_CHECK( dummyImpl.panCalled == true );
252
253     DALI_TEST_CHECK( dummyImpl.tapCalled == false );
254     Integration::TapGestureEvent tap(Gesture::Possible);
255     tap.numberOfTaps = 1u;
256     tap.numberOfTouches = 1u;
257     tap.point = Vector2(50.0f, 50.0f);
258     application.ProcessEvent(tap);
259     tap.state = Gesture::Started;
260     application.ProcessEvent(tap);
261     DALI_TEST_CHECK( dummyImpl.tapCalled == true );
262
263     DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
264     Integration::LongPressGestureEvent longPress(Gesture::Possible);
265     longPress.numberOfTouches = 1u;
266     longPress.point = Vector2(50.0f, 50.0f);
267     application.ProcessEvent(longPress);
268     longPress.state = Gesture::Started;
269     application.ProcessEvent(longPress);
270     DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
271     longPress.state = Gesture::Finished;
272     application.ProcessEvent(longPress);
273
274     Stage::GetCurrent().Remove(dummy);
275   }
276
277   // Ensure full code coverage
278   {
279     DummyControl dummy = DummyControl::New();
280     dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
281
282     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
283     Stage::GetCurrent().Add(dummy);
284
285     // Render and notify a couple of times
286     application.SendNotification();
287     application.Render();
288     application.SendNotification();
289     application.Render();
290
291     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
292     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
293
294     DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
295     Integration::PinchGestureEvent pinch(Gesture::Started);
296     pinch.scale = 10.0f;
297     pinch.speed = 50.0f;
298     pinch.centerPoint = Vector2(20.0f, 20.0f);
299     application.ProcessEvent(pinch);
300
301     // Render and notify a couple of times
302     application.SendNotification();
303     application.Render();
304     application.SendNotification();
305     application.Render();
306     DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
307
308     Integration::PanGestureEvent pan(Gesture::Possible);
309     pan.previousPosition = Vector2(10.0f, 20.0f);
310     pan.currentPosition = Vector2(20.0f, 20.0f);
311     pan.timeDelta = 10;
312     pan.numberOfTouches = 1u;
313     application.ProcessEvent(pan);
314     pan.state = Gesture::Started;
315     application.ProcessEvent(pan);
316
317     Integration::TapGestureEvent tap(Gesture::Possible);
318     tap.numberOfTaps = 1u;
319     tap.numberOfTouches = 1u;
320     tap.point = Vector2(50.0f, 50.0f);
321     application.ProcessEvent(tap);
322     tap.state = Gesture::Started;
323     application.ProcessEvent(tap);
324
325     Integration::LongPressGestureEvent longPress(Gesture::Possible);
326     longPress.numberOfTouches = 1u;
327     longPress.point = Vector2(50.0f, 50.0f);
328     application.ProcessEvent(longPress);
329     longPress.state = Gesture::Started;
330     application.ProcessEvent(longPress);
331     longPress.state = Gesture::Finished;
332     application.ProcessEvent(longPress);
333
334     Stage::GetCurrent().Remove(dummy);
335   }
336   END_TEST;
337 }
338
339 int UtcDaliControlImplChildAddAndRemove(void)
340 {
341   ToolkitTestApplication application;
342
343   {
344     DummyControl dummy = DummyControl::New( true );
345     Stage::GetCurrent().Add(dummy);
346     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
347
348     application.Render();
349     application.SendNotification();
350
351     DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
352     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
353     Actor actor = RenderableActor::New();
354     dummy.Add(actor);
355     DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
356     DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
357
358     application.Render();
359     application.SendNotification();
360
361     DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
362     dummy.Remove( actor );
363     DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
364     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
365
366     application.Render();
367     application.SendNotification();
368
369     Stage::GetCurrent().Remove(dummy);
370   }
371
372   // Ensure full code coverage
373   {
374     DummyControl dummy = DummyControl::New();
375     Stage::GetCurrent().Add(dummy);
376
377     application.Render();
378     application.SendNotification();
379
380     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
381     Actor actor = RenderableActor::New();
382     dummy.Add(actor);
383     DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
384
385     application.Render();
386     application.SendNotification();
387
388     dummy.Remove( actor );
389     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
390
391     application.Render();
392     application.SendNotification();
393
394     Stage::GetCurrent().Remove(dummy);
395   }
396   END_TEST;
397 }
398
399 int UtcDaliControlImplStageConnection(void)
400 {
401   ToolkitTestApplication application;
402
403   {
404     DummyControl dummy = DummyControl::New( true );
405     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
406
407     DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
408     Stage::GetCurrent().Add(dummy);
409     application.Render();
410     application.SendNotification();
411     DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
412
413     DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
414     Stage::GetCurrent().Remove(dummy);
415     application.Render();
416     application.SendNotification();
417     DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
418   }
419
420   // Ensure full code coverage
421   {
422     unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
423     DummyControl dummy = DummyControl::New();
424
425     DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
426     Stage::GetCurrent().Add(dummy);
427     application.Render();
428     application.SendNotification();
429     DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
430
431     Stage::GetCurrent().Remove(dummy);
432     application.Render();
433     application.SendNotification();
434     DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
435   }
436   END_TEST;
437 }
438
439 int UtcDaliControlImplSizeSet(void)
440 {
441   ToolkitTestApplication application;
442
443   {
444     DummyControl dummy = DummyControl::New( true );
445     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
446
447     Stage::GetCurrent().Add(dummy);
448     application.Render();
449     application.SendNotification();
450
451     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION );
452     Vector3 size(100.0f, 200.0f, 0.0f);
453     dummy.SetSize(size);
454
455     application.Render();
456     application.SendNotification();
457     application.Render();
458     application.SendNotification();
459
460     DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
461     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
462
463     Stage::GetCurrent().Remove(dummy);
464   }
465
466   // Ensure full code coverage
467   {
468     DummyControl dummy = DummyControl::New();
469     Stage::GetCurrent().Add(dummy);
470
471     Vector3 size(100.0f, 200.0f, 0.0f);
472     DALI_TEST_CHECK( size != dummy.GetCurrentSize() );
473
474     application.Render();
475     application.SendNotification();
476
477     dummy.SetSize(size);
478
479     application.Render();
480     application.SendNotification();
481     application.Render();
482     application.SendNotification();
483
484     DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
485
486     Stage::GetCurrent().Remove(dummy);
487   }
488   END_TEST;
489 }
490
491 int UtcDaliControlImplSizeAnimation(void)
492 {
493   ToolkitTestApplication application;
494
495   {
496     DummyControl dummy = DummyControl::New( true );
497     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
498
499     Stage::GetCurrent().Add(dummy);
500
501     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
502     Animation animation = Animation::New(1.0f);
503     animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
504     animation.Play();
505
506     application.Render();
507     application.SendNotification();
508     application.Render();
509     application.SendNotification();
510
511     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
512
513     Stage::GetCurrent().Remove(dummy);
514   }
515
516   // Ensure full code coverage
517   {
518     DummyControl dummy = DummyControl::New();
519
520     Stage::GetCurrent().Add(dummy);
521
522     Animation animation = Animation::New(1.0f);
523     animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
524     animation.Play();
525
526     application.Render();
527     application.SendNotification();
528     application.Render();
529     application.SendNotification();
530
531     Stage::GetCurrent().Remove(dummy);
532   }
533   END_TEST;
534 }
535
536 ///////////////////////////////////////////////////////////////////////////////////////////////////
537
538 int UtcDaliControlImplTouchEvent(void)
539 {
540   ToolkitTestApplication application;
541
542   {
543     DummyControl dummy = DummyControl::New( true );
544     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
545
546     dummy.SetSize(100.0f, 100.0f);
547     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
548     Stage::GetCurrent().Add(dummy);
549
550     application.Render();
551     application.SendNotification();
552     application.Render();
553     application.SendNotification();
554
555     DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
556     Integration::TouchEvent touchEvent(1);
557     TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
558     touchEvent.AddPoint(point);
559     application.ProcessEvent(touchEvent);
560     DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
561
562     Stage::GetCurrent().Remove(dummy);
563   }
564
565   // Ensure full code coverage
566   {
567     DummyControl dummy = DummyControl::New();
568
569     dummy.SetSize(100.0f, 100.0f);
570     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
571     Stage::GetCurrent().Add(dummy);
572
573     application.Render();
574     application.SendNotification();
575     application.Render();
576     application.SendNotification();
577
578     Integration::TouchEvent touchEvent(1);
579     TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
580     touchEvent.AddPoint(point);
581     application.ProcessEvent(touchEvent);
582
583     Stage::GetCurrent().Remove(dummy);
584   }
585   END_TEST;
586 }
587
588 ///////////////////////////////////////////////////////////////////////////////////////////////////
589
590
591 int UtcDaliControlImplKeyEvent(void)
592 {
593   ToolkitTestApplication application;
594
595   {
596     DummyControl dummy = DummyControl::New( true );
597     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
598
599     Stage::GetCurrent().Add(dummy);
600     dummy.SetKeyInputFocus();
601
602     application.Render();
603     application.SendNotification();
604     application.Render();
605     application.SendNotification();
606
607     DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
608     Integration::KeyEvent keyEvent;
609     application.ProcessEvent(keyEvent);
610     DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
611
612     Stage::GetCurrent().Remove(dummy);
613   }
614
615   // Ensure full code coverage
616   {
617     DummyControl dummy = DummyControl::New();
618
619     Stage::GetCurrent().Add(dummy);
620     dummy.SetKeyInputFocus();
621
622     application.Render();
623     application.SendNotification();
624     application.Render();
625     application.SendNotification();
626
627     Integration::KeyEvent keyEvent;
628     application.ProcessEvent(keyEvent);
629
630     Stage::GetCurrent().Remove(dummy);
631   }
632   END_TEST;
633 }
634
635 int UtcDaliControlImplStyleChange(void)
636 {
637   ToolkitTestApplication application;
638
639   DummyControl dummy = DummyControl::New( true );
640   DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
641
642   Stage::GetCurrent().Add(dummy);
643
644   application.Render();
645   application.SendNotification();
646   application.Render();
647   application.SendNotification();
648
649   // Add a Control and normal Actor as children
650   DummyControl dummyChild = DummyControl::New();
651   dummy.Add(dummyChild);
652
653   Actor actor = Actor::New();
654   dummy.Add(actor);
655
656   DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, false, TEST_LOCATION );
657   StyleChange styleChange;
658   styleChange.defaultFontChange = true;
659   Dali::StyleMonitor styleMonitor = application.GetAdaptor().GetToolkitStyleMonitor();
660   styleMonitor.EmitStyleChangeSignal(styleChange);
661
662   DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, true, TEST_LOCATION );
663
664   Stage::GetCurrent().Remove(dummy);
665   END_TEST;
666 }
667
668 int UtcDaliControlImplKeyInputFocusGained(void)
669 {
670   ToolkitTestApplication application;
671
672   {
673     DummyControl dummy = DummyControl::New( true );
674     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
675
676     Stage::GetCurrent().Add(dummy);
677
678     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
679
680     dummy.SetKeyInputFocus();
681
682     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
683
684     Stage::GetCurrent().Remove(dummy);
685   }
686
687   // Ensure full code coverage
688   {
689     DummyControl dummy = DummyControl::New();
690
691     Stage::GetCurrent().Add(dummy);
692     dummy.SetKeyInputFocus();
693     Stage::GetCurrent().Remove(dummy);
694   }
695   END_TEST;
696 }
697
698 int UtcDaliControlImplKeyInputFocusLost(void)
699 {
700   ToolkitTestApplication application;
701
702   {
703     DummyControl dummy = DummyControl::New( true );
704     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
705
706     Stage::GetCurrent().Add(dummy);
707
708     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
709
710     dummy.SetKeyInputFocus();
711     dummy.ClearKeyInputFocus();
712
713     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
714
715     Stage::GetCurrent().Remove(dummy);
716   }
717
718   // Ensure full code coverage
719   {
720     DummyControl dummy = DummyControl::New();
721
722     Stage::GetCurrent().Add(dummy);
723     dummy.SetKeyInputFocus();
724     dummy.ClearKeyInputFocus();
725
726     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
727
728     dummyImpl.OnAccessibilityValueChange( true );
729     dummyImpl.IsKeyboardNavigationSupported();
730     dummyImpl.IsKeyboardFocusGroup();
731
732     Stage::GetCurrent().Remove(dummy);
733   }
734   END_TEST;
735 }