2 * Copyright (c) 2017 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/devel-api/visuals/visual-properties-devel.h>
28 #include <dali-toolkit/devel-api/align-enums.h>
30 #include "dummy-control.h"
33 using namespace Dali::Toolkit;
35 void utc_dali_toolkit_control_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_toolkit_control_cleanup(void)
42 test_return_value = TET_PASS;
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
50 bool gObjectCreatedCallBackCalled;
52 void TestCallback(BaseHandle handle)
54 gObjectCreatedCallBackCalled = true;
57 void TestVoidCallback()
61 static bool gKeyInputFocusCallBackCalled;
63 static void TestKeyInputFocusCallback( Control control )
65 tet_infoline(" TestKeyInputFocusCallback");
67 gKeyInputFocusCallBackCalled = true;
72 ///////////////////////////////////////////////////////////////////////////////////////////////////
75 int UtcDaliControlConstructor(void)
77 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
81 DALI_TEST_CHECK( !Control::DownCast(dummy) );
83 dummy = DummyControl::New();
85 DALI_TEST_CHECK( Control::DownCast(dummy) );
89 int UtcDaliControlNew(void)
91 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
95 DALI_TEST_CHECK( !Control::DownCast(control) );
97 control = Control::New();
99 DALI_TEST_CHECK( Control::DownCast(control) );
104 int UtcDaliControlRegister(void)
106 ToolkitTestApplication application;
108 // Ensure the object is registered after creation
109 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
110 DALI_TEST_CHECK( registry );
112 gObjectCreatedCallBackCalled = false;
113 registry.ObjectCreatedSignal().Connect( &TestCallback );
115 Alignment alignment = Alignment::New();
117 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
121 int UtcDaliControlCopyAndAssignment(void)
123 ToolkitTestApplication application;
125 DummyControl control = DummyControl::New();
126 Control emptyControl;
128 Control controlCopy( control );
129 DALI_TEST_CHECK( control == controlCopy );
131 Control emptyControlCopy( emptyControl );
132 DALI_TEST_CHECK( emptyControl == emptyControlCopy );
134 Control controlEquals;
135 controlEquals = control;
136 DALI_TEST_CHECK( control == controlEquals );
138 Control emptyControlEquals;
139 emptyControlEquals = emptyControl;
140 DALI_TEST_CHECK( emptyControl == emptyControlEquals );
144 DALI_TEST_CHECK( control == controlCopy );
148 int UtcDaliControlDownCast(void)
150 ToolkitTestApplication application;
152 DummyControl control;
154 DALI_TEST_CHECK( !Control::DownCast( control ) );
156 control = DummyControl::New();
158 DALI_TEST_CHECK( Control::DownCast( control ) );
162 DALI_TEST_CHECK( !Control::DownCast( actor ) );
164 actor = Actor::New();
166 DALI_TEST_CHECK( !Control::DownCast( actor ) );
170 int UtcDaliControlDownCastTemplate(void)
172 ToolkitTestApplication application;
174 DummyControl control;
176 DALI_TEST_CHECK( !DummyControl::DownCast( control ));
178 control = DummyControl::New();
180 DALI_TEST_CHECK( DummyControl::DownCast( control ) );
184 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
186 actor = Actor::New();
188 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
192 int UtcDaliControlKeyInputFocus(void)
194 ToolkitTestApplication application;
195 Stage stage = Stage::GetCurrent();
197 DummyControl control;
199 PushButton pushButton1 = PushButton::New();
200 stage.Add( pushButton1 );
202 pushButton1.SetKeyInputFocus();
203 DALI_TEST_CHECK( pushButton1.HasKeyInputFocus() );
205 pushButton1.ClearKeyInputFocus();
206 DALI_TEST_CHECK( !pushButton1.HasKeyInputFocus() );
210 int UtcDaliControlGetImplementationN(void)
212 ToolkitTestApplication application;
213 DummyControl control;
219 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
220 (void)controlImpl; // Avoid unused warning
221 tet_result(TET_FAIL);
223 catch (DaliException &exception)
225 tet_result(TET_PASS);
231 int UtcDaliControlGetImplementationConstN(void)
233 ToolkitTestApplication application;
234 DummyControl control;
240 const DummyControl constControl(control);
241 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
242 (void)controlImpl; // Avoid unused warning
243 tet_result(TET_FAIL);
245 catch (DaliException &exception)
247 tet_result(TET_PASS);
253 int UtcDaliControlGetImplementationP(void)
255 ToolkitTestApplication application;
256 DummyControl control = DummyControl::New();
262 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
263 (void)controlImpl; // Avoid unused warning
264 tet_result(TET_PASS);
266 catch (DaliException &exception)
268 tet_result(TET_FAIL);
274 int UtcDaliControlGetImplementationConstP(void)
276 ToolkitTestApplication application;
277 DummyControl control = DummyControl::New();
282 const DummyControl constControl(control);
283 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
284 (void)controlImpl; // Avoid unused warning
285 tet_result(TET_PASS);
287 catch (DaliException &exception)
289 tet_result(TET_FAIL);
295 int UtcDaliControlSignalConnectDisconnect(void)
297 ToolkitTestApplication application;
300 DummyControl dummy = DummyControlImpl::New();
302 Actor actor = Actor::New();
303 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
304 Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
305 DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
307 if( dummyImpl == NULL )
309 tet_result( TET_FAIL );
313 actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
314 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
315 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
317 Stage::GetCurrent().Add( actor );
318 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
320 dummyImpl->mCustomSlot1Called = false;
321 actor.OnStageSignal().Disconnect( dummyImpl, &DummyControlImpl::CustomSlot1 );
322 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
323 Stage::GetCurrent().Remove( actor );
324 Stage::GetCurrent().Add( actor );
325 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
330 int UtcDaliControlSignalAutomaticDisconnect(void)
332 ToolkitTestApplication application;
334 Actor actor = Actor::New();
337 DummyControl dummy = DummyControlImpl::New();
338 Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
339 DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
341 if( dummyImpl == NULL )
343 tet_result( TET_FAIL );
347 actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
348 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
349 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
351 Stage::GetCurrent().Add( actor );
352 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
353 Stage::GetCurrent().Remove( actor );
355 // dummyControl automatically disconnects
357 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
359 const Vector3 ignoredSize( 20, 20, 0 );
360 actor.SetSize( ignoredSize );
364 int UtcDaliControlTestParameters(void)
366 ToolkitTestApplication application;
367 DummyControl test = DummyControl::New();
369 test.SetSize( 0.7f, 0.7f, 0.7f );
371 Stage::GetCurrent().Add( test );
373 application.SendNotification();
374 application.Render();
376 float width = 640.0f;
377 float height = test.GetHeightForWidth( width );
378 DALI_TEST_EQUALS( 640.0f, height, TEST_LOCATION );
379 DALI_TEST_EQUALS( 640.0f, test.GetWidthForHeight( height ), TEST_LOCATION );
381 test.KeyEventSignal();
383 // Provide coverage for pointer destructor
384 Control* testControlPtr = new Control;
385 DALI_TEST_CHECK( testControlPtr );
386 delete testControlPtr;
390 int UtcDaliControlBackgroundColor(void)
392 ToolkitTestApplication application;
393 Control control = Control::New();
395 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
397 control.SetBackgroundColor( Color::RED );
399 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
400 Property::Map* resultMap = propValue.GetMap();
401 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
402 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::COLOR );
403 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
404 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::RED );
406 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
408 control.SetBackgroundColor( Color::YELLOW );
410 propValue = control.GetProperty( Control::Property::BACKGROUND );
411 resultMap = propValue.GetMap();
412 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
413 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::YELLOW );
415 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION );
420 int UtcDaliControlBackgroundImage(void)
422 ToolkitTestApplication application;
423 Control control = Control::New();
425 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
427 Image image = ResourceImage::New("TestImage");
428 control.SetBackgroundImage( image );
430 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
431 Property::Map* resultMap = propValue.GetMap();
432 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
433 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::IMAGE );
434 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
435 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage" );
437 image = ResourceImage::New("TestImage2");
438 control.SetBackgroundImage( image );
440 propValue = control.GetProperty( Control::Property::BACKGROUND );
441 resultMap = propValue.GetMap();
442 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
443 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage2" );
448 int UtcDaliControlBackgroundProperties(void)
450 ToolkitTestApplication application;
451 Control control = Control::New();
453 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
454 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
456 Property::Map imageMap;
457 imageMap[ Visual::Property::TYPE ] = Visual::IMAGE;
458 imageMap[ ImageVisual::Property::URL ] = "TestImage";
459 control.SetProperty( Control::Property::BACKGROUND, imageMap );
460 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
461 Property::Map* resultMap = propValue.GetMap();
462 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
463 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(),(int)Visual::IMAGE, TEST_LOCATION );
464 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
465 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "TestImage", TEST_LOCATION );
467 Property::Map rendererMap;
468 rendererMap[Visual::Property::TYPE] = Visual::COLOR;
469 rendererMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
470 control.SetProperty( Control::Property::BACKGROUND, rendererMap );
471 propValue = control.GetProperty( Control::Property::BACKGROUND );
472 resultMap = propValue.GetMap();
473 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
474 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
475 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
476 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::CYAN, TEST_LOCATION );
478 Property::Map emptyMap;
479 control.SetProperty( Control::Property::BACKGROUND, emptyMap );
480 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
483 control.SetProperty( Control::Property::BACKGROUND, "Foobar.png" );
484 propValue = control.GetProperty( Control::Property::BACKGROUND );
485 resultMap = propValue.GetMap();
486 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
487 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "Foobar.png", TEST_LOCATION );
490 control.SetProperty( Control::Property::BACKGROUND, Color::RED );
491 propValue = control.GetProperty( Control::Property::BACKGROUND );
492 resultMap = propValue.GetMap();
493 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
494 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::RED, TEST_LOCATION );
496 // Deprecated Properties
497 control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW );
498 DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW, TEST_LOCATION );
499 DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), control.GetBackgroundColor(), TEST_LOCATION );
501 control.ClearBackground();
503 Property::Map deprecatedImageMap;
504 deprecatedImageMap[ "filename" ] = "TestImage";
505 control.SetProperty( Control::Property::BACKGROUND_IMAGE, deprecatedImageMap );
506 propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
507 resultMap = propValue.GetMap();
508 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >(), "TestImage" , TEST_LOCATION );
510 control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
511 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
516 int UtcDaliControlKeyProperties(void)
518 ToolkitTestApplication application;
520 Control control = Control::New();
521 Stage::GetCurrent().Add( control );
523 DALI_TEST_EQUALS( control.HasKeyInputFocus(), control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
525 control.SetKeyInputFocus();
526 DALI_TEST_EQUALS( true, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
528 control.ClearKeyInputFocus();
529 DALI_TEST_EQUALS( false, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
531 control.SetProperty( Control::Property::KEY_INPUT_FOCUS, true );
532 DALI_TEST_EQUALS( true, control.HasKeyInputFocus(), TEST_LOCATION );
537 int UtcDaliControlGestureSignals(void)
539 ToolkitTestApplication application;
540 ConnectionTracker connectionTracker;
541 Control control = Control::New();
543 // Each gesture detector gets created when connecting to the gesture signals
544 DALI_TEST_CHECK( !control.GetTapGestureDetector() );
545 control.ConnectSignal( &connectionTracker, "tapped", &TestVoidCallback );
546 DALI_TEST_CHECK( control.GetTapGestureDetector() );
548 DALI_TEST_CHECK( !control.GetPanGestureDetector() );
549 control.ConnectSignal( &connectionTracker, "panned", &TestVoidCallback );
550 DALI_TEST_CHECK( control.GetPanGestureDetector() );
552 DALI_TEST_CHECK( !control.GetPinchGestureDetector() );
553 control.ConnectSignal( &connectionTracker, "pinched", &TestVoidCallback );
554 DALI_TEST_CHECK( control.GetPinchGestureDetector() );
556 DALI_TEST_CHECK( !control.GetLongPressGestureDetector() );
557 control.ConnectSignal( &connectionTracker, "longPressed", &TestVoidCallback );
558 DALI_TEST_CHECK( control.GetLongPressGestureDetector() );
563 int UtcDaliControlImplKeyInputFocusGainedSignal(void)
565 ToolkitTestApplication application;
567 Control control = Control::New();
568 Stage::GetCurrent().Add( control );
570 gKeyInputFocusCallBackCalled = false;
571 control.KeyInputFocusGainedSignal().Connect(&TestKeyInputFocusCallback);
573 application.SendNotification();
574 application.Render();
576 control.SetKeyInputFocus();
578 DALI_TEST_CHECK( control.HasKeyInputFocus() );
580 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
585 int UtcDaliControlImplKeyInputFocusLostSignal(void)
587 ToolkitTestApplication application;
589 Control control = Control::New();
590 Stage::GetCurrent().Add( control );
592 gKeyInputFocusCallBackCalled = false;
593 control.KeyInputFocusLostSignal().Connect(&TestKeyInputFocusCallback);
595 application.SendNotification();
596 application.Render();
598 control.SetKeyInputFocus();
600 DALI_TEST_CHECK( control.HasKeyInputFocus() );
602 control.ClearKeyInputFocus();
604 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
609 int UtcDaliControlImplGetControlExtensionP(void)
611 ToolkitTestApplication application;
612 Control control = Control::New();
614 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
616 DALI_TEST_CHECK( NULL == controlImpl.GetControlExtension() );
621 int UtcDaliControlAutoClipping(void)
623 ToolkitTestApplication application;
624 Control control = Control::New();
626 tet_infoline( "Test to see if a renderer gets added when we are clipping children" );
628 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
630 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
632 Stage::GetCurrent().Add( control );
634 application.SendNotification();
635 application.Render();
637 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
642 int UtcDaliControlAutoClippingN(void)
644 ToolkitTestApplication application;
645 Control control = Control::New();
646 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
647 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
649 tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals" );
651 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
653 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
655 Stage::GetCurrent().Add( control );
657 application.SendNotification();
658 application.Render();
660 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Only 1, not 2
662 // Ensure the background color is still RED rather than what's set by the automatic clipping
663 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
664 Property::Map* map = value.GetMap();
665 DALI_TEST_CHECK( map );
666 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
667 DALI_TEST_CHECK( colorValue );
668 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
673 int UtcDaliControlAutoClippingWhenAlreadyOnStage(void)
675 ToolkitTestApplication application;
676 Control control = Control::New();
678 tet_infoline( "Test to see if a renderer gets added when we are clipping children and when already on stage" );
680 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
682 Stage::GetCurrent().Add( control );
684 application.SendNotification();
685 application.Render();
687 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
689 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
691 application.SendNotification();
692 application.Render();
694 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
699 int UtcDaliControlAutoClippingWhenAlreadyOnStageN(void)
701 ToolkitTestApplication application;
702 Control control = Control::New();
703 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
704 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
706 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" );
708 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
710 Stage::GetCurrent().Add( control );
712 application.SendNotification();
713 application.Render();
715 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
717 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
719 application.SendNotification();
720 application.Render();
722 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Still should be 1
724 // Ensure the background color is still RED rather than what's set by the automatic clipping
725 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
726 Property::Map* map = value.GetMap();
727 DALI_TEST_CHECK( map );
728 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
729 DALI_TEST_CHECK( colorValue );
730 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
735 int UtcDaliControlSetTransformSize(void)
737 ToolkitTestApplication application;
738 Control control = Control::New();
740 Property::Map transformMap;
741 transformMap.Add( DevelVisual::Transform::Property::OFFSET, Vector2( 10, 10 ) )
742 .Add( DevelVisual::Transform::Property::ANCHOR_POINT, Align::BOTTOM_END )
743 .Add( DevelVisual::Transform::Property::ORIGIN, Align::BOTTOM_END )
744 .Add( DevelVisual::Transform::Property::SIZE, Vector2( 10, 20 ) );
746 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
747 .Add( DevelVisual::Property::TRANSFORM, transformMap ) );
749 tet_infoline( "Test to ensure that the control background transform does not get overwritten when adding to the stage" );
751 Stage::GetCurrent().Add( control );
753 application.SendNotification();
754 application.Render();
756 // Ensure the transform property still matches what we set
757 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
758 Property::Map* map = value.GetMap();
759 DALI_TEST_CHECK( map );
760 Property::Value* transformValue = map->Find( DevelVisual::Property::TRANSFORM );
761 DALI_TEST_CHECK( transformValue );
763 Property::Map* retMap = transformValue->GetMap();
764 DALI_TEST_CHECK( retMap );
765 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 10, 10 ), TEST_LOCATION );
766 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ANCHOR_POINT )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
767 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ORIGIN )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
768 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::SIZE )->Get< Vector2 >(), Vector2( 10, 20 ), TEST_LOCATION );