2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
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/controls/alignment/alignment.h>
30 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
31 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
34 #include <toolkit-event-thread-callback.h>
36 #include "dummy-control.h"
39 using namespace Dali::Toolkit;
41 void utc_dali_toolkit_control_startup(void)
43 test_return_value = TET_UNDEF;
46 void utc_dali_toolkit_control_cleanup(void)
48 test_return_value = TET_PASS;
51 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 bool gObjectCreatedCallBackCalled;
58 void TestCallback(BaseHandle handle)
60 gObjectCreatedCallBackCalled = true;
63 void TestVoidCallback()
67 static bool gKeyInputFocusCallBackCalled;
69 static void TestKeyInputFocusCallback( Control control )
71 tet_infoline(" TestKeyInputFocusCallback");
73 gKeyInputFocusCallBackCalled = true;
76 const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png";
77 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
78 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/Kid1.svg";
80 Vector4 GetControlBackgroundColor( Control& control )
82 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
83 Property::Map* resultMap = propValue.GetMap();
84 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
87 resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get( color );
92 bool gResourceReadySignalFired = false;
94 void ResourceReadySignal( Control control )
96 if( control.GetVisualResourceStatus( Control::Property::BACKGROUND ) == Visual::ResourceStatus::FAILED )
98 Property::Map propertyMap;
99 propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
100 control.SetProperty( Control::Property::BACKGROUND, propertyMap );
103 gResourceReadySignalFired = true;
108 ///////////////////////////////////////////////////////////////////////////////////////////////////
111 int UtcDaliControlConstructor(void)
113 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
117 DALI_TEST_CHECK( !Control::DownCast(dummy) );
119 dummy = DummyControl::New();
121 DALI_TEST_CHECK( Control::DownCast(dummy) );
125 int UtcDaliControlNew(void)
127 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
131 DALI_TEST_CHECK( !Control::DownCast(control) );
133 control = Control::New();
135 DALI_TEST_CHECK( Control::DownCast(control) );
140 int UtcDaliControlRegister(void)
142 ToolkitTestApplication application;
144 // Ensure the object is registered after creation
145 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
146 DALI_TEST_CHECK( registry );
148 gObjectCreatedCallBackCalled = false;
149 registry.ObjectCreatedSignal().Connect( &TestCallback );
151 Alignment alignment = Alignment::New();
153 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
157 int UtcDaliControlCopyAndAssignment(void)
159 ToolkitTestApplication application;
161 DummyControl control = DummyControl::New();
162 Control emptyControl;
164 Control controlCopy( control );
165 DALI_TEST_CHECK( control == controlCopy );
167 Control emptyControlCopy( emptyControl );
168 DALI_TEST_CHECK( emptyControl == emptyControlCopy );
170 Control controlEquals;
171 controlEquals = control;
172 DALI_TEST_CHECK( control == controlEquals );
174 Control emptyControlEquals;
175 emptyControlEquals = emptyControl;
176 DALI_TEST_CHECK( emptyControl == emptyControlEquals );
180 DALI_TEST_CHECK( control == controlCopy );
184 int UtcDaliControlDownCast(void)
186 ToolkitTestApplication application;
188 DummyControl control;
190 DALI_TEST_CHECK( !Control::DownCast( control ) );
192 control = DummyControl::New();
194 DALI_TEST_CHECK( Control::DownCast( control ) );
198 DALI_TEST_CHECK( !Control::DownCast( actor ) );
200 actor = Actor::New();
202 DALI_TEST_CHECK( !Control::DownCast( actor ) );
206 int UtcDaliControlDownCastTemplate(void)
208 ToolkitTestApplication application;
210 DummyControl control;
212 DALI_TEST_CHECK( !DummyControl::DownCast( control ));
214 control = DummyControl::New();
216 DALI_TEST_CHECK( DummyControl::DownCast( control ) );
220 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
222 actor = Actor::New();
224 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
228 int UtcDaliControlNavigationProperties(void)
230 ToolkitTestApplication application;
232 Control control = Control::New();
233 application.GetScene().Add( control );
235 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
236 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
237 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
238 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
240 control.SetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 1 );
241 DALI_TEST_EQUALS( 1, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
242 control.SetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, 2 );
243 DALI_TEST_EQUALS( 2, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
244 control.SetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, 3 );
245 DALI_TEST_EQUALS( 3, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
246 control.SetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 4 );
247 DALI_TEST_EQUALS( 4, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
249 control.SetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 15 );
250 DALI_TEST_EQUALS( 15, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
251 control.SetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, 16 );
252 DALI_TEST_EQUALS( 16, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
253 control.SetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, 17 );
254 DALI_TEST_EQUALS( 17, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
255 control.SetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 18 );
256 DALI_TEST_EQUALS( 18, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
261 int UtcDaliControlKeyInputFocus(void)
263 ToolkitTestApplication application;
264 Integration::Scene stage = application.GetScene();
266 DummyControl control;
268 PushButton pushButton1 = PushButton::New();
269 stage.Add( pushButton1 );
271 pushButton1.SetKeyInputFocus();
272 DALI_TEST_CHECK( pushButton1.HasKeyInputFocus() );
274 pushButton1.ClearKeyInputFocus();
275 DALI_TEST_CHECK( !pushButton1.HasKeyInputFocus() );
279 int UtcDaliControlGetImplementationN(void)
281 ToolkitTestApplication application;
282 DummyControl control;
288 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
289 (void)controlImpl; // Avoid unused warning
290 tet_result(TET_FAIL);
292 catch (DaliException &exception)
294 tet_result(TET_PASS);
300 int UtcDaliControlGetImplementationConstN(void)
302 ToolkitTestApplication application;
303 DummyControl control;
309 const DummyControl constControl(control);
310 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
311 (void)controlImpl; // Avoid unused warning
312 tet_result(TET_FAIL);
314 catch (DaliException &exception)
316 tet_result(TET_PASS);
322 int UtcDaliControlGetImplementationP(void)
324 ToolkitTestApplication application;
325 DummyControl control = DummyControl::New();
331 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
332 (void)controlImpl; // Avoid unused warning
333 tet_result(TET_PASS);
335 catch (DaliException &exception)
337 tet_result(TET_FAIL);
343 int UtcDaliControlGetImplementationConstP(void)
345 ToolkitTestApplication application;
346 DummyControl control = DummyControl::New();
351 const DummyControl constControl(control);
352 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
353 (void)controlImpl; // Avoid unused warning
354 tet_result(TET_PASS);
356 catch (DaliException &exception)
358 tet_result(TET_FAIL);
364 int UtcDaliControlSignalConnectDisconnect(void)
366 ToolkitTestApplication application;
369 DummyControl dummy = DummyControlImpl::New();
371 Actor actor = Actor::New();
372 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
373 Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
374 DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
376 if( dummyImpl == NULL )
378 tet_result( TET_FAIL );
382 actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
383 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
384 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
386 application.GetScene().Add( actor );
387 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
389 dummyImpl->mCustomSlot1Called = false;
390 actor.OnStageSignal().Disconnect( dummyImpl, &DummyControlImpl::CustomSlot1 );
391 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
392 application.GetScene().Remove( actor );
393 application.GetScene().Add( actor );
394 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
399 int UtcDaliControlSignalAutomaticDisconnect(void)
401 ToolkitTestApplication application;
403 Actor actor = Actor::New();
406 DummyControl dummy = DummyControlImpl::New();
407 Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
408 DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
410 if( dummyImpl == NULL )
412 tet_result( TET_FAIL );
416 actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
417 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
418 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
420 application.GetScene().Add( actor );
421 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
422 application.GetScene().Remove( actor );
424 // dummyControl automatically disconnects
426 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
428 const Vector3 ignoredSize( 20, 20, 0 );
429 actor.SetProperty( Actor::Property::SIZE, ignoredSize );
433 int UtcDaliControlTestParameters(void)
435 ToolkitTestApplication application;
436 DummyControl test = DummyControl::New();
438 test.SetProperty( Actor::Property::SIZE, Vector3( 0.7f, 0.7f, 0.7f ) );
440 application.GetScene().Add( test );
442 application.SendNotification();
443 application.Render();
445 float width = 640.0f;
446 float height = test.GetHeightForWidth( width );
447 DALI_TEST_EQUALS( 640.0f, height, TEST_LOCATION );
448 DALI_TEST_EQUALS( 640.0f, test.GetWidthForHeight( height ), TEST_LOCATION );
450 test.KeyEventSignal();
452 // Provide coverage for pointer destructor
453 Control* testControlPtr = new Control;
454 DALI_TEST_CHECK( testControlPtr );
455 delete testControlPtr;
459 int UtcDaliControlBackgroundColor(void)
461 ToolkitTestApplication application;
462 Control control = Control::New();
464 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
466 control.SetProperty( Control::Property::BACKGROUND, Color::RED );
468 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
469 Property::Map* resultMap = propValue.GetMap();
470 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
471 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>() == Visual::COLOR );
472 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
473 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::RED );
475 control.SetProperty( Control::Property::BACKGROUND, Color::YELLOW );
477 propValue = control.GetProperty( Control::Property::BACKGROUND );
478 resultMap = propValue.GetMap();
479 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
480 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::YELLOW );
485 int UtcDaliControlBackgroundColorRendererCount(void)
487 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" );
489 ToolkitTestApplication application;
490 Control control = Control::New();
491 application.GetScene().Add( control );
493 tet_infoline( "Set transparent, no renderers should be created" );
494 control.SetBackgroundColor( Color::TRANSPARENT );
495 application.SendNotification();
496 application.Render();
497 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
499 tet_infoline( "Set transparent alpha with positive RGB values, no renderers should be created, but returned color should reflect what we set" );
500 const Vector4 alphaZero( 1.0f, 0.5f, 0.25f, 0.0f );
501 control.SetBackgroundColor( alphaZero );
502 application.SendNotification();
503 application.Render();
504 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
505 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), alphaZero, TEST_LOCATION );
507 tet_infoline( "Set semi transparent alpha with positive RGB values, 1 renderer should be created, but returned color should reflect what we set" );
508 const Vector4 semiTransparent( 1.0f, 0.75f, 0.5f, 0.5f );
509 control.SetBackgroundColor( semiTransparent );
510 application.SendNotification();
511 application.Render();
512 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
513 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), semiTransparent, TEST_LOCATION );
515 Renderer renderer = control.GetRendererAt( 0 );
516 DALI_TEST_CHECK( renderer );
518 tet_infoline( "Set semi transparent alpha with positive RGB values, renderer should not be changed" );
519 const Vector4 newColor( 1.0f, 1.0f, 0.5f, 0.5f );
520 control.SetBackgroundColor( newColor );
521 application.SendNotification();
522 application.Render();
523 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
524 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), newColor, TEST_LOCATION );
525 DALI_TEST_EQUALS( renderer, control.GetRendererAt( 0 ), TEST_LOCATION );
527 tet_infoline( "Set transparent, ensure no renderers are created" );
528 control.SetBackgroundColor( Color::TRANSPARENT );
529 application.SendNotification();
530 application.Render();
531 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
532 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
534 tet_infoline( "Set control to clip its children, a renderer should be created which will be transparent" );
535 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
536 application.SendNotification();
537 application.Render();
538 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
539 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
541 tet_infoline( "Set a color, only 1 renderer should exist" );
542 control.SetBackgroundColor( Color::RED );
543 application.SendNotification();
544 application.Render();
545 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
546 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::RED, TEST_LOCATION );
548 tet_infoline( "Clear the background, no renderers" );
549 control.ClearBackground();
550 application.SendNotification();
551 application.Render();
552 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
554 tet_infoline( "Set control to clip its children again, a renderer should be created which will be transparent" );
555 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
556 application.SendNotification();
557 application.Render();
558 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
559 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
561 tet_infoline( "Disable clipping, no renderers" );
562 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
563 application.SendNotification();
564 application.Render();
565 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
566 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
571 int UtcDaliControlBackgroundImage(void)
573 ToolkitTestApplication application;
574 Control control = Control::New();
576 tet_infoline( "Set first background image" );
577 control.SetProperty( Control::Property::BACKGROUND, "TestImage" );
579 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
580 Property::Map* resultMap = propValue.GetMap();
581 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
582 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>() == Visual::IMAGE );
583 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
584 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage" );
586 tet_infoline( "Set replacement background image" );
587 control.SetProperty( Control::Property::BACKGROUND, "TestImage2" );
589 propValue = control.GetProperty( Control::Property::BACKGROUND );
590 resultMap = propValue.GetMap();
591 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
592 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage2" );
597 int UtcDaliControlBackgroundProperties(void)
599 ToolkitTestApplication application;
600 Control control = Control::New();
602 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
604 Property::Map imageMap;
605 imageMap[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE;
606 imageMap[ ImageVisual::Property::URL ] = "TestImage";
607 control.SetProperty( Control::Property::BACKGROUND, imageMap );
608 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
609 Property::Map* resultMap = propValue.GetMap();
610 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
611 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(),(int)Visual::IMAGE, TEST_LOCATION );
612 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
613 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "TestImage", TEST_LOCATION );
615 Property::Map rendererMap;
616 rendererMap[Visual::Property::TYPE] = Visual::COLOR;
617 rendererMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
618 control.SetProperty( Control::Property::BACKGROUND, rendererMap );
619 propValue = control.GetProperty( Control::Property::BACKGROUND );
620 resultMap = propValue.GetMap();
621 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
622 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
623 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
624 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::CYAN, TEST_LOCATION );
626 Property::Map emptyMap;
627 control.SetProperty( Control::Property::BACKGROUND, emptyMap );
628 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
631 control.SetProperty( Control::Property::BACKGROUND, "Foobar.png" );
632 propValue = control.GetProperty( Control::Property::BACKGROUND );
633 resultMap = propValue.GetMap();
634 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
635 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "Foobar.png", TEST_LOCATION );
638 control.SetProperty( Control::Property::BACKGROUND, Color::RED );
639 propValue = control.GetProperty( Control::Property::BACKGROUND );
640 resultMap = propValue.GetMap();
641 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
642 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::RED, TEST_LOCATION );
647 int UtcDaliControlShadowProperties(void)
649 ToolkitTestApplication application;
650 Control control = Control::New();
652 DALI_TEST_CHECK( control.GetProperty( DevelControl::Property::SHADOW ).Get< Property::Map >().Empty() );
654 Property::Map imageMap;
655 imageMap[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE;
656 imageMap[ ImageVisual::Property::URL ] = "TestImage";
657 control.SetProperty( DevelControl::Property::SHADOW, imageMap );
658 Property::Value propValue = control.GetProperty( DevelControl::Property::SHADOW );
659 Property::Map* resultMap = propValue.GetMap();
660 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
661 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(),(int)Visual::IMAGE, TEST_LOCATION );
662 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
663 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "TestImage", TEST_LOCATION );
665 Property::Map colorMap;
666 colorMap[Visual::Property::TYPE] = Visual::COLOR;
667 colorMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
668 control.SetProperty( DevelControl::Property::SHADOW, colorMap );
669 propValue = control.GetProperty( DevelControl::Property::SHADOW );
670 resultMap = propValue.GetMap();
671 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
672 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
673 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
674 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::CYAN, TEST_LOCATION );
676 Property::Map emptyMap;
677 control.SetProperty( DevelControl::Property::SHADOW, emptyMap );
678 DALI_TEST_CHECK( control.GetProperty( DevelControl::Property::SHADOW ).Get< Property::Map >().Empty() );
683 int UtcDaliControlKeyProperties(void)
685 ToolkitTestApplication application;
687 Control control = Control::New();
688 application.GetScene().Add( control );
690 DALI_TEST_EQUALS( control.HasKeyInputFocus(), control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
692 control.SetKeyInputFocus();
693 DALI_TEST_EQUALS( true, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
695 control.ClearKeyInputFocus();
696 DALI_TEST_EQUALS( false, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
698 control.SetProperty( Control::Property::KEY_INPUT_FOCUS, true );
699 DALI_TEST_EQUALS( true, control.HasKeyInputFocus(), TEST_LOCATION );
704 int UtcDaliControlGestureSignals(void)
706 ToolkitTestApplication application;
707 ConnectionTracker connectionTracker;
708 Control control = Control::New();
710 // Each gesture detector gets created when connecting to the gesture signals
711 DALI_TEST_CHECK( !control.GetTapGestureDetector() );
712 control.ConnectSignal( &connectionTracker, "tapped", &TestVoidCallback );
713 DALI_TEST_CHECK( control.GetTapGestureDetector() );
715 DALI_TEST_CHECK( !control.GetPanGestureDetector() );
716 control.ConnectSignal( &connectionTracker, "panned", &TestVoidCallback );
717 DALI_TEST_CHECK( control.GetPanGestureDetector() );
719 DALI_TEST_CHECK( !control.GetPinchGestureDetector() );
720 control.ConnectSignal( &connectionTracker, "pinched", &TestVoidCallback );
721 DALI_TEST_CHECK( control.GetPinchGestureDetector() );
723 DALI_TEST_CHECK( !control.GetLongPressGestureDetector() );
724 control.ConnectSignal( &connectionTracker, "longPressed", &TestVoidCallback );
725 DALI_TEST_CHECK( control.GetLongPressGestureDetector() );
730 int UtcDaliControlImplKeyInputFocusGainedSignal(void)
732 ToolkitTestApplication application;
734 Control control = Control::New();
735 application.GetScene().Add( control );
737 gKeyInputFocusCallBackCalled = false;
738 control.KeyInputFocusGainedSignal().Connect(&TestKeyInputFocusCallback);
740 application.SendNotification();
741 application.Render();
743 control.SetKeyInputFocus();
745 DALI_TEST_CHECK( control.HasKeyInputFocus() );
747 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
752 int UtcDaliControlImplKeyInputFocusLostSignal(void)
754 ToolkitTestApplication application;
756 Control control = Control::New();
757 application.GetScene().Add( control );
759 gKeyInputFocusCallBackCalled = false;
760 control.KeyInputFocusLostSignal().Connect(&TestKeyInputFocusCallback);
762 application.SendNotification();
763 application.Render();
765 control.SetKeyInputFocus();
767 DALI_TEST_CHECK( control.HasKeyInputFocus() );
769 control.ClearKeyInputFocus();
771 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
776 int UtcDaliControlImplGetControlExtensionP(void)
778 ToolkitTestApplication application;
779 Control control = Control::New();
781 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
783 DALI_TEST_CHECK( NULL == controlImpl.GetControlExtension() );
788 int UtcDaliControlAutoClipping(void)
790 ToolkitTestApplication application;
791 Control control = Control::New();
793 tet_infoline( "Test to see if a renderer gets added when we are clipping children" );
795 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
797 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
799 application.GetScene().Add( control );
801 application.SendNotification();
802 application.Render();
804 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
809 int UtcDaliControlAutoClippingN(void)
811 ToolkitTestApplication application;
812 Control control = Control::New();
813 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
814 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
816 tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals" );
818 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
820 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
822 application.GetScene().Add( control );
824 application.SendNotification();
825 application.Render();
827 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Only 1, not 2
829 // Ensure the background color is still RED rather than what's set by the automatic clipping
830 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
831 Property::Map* map = value.GetMap();
832 DALI_TEST_CHECK( map );
833 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
834 DALI_TEST_CHECK( colorValue );
835 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
840 int UtcDaliControlAutoClippingWhenAlreadyOnStage(void)
842 ToolkitTestApplication application;
843 Control control = Control::New();
845 tet_infoline( "Test to see if a renderer gets added when we are clipping children and when already on stage" );
847 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
849 application.GetScene().Add( control );
851 application.SendNotification();
852 application.Render();
854 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
856 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
858 application.SendNotification();
859 application.Render();
861 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
866 int UtcDaliControlAutoClippingWhenAlreadyOnStageN(void)
868 ToolkitTestApplication application;
869 Control control = Control::New();
870 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
871 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
873 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" );
875 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
877 application.GetScene().Add( control );
879 application.SendNotification();
880 application.Render();
882 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
884 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
886 application.SendNotification();
887 application.Render();
889 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Still should be 1
891 // Ensure the background color is still RED rather than what's set by the automatic clipping
892 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
893 Property::Map* map = value.GetMap();
894 DALI_TEST_CHECK( map );
895 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
896 DALI_TEST_CHECK( colorValue );
897 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
902 int UtcDaliControlSetTransformSize(void)
904 ToolkitTestApplication application;
905 Control control = Control::New();
907 Property::Map transformMap;
908 transformMap.Add( Visual::Transform::Property::OFFSET, Vector2( 10, 10 ) )
909 .Add( Visual::Transform::Property::ANCHOR_POINT, Align::BOTTOM_END )
910 .Add( Visual::Transform::Property::ORIGIN, Align::BOTTOM_END )
911 .Add( Visual::Transform::Property::SIZE, Vector2( 10, 20 ) );
913 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
914 .Add( Visual::Property::TRANSFORM, transformMap ) );
916 tet_infoline( "Test to ensure that the control background transform does not get overwritten when adding to the stage" );
918 application.GetScene().Add( control );
920 application.SendNotification();
921 application.Render();
923 // Ensure the transform property still matches what we set
924 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
925 Property::Map* map = value.GetMap();
926 DALI_TEST_CHECK( map );
927 Property::Value* transformValue = map->Find( Visual::Property::TRANSFORM );
928 DALI_TEST_CHECK( transformValue );
930 Property::Map* retMap = transformValue->GetMap();
931 DALI_TEST_CHECK( retMap );
932 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 10, 10 ), TEST_LOCATION );
933 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::ANCHOR_POINT )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
934 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::ORIGIN )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
935 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::SIZE )->Get< Vector2 >(), Vector2( 10, 20 ), TEST_LOCATION );
941 int UtcDaliControlResourcesReady(void)
943 ToolkitTestApplication application;
944 tet_infoline( "Register 2 visuals and check ResourceReady when a visual is disabled" );
946 VisualFactory factory = VisualFactory::Get();
947 DALI_TEST_CHECK( factory );
949 Property::Map propertyMapLarge;
950 propertyMapLarge.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
951 propertyMapLarge.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
953 Property::Map propertyMapSmall;
954 propertyMapSmall.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
955 propertyMapSmall.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
957 Visual::Base smallVisual = factory.CreateVisual( propertyMapSmall );
958 smallVisual.SetName("smallVisual");
959 DALI_TEST_CHECK( smallVisual );
961 DummyControl actor = DummyControl::New();
962 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
964 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, smallVisual );
966 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
968 Toolkit::Visual::ResourceStatus resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
969 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
970 DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
971 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
973 application.GetScene().Add( actor );
974 application.SendNotification();
975 application.Render();
977 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
979 application.SendNotification();
980 application.Render();
982 resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
983 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
984 DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
985 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::READY), TEST_LOCATION );
987 Visual::Base largeVisual = factory.CreateVisual( propertyMapLarge );
988 largeVisual.SetName("largeVisual");
989 DALI_TEST_CHECK( largeVisual );
991 tet_infoline( "Register Visual but set disabled, IsResourceReady should be true" );
993 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, largeVisual, false );
995 resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
996 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
998 application.SendNotification();
1000 resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
1001 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1002 DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
1003 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
1005 dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL2, true );
1007 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1009 application.SendNotification();
1011 resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
1012 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::READY), TEST_LOCATION );
1017 int UtcDaliControlResourcesReady02(void)
1019 ToolkitTestApplication application;
1020 tet_infoline( "Change a resource during ResourceReady callback" );
1022 gResourceReadySignalFired = false;
1024 Control control = Control::New();
1025 control.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1026 control.ResourceReadySignal().Connect( &ResourceReadySignal );
1028 Property::Map propertyMap;
1029 propertyMap.Insert( ImageVisual::Property::URL, "invalid.jpg" );
1030 control.SetProperty( Control::Property::BACKGROUND, propertyMap );
1032 application.GetScene().Add( control );
1034 application.SendNotification();
1035 application.Render();
1037 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1039 application.SendNotification();
1040 application.Render();
1042 DALI_TEST_EQUALS( control.IsResourceReady(), true, TEST_LOCATION );
1043 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1044 gResourceReadySignalFired = false;
1049 int UtcDaliControlMarginProperty(void)
1051 ToolkitTestApplication application;
1053 Control control = Control::New();
1054 control.SetBackgroundColor( Color::BLUE );
1056 control.SetProperty( Control::Property::MARGIN, Extents( 20, 10, 0, 0 ) );
1058 application.GetScene().Add( control );
1060 application.SendNotification();
1061 application.Render();
1063 DALI_TEST_EQUALS( control.GetProperty<Extents>( Control::Property::MARGIN ), Extents( 20, 10, 0, 0 ), TEST_LOCATION );
1065 // Parent control has one ImageView as a Child.
1066 ImageView image = ImageView::New();
1067 image.SetBackgroundColor( Color::RED );
1068 image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1069 image.SetProperty( Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
1070 control.Add( image );
1072 application.SendNotification();
1073 application.Render();
1075 DALI_TEST_EQUALS( image.GetProperty<Extents>( Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
1080 int UtcDaliControlPaddingProperty(void)
1082 ToolkitTestApplication application;
1084 Control control = Control::New();
1085 control.SetBackgroundColor( Color::BLUE );
1087 control.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1089 application.GetScene().Add( control );
1091 application.SendNotification();
1092 application.Render();
1094 DALI_TEST_EQUALS( control.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1096 Control child = Control::New();
1099 application.SendNotification();
1100 application.Render();
1102 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1104 control.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
1105 application.SendNotification();
1106 application.Render();
1107 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 10, 5, 0 ), TEST_LOCATION );
1109 control.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::LEFT_TO_RIGHT);
1110 application.SendNotification();
1111 application.Render();
1113 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1118 int UtcDaliControlDoAction(void)
1120 ToolkitTestApplication application;
1121 tet_infoline( "DoAction on a visual registered with a control" );
1123 // Set up trace debug
1124 TestGlAbstraction& gl = application.GetGlAbstraction();
1125 TraceCallStack& textureTrace = gl.GetTextureTrace();
1126 textureTrace.Enable( true );
1128 //Created AnimatedImageVisual
1129 VisualFactory factory = VisualFactory::Get();
1130 Visual::Base imageVisual = factory.CreateVisual( TEST_IMAGE_FILE_NAME, ImageDimensions() );
1132 DummyControl dummyControl = DummyControl::New(true);
1133 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1135 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1136 dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1137 application.GetScene().Add( dummyControl );
1139 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1141 application.SendNotification();
1142 application.Render();
1143 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1144 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1145 textureTrace.Reset();
1147 Property::Map attributes;
1148 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, DevelImageVisual::Action::RELOAD, attributes );
1150 tet_infoline( "Perform RELOAD action. should reload Image and generate a texture" );
1151 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1153 application.SendNotification();
1154 application.Render();
1155 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
1156 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1160 int UtcDaliControlDoActionWhenNotStage(void)
1162 ToolkitTestApplication application;
1163 tet_infoline( "DoAction on a visual registered with a control but not staged" );
1165 // Set up trace debug
1166 TestGlAbstraction& gl = application.GetGlAbstraction();
1167 TraceCallStack& textureTrace = gl.GetTextureTrace();
1168 textureTrace.Enable( true );
1170 //Created AnimatedImageVisual
1171 VisualFactory factory = VisualFactory::Get();
1172 Visual::Base imageVisual = factory.CreateVisual( TEST_IMAGE_FILE_NAME, ImageDimensions() );
1174 DummyControl dummyControl = DummyControl::New(true);
1175 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1177 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1178 dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1180 application.SendNotification();
1181 application.Render();
1182 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1183 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1184 textureTrace.Reset();
1186 Property::Map attributes;
1187 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, DevelImageVisual::Action::RELOAD, attributes );
1189 tet_infoline( "Perform RELOAD action. should reload Image and generate a texture" );
1190 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1192 application.SendNotification();
1193 application.Render();
1194 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1195 textureTrace.Reset();
1197 tet_infoline( "Adding control to stage will in turn add the visual to the stage" );
1199 application.GetScene().Add( dummyControl );
1200 application.SendNotification();
1201 application.Render();
1202 tet_infoline( "No change in textures could occurs as already loaded and cached texture will be used" );
1204 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1205 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1206 textureTrace.Reset();