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 UtcDaliControlMoveConstructor(void)
186 ToolkitTestApplication application;
188 Control control = Control::New();
189 DALI_TEST_EQUALS( 1, control.GetBaseObject().ReferenceCount(), TEST_LOCATION );
190 control.SetProperty( Actor::Property::SENSITIVE, false );
191 DALI_TEST_CHECK( false == control.GetProperty< bool >( Actor::Property::SENSITIVE ) );
193 Control moved = std::move( control );
194 DALI_TEST_CHECK( moved );
195 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
196 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
197 DALI_TEST_CHECK( !control );
202 int UtcDaliControlMoveAssignment(void)
204 ToolkitTestApplication application;
206 Control control = Control::New();
207 DALI_TEST_EQUALS( 1, control.GetBaseObject().ReferenceCount(), TEST_LOCATION );
208 control.SetProperty( Actor::Property::SENSITIVE, false );
209 DALI_TEST_CHECK( false == control.GetProperty< bool >( Actor::Property::SENSITIVE ) );
212 moved = std::move( control );
213 DALI_TEST_CHECK( moved );
214 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
215 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
216 DALI_TEST_CHECK( !control );
221 int UtcDaliControlDownCast(void)
223 ToolkitTestApplication application;
225 DummyControl control;
227 DALI_TEST_CHECK( !Control::DownCast( control ) );
229 control = DummyControl::New();
231 DALI_TEST_CHECK( Control::DownCast( control ) );
235 DALI_TEST_CHECK( !Control::DownCast( actor ) );
237 actor = Actor::New();
239 DALI_TEST_CHECK( !Control::DownCast( actor ) );
243 int UtcDaliControlDownCastTemplate(void)
245 ToolkitTestApplication application;
247 DummyControl control;
249 DALI_TEST_CHECK( !DummyControl::DownCast( control ));
251 control = DummyControl::New();
253 DALI_TEST_CHECK( DummyControl::DownCast( control ) );
257 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
259 actor = Actor::New();
261 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
265 int UtcDaliControlNavigationProperties(void)
267 ToolkitTestApplication application;
269 Control control = Control::New();
270 application.GetScene().Add( control );
272 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
273 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
274 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
275 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
277 control.SetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 1 );
278 DALI_TEST_EQUALS( 1, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
279 control.SetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, 2 );
280 DALI_TEST_EQUALS( 2, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
281 control.SetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, 3 );
282 DALI_TEST_EQUALS( 3, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
283 control.SetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 4 );
284 DALI_TEST_EQUALS( 4, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
286 control.SetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 15 );
287 DALI_TEST_EQUALS( 15, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
288 control.SetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, 16 );
289 DALI_TEST_EQUALS( 16, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
290 control.SetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, 17 );
291 DALI_TEST_EQUALS( 17, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
292 control.SetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 18 );
293 DALI_TEST_EQUALS( 18, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
298 int UtcDaliControlKeyInputFocus(void)
300 ToolkitTestApplication application;
301 Integration::Scene stage = application.GetScene();
303 DummyControl control;
305 PushButton pushButton1 = PushButton::New();
306 stage.Add( pushButton1 );
308 pushButton1.SetKeyInputFocus();
309 DALI_TEST_CHECK( pushButton1.HasKeyInputFocus() );
311 pushButton1.ClearKeyInputFocus();
312 DALI_TEST_CHECK( !pushButton1.HasKeyInputFocus() );
316 int UtcDaliControlGetImplementationN(void)
318 ToolkitTestApplication application;
319 DummyControl control;
325 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
326 (void)controlImpl; // Avoid unused warning
327 tet_result(TET_FAIL);
329 catch (DaliException &exception)
331 tet_result(TET_PASS);
337 int UtcDaliControlGetImplementationConstN(void)
339 ToolkitTestApplication application;
340 DummyControl control;
346 const DummyControl constControl(control);
347 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
348 (void)controlImpl; // Avoid unused warning
349 tet_result(TET_FAIL);
351 catch (DaliException &exception)
353 tet_result(TET_PASS);
359 int UtcDaliControlGetImplementationP(void)
361 ToolkitTestApplication application;
362 DummyControl control = DummyControl::New();
368 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
369 (void)controlImpl; // Avoid unused warning
370 tet_result(TET_PASS);
372 catch (DaliException &exception)
374 tet_result(TET_FAIL);
380 int UtcDaliControlGetImplementationConstP(void)
382 ToolkitTestApplication application;
383 DummyControl control = DummyControl::New();
388 const DummyControl constControl(control);
389 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
390 (void)controlImpl; // Avoid unused warning
391 tet_result(TET_PASS);
393 catch (DaliException &exception)
395 tet_result(TET_FAIL);
401 int UtcDaliControlSignalConnectDisconnect(void)
403 ToolkitTestApplication application;
406 DummyControl dummy = DummyControlImpl::New();
408 Actor actor = Actor::New();
409 DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 0u, TEST_LOCATION );
410 Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
411 DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
413 if( dummyImpl == NULL )
415 tet_result( TET_FAIL );
419 actor.OnSceneSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
420 DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 1u, TEST_LOCATION );
421 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
423 application.GetScene().Add( actor );
424 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
426 dummyImpl->mCustomSlot1Called = false;
427 actor.OnSceneSignal().Disconnect( dummyImpl, &DummyControlImpl::CustomSlot1 );
428 DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 0u, TEST_LOCATION );
429 application.GetScene().Remove( actor );
430 application.GetScene().Add( actor );
431 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
436 int UtcDaliControlSignalAutomaticDisconnect(void)
438 ToolkitTestApplication application;
440 Actor actor = Actor::New();
443 DummyControl dummy = DummyControlImpl::New();
444 Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
445 DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
447 if( dummyImpl == NULL )
449 tet_result( TET_FAIL );
453 actor.OnSceneSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
454 DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 1u, TEST_LOCATION );
455 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
457 application.GetScene().Add( actor );
458 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
459 application.GetScene().Remove( actor );
461 // dummyControl automatically disconnects
463 DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 0u, TEST_LOCATION );
465 const Vector3 ignoredSize( 20, 20, 0 );
466 actor.SetProperty( Actor::Property::SIZE, ignoredSize );
470 int UtcDaliControlTestParameters(void)
472 ToolkitTestApplication application;
473 DummyControl test = DummyControl::New();
475 test.SetProperty( Actor::Property::SIZE, Vector3( 0.7f, 0.7f, 0.7f ) );
477 application.GetScene().Add( test );
479 application.SendNotification();
480 application.Render();
482 float width = 640.0f;
483 float height = test.GetHeightForWidth( width );
484 DALI_TEST_EQUALS( 640.0f, height, TEST_LOCATION );
485 DALI_TEST_EQUALS( 640.0f, test.GetWidthForHeight( height ), TEST_LOCATION );
487 test.KeyEventSignal();
489 // Provide coverage for pointer destructor
490 Control* testControlPtr = new Control;
491 DALI_TEST_CHECK( testControlPtr );
492 delete testControlPtr;
496 int UtcDaliControlBackgroundColor(void)
498 ToolkitTestApplication application;
499 Control control = Control::New();
501 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
503 control.SetProperty( Control::Property::BACKGROUND, Color::RED );
505 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
506 Property::Map* resultMap = propValue.GetMap();
507 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
508 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>() == Visual::COLOR );
509 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
510 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::RED );
512 control.SetProperty( Control::Property::BACKGROUND, Color::YELLOW );
514 propValue = control.GetProperty( Control::Property::BACKGROUND );
515 resultMap = propValue.GetMap();
516 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
517 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::YELLOW );
522 int UtcDaliControlBackgroundColorRendererCount(void)
524 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" );
526 ToolkitTestApplication application;
527 Control control = Control::New();
528 application.GetScene().Add( control );
530 tet_infoline( "Set transparent, no renderers should be created" );
531 control.SetBackgroundColor( Color::TRANSPARENT );
532 application.SendNotification();
533 application.Render();
534 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
536 tet_infoline( "Set transparent alpha with positive RGB values, no renderers should be created, but returned color should reflect what we set" );
537 const Vector4 alphaZero( 1.0f, 0.5f, 0.25f, 0.0f );
538 control.SetBackgroundColor( alphaZero );
539 application.SendNotification();
540 application.Render();
541 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
542 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), alphaZero, TEST_LOCATION );
544 tet_infoline( "Set semi transparent alpha with positive RGB values, 1 renderer should be created, but returned color should reflect what we set" );
545 const Vector4 semiTransparent( 1.0f, 0.75f, 0.5f, 0.5f );
546 control.SetBackgroundColor( semiTransparent );
547 application.SendNotification();
548 application.Render();
549 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
550 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), semiTransparent, TEST_LOCATION );
552 Renderer renderer = control.GetRendererAt( 0 );
553 DALI_TEST_CHECK( renderer );
555 tet_infoline( "Set semi transparent alpha with positive RGB values, renderer should not be changed" );
556 const Vector4 newColor( 1.0f, 1.0f, 0.5f, 0.5f );
557 control.SetBackgroundColor( newColor );
558 application.SendNotification();
559 application.Render();
560 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
561 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), newColor, TEST_LOCATION );
562 DALI_TEST_EQUALS( renderer, control.GetRendererAt( 0 ), TEST_LOCATION );
564 tet_infoline( "Set transparent, ensure no renderers are created" );
565 control.SetBackgroundColor( Color::TRANSPARENT );
566 application.SendNotification();
567 application.Render();
568 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
569 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
571 tet_infoline( "Set control to clip its children, a renderer should be created which will be transparent" );
572 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
573 application.SendNotification();
574 application.Render();
575 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
576 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
578 tet_infoline( "Set a color, only 1 renderer should exist" );
579 control.SetBackgroundColor( Color::RED );
580 application.SendNotification();
581 application.Render();
582 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
583 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::RED, TEST_LOCATION );
585 tet_infoline( "Clear the background, no renderers" );
586 control.ClearBackground();
587 application.SendNotification();
588 application.Render();
589 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
591 tet_infoline( "Set control to clip its children again, a renderer should be created which will be transparent" );
592 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
593 application.SendNotification();
594 application.Render();
595 DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
596 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
598 tet_infoline( "Disable clipping, no renderers" );
599 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
600 application.SendNotification();
601 application.Render();
602 DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
603 DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
608 int UtcDaliControlBackgroundImage(void)
610 ToolkitTestApplication application;
611 Control control = Control::New();
613 tet_infoline( "Set first background image" );
614 control.SetProperty( Control::Property::BACKGROUND, "TestImage" );
616 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
617 Property::Map* resultMap = propValue.GetMap();
618 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
619 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>() == Visual::IMAGE );
620 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
621 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage" );
623 tet_infoline( "Set replacement background image" );
624 control.SetProperty( Control::Property::BACKGROUND, "TestImage2" );
626 propValue = control.GetProperty( Control::Property::BACKGROUND );
627 resultMap = propValue.GetMap();
628 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
629 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage2" );
634 int UtcDaliControlBackgroundProperties(void)
636 ToolkitTestApplication application;
637 Control control = Control::New();
639 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
641 Property::Map imageMap;
642 imageMap[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE;
643 imageMap[ ImageVisual::Property::URL ] = "TestImage";
644 control.SetProperty( Control::Property::BACKGROUND, imageMap );
645 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
646 Property::Map* resultMap = propValue.GetMap();
647 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
648 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(),(int)Visual::IMAGE, TEST_LOCATION );
649 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
650 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "TestImage", TEST_LOCATION );
652 Property::Map rendererMap;
653 rendererMap[Visual::Property::TYPE] = Visual::COLOR;
654 rendererMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
655 control.SetProperty( Control::Property::BACKGROUND, rendererMap );
656 propValue = control.GetProperty( Control::Property::BACKGROUND );
657 resultMap = propValue.GetMap();
658 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
659 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
660 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
661 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::CYAN, TEST_LOCATION );
663 Property::Map emptyMap;
664 control.SetProperty( Control::Property::BACKGROUND, emptyMap );
665 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
668 control.SetProperty( Control::Property::BACKGROUND, "Foobar.png" );
669 propValue = control.GetProperty( Control::Property::BACKGROUND );
670 resultMap = propValue.GetMap();
671 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
672 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "Foobar.png", TEST_LOCATION );
675 control.SetProperty( Control::Property::BACKGROUND, Color::RED );
676 propValue = control.GetProperty( Control::Property::BACKGROUND );
677 resultMap = propValue.GetMap();
678 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
679 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::RED, TEST_LOCATION );
684 int UtcDaliControlShadowProperties(void)
686 ToolkitTestApplication application;
687 Control control = Control::New();
689 DALI_TEST_CHECK( control.GetProperty( DevelControl::Property::SHADOW ).Get< Property::Map >().Empty() );
691 Property::Map imageMap;
692 imageMap[ Toolkit::Visual::Property::TYPE ] = Visual::IMAGE;
693 imageMap[ ImageVisual::Property::URL ] = "TestImage";
694 control.SetProperty( DevelControl::Property::SHADOW, imageMap );
695 Property::Value propValue = control.GetProperty( DevelControl::Property::SHADOW );
696 Property::Map* resultMap = propValue.GetMap();
697 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
698 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(),(int)Visual::IMAGE, TEST_LOCATION );
699 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
700 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "TestImage", TEST_LOCATION );
702 Property::Map colorMap;
703 colorMap[Visual::Property::TYPE] = Visual::COLOR;
704 colorMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
705 control.SetProperty( DevelControl::Property::SHADOW, colorMap );
706 propValue = control.GetProperty( DevelControl::Property::SHADOW );
707 resultMap = propValue.GetMap();
708 DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
709 DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
710 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
711 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::CYAN, TEST_LOCATION );
713 Property::Map emptyMap;
714 control.SetProperty( DevelControl::Property::SHADOW, emptyMap );
715 DALI_TEST_CHECK( control.GetProperty( DevelControl::Property::SHADOW ).Get< Property::Map >().Empty() );
720 int UtcDaliControlKeyProperties(void)
722 ToolkitTestApplication application;
724 Control control = Control::New();
725 application.GetScene().Add( control );
727 DALI_TEST_EQUALS( control.HasKeyInputFocus(), control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
729 control.SetKeyInputFocus();
730 DALI_TEST_EQUALS( true, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
732 control.ClearKeyInputFocus();
733 DALI_TEST_EQUALS( false, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
735 control.SetProperty( Control::Property::KEY_INPUT_FOCUS, true );
736 DALI_TEST_EQUALS( true, control.HasKeyInputFocus(), TEST_LOCATION );
741 int UtcDaliControlGestureSignals(void)
743 ToolkitTestApplication application;
744 ConnectionTracker connectionTracker;
745 Control control = Control::New();
747 // Each gesture detector gets created when connecting to the gesture signals
748 DALI_TEST_CHECK( !control.GetTapGestureDetector() );
749 control.ConnectSignal( &connectionTracker, "tapped", &TestVoidCallback );
750 DALI_TEST_CHECK( control.GetTapGestureDetector() );
752 DALI_TEST_CHECK( !control.GetPanGestureDetector() );
753 control.ConnectSignal( &connectionTracker, "panned", &TestVoidCallback );
754 DALI_TEST_CHECK( control.GetPanGestureDetector() );
756 DALI_TEST_CHECK( !control.GetPinchGestureDetector() );
757 control.ConnectSignal( &connectionTracker, "pinched", &TestVoidCallback );
758 DALI_TEST_CHECK( control.GetPinchGestureDetector() );
760 DALI_TEST_CHECK( !control.GetLongPressGestureDetector() );
761 control.ConnectSignal( &connectionTracker, "longPressed", &TestVoidCallback );
762 DALI_TEST_CHECK( control.GetLongPressGestureDetector() );
767 int UtcDaliControlImplKeyInputFocusGainedSignal(void)
769 ToolkitTestApplication application;
771 Control control = Control::New();
772 application.GetScene().Add( control );
774 gKeyInputFocusCallBackCalled = false;
775 control.KeyInputFocusGainedSignal().Connect(&TestKeyInputFocusCallback);
777 application.SendNotification();
778 application.Render();
780 control.SetKeyInputFocus();
782 DALI_TEST_CHECK( control.HasKeyInputFocus() );
784 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
789 int UtcDaliControlImplKeyInputFocusLostSignal(void)
791 ToolkitTestApplication application;
793 Control control = Control::New();
794 application.GetScene().Add( control );
796 gKeyInputFocusCallBackCalled = false;
797 control.KeyInputFocusLostSignal().Connect(&TestKeyInputFocusCallback);
799 application.SendNotification();
800 application.Render();
802 control.SetKeyInputFocus();
804 DALI_TEST_CHECK( control.HasKeyInputFocus() );
806 control.ClearKeyInputFocus();
808 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
813 int UtcDaliControlImplGetControlExtensionP(void)
815 ToolkitTestApplication application;
816 Control control = Control::New();
818 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
820 DALI_TEST_CHECK( NULL == controlImpl.GetControlExtension() );
825 int UtcDaliControlAutoClipping(void)
827 ToolkitTestApplication application;
828 Control control = Control::New();
830 tet_infoline( "Test to see if a renderer gets added when we are clipping children" );
832 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
834 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
836 application.GetScene().Add( control );
838 application.SendNotification();
839 application.Render();
841 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
846 int UtcDaliControlAutoClippingN(void)
848 ToolkitTestApplication application;
849 Control control = Control::New();
850 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
851 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
853 tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals" );
855 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
857 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
859 application.GetScene().Add( control );
861 application.SendNotification();
862 application.Render();
864 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Only 1, not 2
866 // Ensure the background color is still RED rather than what's set by the automatic clipping
867 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
868 Property::Map* map = value.GetMap();
869 DALI_TEST_CHECK( map );
870 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
871 DALI_TEST_CHECK( colorValue );
872 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
877 int UtcDaliControlAutoClippingWhenAlreadyOnStage(void)
879 ToolkitTestApplication application;
880 Control control = Control::New();
882 tet_infoline( "Test to see if a renderer gets added when we are clipping children and when already on stage" );
884 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
886 application.GetScene().Add( control );
888 application.SendNotification();
889 application.Render();
891 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
893 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
895 application.SendNotification();
896 application.Render();
898 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
903 int UtcDaliControlAutoClippingWhenAlreadyOnStageN(void)
905 ToolkitTestApplication application;
906 Control control = Control::New();
907 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
908 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
910 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" );
912 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
914 application.GetScene().Add( control );
916 application.SendNotification();
917 application.Render();
919 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
921 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
923 application.SendNotification();
924 application.Render();
926 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Still should be 1
928 // Ensure the background color is still RED rather than what's set by the automatic clipping
929 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
930 Property::Map* map = value.GetMap();
931 DALI_TEST_CHECK( map );
932 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
933 DALI_TEST_CHECK( colorValue );
934 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
939 int UtcDaliControlSetTransformSize(void)
941 ToolkitTestApplication application;
942 Control control = Control::New();
944 Property::Map transformMap;
945 transformMap.Add( Visual::Transform::Property::OFFSET, Vector2( 10, 10 ) )
946 .Add( Visual::Transform::Property::ANCHOR_POINT, Align::BOTTOM_END )
947 .Add( Visual::Transform::Property::ORIGIN, Align::BOTTOM_END )
948 .Add( Visual::Transform::Property::SIZE, Vector2( 10, 20 ) );
950 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
951 .Add( Visual::Property::TRANSFORM, transformMap ) );
953 tet_infoline( "Test to ensure that the control background transform does not get overwritten when adding to the stage" );
955 application.GetScene().Add( control );
957 application.SendNotification();
958 application.Render();
960 // Ensure the transform property still matches what we set
961 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
962 Property::Map* map = value.GetMap();
963 DALI_TEST_CHECK( map );
964 Property::Value* transformValue = map->Find( Visual::Property::TRANSFORM );
965 DALI_TEST_CHECK( transformValue );
967 Property::Map* retMap = transformValue->GetMap();
968 DALI_TEST_CHECK( retMap );
969 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 10, 10 ), TEST_LOCATION );
970 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::ANCHOR_POINT )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
971 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::ORIGIN )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
972 DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::SIZE )->Get< Vector2 >(), Vector2( 10, 20 ), TEST_LOCATION );
978 int UtcDaliControlResourcesReady(void)
980 ToolkitTestApplication application;
981 tet_infoline( "Register 2 visuals and check ResourceReady when a visual is disabled" );
983 VisualFactory factory = VisualFactory::Get();
984 DALI_TEST_CHECK( factory );
986 Property::Map propertyMapLarge;
987 propertyMapLarge.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
988 propertyMapLarge.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
990 Property::Map propertyMapSmall;
991 propertyMapSmall.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
992 propertyMapSmall.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
994 Visual::Base smallVisual = factory.CreateVisual( propertyMapSmall );
995 smallVisual.SetName("smallVisual");
996 DALI_TEST_CHECK( smallVisual );
998 DummyControl actor = DummyControl::New();
999 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1001 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, smallVisual );
1003 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1005 Toolkit::Visual::ResourceStatus resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1006 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1007 DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
1008 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
1010 application.GetScene().Add( actor );
1011 application.SendNotification();
1012 application.Render();
1014 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1016 application.SendNotification();
1017 application.Render();
1019 resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
1020 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1021 DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
1022 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::READY), TEST_LOCATION );
1024 Visual::Base largeVisual = factory.CreateVisual( propertyMapLarge );
1025 largeVisual.SetName("largeVisual");
1026 DALI_TEST_CHECK( largeVisual );
1028 tet_infoline( "Register Visual but set disabled, IsResourceReady should be true" );
1030 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, largeVisual, false );
1032 resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
1033 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
1035 application.SendNotification();
1037 resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
1038 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1039 DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
1040 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
1042 dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL2, true );
1044 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1046 application.SendNotification();
1048 resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
1049 DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::READY), TEST_LOCATION );
1054 int UtcDaliControlResourcesReady02(void)
1056 ToolkitTestApplication application;
1057 tet_infoline( "Change a resource during ResourceReady callback" );
1059 gResourceReadySignalFired = false;
1061 Control control = Control::New();
1062 control.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1063 control.ResourceReadySignal().Connect( &ResourceReadySignal );
1065 Property::Map propertyMap;
1066 propertyMap.Insert( ImageVisual::Property::URL, "invalid.jpg" );
1067 control.SetProperty( Control::Property::BACKGROUND, propertyMap );
1069 application.GetScene().Add( control );
1071 application.SendNotification();
1072 application.Render();
1074 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1076 application.SendNotification();
1077 application.Render();
1079 DALI_TEST_EQUALS( control.IsResourceReady(), true, TEST_LOCATION );
1080 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
1081 gResourceReadySignalFired = false;
1086 int UtcDaliControlMarginProperty(void)
1088 ToolkitTestApplication application;
1090 Control control = Control::New();
1091 control.SetBackgroundColor( Color::BLUE );
1093 control.SetProperty( Control::Property::MARGIN, Extents( 20, 10, 0, 0 ) );
1095 application.GetScene().Add( control );
1097 application.SendNotification();
1098 application.Render();
1100 DALI_TEST_EQUALS( control.GetProperty<Extents>( Control::Property::MARGIN ), Extents( 20, 10, 0, 0 ), TEST_LOCATION );
1102 // Parent control has one ImageView as a Child.
1103 ImageView image = ImageView::New();
1104 image.SetBackgroundColor( Color::RED );
1105 image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1106 image.SetProperty( Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
1107 control.Add( image );
1109 application.SendNotification();
1110 application.Render();
1112 DALI_TEST_EQUALS( image.GetProperty<Extents>( Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
1117 int UtcDaliControlPaddingProperty(void)
1119 ToolkitTestApplication application;
1121 Control control = Control::New();
1122 control.SetBackgroundColor( Color::BLUE );
1124 control.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
1126 application.GetScene().Add( control );
1128 application.SendNotification();
1129 application.Render();
1131 DALI_TEST_EQUALS( control.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
1133 Control child = Control::New();
1136 application.SendNotification();
1137 application.Render();
1139 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1141 control.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
1142 application.SendNotification();
1143 application.Render();
1144 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 10, 5, 0 ), TEST_LOCATION );
1146 control.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::LEFT_TO_RIGHT);
1147 application.SendNotification();
1148 application.Render();
1150 DALI_TEST_EQUALS( child.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
1155 int UtcDaliControlDoAction(void)
1157 ToolkitTestApplication application;
1158 tet_infoline( "DoAction on a visual registered with a control" );
1160 // Set up trace debug
1161 TestGlAbstraction& gl = application.GetGlAbstraction();
1162 TraceCallStack& textureTrace = gl.GetTextureTrace();
1163 textureTrace.Enable( true );
1165 //Created AnimatedImageVisual
1166 VisualFactory factory = VisualFactory::Get();
1167 Visual::Base imageVisual = factory.CreateVisual( TEST_IMAGE_FILE_NAME, ImageDimensions() );
1169 DummyControl dummyControl = DummyControl::New(true);
1170 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1172 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1173 dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1174 application.GetScene().Add( dummyControl );
1176 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1178 application.SendNotification();
1179 application.Render();
1180 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1181 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1182 textureTrace.Reset();
1184 Property::Map attributes;
1185 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, DevelImageVisual::Action::RELOAD, attributes );
1187 tet_infoline( "Perform RELOAD action. should reload Image and generate a texture" );
1188 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1190 application.SendNotification();
1191 application.Render();
1192 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
1193 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1197 int UtcDaliControlDoActionWhenNotStage(void)
1199 ToolkitTestApplication application;
1200 tet_infoline( "DoAction on a visual registered with a control but not staged" );
1202 // Set up trace debug
1203 TestGlAbstraction& gl = application.GetGlAbstraction();
1204 TraceCallStack& textureTrace = gl.GetTextureTrace();
1205 textureTrace.Enable( true );
1207 //Created AnimatedImageVisual
1208 VisualFactory factory = VisualFactory::Get();
1209 Visual::Base imageVisual = factory.CreateVisual( TEST_IMAGE_FILE_NAME, ImageDimensions() );
1211 DummyControl dummyControl = DummyControl::New(true);
1212 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
1214 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1215 dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1217 application.SendNotification();
1218 application.Render();
1219 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1220 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1221 textureTrace.Reset();
1223 Property::Map attributes;
1224 DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, DevelImageVisual::Action::RELOAD, attributes );
1226 tet_infoline( "Perform RELOAD action. should reload Image and generate a texture" );
1227 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1229 application.SendNotification();
1230 application.Render();
1231 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1232 textureTrace.Reset();
1234 tet_infoline( "Adding control to stage will in turn add the visual to the stage" );
1236 application.GetScene().Add( dummyControl );
1237 application.SendNotification();
1238 application.Render();
1239 tet_infoline( "No change in textures could occurs as already loaded and cached texture will be used" );
1241 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1242 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1243 textureTrace.Reset();