Merge "Use stylesheet from StyleMonitor" into tizen
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ControlImpl.cpp
1 /*
2  * Copyright (c) 2015 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( Vector2(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( Vector2( 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 UtcDaliControlImplSizeSetP(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 ); // Size not set, no onSizeSet called
453     Vector2 size(100.0f, 200.0f);
454     dummy.SetSize( size );
455
456     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size is going to get negotiated, no onSizeSet called
457
458     application.SendNotification();
459     application.Render();
460
461     DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
462     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
463
464     Stage::GetCurrent().Remove(dummy);
465   }
466
467   END_TEST;
468 }
469
470 int UtcDaliControlImplSizeSet2P(void)
471 {
472   ToolkitTestApplication application;
473
474   {
475     DummyControl dummy = DummyControl::New();
476     Stage::GetCurrent().Add(dummy);
477
478     Vector2 size(100.0f, 200.0f);
479     DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
480
481     application.SendNotification();
482     application.Render();
483
484     dummy.SetSize(size);
485
486     application.SendNotification();
487     application.Render();
488
489     DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
490
491     Stage::GetCurrent().Remove(dummy);
492   }
493   END_TEST;
494 }
495
496
497 int UtcDaliControlImplSizeAnimation(void)
498 {
499   ToolkitTestApplication application;
500
501   {
502     DummyControl dummy = DummyControl::New( true );
503     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
504
505     Stage::GetCurrent().Add(dummy);
506
507     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
508     Animation animation = Animation::New(1.0f);
509     animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
510     animation.Play();
511
512     application.Render();
513     application.SendNotification();
514     application.Render();
515     application.SendNotification();
516
517     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
518
519     Stage::GetCurrent().Remove(dummy);
520   }
521
522   // Ensure full code coverage
523   {
524     DummyControl dummy = DummyControl::New();
525
526     Stage::GetCurrent().Add(dummy);
527
528     Animation animation = Animation::New(1.0f);
529     animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
530     animation.Play();
531
532     application.Render();
533     application.SendNotification();
534     application.Render();
535     application.SendNotification();
536
537     Stage::GetCurrent().Remove(dummy);
538   }
539   END_TEST;
540 }
541
542 ///////////////////////////////////////////////////////////////////////////////////////////////////
543
544 int UtcDaliControlImplTouchEvent(void)
545 {
546   ToolkitTestApplication application;
547
548   {
549     DummyControl dummy = DummyControl::New( true );
550     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
551
552     dummy.SetSize( 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
575     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
576     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
577     Stage::GetCurrent().Add(dummy);
578
579     application.Render();
580     application.SendNotification();
581     application.Render();
582     application.SendNotification();
583
584     Integration::TouchEvent touchEvent(1);
585     TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
586     touchEvent.AddPoint(point);
587     application.ProcessEvent(touchEvent);
588
589     Stage::GetCurrent().Remove(dummy);
590   }
591   END_TEST;
592 }
593
594 ///////////////////////////////////////////////////////////////////////////////////////////////////
595
596
597 int UtcDaliControlImplKeyEvent(void)
598 {
599   ToolkitTestApplication application;
600
601   {
602     DummyControl dummy = DummyControl::New( true );
603     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
604
605     Stage::GetCurrent().Add(dummy);
606     dummy.SetKeyInputFocus();
607
608     application.Render();
609     application.SendNotification();
610     application.Render();
611     application.SendNotification();
612
613     DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
614     Integration::KeyEvent keyEvent;
615     application.ProcessEvent(keyEvent);
616     DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
617
618     Stage::GetCurrent().Remove(dummy);
619   }
620
621   // Ensure full code coverage
622   {
623     DummyControl dummy = DummyControl::New();
624
625     Stage::GetCurrent().Add(dummy);
626     dummy.SetKeyInputFocus();
627
628     application.Render();
629     application.SendNotification();
630     application.Render();
631     application.SendNotification();
632
633     Integration::KeyEvent keyEvent;
634     application.ProcessEvent(keyEvent);
635
636     Stage::GetCurrent().Remove(dummy);
637   }
638   END_TEST;
639 }
640
641 int UtcDaliControlImplKeyInputFocusGained(void)
642 {
643   ToolkitTestApplication application;
644
645   {
646     DummyControl dummy = DummyControl::New( true );
647     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
648
649     Stage::GetCurrent().Add(dummy);
650
651     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
652
653     dummy.SetKeyInputFocus();
654
655     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
656
657     Stage::GetCurrent().Remove(dummy);
658   }
659
660   // Ensure full code coverage
661   {
662     DummyControl dummy = DummyControl::New();
663
664     Stage::GetCurrent().Add(dummy);
665     dummy.SetKeyInputFocus();
666     Stage::GetCurrent().Remove(dummy);
667   }
668   END_TEST;
669 }
670
671 int UtcDaliControlImplKeyInputFocusLost(void)
672 {
673   ToolkitTestApplication application;
674
675   {
676     DummyControl dummy = DummyControl::New( true );
677     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
678
679     Stage::GetCurrent().Add(dummy);
680
681     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
682
683     dummy.SetKeyInputFocus();
684     dummy.ClearKeyInputFocus();
685
686     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
687
688     Stage::GetCurrent().Remove(dummy);
689   }
690
691   // Ensure full code coverage
692   {
693     DummyControl dummy = DummyControl::New();
694
695     Stage::GetCurrent().Add(dummy);
696     dummy.SetKeyInputFocus();
697     dummy.ClearKeyInputFocus();
698
699     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
700
701     dummyImpl.OnAccessibilityValueChange( true );
702     dummyImpl.IsKeyboardNavigationSupported();
703     dummyImpl.IsKeyboardFocusGroup();
704
705     Stage::GetCurrent().Remove(dummy);
706   }
707   END_TEST;
708 }
709
710 int UtcDaliControlImplTypeRegistry(void)
711 {
712   ToolkitTestApplication application;
713
714   // Register Type
715   TypeInfo type;
716   type = TypeRegistry::Get().GetTypeInfo( "Control" );
717   DALI_TEST_CHECK( type );
718   BaseHandle handle = type.CreateInstance();
719   DALI_TEST_CHECK( handle );
720
721   // Check if it's a control
722   DALI_TEST_CHECK( Control::DownCast(handle) );
723   END_TEST;
724 }
725
726
727 ///////////////////////////////////////////////////////////////////////////////////////////////////
728 namespace
729 {
730 static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
731 {
732   return false;
733 }
734 }
735
736 int UtcDaliControlImplMouseWheelEvent(void)
737 {
738   ToolkitTestApplication application;
739
740   {
741     DummyControl dummy = DummyControl::New( true );
742     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
743
744     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
745     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
746     Stage::GetCurrent().Add(dummy);
747
748     dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
749
750     application.Render();
751     application.SendNotification();
752     application.Render();
753     application.SendNotification();
754
755     DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
756
757     // simulate a mouse wheel event
758     Vector2 screenCoordinates( 10.0f, 10.0f );
759     Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
760     application.ProcessEvent(event);
761     DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
762
763     Stage::GetCurrent().Remove(dummy);
764   }
765
766   // Ensure full code coverage
767   {
768     DummyControl dummy = DummyControl::New();
769
770     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
771     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
772     Stage::GetCurrent().Add(dummy);
773
774     dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
775
776     application.Render();
777     application.SendNotification();
778     application.Render();
779     application.SendNotification();
780
781     // simulate a mouse wheel event
782     Vector2 screenCoordinates( 20.0f, 20.0f );
783     Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
784     application.ProcessEvent(event);
785
786     Stage::GetCurrent().Remove(dummy);
787   }
788   END_TEST;
789 }