Add the logical key to Integration::KeyEvent
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Control.cpp
1 /*
2  * Copyright (c) 2017 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
25 #include <dali.h>
26 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali-toolkit/public-api/align-enumerations.h>
28 #include <dali-toolkit/devel-api/controls/control-devel.h>
29 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
30 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
31
32
33 #include <toolkit-event-thread-callback.h>
34
35 #include "dummy-control.h"
36
37 using namespace Dali;
38 using namespace Dali::Toolkit;
39
40 void utc_dali_toolkit_control_startup(void)
41 {
42   test_return_value = TET_UNDEF;
43 }
44
45 void utc_dali_toolkit_control_cleanup(void)
46 {
47   test_return_value = TET_PASS;
48 }
49
50 ///////////////////////////////////////////////////////////////////////////////////////////////////
51
52 namespace
53 {
54
55 bool gObjectCreatedCallBackCalled;
56
57 void TestCallback(BaseHandle handle)
58 {
59   gObjectCreatedCallBackCalled = true;
60 }
61
62 void TestVoidCallback()
63 {
64 }
65
66 static bool gKeyInputFocusCallBackCalled;
67
68 static void TestKeyInputFocusCallback( Control control )
69 {
70   tet_infoline(" TestKeyInputFocusCallback");
71
72   gKeyInputFocusCallBackCalled = true;
73 }
74
75 const char* TEST_LARGE_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR "/tbcol.png";
76 const char* TEST_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR "/gallery-small-1.jpg";
77
78 Vector4 GetControlBackgroundColor( Control& control )
79 {
80   Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
81   Property::Map* resultMap = propValue.GetMap();
82   DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
83
84   Vector4 color;
85   resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get( color );
86
87   return color;
88 }
89
90 } // namespace
91
92 ///////////////////////////////////////////////////////////////////////////////////////////////////
93
94
95 int UtcDaliControlConstructor(void)
96 {
97   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
98
99   DummyControl dummy;
100
101   DALI_TEST_CHECK( !Control::DownCast(dummy) );
102
103   dummy = DummyControl::New();
104
105   DALI_TEST_CHECK( Control::DownCast(dummy) );
106   END_TEST;
107 }
108
109 int UtcDaliControlNew(void)
110 {
111   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
112
113   Control control;
114
115   DALI_TEST_CHECK( !Control::DownCast(control) );
116
117   control = Control::New();
118
119   DALI_TEST_CHECK( Control::DownCast(control) );
120   END_TEST;
121 }
122
123
124 int UtcDaliControlRegister(void)
125 {
126   ToolkitTestApplication application;
127
128   // Ensure the object is registered after creation
129   ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
130   DALI_TEST_CHECK( registry );
131
132   gObjectCreatedCallBackCalled = false;
133   registry.ObjectCreatedSignal().Connect( &TestCallback );
134   {
135     Alignment alignment = Alignment::New();
136   }
137   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
138   END_TEST;
139 }
140
141 int UtcDaliControlCopyAndAssignment(void)
142 {
143   ToolkitTestApplication application;
144
145   DummyControl control = DummyControl::New();
146   Control emptyControl;
147
148   Control controlCopy( control );
149   DALI_TEST_CHECK( control == controlCopy );
150
151   Control emptyControlCopy( emptyControl );
152   DALI_TEST_CHECK( emptyControl == emptyControlCopy );
153
154   Control controlEquals;
155   controlEquals = control;
156   DALI_TEST_CHECK( control == controlEquals );
157
158   Control emptyControlEquals;
159   emptyControlEquals = emptyControl;
160   DALI_TEST_CHECK( emptyControl == emptyControlEquals );
161
162   // Self assignment
163   control = control;
164   DALI_TEST_CHECK( control == controlCopy );
165   END_TEST;
166 }
167
168 int UtcDaliControlDownCast(void)
169 {
170   ToolkitTestApplication application;
171
172   DummyControl control;
173
174   DALI_TEST_CHECK( !Control::DownCast( control ) );
175
176   control = DummyControl::New();
177
178   DALI_TEST_CHECK( Control::DownCast( control ) );
179
180   Actor actor;
181
182   DALI_TEST_CHECK( !Control::DownCast( actor ) );
183
184   actor = Actor::New();
185
186   DALI_TEST_CHECK( !Control::DownCast( actor ) );
187   END_TEST;
188 }
189
190 int UtcDaliControlDownCastTemplate(void)
191 {
192   ToolkitTestApplication application;
193
194   DummyControl control;
195
196   DALI_TEST_CHECK( !DummyControl::DownCast( control ));
197
198   control = DummyControl::New();
199
200   DALI_TEST_CHECK( DummyControl::DownCast( control ) );
201
202   Actor actor;
203
204   DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
205
206   actor = Actor::New();
207
208   DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
209   END_TEST;
210 }
211
212 int UtcDaliControlNavigationProperties(void)
213 {
214   ToolkitTestApplication application;
215
216   Control control = Control::New();
217   Stage::GetCurrent().Add( control );
218
219   DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
220   DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
221   DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
222   DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
223
224   control.SetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 1 );
225   DALI_TEST_EQUALS( 1, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
226   control.SetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, 2 );
227   DALI_TEST_EQUALS( 2, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
228   control.SetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, 3 );
229   DALI_TEST_EQUALS( 3, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
230   control.SetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 4 );
231   DALI_TEST_EQUALS( 4, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
232
233   control.SetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 15 );
234   DALI_TEST_EQUALS( 15, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
235   control.SetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, 16 );
236   DALI_TEST_EQUALS( 16, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
237   control.SetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, 17 );
238   DALI_TEST_EQUALS( 17, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
239   control.SetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 18 );
240   DALI_TEST_EQUALS( 18, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
241
242   END_TEST;
243 }
244
245 int UtcDaliControlKeyInputFocus(void)
246 {
247   ToolkitTestApplication application;
248   Stage stage = Stage::GetCurrent();
249
250   DummyControl control;
251
252   PushButton pushButton1 = PushButton::New();
253   stage.Add( pushButton1 );
254
255   pushButton1.SetKeyInputFocus();
256   DALI_TEST_CHECK( pushButton1.HasKeyInputFocus() );
257
258   pushButton1.ClearKeyInputFocus();
259   DALI_TEST_CHECK( !pushButton1.HasKeyInputFocus() );
260   END_TEST;
261 }
262
263 int UtcDaliControlGetImplementationN(void)
264 {
265   ToolkitTestApplication application;
266   DummyControl control;
267
268   // Get Empty
269   {
270     try
271     {
272       Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
273       (void)controlImpl; // Avoid unused warning
274       tet_result(TET_FAIL);
275     }
276     catch (DaliException &exception)
277     {
278       tet_result(TET_PASS);
279     }
280   }
281   END_TEST;
282 }
283
284 int UtcDaliControlGetImplementationConstN(void)
285 {
286   ToolkitTestApplication application;
287   DummyControl control;
288
289   // Get Const Empty
290   {
291     try
292     {
293       const DummyControl constControl(control);
294       const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
295       (void)controlImpl; // Avoid unused warning
296       tet_result(TET_FAIL);
297     }
298     catch (DaliException &exception)
299     {
300       tet_result(TET_PASS);
301     }
302   }
303   END_TEST;
304 }
305
306 int UtcDaliControlGetImplementationP(void)
307 {
308   ToolkitTestApplication application;
309   DummyControl control = DummyControl::New();
310
311   // Get
312   {
313     try
314     {
315       Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
316       (void)controlImpl; // Avoid unused warning
317       tet_result(TET_PASS);
318     }
319     catch (DaliException &exception)
320     {
321       tet_result(TET_FAIL);
322     }
323   }
324   END_TEST;
325 }
326
327 int UtcDaliControlGetImplementationConstP(void)
328 {
329   ToolkitTestApplication application;
330   DummyControl control = DummyControl::New();
331   // Get Const
332   {
333     try
334     {
335       const DummyControl constControl(control);
336       const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
337       (void)controlImpl; // Avoid unused warning
338       tet_result(TET_PASS);
339     }
340     catch (DaliException &exception)
341     {
342       tet_result(TET_FAIL);
343     }
344   }
345   END_TEST;
346 }
347
348 int UtcDaliControlSignalConnectDisconnect(void)
349 {
350   ToolkitTestApplication application;
351
352   {
353     DummyControl dummy = DummyControlImpl::New();
354
355     Actor actor = Actor::New();
356     DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
357     Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
358     DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
359
360     if( dummyImpl == NULL )
361     {
362       tet_result( TET_FAIL );
363       END_TEST;
364     }
365
366     actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
367     DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
368     DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
369
370     Stage::GetCurrent().Add( actor );
371     DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
372
373     dummyImpl->mCustomSlot1Called = false;
374     actor.OnStageSignal().Disconnect( dummyImpl, &DummyControlImpl::CustomSlot1 );
375     DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
376     Stage::GetCurrent().Remove( actor );
377     Stage::GetCurrent().Add( actor );
378     DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
379   }
380   END_TEST;
381 }
382
383 int UtcDaliControlSignalAutomaticDisconnect(void)
384 {
385   ToolkitTestApplication application;
386
387   Actor actor = Actor::New();
388
389   {
390     DummyControl dummy = DummyControlImpl::New();
391     Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
392     DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
393
394     if( dummyImpl == NULL )
395     {
396       tet_result( TET_FAIL );
397       END_TEST;
398     }
399
400     actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
401     DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
402     DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
403
404     Stage::GetCurrent().Add( actor );
405     DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
406     Stage::GetCurrent().Remove( actor );
407   }
408   // dummyControl automatically disconnects
409
410   DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
411
412   const Vector3 ignoredSize( 20, 20, 0 );
413   actor.SetSize( ignoredSize );
414   END_TEST;
415 }
416
417 int UtcDaliControlTestParameters(void)
418 {
419   ToolkitTestApplication application;
420   DummyControl test = DummyControl::New();
421
422   test.SetSize( 0.7f, 0.7f, 0.7f );
423
424   Stage::GetCurrent().Add( test );
425
426   application.SendNotification();
427   application.Render();
428
429   float width = 640.0f;
430   float height = test.GetHeightForWidth( width );
431   DALI_TEST_EQUALS( 640.0f, height, TEST_LOCATION );
432   DALI_TEST_EQUALS( 640.0f, test.GetWidthForHeight( height ), TEST_LOCATION );
433
434   test.KeyEventSignal();
435
436   // Provide coverage for pointer destructor
437   Control* testControlPtr = new Control;
438   DALI_TEST_CHECK( testControlPtr );
439   delete testControlPtr;
440   END_TEST;
441 }
442
443 int UtcDaliControlBackgroundColor(void)
444 {
445   ToolkitTestApplication application;
446   Control control = Control::New();
447
448   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
449
450   control.SetBackgroundColor( Color::RED );
451
452   Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
453   Property::Map* resultMap = propValue.GetMap();
454   DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
455   DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>() == Visual::COLOR );
456   DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
457   DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::RED );
458
459   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
460
461   control.SetBackgroundColor( Color::YELLOW );
462
463   propValue = control.GetProperty( Control::Property::BACKGROUND );
464   resultMap = propValue.GetMap();
465   DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
466   DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::YELLOW );
467
468   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION );
469
470   END_TEST;
471 }
472
473 int UtcDaliControlBackgroundColorRendererCount(void)
474 {
475   tet_infoline( "Test ensures we only create renderers when non-transparent color is requested or if we our clipping-mode is set to CLIP_CHILDREN" );
476
477   ToolkitTestApplication application;
478   Control control = Control::New();
479   Stage::GetCurrent().Add( control );
480
481   tet_infoline( "Set transparent, no renderers should be created" );
482   control.SetBackgroundColor( Color::TRANSPARENT );
483   application.SendNotification();
484   application.Render();
485   DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
486
487   tet_infoline( "Set transparent alpha with positive RGB values, no renderers should be created, but returned color should reflect what we set" );
488   const Vector4 alphaZero( 1.0f, 0.5f, 0.25f, 0.0f );
489   control.SetBackgroundColor( alphaZero );
490   application.SendNotification();
491   application.Render();
492   DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
493   DALI_TEST_EQUALS( GetControlBackgroundColor( control ), alphaZero, TEST_LOCATION );
494
495   tet_infoline( "Set semi transparent alpha with positive RGB values, 1 renderer should be created, but returned color should reflect what we set" );
496   const Vector4 semiTransparent( 1.0f, 0.75f, 0.5f, 0.5f );
497   control.SetBackgroundColor( semiTransparent );
498   application.SendNotification();
499   application.Render();
500   DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
501   DALI_TEST_EQUALS( GetControlBackgroundColor( control ), semiTransparent, TEST_LOCATION );
502
503   tet_infoline( "Set transparent, ensure no renderers are created" );
504   control.SetBackgroundColor( Color::TRANSPARENT );
505   application.SendNotification();
506   application.Render();
507   DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
508   DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
509
510   tet_infoline( "Set control to clip its children, a renderer should be created which will be transparent" );
511   control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
512   application.SendNotification();
513   application.Render();
514   DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
515   DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
516
517   tet_infoline( "Set a color, only 1 renderer should exist" );
518   control.SetBackgroundColor( Color::RED );
519   application.SendNotification();
520   application.Render();
521   DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
522   DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::RED, TEST_LOCATION );
523
524   tet_infoline( "Clear the background, no renderers" );
525   control.ClearBackground();
526   application.SendNotification();
527   application.Render();
528   DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
529
530   tet_infoline( "Set control to clip its children again, a renderer should be created which will be transparent" );
531   control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
532   application.SendNotification();
533   application.Render();
534   DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
535   DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
536
537   tet_infoline( "Disable clipping, no renderers" );
538   control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
539   application.SendNotification();
540   application.Render();
541   DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
542   DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
543
544   END_TEST;
545 }
546
547 int UtcDaliControlBackgroundImage(void)
548 {
549   ToolkitTestApplication application;
550   Control control = Control::New();
551
552   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
553
554   Image image = ResourceImage::New("TestImage");
555   control.SetBackgroundImage( image );
556
557   Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
558   Property::Map* resultMap = propValue.GetMap();
559   DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
560   DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>() == Visual::IMAGE );
561   DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
562   DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage" );
563
564   image = ResourceImage::New("TestImage2");
565   control.SetBackgroundImage( image );
566
567   propValue = control.GetProperty( Control::Property::BACKGROUND );
568   resultMap = propValue.GetMap();
569   DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
570   DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage2" );
571
572   END_TEST;
573 }
574
575 int UtcDaliControlBackgroundProperties(void)
576 {
577   ToolkitTestApplication application;
578   Control control = Control::New();
579
580   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
581   DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
582
583   Property::Map imageMap;
584   imageMap[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE;
585   imageMap[ ImageVisual::Property::URL ] = "TestImage";
586   control.SetProperty( Control::Property::BACKGROUND, imageMap );
587   Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
588   Property::Map* resultMap = propValue.GetMap();
589   DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
590   DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(),(int)Visual::IMAGE, TEST_LOCATION );
591   DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
592   DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "TestImage", TEST_LOCATION );
593
594   Property::Map rendererMap;
595   rendererMap[Visual::Property::TYPE] = Visual::COLOR;
596   rendererMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
597   control.SetProperty( Control::Property::BACKGROUND, rendererMap );
598   propValue = control.GetProperty( Control::Property::BACKGROUND );
599   resultMap = propValue.GetMap();
600   DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
601   DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
602   DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
603   DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::CYAN, TEST_LOCATION );
604
605   Property::Map emptyMap;
606   control.SetProperty( Control::Property::BACKGROUND, emptyMap );
607   DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
608
609   // set as URL
610   control.SetProperty( Control::Property::BACKGROUND, "Foobar.png" );
611   propValue = control.GetProperty( Control::Property::BACKGROUND );
612   resultMap = propValue.GetMap();
613   DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
614   DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "Foobar.png", TEST_LOCATION );
615
616   // set as Color
617   control.SetProperty( Control::Property::BACKGROUND, Color::RED );
618   propValue = control.GetProperty( Control::Property::BACKGROUND );
619   resultMap = propValue.GetMap();
620   DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
621   DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::RED, TEST_LOCATION );
622
623   // Deprecated Properties
624   control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW );
625   DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW, TEST_LOCATION );
626   DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), control.GetBackgroundColor(), TEST_LOCATION );
627
628   control.ClearBackground();
629
630   Property::Map deprecatedImageMap;
631   deprecatedImageMap[ "filename" ] = "TestImage";
632   control.SetProperty( Control::Property::BACKGROUND_IMAGE, deprecatedImageMap );
633   propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
634   resultMap = propValue.GetMap();
635   DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >(), "TestImage" , TEST_LOCATION );
636
637   control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
638   DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
639
640   END_TEST;
641 }
642
643 int UtcDaliControlKeyProperties(void)
644 {
645   ToolkitTestApplication application;
646
647   Control control = Control::New();
648   Stage::GetCurrent().Add( control );
649
650   DALI_TEST_EQUALS( control.HasKeyInputFocus(), control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
651
652   control.SetKeyInputFocus();
653   DALI_TEST_EQUALS( true, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
654
655   control.ClearKeyInputFocus();
656   DALI_TEST_EQUALS( false, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
657
658   control.SetProperty( Control::Property::KEY_INPUT_FOCUS, true );
659   DALI_TEST_EQUALS( true, control.HasKeyInputFocus(), TEST_LOCATION );
660
661   END_TEST;
662 }
663
664 int UtcDaliControlGestureSignals(void)
665 {
666   ToolkitTestApplication application;
667   ConnectionTracker connectionTracker;
668   Control control = Control::New();
669
670   // Each gesture detector gets created when connecting to the gesture signals
671   DALI_TEST_CHECK( !control.GetTapGestureDetector() );
672   control.ConnectSignal( &connectionTracker, "tapped", &TestVoidCallback );
673   DALI_TEST_CHECK( control.GetTapGestureDetector() );
674
675   DALI_TEST_CHECK( !control.GetPanGestureDetector() );
676   control.ConnectSignal( &connectionTracker, "panned", &TestVoidCallback );
677   DALI_TEST_CHECK( control.GetPanGestureDetector() );
678
679   DALI_TEST_CHECK( !control.GetPinchGestureDetector() );
680   control.ConnectSignal( &connectionTracker, "pinched", &TestVoidCallback );
681   DALI_TEST_CHECK( control.GetPinchGestureDetector() );
682
683   DALI_TEST_CHECK( !control.GetLongPressGestureDetector() );
684   control.ConnectSignal( &connectionTracker, "longPressed",  &TestVoidCallback );
685   DALI_TEST_CHECK( control.GetLongPressGestureDetector() );
686
687   END_TEST;
688 }
689
690 int UtcDaliControlImplKeyInputFocusGainedSignal(void)
691 {
692   ToolkitTestApplication application;
693
694   Control control = Control::New();
695   Stage::GetCurrent().Add( control );
696
697   gKeyInputFocusCallBackCalled = false;
698   control.KeyInputFocusGainedSignal().Connect(&TestKeyInputFocusCallback);
699
700   application.SendNotification();
701   application.Render();
702
703   control.SetKeyInputFocus();
704
705   DALI_TEST_CHECK( control.HasKeyInputFocus() );
706
707   DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
708
709   END_TEST;
710 }
711
712 int UtcDaliControlImplKeyInputFocusLostSignal(void)
713 {
714   ToolkitTestApplication application;
715
716   Control control = Control::New();
717   Stage::GetCurrent().Add( control );
718
719   gKeyInputFocusCallBackCalled = false;
720   control.KeyInputFocusLostSignal().Connect(&TestKeyInputFocusCallback);
721
722   application.SendNotification();
723   application.Render();
724
725   control.SetKeyInputFocus();
726
727   DALI_TEST_CHECK( control.HasKeyInputFocus() );
728
729   control.ClearKeyInputFocus();
730
731   DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
732
733   END_TEST;
734 }
735
736 int UtcDaliControlImplGetControlExtensionP(void)
737 {
738   ToolkitTestApplication application;
739   Control control = Control::New();
740
741   Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
742
743   DALI_TEST_CHECK( NULL == controlImpl.GetControlExtension() );
744
745   END_TEST;
746 }
747
748 int UtcDaliControlAutoClipping(void)
749 {
750   ToolkitTestApplication application;
751   Control control = Control::New();
752
753   tet_infoline( "Test to see if a renderer gets added when we are clipping children" );
754
755   DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
756
757   control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
758
759   Stage::GetCurrent().Add( control );
760
761   application.SendNotification();
762   application.Render();
763
764   DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
765
766   END_TEST;
767 }
768
769 int UtcDaliControlAutoClippingN(void)
770 {
771   ToolkitTestApplication application;
772   Control control = Control::New();
773   control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
774                                                                      .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
775
776   tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals" );
777
778   DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
779
780   control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
781
782   Stage::GetCurrent().Add( control );
783
784   application.SendNotification();
785   application.Render();
786
787   DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Only 1, not 2
788
789   // Ensure the background color is still RED rather than what's set by the automatic clipping
790   Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
791   Property::Map* map = value.GetMap();
792   DALI_TEST_CHECK( map );
793   Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
794   DALI_TEST_CHECK( colorValue );
795   DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
796
797   END_TEST;
798 }
799
800 int UtcDaliControlAutoClippingWhenAlreadyOnStage(void)
801 {
802   ToolkitTestApplication application;
803   Control control = Control::New();
804
805   tet_infoline( "Test to see if a renderer gets added when we are clipping children and when already on stage" );
806
807   DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
808
809   Stage::GetCurrent().Add( control );
810
811   application.SendNotification();
812   application.Render();
813
814   DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
815
816   control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
817
818   application.SendNotification();
819   application.Render();
820
821   DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
822
823   END_TEST;
824 }
825
826 int UtcDaliControlAutoClippingWhenAlreadyOnStageN(void)
827 {
828   ToolkitTestApplication application;
829   Control control = Control::New();
830   control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
831                                                                      .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
832
833   tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals and when already on stage" );
834
835   DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
836
837   Stage::GetCurrent().Add( control );
838
839   application.SendNotification();
840   application.Render();
841
842   DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
843
844   control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
845
846   application.SendNotification();
847   application.Render();
848
849   DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Still should be 1
850
851   // Ensure the background color is still RED rather than what's set by the automatic clipping
852   Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
853   Property::Map* map = value.GetMap();
854   DALI_TEST_CHECK( map );
855   Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
856   DALI_TEST_CHECK( colorValue );
857   DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
858
859   END_TEST;
860 }
861
862 int UtcDaliControlSetTransformSize(void)
863 {
864   ToolkitTestApplication application;
865   Control control = Control::New();
866
867   Property::Map transformMap;
868   transformMap.Add( Visual::Transform::Property::OFFSET, Vector2( 10, 10 ) )
869               .Add( Visual::Transform::Property::ANCHOR_POINT, Align::BOTTOM_END )
870               .Add( Visual::Transform::Property::ORIGIN, Align::BOTTOM_END )
871               .Add( Visual::Transform::Property::SIZE, Vector2( 10, 20 ) );
872
873   control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
874                                                                      .Add( Visual::Property::TRANSFORM, transformMap ) );
875
876   tet_infoline( "Test to ensure that the control background transform does not get overwritten when adding to the stage" );
877
878   Stage::GetCurrent().Add( control );
879
880   application.SendNotification();
881   application.Render();
882
883   // Ensure the transform property still matches what we set
884   Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
885   Property::Map* map = value.GetMap();
886   DALI_TEST_CHECK( map );
887   Property::Value* transformValue = map->Find( Visual::Property::TRANSFORM );
888   DALI_TEST_CHECK( transformValue );
889
890   Property::Map* retMap = transformValue->GetMap();
891   DALI_TEST_CHECK( retMap );
892   DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 10, 10 ), TEST_LOCATION );
893   DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::ANCHOR_POINT )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
894   DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::ORIGIN )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
895   DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::SIZE )->Get< Vector2 >(), Vector2( 10, 20 ), TEST_LOCATION );
896
897   END_TEST;
898 }
899
900
901 int UtcDaliControlResourcesReady(void)
902 {
903   ToolkitTestApplication application;
904   tet_infoline( "Register 2 visuals and check ResourceReady when a visual is disabled" );
905
906   VisualFactory factory = VisualFactory::Get();
907   DALI_TEST_CHECK( factory );
908
909   Property::Map propertyMapLarge;
910   propertyMapLarge.Insert( Toolkit::Visual::Property::TYPE,  Visual::IMAGE );
911   propertyMapLarge.Insert( ImageVisual::Property::URL,  TEST_LARGE_IMAGE_FILE_NAME );
912
913   Property::Map propertyMapSmall;
914   propertyMapSmall.Insert( Toolkit::Visual::Property::TYPE,  Visual::IMAGE );
915   propertyMapSmall.Insert( ImageVisual::Property::URL,  TEST_IMAGE_FILE_NAME );
916
917   Visual::Base smallVisual = factory.CreateVisual( propertyMapSmall );
918   smallVisual.SetName("smallVisual");
919   DALI_TEST_CHECK( smallVisual );
920
921   DummyControl actor = DummyControl::New();
922   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
923
924   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, smallVisual );
925
926   actor.SetSize( 200.f, 200.f );
927
928   Toolkit::Visual::ResourceStatus resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
929   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
930   DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
931   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
932
933   Stage::GetCurrent().Add( actor );
934   application.SendNotification();
935   application.Render();
936
937   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
938
939   application.SendNotification();
940   application.Render();
941
942   resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
943   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
944   DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
945   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::READY), TEST_LOCATION );
946
947   Visual::Base largeVisual = factory.CreateVisual( propertyMapLarge );
948   largeVisual.SetName("largeVisual");
949   DALI_TEST_CHECK( largeVisual );
950
951   tet_infoline( "Register Visual but set disabled, IsResourceReady should be true" );
952
953   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, largeVisual, false );
954
955   resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
956   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
957
958   application.SendNotification();
959
960   resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
961   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
962   DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
963   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
964
965   dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL2, true );
966
967   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
968
969   application.SendNotification();
970
971   resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
972   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::READY), TEST_LOCATION );
973
974   END_TEST;
975 }
976
977 int UtcDaliControlMarginProperty(void)
978 {
979   ToolkitTestApplication application;
980
981   Control control = Control::New();
982   control.SetBackgroundColor( Color::BLUE );
983
984   control.SetProperty( Control::Property::MARGIN, Extents( 20, 10, 0, 0 ) );
985
986   Stage::GetCurrent().Add( control );
987
988   application.SendNotification();
989   application.Render();
990
991   DALI_TEST_EQUALS( control.GetProperty<Extents>( Control::Property::MARGIN ), Extents( 20, 10, 0, 0 ), TEST_LOCATION );
992
993   // Parent control has one ImageView as a Child.
994   ImageView image = ImageView::New();
995   image.SetBackgroundColor( Color::RED );
996   image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
997   image.SetProperty( Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
998   control.Add( image );
999
1000   application.SendNotification();
1001   application.Render();
1002
1003   DALI_TEST_EQUALS( image.GetProperty<Extents>( Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
1004
1005   END_TEST;
1006 }
1007
1008 int UtcDaliControlPaddingProperty(void)
1009 {
1010   ToolkitTestApplication application;
1011
1012   Control control = Control::New();
1013   control.SetBackgroundColor( Color::BLUE );
1014
1015   control.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1016
1017   Stage::GetCurrent().Add( control );
1018
1019   application.SendNotification();
1020   application.Render();
1021
1022   DALI_TEST_EQUALS( control.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1023
1024   Control child = Control::New();
1025   control.Add(child);
1026
1027   application.SendNotification();
1028   application.Render();
1029
1030   DALI_TEST_EQUALS( child.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1031
1032   control.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,  Dali::LayoutDirection::RIGHT_TO_LEFT);
1033   application.SendNotification();
1034   application.Render();
1035   DALI_TEST_EQUALS( child.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 10, 5, 0 ), TEST_LOCATION );
1036
1037   control.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,  Dali::LayoutDirection::LEFT_TO_RIGHT);
1038   application.SendNotification();
1039   application.Render();
1040
1041   DALI_TEST_EQUALS( child.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1042
1043   END_TEST;
1044 }
1045
1046 int UtcDaliControlDoAction(void)
1047 {
1048   ToolkitTestApplication application;
1049   tet_infoline( "DoAction on a visual registered with a control" );
1050
1051   // Set up trace debug
1052   TestGlAbstraction& gl = application.GetGlAbstraction();
1053   TraceCallStack& textureTrace = gl.GetTextureTrace();
1054   textureTrace.Enable( true );
1055
1056   //Created AnimatedImageVisual
1057   VisualFactory factory = VisualFactory::Get();
1058   Visual::Base imageVisual = factory.CreateVisual( TEST_IMAGE_FILE_NAME, ImageDimensions() );
1059
1060   DummyControl dummyControl = DummyControl::New(true);
1061   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1062
1063   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1064   dummyControl.SetSize(200.f, 200.f);
1065   Stage::GetCurrent().Add( dummyControl );
1066
1067   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1068
1069   application.SendNotification();
1070   application.Render();
1071   DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1072   DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1073   textureTrace.Reset();
1074
1075   Property::Map attributes;
1076   DevelControl::DoAction( dummyControl,  DummyControl::Property::TEST_VISUAL, DevelImageVisual::Action::RELOAD, attributes );
1077
1078   tet_infoline( "Perform RELOAD action. should reload Image and generate a texture" );
1079   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1080
1081   application.SendNotification();
1082   application.Render();
1083   DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
1084   DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1085   END_TEST;
1086 }
1087
1088 int UtcDaliControlDoActionWhenNotStage(void)
1089 {
1090   ToolkitTestApplication application;
1091   tet_infoline( "DoAction on a visual registered with a control but not staged" );
1092
1093   // Set up trace debug
1094   TestGlAbstraction& gl = application.GetGlAbstraction();
1095   TraceCallStack& textureTrace = gl.GetTextureTrace();
1096   textureTrace.Enable( true );
1097
1098   //Created AnimatedImageVisual
1099   VisualFactory factory = VisualFactory::Get();
1100   Visual::Base imageVisual = factory.CreateVisual( TEST_IMAGE_FILE_NAME, ImageDimensions() );
1101
1102   DummyControl dummyControl = DummyControl::New(true);
1103   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1104
1105   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1106   dummyControl.SetSize(200.f, 200.f);
1107
1108   application.SendNotification();
1109   application.Render();
1110   DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1111   DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1112   textureTrace.Reset();
1113
1114   Property::Map attributes;
1115   DevelControl::DoAction( dummyControl,  DummyControl::Property::TEST_VISUAL, DevelImageVisual::Action::RELOAD, attributes );
1116
1117   tet_infoline( "Perform RELOAD action. should reload Image and generate a texture" );
1118   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1119
1120   application.SendNotification();
1121   application.Render();
1122   DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1123   textureTrace.Reset();
1124
1125   tet_infoline( "Adding control to stage will in turn add the visual to the stage" );
1126
1127   Stage::GetCurrent().Add( dummyControl );
1128   application.SendNotification();
1129   application.Render();
1130   tet_infoline( "No change in textures could occurs as already loaded and cached texture will be used" );
1131
1132   DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1133   DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1134   textureTrace.Reset();
1135
1136   END_TEST;
1137 }