Changes after touch changes to Core
[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/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 #include <dali/integration-api/events/hover-event-integ.h>
36
37
38 #include "dummy-control.h"
39
40 using namespace Dali;
41 using namespace Dali::Toolkit;
42
43 void utc_dali_toolkit_control_impl_startup(void)
44 {
45   test_return_value = TET_UNDEF;
46 }
47
48 void utc_dali_toolkit_control_impl_cleanup(void)
49 {
50   test_return_value = TET_PASS;
51 }
52
53 int UtcDaliControlImplNew(void)
54 {
55   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
56
57   Control control;
58
59   DALI_TEST_CHECK( !Control::DownCast(control) );
60
61   control = Toolkit::Internal::Control::New();
62
63   DALI_TEST_CHECK( Control::DownCast(control) );
64   END_TEST;
65 }
66
67
68 int UtcDaliControlImplEnableGestureDetector(void)
69 {
70   ToolkitTestApplication application;
71
72   // Enable individually
73   {
74     DummyControl dummy = DummyControl::New();
75     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
76
77     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
78     dummyImpl.EnableGestureDetection(Gesture::Pinch);
79     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
80
81     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
82     dummyImpl.EnableGestureDetection(Gesture::Pan);
83     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
84
85     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
86     dummyImpl.EnableGestureDetection(Gesture::Tap);
87     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
88
89     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
90     dummyImpl.EnableGestureDetection(Gesture::LongPress);
91     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
92   }
93
94   // Enable All
95   {
96     DummyControl dummy = DummyControl::New();
97     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
98
99     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
100     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
101     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
102     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
103
104     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
105
106     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
107     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
108     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
109     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
110
111     // Enable when already enabled
112
113     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
114
115     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
116     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
117     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
118     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
119   }
120   END_TEST;
121 }
122
123 int UtcDaliControlImplDisableGestureDetector(void)
124 {
125   ToolkitTestApplication application;
126
127   // Disable individually
128   {
129     DummyControl dummy = DummyControl::New();
130     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
131
132     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
133
134     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
135     dummyImpl.DisableGestureDetection(Gesture::Pinch);
136     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
137
138     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
139     dummyImpl.DisableGestureDetection(Gesture::Pan);
140     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
141
142     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
143     dummyImpl.DisableGestureDetection(Gesture::Tap);
144     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
145
146     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
147     dummyImpl.DisableGestureDetection(Gesture::LongPress);
148     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
149   }
150
151   // Disable All
152   {
153     DummyControl dummy = DummyControl::New();
154     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
155
156     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
157
158     DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
159     DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
160     DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
161     DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
162
163     dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
164
165     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
166     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
167     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
168     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
169   }
170
171   // Disable When not enabled
172   {
173     DummyControl dummy = DummyControl::New();
174     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
175
176     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
177     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
178     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
179     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
180
181     dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
182
183     DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
184     DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
185     DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
186     DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
187   }
188
189   // Ensure control is detached if gesture detector is not deleted
190   {
191     DummyControl dummy = DummyControl::New();
192     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
193
194     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
195
196     PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
197     PanGestureDetector pan   = dummyImpl.GetPanGestureDetector();
198     TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
199     LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
200
201     DALI_TEST_EQUALS( 0 == pinch.GetAttachedActorCount(), false, TEST_LOCATION );
202     DALI_TEST_EQUALS( 0 == pan.GetAttachedActorCount(), false, TEST_LOCATION );
203     DALI_TEST_EQUALS( 0 == tap.GetAttachedActorCount(), false, TEST_LOCATION );
204     DALI_TEST_EQUALS( 0 == longPress.GetAttachedActorCount(), false, TEST_LOCATION );
205
206     dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
207
208     DALI_TEST_EQUALS( 0 == pinch.GetAttachedActorCount(), true, TEST_LOCATION );
209     DALI_TEST_EQUALS( 0 == pan.GetAttachedActorCount(), true, TEST_LOCATION );
210     DALI_TEST_EQUALS( 0 == tap.GetAttachedActorCount(), true, TEST_LOCATION );
211     DALI_TEST_EQUALS( 0 == longPress.GetAttachedActorCount(), true, TEST_LOCATION );
212   }
213   END_TEST;
214 }
215
216 int UtcDaliControlImplOnGestureMethods(void)
217 {
218   ToolkitTestApplication application;
219
220   // Check gesture actually happens
221   {
222     DummyControl dummy = DummyControl::New(true);
223     dummy.SetSize( Vector2(100.0f, 100.0f ) );
224
225     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
226     Stage::GetCurrent().Add(dummy);
227
228     // Render and notify a couple of times
229     application.SendNotification();
230     application.Render();
231     application.SendNotification();
232     application.Render();
233
234     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
235     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
236
237     DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
238     Integration::PinchGestureEvent pinch(Gesture::Started);
239     pinch.scale = 10.0f;
240     pinch.speed = 50.0f;
241     pinch.centerPoint = Vector2(20.0f, 20.0f);
242     application.ProcessEvent(pinch);
243     DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
244
245     DALI_TEST_CHECK( dummyImpl.panCalled == false );
246     Integration::PanGestureEvent pan(Gesture::Possible);
247     pan.previousPosition = Vector2(10.0f, 20.0f);
248     pan.currentPosition = Vector2(20.0f, 20.0f);
249     pan.timeDelta = 10;
250     pan.numberOfTouches = 1u;
251     application.ProcessEvent(pan);
252     pan.state = Gesture::Started;
253     application.ProcessEvent(pan);
254     DALI_TEST_CHECK( dummyImpl.panCalled == true );
255
256     DALI_TEST_CHECK( dummyImpl.tapCalled == false );
257     Integration::TapGestureEvent tap(Gesture::Possible);
258     tap.numberOfTaps = 1u;
259     tap.numberOfTouches = 1u;
260     tap.point = Vector2(50.0f, 50.0f);
261     application.ProcessEvent(tap);
262     tap.state = Gesture::Started;
263     application.ProcessEvent(tap);
264     DALI_TEST_CHECK( dummyImpl.tapCalled == true );
265
266     DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
267     Integration::LongPressGestureEvent longPress(Gesture::Possible);
268     longPress.numberOfTouches = 1u;
269     longPress.point = Vector2(50.0f, 50.0f);
270     application.ProcessEvent(longPress);
271     longPress.state = Gesture::Started;
272     application.ProcessEvent(longPress);
273     DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
274     longPress.state = Gesture::Finished;
275     application.ProcessEvent(longPress);
276
277     Stage::GetCurrent().Remove(dummy);
278   }
279
280   // Ensure full code coverage
281   {
282     DummyControl dummy = DummyControl::New();
283     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
284
285     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
286     Stage::GetCurrent().Add(dummy);
287
288     // Render and notify a couple of times
289     application.SendNotification();
290     application.Render();
291     application.SendNotification();
292     application.Render();
293
294     DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
295     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
296
297     DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
298     Integration::PinchGestureEvent pinch(Gesture::Started);
299     pinch.scale = 10.0f;
300     pinch.speed = 50.0f;
301     pinch.centerPoint = Vector2(20.0f, 20.0f);
302     application.ProcessEvent(pinch);
303
304     // Render and notify a couple of times
305     application.SendNotification();
306     application.Render();
307     application.SendNotification();
308     application.Render();
309     DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
310
311     Integration::PanGestureEvent pan(Gesture::Possible);
312     pan.previousPosition = Vector2(10.0f, 20.0f);
313     pan.currentPosition = Vector2(20.0f, 20.0f);
314     pan.timeDelta = 10;
315     pan.numberOfTouches = 1u;
316     application.ProcessEvent(pan);
317     pan.state = Gesture::Started;
318     application.ProcessEvent(pan);
319
320     Integration::TapGestureEvent tap(Gesture::Possible);
321     tap.numberOfTaps = 1u;
322     tap.numberOfTouches = 1u;
323     tap.point = Vector2(50.0f, 50.0f);
324     application.ProcessEvent(tap);
325     tap.state = Gesture::Started;
326     application.ProcessEvent(tap);
327
328     Integration::LongPressGestureEvent longPress(Gesture::Possible);
329     longPress.numberOfTouches = 1u;
330     longPress.point = Vector2(50.0f, 50.0f);
331     application.ProcessEvent(longPress);
332     longPress.state = Gesture::Started;
333     application.ProcessEvent(longPress);
334     longPress.state = Gesture::Finished;
335     application.ProcessEvent(longPress);
336
337     Stage::GetCurrent().Remove(dummy);
338   }
339   END_TEST;
340 }
341
342 int UtcDaliControlImplChildAddAndRemove(void)
343 {
344   ToolkitTestApplication application;
345
346   {
347     DummyControl dummy = DummyControl::New( true );
348     Stage::GetCurrent().Add(dummy);
349     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
350
351     application.Render();
352     application.SendNotification();
353
354     DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
355     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
356     Actor actor = Actor::New();
357     dummy.Add(actor);
358     DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
359     DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
360
361     application.Render();
362     application.SendNotification();
363
364     DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
365     dummy.Remove( actor );
366     DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
367     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
368
369     application.Render();
370     application.SendNotification();
371
372     Stage::GetCurrent().Remove(dummy);
373   }
374
375   // Ensure full code coverage
376   {
377     DummyControl dummy = DummyControl::New();
378     Stage::GetCurrent().Add(dummy);
379
380     application.Render();
381     application.SendNotification();
382
383     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
384     Actor actor = Actor::New();
385     dummy.Add(actor);
386     DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
387
388     application.Render();
389     application.SendNotification();
390
391     dummy.Remove( actor );
392     DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
393
394     application.Render();
395     application.SendNotification();
396
397     Stage::GetCurrent().Remove(dummy);
398   }
399   END_TEST;
400 }
401
402 int UtcDaliControlImplStageConnection(void)
403 {
404   ToolkitTestApplication application;
405
406   {
407     DummyControl dummy = DummyControl::New( true );
408     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
409
410     DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
411     Stage::GetCurrent().Add(dummy);
412     application.Render();
413     application.SendNotification();
414     DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
415
416     DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
417     Stage::GetCurrent().Remove(dummy);
418     application.Render();
419     application.SendNotification();
420     DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
421   }
422
423   // Ensure full code coverage
424   {
425     unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
426     DummyControl dummy = DummyControl::New();
427
428     DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
429     Stage::GetCurrent().Add(dummy);
430     application.Render();
431     application.SendNotification();
432     DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
433
434     Stage::GetCurrent().Remove(dummy);
435     application.Render();
436     application.SendNotification();
437     DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
438   }
439   END_TEST;
440 }
441
442 int UtcDaliControlImplSizeSetP(void)
443 {
444   ToolkitTestApplication application;
445
446   {
447     DummyControl dummy = DummyControl::New( true );
448     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
449
450     Stage::GetCurrent().Add(dummy);
451     application.Render();
452     application.SendNotification();
453
454     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size not set, no onSizeSet called
455     Vector2 size(100.0f, 200.0f);
456     dummy.SetSize( size );
457
458     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size is going to get negotiated, no onSizeSet called
459
460     application.SendNotification();
461     application.Render();
462
463     DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
464     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
465
466     Stage::GetCurrent().Remove(dummy);
467   }
468
469   END_TEST;
470 }
471
472 int UtcDaliControlImplSizeSet2P(void)
473 {
474   ToolkitTestApplication application;
475
476   {
477     DummyControl dummy = DummyControl::New();
478     Stage::GetCurrent().Add(dummy);
479
480     Vector2 size(100.0f, 200.0f);
481     DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
482
483     application.SendNotification();
484     application.Render();
485
486     dummy.SetSize(size);
487
488     application.SendNotification();
489     application.Render();
490
491     DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
492
493     Stage::GetCurrent().Remove(dummy);
494   }
495   END_TEST;
496 }
497
498
499 int UtcDaliControlImplSizeAnimation(void)
500 {
501   ToolkitTestApplication application;
502
503   {
504     DummyControl dummy = DummyControl::New( true );
505     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
506
507     Stage::GetCurrent().Add(dummy);
508
509     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
510     Animation animation = Animation::New(1.0f);
511     animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
512     animation.Play();
513
514     application.Render();
515     application.SendNotification();
516     application.Render();
517     application.SendNotification();
518
519     DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
520
521     Stage::GetCurrent().Remove(dummy);
522   }
523
524   // Ensure full code coverage
525   {
526     DummyControl dummy = DummyControl::New();
527
528     Stage::GetCurrent().Add(dummy);
529
530     Animation animation = Animation::New(1.0f);
531     animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
532     animation.Play();
533
534     application.Render();
535     application.SendNotification();
536     application.Render();
537     application.SendNotification();
538
539     Stage::GetCurrent().Remove(dummy);
540   }
541   END_TEST;
542 }
543
544 ///////////////////////////////////////////////////////////////////////////////////////////////////
545
546 int UtcDaliControlImplTouchEvent(void)
547 {
548   ToolkitTestApplication application;
549
550   {
551     DummyControl dummy = DummyControl::New( true );
552     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
553
554     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
555     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
556     Stage::GetCurrent().Add(dummy);
557
558     application.Render();
559     application.SendNotification();
560     application.Render();
561     application.SendNotification();
562
563     DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
564     Integration::TouchEvent touchEvent(1);
565     Integration::Point point;
566     point.SetDeviceId( 1 );
567     point.SetState( PointState::DOWN );
568     point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
569     touchEvent.AddPoint(point);
570     application.ProcessEvent(touchEvent);
571     DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
572
573     Stage::GetCurrent().Remove(dummy);
574   }
575
576   // Ensure full code coverage
577   {
578     DummyControl dummy = DummyControl::New();
579
580     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
581     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
582     Stage::GetCurrent().Add(dummy);
583
584     application.Render();
585     application.SendNotification();
586     application.Render();
587     application.SendNotification();
588
589     Integration::TouchEvent touchEvent(1);
590     Integration::Point point;
591     point.SetDeviceId( 1 );
592     point.SetState( PointState::DOWN );
593     point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
594     touchEvent.AddPoint(point);
595     application.ProcessEvent(touchEvent);
596
597     Stage::GetCurrent().Remove(dummy);
598   }
599   END_TEST;
600 }
601
602 int UtcDaliControlImplHoverEvent(void)
603 {
604   ToolkitTestApplication application;
605
606   {
607     DummyControl dummy = DummyControl::New( true );
608     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
609
610     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
611     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
612     Stage::GetCurrent().Add(dummy);
613
614     application.Render();
615     application.SendNotification();
616     application.Render();
617     application.SendNotification();
618
619     DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, false, TEST_LOCATION );
620     Integration::HoverEvent event(1);
621     Integration::Point point;
622     point.SetDeviceId( 1 );
623     point.SetState( PointState::MOTION );
624     point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
625     event.AddPoint(point);
626     application.ProcessEvent( event );
627     DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, true, TEST_LOCATION );
628
629     Stage::GetCurrent().Remove(dummy);
630   }
631
632   // Ensure full code coverage
633   {
634     DummyControl dummy = DummyControl::New();
635
636     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
637     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
638     Stage::GetCurrent().Add(dummy);
639
640     application.Render();
641     application.SendNotification();
642     application.Render();
643     application.SendNotification();
644
645     Integration::HoverEvent event(1);
646     Integration::Point point;
647     point.SetDeviceId( 1 );
648     point.SetState( PointState::MOTION );
649     point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
650     event.AddPoint(point);
651     application.ProcessEvent( event );
652
653     Stage::GetCurrent().Remove(dummy);
654   }
655   END_TEST;
656 }
657
658 ///////////////////////////////////////////////////////////////////////////////////////////////////
659
660
661 int UtcDaliControlImplKeyEvent(void)
662 {
663   ToolkitTestApplication application;
664
665   {
666     DummyControl dummy = DummyControl::New( true );
667     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
668
669     Stage::GetCurrent().Add(dummy);
670     dummy.SetKeyInputFocus();
671
672     application.Render();
673     application.SendNotification();
674     application.Render();
675     application.SendNotification();
676
677     DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
678     Integration::KeyEvent keyEvent;
679     application.ProcessEvent(keyEvent);
680     DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
681
682     Stage::GetCurrent().Remove(dummy);
683   }
684
685   // Ensure full code coverage
686   {
687     DummyControl dummy = DummyControl::New();
688
689     Stage::GetCurrent().Add(dummy);
690     dummy.SetKeyInputFocus();
691
692     application.Render();
693     application.SendNotification();
694     application.Render();
695     application.SendNotification();
696
697     Integration::KeyEvent keyEvent;
698     application.ProcessEvent(keyEvent);
699
700     Stage::GetCurrent().Remove(dummy);
701   }
702   END_TEST;
703 }
704
705 int UtcDaliControlImplKeyInputFocusGained(void)
706 {
707   ToolkitTestApplication application;
708
709   {
710     DummyControl dummy = DummyControl::New( true );
711     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
712
713     Stage::GetCurrent().Add(dummy);
714
715     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
716
717     dummy.SetKeyInputFocus();
718
719     DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
720
721     Stage::GetCurrent().Remove(dummy);
722   }
723
724   // Ensure full code coverage
725   {
726     DummyControl dummy = DummyControl::New();
727
728     Stage::GetCurrent().Add(dummy);
729     dummy.SetKeyInputFocus();
730     Stage::GetCurrent().Remove(dummy);
731   }
732   END_TEST;
733 }
734
735 int UtcDaliControlImplKeyInputFocusLost(void)
736 {
737   ToolkitTestApplication application;
738
739   {
740     DummyControl dummy = DummyControl::New( true );
741     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
742
743     Stage::GetCurrent().Add(dummy);
744
745     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
746
747     dummy.SetKeyInputFocus();
748     dummy.ClearKeyInputFocus();
749
750     DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
751
752     Stage::GetCurrent().Remove(dummy);
753   }
754
755   // Ensure full code coverage
756   {
757     DummyControl dummy = DummyControl::New();
758
759     Stage::GetCurrent().Add(dummy);
760     dummy.SetKeyInputFocus();
761     dummy.ClearKeyInputFocus();
762
763     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
764
765     dummyImpl.OnAccessibilityValueChange( true );
766     dummyImpl.IsKeyboardNavigationSupported();
767     dummyImpl.IsKeyboardFocusGroup();
768
769     Stage::GetCurrent().Remove(dummy);
770   }
771   END_TEST;
772 }
773
774 int UtcDaliControlImplTypeRegistry(void)
775 {
776   ToolkitTestApplication application;
777
778   // Register Type
779   TypeInfo type;
780   type = TypeRegistry::Get().GetTypeInfo( "Control" );
781   DALI_TEST_CHECK( type );
782   BaseHandle handle = type.CreateInstance();
783   DALI_TEST_CHECK( handle );
784
785   // Check if it's a control
786   DALI_TEST_CHECK( Control::DownCast(handle) );
787   END_TEST;
788 }
789
790
791 ///////////////////////////////////////////////////////////////////////////////////////////////////
792 namespace
793 {
794 static bool WheelEventCallback(Actor actor, const WheelEvent& event)
795 {
796   return false;
797 }
798 }
799
800 int UtcDaliControlImplWheelEvent(void)
801 {
802   ToolkitTestApplication application;
803
804   {
805     DummyControl dummy = DummyControl::New( true );
806     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
807
808     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
809     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
810     Stage::GetCurrent().Add(dummy);
811
812     dummy.WheelEventSignal().Connect(&WheelEventCallback);
813
814     application.Render();
815     application.SendNotification();
816     application.Render();
817     application.SendNotification();
818
819     DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, false, TEST_LOCATION );
820
821     // simulate a wheel event
822     Vector2 screenCoordinates( 10.0f, 10.0f );
823     Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
824     application.ProcessEvent( event );
825     DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, true, TEST_LOCATION );
826
827     Stage::GetCurrent().Remove(dummy);
828   }
829
830   // Ensure full code coverage
831   {
832     DummyControl dummy = DummyControl::New();
833
834     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
835     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
836     Stage::GetCurrent().Add(dummy);
837
838     dummy.WheelEventSignal().Connect(&WheelEventCallback);
839
840     application.Render();
841     application.SendNotification();
842     application.Render();
843     application.SendNotification();
844
845     // simulate a wheel event
846     Vector2 screenCoordinates( 20.0f, 20.0f );
847     Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
848     application.ProcessEvent( event );
849
850     Stage::GetCurrent().Remove(dummy);
851   }
852   END_TEST;
853 }
854
855 int UtcDaliControlImplSetStyleName(void)
856 {
857   ToolkitTestApplication application;
858
859   {
860     DummyControl dummy = DummyControl::New( true );
861
862     dummy.SetSize( Vector2( 100.0f, 100.0f ) );
863     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
864     Stage::GetCurrent().Add(dummy);
865
866     dummy.SetStyleName("TestStyle");
867
868     DALI_TEST_CHECK( dummy.GetStyleName() == "TestStyle" );
869
870     Stage::GetCurrent().Remove(dummy);
871   }
872   END_TEST;
873 }
874
875 int UtcDaliControlImplOnStyleChangeN(void)
876 {
877   ToolkitTestApplication application;
878   Control dummy = Control::New();
879   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
880
881   // test that style manager is being used, passing an empty handle does nothing but does not crash either
882   Dali::Toolkit::StyleManager styleManager;
883   controlImpl.OnStyleChange( styleManager, StyleChange::THEME_CHANGE );
884   // no crash so test passes
885   tet_result(TET_PASS);
886
887   END_TEST;
888 }
889
890
891 int UtcDaliControlImplOnAccessibilityPanP(void)
892 {
893   ToolkitTestApplication application;
894   Control dummy = Control::New();
895   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
896
897   PanGesture pan;
898   DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityPan( pan ), TEST_LOCATION );
899
900   END_TEST;
901 }
902
903 int UtcDaliControlImplOnAccessibilityTouchP(void)
904 {
905   ToolkitTestApplication application;
906   Control dummy = Control::New();
907   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
908   TouchEvent touch;
909   DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityTouch( touch ), TEST_LOCATION );
910
911   END_TEST;
912 }
913
914 int UtcDaliControlImplOnAccessibilityActivatedP(void)
915 {
916   ToolkitTestApplication application;
917
918   Control dummy = Control::New();
919   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
920   DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityActivated(), TEST_LOCATION );
921
922   // Invoke the control's activate action
923   TypeInfo type = TypeRegistry::Get().GetTypeInfo( "Control" );
924   DALI_TEST_CHECK( type );
925
926   BaseHandle handle = type.CreateInstance();
927   DALI_TEST_CHECK( handle );
928
929   Property::Map attributes;
930   DALI_TEST_EQUALS( false, handle.DoAction("accessibilityActivated",  attributes), TEST_LOCATION );
931
932   END_TEST;
933 }
934
935 int UtcDaliControlImplGetNextKeyboardFocusableActorP(void)
936 {
937   ToolkitTestApplication application;
938   Control dummy = Control::New();
939   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
940
941   Actor currentFocusedActor;
942   Actor result = controlImpl.GetNextKeyboardFocusableActor( currentFocusedActor, Control::KeyboardFocus::LEFT, false );
943
944   DALI_TEST_EQUALS( result, currentFocusedActor, TEST_LOCATION );
945
946   END_TEST;
947 }