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