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