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